Skip to content
VictorMinemuPublic

About

Round-robin proxy for multiple Claude Max subscriptions — multiply your Claude Code throughput with automatic OAuth token rotation and transparent request routing

Topics

Resources

Contributing

Security policy

Stars

46 stars

Watchers

0 watching

Forks

Repository files navigation

CC-Router

Turn your Claude and ChatGPT subscriptions into one OpenAI-compatible API.
CC-Router is a self-hosted, OpenRouter-style gateway: point any OpenAI SDK at it, pick anthropic/... or openai/... as the model, and the request runs on your own Claude Max or ChatGPT Plus/Pro subscription. It also routes Claude Code and Codex CLI across several accounts.

from openai import OpenAI

client = OpenAI(base_url="http://localhost:3456/v1", api_key="ccr_...")
client.chat.completions.create(model="anthropic/claude-sonnet-4-6", messages=[{"role": "user", "content": "Hi"}])
client.chat.completions.create(model="openai/gpt-5-codex", messages=[{"role": "user", "content": "Hi"}])
client.images.generate(model="gpt-image-2.5-flare", prompt="A lighthouse at dawn")

npm License: MIT

CC-Router Dashboard

Features

  • OpenAI-compatible API, OpenRouter-style — /v1/chat/completions, /v1/models and /v1/images/generations on top of your subscriptions; works with the official OpenAI SDKs and any tool that accepts a custom base_url (details)
  • One API, two providers — the model prefix picks the provider: anthropic/* runs on a Claude subscription, openai/* on a ChatGPT/Codex subscription
  • Full Chat Completions surface — streaming with usage, function tools, image and PDF input, JSON mode and JSON schema, stop sequences, and reasoning control with returned reasoning
  • Drop-in for OpenRouter clients — OpenRouter model ids, reasoning, modalities, usage details and error format (details)
  • Image generation — OpenAI Images API, including streamed partial images, served by your ChatGPT subscription
  • Per-service API keys with token quotas — issue a ccr_ key per service with 5-hour, 7-day and 30-day limits; revoke or change limits live
  • Round-robin token rotation — distribute requests across 2-20 Claude Max accounts automatically
  • Multi-provider routing — route openai/* models to OpenAI ChatGPT/Codex subscription accounts and Claude models to Claude subscriptions
  • Transparent Claude proxy — Claude Code works normally; streaming, thinking, tool use, prompt caching all pass through
  • Codex CLI support — configure Codex to use CC-Router as a Responses-compatible provider
  • Automatic token refresh — OAuth tokens are refreshed before they expire, saved atomically to disk
  • Rate limit awareness — detects 429/529 responses and coolsdown accounts; picks the least-loaded one
  • Client mode — connect to a remote CC-Router from any machine with one command (cc-router client connect <url>)
  • Claude Desktop support — route Cowork / Agent-mode traffic through CC-Router via mitmproxy interception (macOS, Windows, Linux)
  • Guided setup wizard — cc-router setup signs accounts in with a code (works on headless servers) and configures everything
  • Live dashboard — real-time terminal UI showing account health, request counts, token usage, recent activity
  • Proxy authentication — optional Bearer / x-api-key secret for internet-exposed deployments
  • Auto-update — patch/minor releases install automatically (opt-out available)
  • Multiple deployment modes — background daemon, native OS auto-start (launchd/systemd), foreground, Docker Compose
  • Cross-platform — macOS, Linux, Windows; Node.js 22.13+ (or 23.4+)

Warning
CC-Router is an unofficial tool, not affiliated with Anthropic or OpenAI. Using a subscription through it, and especially as an API for other services, may break the provider's terms and can get accounts limited or banned. You use it entirely at your own risk — read the disclaimer first.


How it works

Claude Code  (terminal)  ─┐
                          │  ANTHROPIC_BASE_URL=http://localhost:3456
                          │
Claude Desktop  ─[mitmproxy]─┐  (optional — intercepts api.anthropic.com)
                             │
                             ▼
┌─────────────────────────────────────┐
│  CC-Router  :3456                   │
│                                     │
│  1. Receives /v1/messages or        │
│     /v1/responses                   │
│  2. Parses model provider prefix    │
│  3. Picks a Claude or OpenAI account│
│  4. Refreshes token if expiring     │
│  5. Injects Authorization: Bearer   │
│  6. Forwards to Anthropic, OpenAI   │
│     Codex backend, or LiteLLM       │
└──────────────┬──────────────────────┘
               │
               ▼
        api.anthropic.com
        (authenticated with
         OAuth token of account N)

All standard Claude Code features work transparently on the Claude route: streaming, extended thinking, tool use, prompt caching. OpenAI subscription routing is available for Codex-compatible Responses requests and Claude Code cross-routing with the limitations documented below.

Claude Desktop support is opt-in and requires a small interceptor (mitmproxy) because Claude Desktop doesn't expose a custom API endpoint setting. See Claude Desktop support.


Use cases

Heavy user — one account isn't enough

Claude Max has rate limits per account. If you hit them regularly mid-session — waiting for cooldowns, getting 429s — you're a good candidate.

With two accounts you double your effective rate limit. With three, you triple it. The proxy distributes requests automatically; you don't change how you use Claude Code at all.

1 account  →  hit limit, wait 60s, continue
3 accounts →  request rotates across all three, limit effectively tripled

Team sharing accounts — fewer subscriptions, same throughput

A team of five doesn't need five Max subscriptions. In practice, developers don't all peak at the same time. Three accounts can comfortably serve five people working normal hours.

Example setup: 5 devs, 3 accounts

cc-router (hosted on a shared machine or VPS)
     │
     ├── max-account-1   ← alice's subscription
     ├── max-account-2   ← bob's subscription
     └── max-account-3   ← carol's subscription
           │
           └── serves: alice, bob, carol, dave, eve

Each developer sets their ANTHROPIC_BASE_URL to the shared proxy. Done. The proxy handles routing and token refresh invisibly.

Cost example

Setup Monthly cost
5 individual Max subscriptions 5 × $100 = $500/mo
3 shared via cc-router 3 × $100 = $300/mo

You save $200/mo without any loss in capability for a typical team workload.


Hosting cc-router on a shared machine

Run cc-router on a machine everyone on the team can reach — a home server, a VPS, or a spare machine on the office network.

On the server

npm install -g ai-cc-router
cc-router setup          # configure the 3 shared accounts
cc-router start          # first run asks: background/boot/server mode — choose "server mode"

When you enable server mode during cc-router start, the proxy automatically binds to all interfaces (0.0.0.0) and prints instructions for connecting clients.

On each developer's machine

No installation needed. Just set two environment variables in ~/.claude/settings.json:

{
  "env": {
    "ANTHROPIC_BASE_URL": "http://192.168.1.50:3456",
    "ANTHROPIC_AUTH_TOKEN": "proxy-managed"
  }
}

Replace 192.168.1.50 with the server's IP or hostname. Then run claude normally.

Or use the CLI to write the settings automatically:

cc-router configure --port 3456
# Then manually update ANTHROPIC_BASE_URL to the remote IP

Hosting on a VPS (internet-accessible)

If your team is distributed or works remotely, run cc-router on a VPS and expose it over HTTPS via a reverse proxy.

Recommended nginx config

server {
    listen 443 ssl;
    server_name cc-router.yourcompany.com;

    # ... SSL cert config (e.g. Let's Encrypt) ...

    location / {
        proxy_pass http://127.0.0.1:3456;
        proxy_buffering off;          # required for SSE streaming
        proxy_read_timeout 300s;      # required for long thinking requests
        proxy_set_header X-Forwarded-For $remote_addr;
    }
}

For longer requests, set proxyRequestTimeoutMs in ~/.cc-router/config.json (milliseconds) and keep proxy_read_timeout at least as high.

Each developer then points to:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://cc-router.yourcompany.com",
    "ANTHROPIC_AUTH_TOKEN": "proxy-managed"
  }
}

Security note: if the proxy is internet-accessible, add authentication at the nginx level (basic auth, mTLS, or IP allowlist) so only your team can use it. cc-router does not implement user authentication itself.


Quickstart

# 1. Install
npm install -g ai-cc-router

# 2. Wizard: extract tokens + configure Claude Code automatically
cc-router setup

# 3. Start the proxy
cc-router start

# 4. Use Claude Code normally — the proxy is transparent
claude

That's it. Claude Code will route through the proxy without any further changes.

On first run, cc-router start asks how you want to run (background/foreground, auto-start on boot, server mode) and remembers your choice. Next time, it just starts. To change preferences later:

cc-router start --reconfigure

Installation

Requirements: Node.js 20 or 22.

npm install -g ai-cc-router

Verify:

cc-router --version

Adding accounts

Claude — sign in with a code (any platform, works on servers)

cc-router accounts login

The CLI prints a link. Open it on any device (your phone or laptop is fine; the server needs no browser), sign in with the Claude account to add, click Authorize and paste the code the page shows back into the terminal. Repeat for each account.

The router gets its own login this way. Copying Claude Code's login (Keychain or ~/.claude/.credentials.json, still offered by cc-router setup) shares one refresh token between two programs; refresh tokens rotate, so whichever refreshes first signs the other out.

OpenAI (ChatGPT/Codex) — device code

cc-router accounts login-openai

Open the printed URL on any device and enter the code.

Changes apply live

The proxy reloads accounts.json within a few seconds when it changes. accounts login, login-openai, remove and edits to the file take effect without a restart, and the proxy never rewrites the file from memory, so it cannot bring back an account you removed.

When an account says "needs login"

cc-router accounts list shows ✗ needs login when the provider rejected the refresh token (revoked, or used by another program). Sign in again under the same id; the running proxy picks up the new tokens and keeps the account's settings:

cc-router accounts login --id <id>          # Claude
cc-router accounts login-openai --id <id>   # OpenAI

An access token past its expiry is normal and shows as refresh due; it is renewed on the next request.


CLI Reference

cc-router setup              Interactive wizard: extract tokens + configure Claude Code
cc-router setup --add        Add another account to an existing configuration

cc-router start              Start proxy (asks preferences on first run, then remembers)
cc-router start --foreground Run in the foreground (stays in terminal)
cc-router start --reconfigure  Re-ask run preferences (background/service/server mode)
cc-router start --litellm    Start with LiteLLM in Docker (advanced mode)

cc-router stop               Stop proxy (offers to remove auto-start / config)
cc-router stop --keep-config Stop proxy only (keep settings.json)
cc-router stop --full        Stop + remove auto-start + revert Claude Code (no prompts)
cc-router revert             Same as stop --full

cc-router status             Live dashboard (updates every 2s, press q to quit)
cc-router status --json      Print current stats as JSON and exit

cc-router models list        List models discovered live from provider APIs
cc-router models list --json Print discovered models + routing as JSON
cc-router models set --claude-model anthropic/claude-sonnet-4-6
cc-router models set --openai-model openai/gpt-5-codex

cc-router logs               View proxy logs (background mode)
cc-router logs -f            Follow log output in real time
cc-router logs --lines 100   Show last 100 lines

cc-router accounts list      List accounts, their health and how to fix a failing one
cc-router accounts login [--id <id>]  Sign in to a Claude account with a code (works over SSH)
cc-router accounts add       Add a Claude account (code login, or copy Claude Code's login)
cc-router accounts login-openai [--id <id>]  Sign in to an OpenAI subscription with a device code
cc-router accounts add-openai  Add an OpenAI subscription account manually (experimental)
cc-router accounts remove <id>  Remove a Claude or OpenAI account

cc-router configure          (Re)write ~/.claude/settings.json
cc-router configure codex    (Re)write ~/.codex/config.toml for Codex CLI
cc-router configure codex --model openai/gpt-5-codex
cc-router configure models --claude-model claude-sonnet-4-6 --openai-model gpt-5-codex
cc-router configure --show   Show current Claude Code proxy settings
cc-router configure --remove Remove cc-router settings (same as revert without stopping)

cc-router client connect <url>       Connect Claude Code to a remote CC-Router
cc-router client connect --desktop   Also configure Claude Desktop interception
cc-router client disconnect          Revert all client configuration
cc-router client status              Show connection + remote server health
cc-router client start-desktop       Start mitmproxy interceptor for Claude Desktop
cc-router client stop-desktop        Stop mitmproxy interceptor

cc-router docker up          Start full Docker stack (cc-router + LiteLLM)
cc-router docker up --build  Rebuild cc-router image before starting
cc-router docker down        Stop Docker containers
cc-router docker logs        Tail all Docker logs
cc-router docker ps          Show container status
cc-router docker keys ...    Manage API keys inside the container (keys live on the cc-router-data volume)
cc-router docker restart [service]  Restart a service

API keys and quotas

CC-Router can issue individual API keys, each with its own token quota, instead of sharing a single secret across every client.

cc-router keys create laptop --owner victor --limit-5h 200000 --limit-month 5000000
cc-router keys list
cc-router keys limit <id> --limit-5h 400000
cc-router keys revoke <id>

The plaintext key is shown once, at creation — only its SHA-256 is stored. Point a client at the router with it exactly as with the shared secret, via ANTHROPIC_AUTH_TOKEN or the x-api-key header.

Quotas count every token type, cache reads included, over 5-hour, 7-day and 30-day windows. Exhausting one returns HTTP 429 with retry-after and x-ccrouter-quota-* headers describing which window closed and when it reopens. Windows are measured in hourly buckets, so they are slightly conservative: they cover between N and N+1 hours and block a little early rather than a little late.

Key changes made from the CLI (create, revoke, limit) reach a running proxy within 5 seconds — no restart needed. Once any key exists, admin endpoints (/cc-router/*, used by the dashboard) require the admin proxySecret; API keys can never use them.

The existing shared proxySecret keeps working, treated as an unlimited key, so upgrading breaks nothing.

Requires Node >= 22.13 (or >= 23.4), where the built-in node:sqlite module needs no flag.

OpenAI-compatible gateway

CC-Router exposes an OpenRouter-style API backed by the connected Claude Max and ChatGPT subscriptions. Any OpenAI client works: set base_url to the router and use a ccr_ key (see API keys and quotas). The model id picks the provider, and the same key and quota apply to both.

Model id Runs on
anthropic/<model> (e.g. anthropic/claude-sonnet-4-6) a connected Claude subscription
openai/<model> (e.g. openai/gpt-5-codex) a connected ChatGPT/Codex subscription
claude/sonnet, claude/opus, claude/haiku, … the newest active Claude model of that line
claude/default, openai/default the default model set with cc-router configure models

Requests leave the router shaped like Claude Code or Codex traffic, which is what the subscription backends accept. When several accounts are connected, the router rotates requests across them; Claude accounts that hit a rate limit are skipped until they cool down.

from openai import OpenAI

client = OpenAI(base_url="http://localhost:3456/v1", api_key="ccr_...")

response = client.chat.completions.create(
    model="anthropic/claude-sonnet-4-6",  # or openai/gpt-5-codex
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)

Streaming and function tools use the standard OpenAI shapes:

for chunk in client.chat.completions.create(
    model="openai/gpt-5-codex",
    messages=[{"role": "user", "content": "Explain WAL briefly"}],
    stream=True,
):
    print(chunk.choices[0].delta.content or "", end="")

Models

GET /v1/models lists the models your subscriptions can use right now. The list is fetched live from Anthropic and OpenAI with your accounts and cached for 10 minutes, so new releases appear and retired models disappear on their own. Each entry carries OpenRouter's fields: name, created, context_length, architecture.input_modalities / output_modalities, top_provider, supported_parameters and pricing (always 0), plus reasoning_efforts. GET /v1/models/<provider>/<model> returns a single entry.

Every request is checked against that list before it reaches a provider. An unknown, misspelled or retired model id gets a 404 with suggestions, and nothing is sent upstream:

{"error": {"code": 404, "type": "invalid_request_error",
  "message": "The model \"anthropic/claude-sonet-5-5\" is not available on the connected subscriptions. Did you mean \"anthropic/claude-sonnet-5-5\"? …",
  "metadata": {"reason": "model_not_found", "suggestions": ["anthropic/claude-sonnet-5-5"]}}}
  • Bare ids are accepted and routed to the provider that has them: claude-sonnet-5-5 runs on Claude and gpt-6.2-sol on ChatGPT. Responses report the canonical prefixed id.
  • claude/default and openai/default return 404 (default_model_not_configured) until a default is configured.
  • Image models are not published by OpenAI, so they come from configuration: modelRouting.imageModels in ~/.cc-router/config.json (default ["gpt-image-2.5-flare"]).
  • If a provider's catalog cannot be fetched at all, its model ids are passed through unchecked and the provider decides. After one successful fetch, the last known list is kept while the provider is unreachable.

Compatibility

Feature Claude (anthropic/*) ChatGPT (openai/*)
Text, system and developer messages ✓ ✓
Streaming (stream, stream_options.include_usage) ✓ ✓
Function tools, parallel calls, tool results ✓ ✓
tool_choice: "auto" / "none" ✓ ✓
tool_choice: "required" or a named function emulated ¹ ✓
response_format json_object / json_schema emulated ¹ ✓
Image input (image_url: http(s) or base64) ✓ ✓
PDF and text files (file part: base64 data URL or public URL) ✓ ✓
max_tokens / max_completion_tokens ✓ ✓
stop ✓ (whitespace-only sequences emulated ¹) emulated ¹
reasoning (effort, max_tokens, exclude, enabled), reasoning_effort ✓ ³ ✓ ³
cache_control on text parts (prompt caching) ✓ ignored
temperature, top_p ✓ (ignored while reasoning ²) ignored ²
Image generation in chat (modalities: ["image", "text"]) — ✓
Image generation (/v1/images/generations) — ✓
Audio or video input — ⁴ — ⁴
n > 1 — —

¹ Claude subscriptions reject forced tool choice and native structured output, so the router asks the model for it in the system prompt instead. It works reliably in practice but is not a hard guarantee. Stop sequences the provider cannot apply (all of them on Codex, whitespace-only ones such as "\n" on Claude) are applied by the router to the generated text. The response carries x-cc-router-emulated-params naming what was emulated.
² The Codex backend rejects sampling parameters, and Claude requires the defaults while it reasons, so they are dropped and listed in the x-cc-router-ignored-params response header.
³ Reasoning is returned as message.reasoning / delta.reasoning plus reasoning_details. Send reasoning_details back with the assistant message in tool loops so the model keeps its reasoning. Codex has no minimal effort, so minimal runs as low.
⁴ Neither subscription backend accepts audio or video; such parts get a 400.

Anthropic Messages API with OpenAI models

/v1/messages also runs ChatGPT models, so Anthropic SDKs and Claude Code can use them. Name the model as openai/gpt-6.2-sol, gpt-6.2-sol or an alias such as codex. Requests, responses, stream events and errors follow the Messages API:

Feature ChatGPT (openai/*) on /v1/messages
Text, system prompt, mid-conversation system messages ✓
Streaming (named SSE events, usage in message_start and message_delta) ✓
Client tools, tool_choice (auto, any, tool, none), disable_parallel_tool_use ✓
Images, PDFs and text documents, including images in tool_result ✓
output_config.effort, thinking mapped to the reasoning effort; no thinking blocks are returned
usage.cache_read_input_tokens ✓ (from OpenAI's cached tokens)
stop_reason max_tokens when the limit is hit ✓
/v1/messages/count_tokens estimated (about 4 characters per token)
cache_control accepted, ignored (OpenAI caches automatically)
Server tools (web_search, web_fetch, code execution) 400 — they run on Anthropic's servers
stop_sequences, temperature, top_p ignored

A malformed request gets a 400 invalid_request_error, as on the Anthropic API, instead of reaching OpenAI. A conversation over the model's context window gets Anthropic's prompt is too long error, so Claude Code compacts and retries.

Claude Code doesn't know the context window of an OpenAI model id and assumes 1M tokens. Tell it the real window, and point its background model at OpenAI when no Claude account is connected:

export ANTHROPIC_BASE_URL=http://your-server:3456
export ANTHROPIC_API_KEY=ccr_...
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=272000            # the model's context_length in GET /v1/models
export ANTHROPIC_DEFAULT_HAIKU_MODEL=openai/gpt-6.2-sol  # background tasks
claude --model openai/gpt-6.2-sol

Drop-in replacement for OpenRouter

Point an OpenRouter client at the router by changing only the base URL and the key. OpenRouter model ids work as they are, including dotted Claude versions (anthropic/claude-sonnet-4.6 runs claude-sonnet-4-6). Responses follow OpenRouter's shape:

  • usage includes prompt_tokens_details.cached_tokens, cache_write_tokens, completion_tokens_details.reasoning_tokens and cost (always 0: subscription traffic has no per-request price). prompt_tokens includes cached tokens. usage: {"include": true} adds the usage chunk to streams, like stream_options.include_usage.
  • Each response and chunk names its provider (Anthropic or OpenAI), and choices carry the provider's native_finish_reason.
  • Errors use a numeric code equal to the HTTP status, with metadata.provider_name for provider errors. A stream that fails midway ends with a chunk whose finish_reason is "error".
  • Images generated in chat arrive in message.images (or delta.images) as base64 PNG data URLs.

Not available: OpenRouter's own routing features (openrouter/auto, model suffixes such as :online, fallback models lists and provider preferences, which are accepted and ignored), and the /embeddings, /completions, /key and /credits endpoints.

A response cut off by the token limit ends with finish_reason: "length".

Multimodal user messages accept OpenAI text, image_url and file content parts. Remote http(s) images and base64 data URLs (jpeg, png, gif, webp) are translated for both Claude Messages and OpenAI Responses.

Image output is available in chat completions with modalities: ["image", "text"] on any openai/* model, or with an image model id such as openai/gpt-image-2.5-flare, and through the OpenAI Images-compatible endpoint when an OpenAI subscription account is connected:

image = client.images.generate(
    model="gpt-image-2.5-flare",
    prompt="A blue square on a white background",
    quality="low",
)
print(len(image.data[0].b64_json))

POST /v1/images/generations supports base64 JSON responses and Image API SSE streaming (stream=true, partial_images=0..3). The subscription backend currently supports one image per request (n=1). Claude supports image input, but does not generate images.

Run real provider smoke tests against a running router:

npm run test:live -- --require-all
npm run test:live -- --require-all --images  # incurs one image generation

The live suite checks text, SSE streaming with usage, and forced function tools for both configured providers. It prints only model ids, token counts, event counts, and image byte length—never credentials or image data.


Modes of operation

Standalone (default — no Docker)

Claude Code → cc-router:3456 → api.anthropic.com

Best for personal use. No Docker required. Runs in the background by default, auto-starts on boot if you choose.

cc-router start

Full mode with LiteLLM (optional — requires Docker)

Claude Code → cc-router:3456 → LiteLLM:4000 → api.anthropic.com

Adds a LiteLLM layer for usage logging, rate limiting, and a web dashboard at http://localhost:4000/ui.

cc-router docker up
# or: cc-router start --litellm

See docs/litellm-setup.md for details.


Codex CLI support (experimental)

CC-Router exposes an OpenAI Responses-compatible endpoint for Codex CLI at /v1/responses. This lets Codex use OpenAI ChatGPT/Codex subscription accounts through the same local router that Claude Code uses for Claude subscriptions.

Configure Codex:

cc-router configure codex --model openai/gpt-5-codex

This writes a managed provider block to ~/.codex/config.toml:

model = "openai/gpt-5-codex"
model_provider = "cc-router"

[model_providers.cc-router]
name = "CC-Router"
base_url = "http://localhost:3456/v1"
wire_api = "responses"
env_key = "CC_ROUTER_TOKEN"

Configure router-side model defaults and aliases:

cc-router configure models \
  --claude-model claude-sonnet-4-6 \
  --openai-model gpt-5-codex

This writes modelRouting to ~/.cc-router/config.json. It sets the Claude default, the OpenAI default, and practical aliases so claude/sonnet, sonnet, openai/default, and openai/codex resolve to the models you selected. Restart the router after changing these values.

Model discovery is dynamic. GET /v1/models returns an OpenAI-compatible model list by querying the configured Anthropic and OpenAI subscription APIs live:

curl http://localhost:3456/v1/models

Results are provider-prefixed, for example anthropic/claude-sonnet-4-6 and openai/gpt-5-codex. Configured aliases such as openai/codex are added when their upstream model is available. If one provider is temporarily unavailable, CC-Router still returns the models discovered from the other providers. The same list validates requests on /v1/chat/completions, /v1/images/generations, /v1/responses and openai/* requests on /v1/messages (see Models).

Then run Codex with the proxy secret in CC_ROUTER_TOKEN when your router is password-protected:

CC_ROUTER_TOKEN=cc-rtr-your-secret codex -m openai/gpt-5.5

Model prefixes:

Prefix Upstream
openai/* OpenAI ChatGPT/Codex subscription route
claude/* Claude subscription route
anthropic/* Claude subscription route

Examples after the configuration above:

Public model Routed upstream model
openai/codex gpt-5-codex
openai/default gpt-5-codex
claude/sonnet claude-sonnet-4-6

Claude Code can also send a /v1/messages request with an openai/* model. CC-Router translates that Anthropic Messages request into an OpenAI Responses request and converts JSON or basic text SSE responses back into Anthropic-shaped message responses.

OpenAI-to-Anthropic conversion supports text and function tool calls in both streaming and non-streaming responses.

OpenAI subscription account records are separated from Claude accounts with provider: "openai_subscription" so they do not enter the Anthropic token pool:

{
  "id": "openai-primary",
  "provider": "openai_subscription",
  "accessToken": "eyJ...",
  "refreshToken": "...",
  "expiresAt": 1999999999000,
  "scopes": ["openid", "profile", "email", "offline_access"]
}

Recommended OpenAI subscription login:

cc-router accounts login-openai

This uses the Codex device-code auth flow: the CLI prints a verification URL and one-time code, you approve the login in your browser, and CC-Router saves the resulting OpenAI subscription account record. A running proxy loads it within a few seconds; pass --id <id> to re-authenticate an existing account.

Manual account entry is also available for debugging:

cc-router accounts add-openai

This prompts for the OpenAI access token, refresh token, expiry timestamp, and scopes, validates the record shape, and saves it without overwriting Claude accounts.


Client mode — connecting to an existing CC-Router

If someone on your team already hosts a CC-Router instance (on a VPS, home server, or another machine on the LAN), you don't need to install accounts locally. You just point your Claude Code at the remote proxy.

The setup wizard asks about this at the very first step:

cc-router setup
# → What do you want to do?
#   • Host CC-Router on this machine
#   • Connect to an existing CC-Router server  ← pick this

Or use the dedicated command directly:

# Quick connect — just point Claude Code at the remote proxy
cc-router client connect http://192.168.1.50:3456 --secret cc-rtr-abc123...

# Check status
cc-router client status

# Disconnect (restores Claude Code defaults)
cc-router client disconnect

Client mode writes ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN into ~/.claude/settings.json, so Claude Code talks directly to the remote proxy. Nothing runs locally — no accounts, no proxy process, no resources.

CLI reference

cc-router client connect <url>       Connect Claude Code to a CC-Router server
cc-router client connect --desktop   Also configure Claude Desktop interception
cc-router client connect -s <secret> Pass the proxy secret inline (or use --secret)
cc-router client disconnect          Revert all client configuration
cc-router client status              Show current connection + remote server health
cc-router client start-desktop       Start the Claude Desktop mitmproxy interceptor
cc-router client stop-desktop        Stop the Claude Desktop interceptor

Claude Desktop support

Claude Desktop (chat + Cowork) can be routed through CC-Router, but unlike Claude Code it does not respect ANTHROPIC_BASE_URL. It talks directly to api.anthropic.com via an embedded Anthropic SDK. To redirect its traffic, CC-Router uses mitmproxy in local redirect mode — a process-scoped interceptor that only captures Claude Desktop's network traffic and forwards it to the proxy.

This is opt-in — the setup wizard will ask if you want it.

Requirements

  • mitmproxy ≥ 10.1.5 (macOS, Windows) or ≥ 11.1 (Linux — requires kernel ≥ 6.8)
  • Admin access to install the mitmproxy CA certificate
  • On macOS: manual approval of mitmproxy's Network Extension (one time, via System Settings)

Installing mitmproxy

# macOS
brew install mitmproxy

# Windows
# Download the installer from https://mitmproxy.org/downloads/
# (or: pip install mitmproxy)

# Linux
pip install mitmproxy        # kernel 6.8+ required for local mode

Enabling Desktop interception

During cc-router setup or cc-router client connect, answer Yes when asked about Claude Desktop. The wizard will:

  1. Check that mitmproxy is installed
  2. Generate the mitmproxy CA certificate (if not already present)
  3. Install the CA into the OS trust store (requires sudo/admin)
  4. Write the redirect addon to ~/.cc-router/interceptor/addon.py
  5. On macOS, prompt you to approve the Network Extension

Then start the interceptor:

cc-router client start-desktop

Open Claude Desktop and send a message. The request will be intercepted, redirected to CC-Router, and round-robinned across your accounts just like Claude Code traffic.

Stopping / removing Desktop interception

cc-router client stop-desktop    # Stop the interceptor (keep configuration)
cc-router client disconnect      # Stop + remove all client config

How it works under the hood

Claude Desktop
     │
     │  tries to connect to api.anthropic.com:443
     ▼
mitmproxy (local mode)
     │  addon.py rewrites scheme/host to CC-Router
     ▼
CC-Router :3456 ──► api.anthropic.com  (with OAuth Bearer token)

mitmproxy's local mode is process-scoped — it only intercepts traffic from the Claude process, not your browser, curl, or any other app. The OS-level interception uses:

Platform Mechanism
macOS Network Extension (App Proxy Provider API)
Windows WinDivert (WFP kernel driver)
Linux eBPF (kernel ≥ 6.8)

Troubleshooting

  • macOS: "provider rejected new flow" — re-enable Mitmproxy Redirector in System Settings → General → Login Items & Extensions → Network Extensions, then restart mitmproxy.
  • Windows: UAC prompt every start — expected; mitmproxy's redirector needs admin at runtime.
  • Linux: "eBPF program failed to load" — check your kernel version with uname -r. You need ≥ 6.8.
  • Chat shows "failed to connect" — make sure CC-Router is reachable from the mitmproxy process. Run curl http://localhost:3456/cc-router/health to verify the proxy is up.

Reverting to normal Claude Code

To stop using cc-router and go back to normal Claude Code authentication:

cc-router revert

This stops the proxy process, removes the auto-start service (if installed), and removes cc-router's settings from ~/.claude/settings.json. Claude Code will use its own authentication on the next launch.

For a gentler approach, cc-router stop interactively asks what you want to clean up.


Status dashboard

cc-router status
 CC-Router  ·  standalone → api.anthropic.com  ·  up 2h 14m  ·  [q] quit

 OPERATIONS  base http://localhost:3456  ·  auth protected  ·  models dynamic
  Claude 2/2 healthy  OpenAI 1/1 healthy  ·  cross-route ready
  endpoints /v1/messages /v1/responses /v1/models /cc-router/accounts
  routing claude=claude-sonnet-4-6 aliases[sonnet]  openai=gpt-5-codex aliases[codex]
  models [m] list/select  change [c] Claude [o] OpenAI

 MODELS  [m/r] refresh  [↑/↓] select  [c] Claude default  [o] OpenAI default
  current claude=claude-sonnet-4-6  openai=gpt-5-codex
  ▶ anthropic/claude-sonnet-4-6 Claude
    openai/gpt-5-codex OpenAI

 ACCOUNTS  2/2 healthy

  ● max-account-1    ok      req   142  err   0  expires  6h 48m  last  2s ago
  ● max-account-2    ok      req   139  err   0  expires  6h 51m  last  5s ago

 TOTALS  requests 281  ·  errors 0  ·  refreshes 2

 RECENT ACTIVITY
  14:23:01  → max-account-1    route
  14:22:58  → max-account-2    route
  14:22:45  ↻ max-account-1    refresh

Press q to quit. Run with --json for non-interactive output; the JSON includes an operational block with capabilities, endpoints, provider readiness, auth status, and model routing. Secrets and account tokens are never included.

The dashboard is also a control surface. In local mode it controls the local proxy; in client mode it controls the remote CC-Router configured by cc-router client connect.

Key Action
Tab Switch focus between logs, accounts, and models
n Add a Claude account
e Enable/disable selected Claude account
w / s Change selected Claude account weekly/session cap
d Delete selected Claude account
m / r Load or refresh discovered provider models
c Set selected anthropic/* model as Claude default
o Set selected openai/* model as OpenAI default

List and change models without waiting for a package update:

cc-router models list
cc-router models set --claude-model anthropic/claude-sonnet-4-6
cc-router models set --openai-model openai/gpt-5-codex

When the proxy is running, models set updates the live router and persists the new defaults. If the proxy is offline, it writes the configuration for the next start.


Security

  • Tokens are stored locally in ~/.cc-router/accounts.json, never in the repository
  • The file is excluded by .gitignore
  • Writes are atomic (write to .tmp, then rename) — no corruption on crash
  • Keychain reads use execFile with a fixed argument array — no shell injection
  • Anonymous opt-out telemetry via Aptabase (see Telemetry below)

See docs/security.md for details.


Telemetry

CC-Router sends a handful of anonymous lifecycle events to Aptabase (privacy-first, open source, EU-hosted). The goal is simple: know how many people use the project, which versions are live, and roughly how many instances are running — so we can prioritize fixes and features.

What we send — the entire payload lives in src/utils/telemetry.ts, audit it yourself:

Event When Custom props
app_started First proxy start after install first_run: true
setup_completed Setup wizard finishes successfully account_count
proxy_started Each cc-router start account_count, mode
proxy_heartbeat Every hour while the proxy is running uptime_minutes, account_count
telemetry_disabled When you run cc-router telemetry off —

Plus anonymous system props with every event: appVersion, osName (macOS/Linux/Windows), osVersion, locale, engineVersion (Node), and an anonymous installId (random UUID generated on first run, stored in ~/.cc-router/telemetry.json).

What we never send: IPs, OAuth tokens, account names, request content, prompts, responses, URLs, hostnames, usernames, file paths — nothing that could identify you or your usage patterns.

Disable it — three ways, any one works:

# 1. Persistent opt-out (recommended)
cc-router telemetry off

# 2. Respect the de-facto standard (honored by many OSS tools)
export DO_NOT_TRACK=1

# 3. Project-specific override
export CC_ROUTER_TELEMETRY=0

Check status anytime: cc-router telemetry status.


Disclaimer

CC-Router is an independent, unofficial project. It is not affiliated with, endorsed by, or supported by Anthropic or OpenAI. "Claude", "ChatGPT", "Codex" and related names are trademarks of their respective owners.

CC-Router uses the OAuth tokens of your own Claude and ChatGPT subscriptions. Its OpenAI-compatible API sends that traffic in the form the subscription backends expect from Claude Code and Codex. Read Anthropic's and OpenAI's terms of service before using it. Subscriptions are generally licensed for personal, interactive use: serving them as an API to other services, sharing them between people, or pooling several to increase throughput may violate those terms. Both providers can limit, suspend or ban accounts for usage they consider abnormal, and they can change their backends at any time, which may break this software without notice.

You are solely responsible for how you use CC-Router — including compliance with the providers' terms, with the law, and with any data-protection obligations for the content you send through it, and for securing any instance you expose to a network.

The software is provided "as is", without warranty of any kind (see the MIT License). The authors and contributors accept no liability for account bans or suspensions, loss of access or of subscription fees, unexpected charges, data loss or leaks, service interruptions, incorrect model output, or any other damage or consequence arising from the use of this software. Use it at your own risk.


Contributing

See CONTRIBUTING.md.

Bug reports → GitHub Issues


License

MIT

About

Round-robin proxy for multiple Claude Max subscriptions — multiply your Claude Code throughput with automatic OAuth token rotation and transparent request routing

Topics

Resources

Contributing

Security policy

Stars

46 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages