Claude Code Proxy with Multi-Account Rotation & Rate Limit Failover
Fork of CaddyGlow/claude-code-proxy
This fork adds: Multi-account rotation with automatic failover
Features · Quick Start · Multi-Account Setup · API Reference · Configuration
- Claude API Proxy — Access via Claude Max subscription
- OpenAI Format — Accepts requests in OpenAI chat completions format
- Dual Modes — SDK mode (with MCP tools) and API mode (direct proxy)
- OAuth2 PKCE — Automatic credential management and token refresh
- 3x+ throughput by distributing requests across multiple Claude accounts
- Zero downtime with automatic failover when accounts hit rate limits
- Proactive token refresh before expiration via background scheduler
- Hot-reload — add/remove accounts without restart
docker run -d -p 8000:8000 -v ccproxy-data:/data/home \
--name ccproxy ghcr.io/joachimbrindeau/claude-proxy-multi:latestOr with Docker Compose (deploy/docker-compose.yaml):
docker compose -f deploy/docker-compose.yaml up -dOpen http://localhost:8000 to add accounts via the web UI.
# Install dependencies
uv sync --all-extras --dev
# Start dev server
make dev- Request arrives at proxy
- Rotation pool selects next available account
- Request forwarded with account's auth token
- On success: response returned, rotation advances
- On 429: automatic retry with next account
cat > ~/.claude/accounts.json << 'EOF'
{
"version": 1,
"accounts": {
"primary": {
"accessToken": "sk-ant-oat01-...",
"refreshToken": "sk-ant-ort01-...",
"expiresAt": 1747909518727
},
"secondary": {
"accessToken": "sk-ant-oat01-...",
"refreshToken": "sk-ant-ort01-...",
"expiresAt": 1747909518727
}
}
}
EOF| Variable | Default | Description |
|---|---|---|
CCPROXY_ACCOUNTS_PATH |
~/.claude/accounts.json |
Accounts file location |
CCPROXY_ROTATION_ENABLED |
true |
Enable/disable rotation |
CCPROXY_HOT_RELOAD |
true |
Watch file for changes |
CCPROXY_REFRESH_BUFFER |
600 |
Seconds before expiry to refresh |
| Endpoint | Method | Description |
|---|---|---|
/status |
GET | Pool aggregate status |
/status/accounts |
GET | All accounts list |
/status/accounts/{name} |
GET | Single account details |
/status/accounts/{name}/refresh |
POST | Force token refresh |
/status/accounts/{name}/enable |
POST | Re-enable disabled account |
| Endpoint | Format | Mode |
|---|---|---|
POST /api/v1/messages |
Anthropic | Direct Proxy |
POST /api/v1/chat/completions |
OpenAI | Direct Proxy |
POST /sdk/v1/messages |
Anthropic | SDK with Tools |
POST /sdk/v1/chat/completions |
OpenAI | SDK with Tools |
GET /api/v1/models |
- | List Models |
| Endpoint | Description |
|---|---|
GET /health |
Health check |
GET /status |
Rotation pool status |
# For Anthropic-compatible clients
export ANTHROPIC_BASE_URL="http://localhost:8000/api"
export ANTHROPIC_API_KEY="dummy"
# For OpenAI-compatible clients
export OPENAI_BASE_URL="http://localhost:8000/api/v1"
export OPENAI_API_KEY="dummy"# Enable API key authentication
export CCPROXY_SECURITY_API_KEYS_ENABLED=true
export CCPROXY_SECURITY_API_KEY_SECRET=$(openssl rand -hex 32)
# Create a key
ccproxy auth create-key --user john --expires 90
# Use it
curl -H "Authorization: Bearer <token>" http://localhost:8000/v1/chat/completionsMIT License - see LICENSE.
Built on claude-code-proxy by @CaddyGlow.