ccLoad

caidaoliMIT活跃维护

自托管的 AI API 网关,把 Claude Code、Codex、Gemini 的 API Key 和订阅账号汇到一个端点,统一做故障转移、协议转换和成本统计。

Self-hosted AI API gateway for Claude Code, Codex and Gemini: pool API keys and subscription accounts behind one endpoint with failover, protocol conversion and cost tracking.

v4.13.19-beta.1发布于 2026-11-09 15:07 UTC437star +3 / 7 天79fork同步于 2026-11-10 18:00 UTC

怎么上手

由 README 提炼,执行前请确认
docker run -d --name ccload -p 8080:8080 -e CCLOAD_PASS=your_admin_password -v ccload_data:/app/data ghcr.io/caidaoli/ccload:latest
硬件要求按 README 说明

README 未说明硬件要求;提供 Docker、Homebrew 和预编译二进制(linux/darwin amd64、arm64、windows amd64),也支持免费部署到 Hugging Face Spaces。

有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

自托管 AI API 网关,把多个 API Key 和订阅账号聚合成一个端点,供 Claude Code、Codex、Gemini 使用

自托管的 AI API 网关,把 Claude Code、Codex、Gemini 的 API Key 和订阅账号汇到一个端点,统一做故障转移、协议转换和成本统计。

核心能力

  • 把官方 API Key、中转服务和订阅账号统一配置为 Channel
  • 按客户端请求的模型名选择上游,失败后自动重试下一个
  • 在 Anthropic、OpenAI Chat、Codex Responses、Gemini 协议之间自动转换
  • 为每个客户端签发独立 API Token,可设置模型、预算和并发限制
  • 记录每次请求的用量与成本,并在 Logs 页面查看失败原因

容易踩的坑

必须设置环境变量 CCLOAD_PASS,否则服务启动后立即退出;密码含 $ 时在 .env 中用单引号包裹;客户端必须使用 ccLoad 签发的 API Token,而不是上游 Key 或管理密码,否则返回 401;客户端请求的模型名必须出现在某个 Channel 的模型列表中,否则报 404 或 503;默认监听 8080 端口,被占用时用 PORT 环境变量或改 Docker 端口映射;Codex 的 base_url 必须带 /v1,且 model_provider 行要放在 config.toml 最顶部;使用 app-server 守护进程时改配置或重新登录后需执行 codex app-server daemon restart。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v4.13.19-beta.1
  1. v4.13.19-beta.1Release v4.13.19-beta.1pre-release最新正式版2026-11-09 · 2026-11-09 15:07 UTC

    What's Changed

    • feat(zai): support ZCode trial plans with international/domestic sites (287064bc)
    • fix(zai): isolate credential changes and retire failed trial accounts (140cebaf)
    • fix(zai): refine Trial cooldown isolation and address review findings (130392b5)
    • docs: add agent workflow conventions (b192cb32)

    Full Changelog: https://github.com/caidaoli/ccLoad/compare/v4.13.18-beta.1...v4.13.19-beta.1

  2. v4.13.18-beta.1Release v4.13.18-beta.1pre-release2026-11-08 · 2026-11-08 08:25 UTC
    查看更新说明

    What's Changed

    • refactor: remove route preview feature (08cefb2f)
    • fix(proxy): detect configured errors in successful responses (18e66b9b)
    • feat(proxy): add shared request body memory budget and improve protocol compatibility (27125f12)

    Full Changelog: https://github.com/caidaoli/ccLoad/compare/v4.13.17-beta.1...v4.13.18-beta.1

  3. v4.13.17-beta.1Release v4.13.17-beta.1pre-release2026-11-07 · 2026-11-07 06:57 UTC
    查看更新说明

    What's Changed

    • feat(protocol): support GPT-6 Chat Thinking and fix Gemini translation (0ba6172e)

    Full Changelog: https://github.com/caidaoli/ccLoad/compare/v4.13.16-beta.5...v4.13.17-beta.1

  4. v4.13.16-beta.5Release v4.13.16-beta.5pre-release2026-11-07 · 2026-11-07 01:35 UTC
    查看更新说明

    What's Changed

    • fix(codex): prevent refresh replay and preserve deferred tool cache prefixes (da87bd41)

    Full Changelog: https://github.com/caidaoli/ccLoad/compare/v4.13.16-beta.4...v4.13.16-beta.5

  5. v4.13.16-beta.4Release v4.13.16-beta.4pre-release2026-11-06 · 2026-11-06 08:56 UTC
    查看更新说明

    What's Changed

    • fix(antigravity): preserve Claude tool schema unions (16cfa97a)

    Full Changelog: https://github.com/caidaoli/ccLoad/compare/v4.13.16-beta.3...v4.13.16-beta.4

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    ccLoad

    Self-hosted AI API gateway for Claude Code, Codex, Gemini, and OpenAI-compatible clients.

    English | 简体中文 · Website

    Release Test Go License

    Watch the 47-second ccLoad overview

    ▶ Watch the 47-second overview · 中文版

    What Is ccLoad

    You may have several AI sources: official API keys, third-party relay services, and ChatGPT or Claude subscriptions. Each client has to be configured separately, and when one quota runs out or an upstream fails, a running Claude Code or Codex session stops.

    ccLoad is a gateway you run on your own computer or server. It manages all of those sources, and every client only needs the ccLoad address and a ccLoad token:

    Claude Code / Codex / Gemini / OpenAI-compatible tools
                    │  one address + one ccLoad token
                    ▼
                 ccLoad   pick an upstream → retry the next one on failure → convert protocols if needed → record usage and cost
                    │
       ┌────────────┼──────────────┬──────────────────────────┐
    Official API keys  Relay services  Codex / Claude and other subscriptions  …
    

    Three terms are used throughout the steps below:

    • Channel: one upstream source, such as "a relay service's URL plus key" or "a signed-in Codex account". Each channel lists the models it serves.
    • API token: the key ccLoad gives to your clients. Clients only talk to ccLoad with this token and never see the real upstream keys.
    • Admin console: open http://your-host:8080/web/ and sign in with the admin password CCLOAD_PASS to add channels, create tokens, and view logs and costs.

    Who It's For

    • Developers with several AI subscriptions: Combine ChatGPT, Claude and other plans with spare API keys, so Claude Code and Codex keep running when one quota runs out.
    • Teams sharing model access: Give each teammate a token with model, budget and concurrency limits. Upstream credentials stay in one place and access can be revoked at any time.
    • Operators running many channels: Manage channels with priorities, health-based ordering, scheduled checks, CSV import and export, and a log entry for every request.

    Quick Start

    Five steps get Claude Code or Codex working through ccLoad.

    Step 1: Install and start

    Pick one method. Every method requires the admin password CCLOAD_PASS; without it the service exits immediately. The service listens on port 8080 by default.

    Docker (recommended):

    docker run -d --name ccload \
      -p 8080:8080 \
      -e CCLOAD_PASS=your_admin_password \
      -v ccload_data:/app/data \
      ghcr.io/caidaoli/ccload:latest
    

    Data lives in the Docker volume ccload_data, so removing or upgrading the container keeps it.

    Docker Compose:

    curl -o docker-compose.yml https://raw.githubusercontent.com/caidaoli/ccLoad/master/docker-compose.yml
    curl -o .env https://raw.githubusercontent.com/caidaoli/ccLoad/master/.env.docker.example
    # Edit .env and set CCLOAD_PASS to your admin password
    docker compose up -d
    

    Homebrew (macOS / Linux):

    brew tap caidaoli/ccload https://github.com/caidaoli/ccLoad.git
    brew install caidaoli/ccload/ccload
    
    # Create .env in the config directory with one line: CCLOAD_PASS=your_admin_password
    mkdir -p "$(brew --prefix)/var/ccload"
    cd "$(brew --prefix)/var/ccload"
    (umask 077; touch .env)
    ${EDITOR:-vi} .env
    
    brew services start caidaoli/ccload/ccload
    

    Download the binary: get the file for your platform from Releases (ccload-linux-amd64, ccload-linux-arm64, ccload-darwin-arm64, ccload-darwin-amd64, ccload-windows-amd64.exe). On Linux:

    chmod +x ccload-linux-amd64
    CCLOAD_PASS=your_admin_password ./ccload-linux-amd64
    

    Data is stored in data/ccload.db under the current directory by default.

    Without a server, you can deploy for free on Hugging Face Spaces; see Deployment.

    Check that the service is up:

    curl http://localhost:8080/health
    

    On a server, replace every localhost in this guide with the server's IP address or domain.

    Step 2: Sign in to the admin console

    Open http://localhost:8080/web/ and sign in with the CCLOAD_PASS from step 1.

    Step 3: Add a channel

    Go to Channels and click Add Channel:

    • API-key upstreams (official APIs, relay services): the easiest way is Auto-fill channel configuration. Paste the address and key your provider gave you (for example OPENAI_BASE_URL=https://api.example.com and OPENAI_API_KEY=sk-...); ccLoad checks the connection and fetches the model list. When filling the form by hand, enter only the base URL, without /v1 or an endpoint path. OpenCode Zen / Zen Go have their own entry that prefills the address, so you only add the key.
    • Subscription accounts (Codex/ChatGPT, Claude, Antigravity, xAI, CodeBuddy, Z.ai Coding Plan, Cursor, Zed): choose the account type in Channels and follow the prompts to authorize in the browser or import credentials.
    • Google Vertex AI: import a Google Cloud service account key (JSON); ccLoad exchanges it for access tokens and serves Gemini models.

    The model list decides whether a channel is used. ccLoad picks channels by the model name the client requests: if the client asks for claude-sonnet-4-6, some channel must list claude-sonnet-4-6. Add models with Fetch Models or Common Models; when the upstream uses a different name, put the upstream name in Redirect Target.

    After saving, click Test on the channel to confirm it responds.

    Step 4: Create an API token

    Go to API Tokens (/web/tokens.html), create a token and copy it. Every client uses it to reach ccLoad; /v1/* and /v1beta/* requests without a token return 401.

    Step 5: Point your clients at ccLoad

    Test with curl first. Replace your-api-token with the token from step 4 and the model with one configured on your channel:

    curl -X POST http://localhost:8080/v1/messages \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer your-api-token" \
      -H "anthropic-version: 2023-06-01" \
      -d '{
        "model": "claude-sonnet-4-6",
        "max_tokens": 1024,
        "messages": [{"role": "user", "content": "Hello, Claude!"}]
      }'
    

    Claude Code:

    1. Edit ~/.claude/settings.json (%USERPROFILE%\.claude\settings.json on Windows). Create it if it does not exist; if it already has other settings, merge just these two entries into env:

      {
        "env": {
          "ANTHROPIC_BASE_URL": "http://localhost:8080",
          "ANTHROPIC_AUTH_TOKEN": "your-api-token"
        }
      }
      

      Leave /v1 off the address; Claude Code appends /v1/messages itself. Settings in this file apply to every terminal and IDE extension, so no shell profile changes are needed.

    2. Make sure the model names match. Besides the main model, Claude Code uses a Haiku model (such as claude-haiku-4-5) for background tasks like title generation, and every one of these names must appear in some channel's model list. If your channels lack them, point them at models your channels do have; the full file becomes:

      {
        "env": {
          "ANTHROPIC_BASE_URL": "http://localhost:8080",
          "ANTHROPIC_AUTH_TOKEN": "your-api-token",
          "ANTHROPIC_DEFAULT_OPUS_MODEL": "model-name-from-your-channel",
          "ANTHROPIC_DEFAULT_SONNET_MODEL": "model-name-from-your-channel",
          "ANTHROPIC_DEFAULT_HAIKU_MODEL": "model-name-from-your-channel"
        }
      }
      
    3. Verify: run claude -p "hello"; a reply means it works. In interactive mode, /status shows the current base URL.

    Codex CLI:

    1. Log in with your ccLoad token (this replaces any existing ChatGPT login in Codex; the same command works in Windows PowerShell):

      echo your-api-token | codex login --with-api-key
      
    2. Edit ~/.codex/config.toml (%USERPROFILE%\.codex\config.toml on Windows), If the file does not exist, create it and paste everything below. If it already has content, add the two parts separately: the model_provider = "ccload" line at the very top of the file (before any [...] section, or it will not take effect), and the whole [model_providers.ccload] block at the end of the file:

      model_provider = "ccload"
      
      [model_providers.ccload]
      name = "OpenAI"
      base_url = "http://localhost:8080/v1"
      wire_api = "responses"
      requires_openai_auth = true
      supports_websockets = true
      

      base_url must include /v1. requires_openai_auth = true makes Codex use the token from the previous step, and supports_websockets = true enables Responses WebSocket.

    3. Verify: run codex exec --skip-git-repo-check "hello"; a reply means it works.

      If you use the app-server daemon (for example codex agents or codex remote-control): the daemon is a long-running process, so not every change applies right away. After you edit config.toml, sessions already open keep the old settings and only new sessions pick up the change; after you run codex login again with a new token, the daemon keeps using the old token until it restarts. After changing the config or logging in again, run:

      codex app-server daemon restart
      

      To check whether the daemon is running, run codex app-server daemon version; a failed to connect error means it is not running and needs no restart.

    Other OpenAI-compatible tools (Cherry Studio, SDKs, and so on): set the base URL to http://localhost:8080/v1 and the API key to your ccLoad token.

    The client protocol does not have to match the upstream; ccLoad converts between them when they differ. More endpoints and options are in the Usage Guide.

    Troubleshooting

    • The service exits right after starting: CCLOAD_PASS is not set. If the password contains $, wrap it in single quotes in .env, for example CCLOAD_PASS='abc$def'.
    • Requests return 401: the client sends no token or a wrong one. Use the ccLoad token from step 4, not an upstream key or the admin password.
    • 404 model: xxx or 503 no available upstream: no channel lists that model name, or every usable channel is cooling down. Check the channel's model list and see each attempt's failure reason on the Logs page.
    • Port 8080 is in use: set the PORT environment variable, or change the left side of -p for Docker.
    • Other machines cannot connect: check the firewall and port mapping. For public deployments, put ccLoad behind an HTTPS reverse proxy; see Security.

    Why ccLoad

    A reverse proxy forwards requests. ccLoad is built for coding agents that stream long responses, run for hours, and spend real money, so every design choice is about keeping the session alive and the bill predictable.

    • Subscription accounts, not just API keys: Sign in Codex (ChatGPT), Claude, Antigravity, xAI, CodeBuddy, Z.ai Coding Plan, Cursor and Zed accounts, or import Vertex AI service accounts, as channels. Tokens refresh automatically, and quota usage is tracked against each provider's reset window.
    • Any client on any upstream: Anthropic Messages, OpenAI Chat, Codex Responses and Gemini clients can all use every channel that serves the model. Requests and streamed responses are converted when the protocols differ, including Codex Responses over WebSocket.
    • Failover your client never sees: If an upstream fails before the first byte reaches the client, ccLoad retries the next candidate. Errors disguised as HTTP 200 and rate limits inside SSE streams count as failures too.
    • Cooldown at the right scope: A revoked key, a rate-limited model, or a dead URL cools down on its own with exponential backoff and honors upstream reset times. The rest of the channel keeps serving.
    • Secrets stay in the gateway: Optionally replace keys, passwords, personal data and your own terms with placeholders before a request leaves for the upstream, then restore them in the reply so the client still sees the original text.
    • Cost you can check and cap: Pricing covers cache reads and writes, long-context tiers, OpenAI service_tier and image generation. Cap spend per channel per day and per token in total, per day or per month.
    • Light to run: One Go binary with embedded SQLite and a built-in admin console. Add MySQL or PostgreSQL only when you need them, or run it for free on Hugging Face Spaces.

    Features

    Routing and failover

    • Priority routing: High-priority channels are selected first; channels at the same priority use smooth weighted round-robin, with health-based dynamic sorting.
    • Scoped failover: Errors are classified as key-, model-, channel-, or client-level, and only the failed scope is skipped. Cooldowns use one exponential-backoff policy and honor explicit upstream reset times.
    • Model-aware cooldown: A failing model cools down alone; other models on the same channel stay available. The channel cools only when every configured model or every enabled key is cooling.
    • Soft-error detection: HTTP 200 responses that carry an error body, SSE error events with explicit rate limits, and quota errors trigger the same failover path as regular upstream failures.
    • Multiple URLs per channel: Latency-weighted selection with independent per-URL cooldown.
    • Channel limits: Daily cost, RPM, concurrency, availability time window, and per-key model allowlists take a channel out of routing without cooling it.
    • Per-channel upstream proxy: http/https/socks5/socks5h, with isolated connection pools.
    • Scheduled checks: Background probing detects failed channels.

    Protocols and clients

    • Four client protocols on every channel: Anthropic, OpenAI, Codex (Responses), and Gemini. Each upstream URL declares the wire protocols it accepts, or ccLoad detects and caches them; requests are converted between protocols when client and upstream differ.
    • Responses WebSocket: Codex clients keep a downstream WebSocket while each candidate uses native Codex WebSocket or HTTP/SSE.
    • Account-based channels: Codex (ChatGPT) OAuth and personal access tokens, Anthropic (Claude), Antigravity, and xAI OAuth, CodeBuddy, Z.ai Coding Plan, Cursor, Zed, and Vertex AI service accounts, with token refresh where supported, batch import, quota refresh, and automatic disabling of permanently rejected credentials.
    • Model thinking suffix: model(high) or model(16384) maps to the upstream protocol's thinking parameters while routing uses the base model name.
    • Dynamic reasoning effort: For selected models, a decision channel (System One) judges each turn and picks a reasoning level the model supports; an explicit level from the client is left alone.
    • Multimodal fallback: Requests with images or files are moved from non-vision models to configured fallback models before routing.
    • Custom request rules: Per-channel header and JSON body rewriting, with protected authentication headers.
    • Local token counting: /v1/messages/count_tokens is answered locally without an upstream call.

    Cost, access control and privacy

    • API tokens: Per-token cost limits, model restrictions, channel allowlist/denylist, and concurrency caps. Upstream credentials stay in the gateway.
    • Cost accounting: OpenAI service_tier multipliers, tiered long-context pricing, cache-token discounts, and image-generation tool billing.
    • OAuth quota cost: Per-credential weekly and monthly standard cost aligned with upstream quota windows.
    • Read-only token login: An API token can sign in to the web console and see only its own usage.
    • Privacy masking: Keys, passwords, personal data and custom word lists or rules are replaced with placeholders before the upstream sees them, and restored in HTTP, SSE and Responses WebSocket replies. Mappings are isolated per caller token and kept in memory only.

    Observability

    • Dashboard: Active requests, trends, logs, token usage, time to first byte, and cost by channel, model, and token, plus process metrics (CPU, RSS, GC).
    • Request control: Abort an in-flight request from the logs page; it fails over like an upstream disconnect.
    • Debug logs: Raw upstream request and response capture with sensitive headers masked.
    • Model testing workbench: Test by channel, by model, or in a chat, with image upload, reasoning level, built-in search, and image generation.

    ccLoad Dashboard ccLoad Logs

    Deployment

    • Single binary with embedded SQLite; MySQL or PostgreSQL optional, including a hybrid mode that keeps SQLite on the hot path.
    • Multi-arch Docker images (linux/amd64, linux/arm64) on GHCR, and Hugging Face Spaces deployment.
    • Release channels: Stable or preview updates, verified by SHA-256 before the binary is replaced; containers update by pulling a new tag.
    • CSV import and export for channel configuration.

    How It Works

    ccLoad program architecture

    A request is authenticated with a ccLoad token, matched to candidate channels by model, priority, and limits, and forwarded to an upstream URL and key. If the upstream fails before any output reaches the client, ccLoad cools the failed scope and retries the next candidate. Protocol conversion happens only when the client protocol and the selected upstream protocol differ. Details: Architecture.

    Documentation

    TopicContents
    DeploymentDocker, binary, source build, Hugging Face Spaces, databases, image tags, updates, troubleshooting
    Usage GuideAPI endpoints, Codex CLI and Responses WebSocket, thinking suffix and dynamic reasoning effort, privacy masking, channel management, request rules, CSV import/export, admin console
    ConfigurationEnvironment variables, storage modes, system settings, channel sorting, API tokens, authentication
    ArchitectureProtocol routing, dependencies, module layout, database structure

    The website has the same topics as guided pages: Install · Configure · Use · Feedback.

    Security

    • Set a strong CCLOAD_PASS; the service does not start without one.
    • Give clients ccLoad API tokens, never upstream keys. Tokens are managed at /web/tokens.html.
    • Upstream API keys and account credentials are stored in the database and included in CSV exports. Protect the database and delete exported files after use.
    • To keep keys or personal data away from upstreams, turn on Settings → Privacy redaction. It handles recognizable text only, can miss or over-match, and does not replace access control.
    • The browser stores only a random web-session token that expires after 24 hours.
    • Put the service behind an HTTPS reverse proxy, and set TRUSTED_PROXIES so forwarded client addresses cannot be spoofed.

    Contributing

    Issues and pull requests are welcome: https://github.com/caidaoli/ccLoad/issues

    Go commands need the sonic build tag. Before sending a change, run the checks that match the touched area:

    go test -tags sonic ./internal/...
    make verify-web     # frontend node:test checks
    make race-fast      # race-sensitive packages; make race for the full suite
    golangci-lint run ./...
    bash .agents/skills/sync-cliproxy-core/scripts/verify.sh --tests  # protocol translation changes
    

    License

    MIT License. The synchronized translator snapshot under internal/protocol/cliproxy retains its upstream MIT notice and provenance record.