Docker setup for Claude Code Mux - intelligent model routing proxy for Claude Code with multi-provider support and automatic failover.
Note: This is an unofficial Docker wrapper. For the official project, documentation, and features, visit 9j/claude-code-mux.
Claude Code Mux is a lightweight Rust-powered proxy that enables:
- Multi-model routing (use different AI models for different tasks)
- Provider failover (automatic backup when primary fails)
- OAuth support (free API access for Claude Pro/Max, ChatGPT Plus/Pro, Google AI Pro/Ultra)
- 18+ provider support (Anthropic, OpenAI, Google, Groq, OpenRouter, etc.)
- Intelligent routing by task type (websearch, reasoning, background, default)
See the official repository for complete features and documentation.
git clone https://github.com/shekohex/ccm-docker
cd ccm-docker
# Copy and configure environment variables
cp .env.example .env
# Edit .env with your API keys
# Start the service
docker compose up -d
# View logs
docker compose logs -fAccess the admin UI at: http://localhost:13456
To update to the latest claude-code-mux version (v0.6.2+):
# Pull latest changes
git pull
# Rebuild image with latest upstream version
docker compose build --no-cache
# Restart with new image
docker compose up -d
# Re-authenticate OAuth providers (required after update)
# Visit http://localhost:13456 and authenticate againNote: OAuth token format changed in v0.6.2. After updating, you must re-authenticate OAuth providers via the admin UI.
The proxy works immediately with API key providers (GLM, Minimax, Kimi). OAuth models (Claude, GPT, Gemini) require authentication:
- Configure API keys in
.env(required for GLM/Minimax/Kimi) - Authenticate OAuth at http://localhost:13456 (optional, for Claude/GPT/Gemini)
Automatic Failover: OAuth models automatically fall back to GLM models if OAuth is not configured. Once you authenticate OAuth providers, the proxy will use them as the primary models.
Create a .env file from the example:
cp .env.example .envEdit .env and add your API keys:
# Required for GLM models (glm-4.6, glm-4.5-air, glm-4.5v)
ZAI_API_KEY=your-zai-api-key-here
# Required for MiniMax-M2 model
MINIMAX_API_KEY=your-minimax-api-key-here
# Required for kimi-k2-thinking model
KIMI_API_KEY=your-kimi-api-key-hereOAuth providers (Anthropic, OpenAI, Gemini) are configured via the web UI at http://localhost:13456 - no environment variables needed.
-
./config→/configin container (bind mount)config.toml- Main configuration file
-
ccm-data→/home/ccm/.claude-code-muxin container (named volume)oauth_tokens.json- OAuth authentication tokensccm.pid- Process ID file- Logs are sent to stdout/stderr (view with
docker compose logs)
Edit ./config/config.toml on your host machine. The default config includes:
- 6 Providers: Anthropic (OAuth), OpenAI (OAuth), Gemini (OAuth), Z.AI (API key), Minimax (API key), Kimi (API key)
- 18 Models: Claude Opus/Sonnet/Haiku, GPT-5.1 variants (4 models), Gemini models (6 models), GLM models, MiniMax M2, Kimi K2
- Smart Routing: Automatically routes to best model based on task type
- Multi-Tier Fallback: Gemini models cascade through multiple tiers before GLM fallback
Restart after config changes:
docker compose restartSee Available Models and Router Configuration sections for details.
- Edit
./config/config.toml - Add provider entry:
[[providers]]
name = "my-provider"
provider_type = "openai"
enabled = true
api_key = "sk-..."
models = []Supported provider types:
anthropic- Anthropic API (supports OAuth)openai- OpenAI API (supports OAuth)gemini- Google Gemini (supports OAuth and API key)z.ai- Z.AI (API key for GLM models)minimax- Minimax (API key)kimi-coding- Kimi/Moonshot (API key)openrouter- OpenRoutergroq- Groqzenmux- ZenMuxvertex-ai- Google Vertex AI
OAuth tokens are stored in the ccm-data volume at /home/ccm/.claude-code-mux/oauth_tokens.json.
Use the web UI at http://localhost:13456 to set up OAuth authentication for:
- Anthropic Claude Pro/Max - Free API access to Claude models
- OpenAI ChatGPT Plus/Pro/Codex - Free API access to GPT-5.1 models
- Google Gemini AI Pro/Ultra - Free API access to Gemini 2.5 & 3 models
OAuth setup is done entirely through the web UI - no environment variables or API keys needed.
The default configuration includes the following models:
Note: OAuth models automatically fall back to GLM models if OAuth is not configured. See Router Configuration for details.
- claude-opus-4.1 - Most powerful reasoning (uses
thinkrouting) - claude-sonnet-4.5 - Balanced performance (default routing)
- claude-haiku-4.5 - Fast responses
- claude-sonnet-3.7 - Alternative Sonnet version
- gpt-5.1 - Latest flagship model (uses
websearchrouting) - gpt-5.1-chat-latest - Chat-optimized variant
- gpt-5.1-codex - Full coding model
- gpt-5.1-codex-mini - Lightweight coding model
- gemini-3-pro-preview - Preview of Gemini 3 (fallback: 2.5-pro → 2.5-flash → 2.0-flash → GLM)
- gemini-2.5-pro - Most capable Gemini 2.5 (fallback: 2.5-flash → 2.0-flash → GLM)
- gemini-2.5-flash - Fast Gemini 2.5 (fallback: 2.0-flash → GLM)
- gemini-2.0-flash - Fast Gemini 2.0 (fallback: GLM)
- gemini-1.5-pro - Gemini 1.5 Pro (fallback: 1.5-flash → GLM)
- gemini-1.5-flash - Fast Gemini 1.5 (fallback: GLM)
- glm-4.6 - Latest GLM model
- glm-4.5-air - Lightweight, fast (uses
backgroundrouting) - glm-4.5v - Vision-capable variant
- minimax-m2 - MiniMax M2 model
- kimi-k2-thinking - Reasoning-capable model
The router automatically selects models based on task type:
[router]
default = "claude-sonnet-4.5" # General tasks (→ glm-4.6 if OAuth not configured)
think = "claude-opus-4.1" # Complex reasoning (→ glm-4.6 fallback)
websearch = "gpt-5.1" # Web search tasks (→ glm-4.6 fallback)
background = "glm-4.5-air" # Fast background tasks (API key only)Task Routing:
- default - All standard requests
- think - Requests with extended thinking enabled
- websearch - Requests using web search tools
- background - Fast, simple tasks (configurable via regex)
Automatic Failover: If OAuth is not configured, Claude/GPT models automatically fall back to GLM models (priority 2). Once OAuth is authenticated, requests will use the primary models (priority 1).
[[models]]
name = "fast-model"
[[models.mappings]]
provider = "provider-name"
actual_model = "provider/model-id"
priority = 1All OAuth models are configured with automatic failover to GLM models. Gemini models use multi-tier fallback for maximum reliability:
Simple Failover (Claude/GPT):
[[models]]
name = "claude-sonnet-4.5"
# Priority 1: OAuth provider (requires authentication)
[[models.mappings]]
actual_model = "claude-sonnet-4-5-20250929"
priority = 1
provider = "claude-max-main"
# Priority 2: Fallback to GLM if OAuth fails
[[models.mappings]]
actual_model = "glm-4.6"
priority = 2
provider = "zai-coding-plan"Multi-Tier Failover (Gemini):
[[models]]
name = "gemini-3-pro-preview"
# Priority 1: Gemini 3 Pro (OAuth)
[[models.mappings]]
actual_model = "gemini-3-pro-preview"
priority = 1
provider = "gemini-oauth"
# Priority 2: Fallback to Gemini 2.5 Pro
[[models.mappings]]
actual_model = "gemini-2.5-pro"
priority = 2
provider = "gemini-oauth"
# Priority 3: Fallback to Gemini 2.5 Flash
[[models.mappings]]
actual_model = "gemini-2.5-flash"
priority = 3
provider = "gemini-oauth"
# Priority 4: Fallback to Gemini 2.0 Flash
[[models.mappings]]
actual_model = "gemini-2.0-flash"
priority = 4
provider = "gemini-oauth"
# Priority 5: Final fallback to GLM
[[models.mappings]]
actual_model = "glm-4.6"
priority = 5
provider = "zai-coding-plan"How it works: The proxy tries providers in priority order. Gemini models cascade through multiple model tiers within OAuth before falling back to GLM, maximizing availability.
docker compose up -ddocker compose logs -fdocker compose restartdocker compose downdocker compose build --no-cachedocker compose exec ccm shAll runtime data (OAuth tokens, PID files) is stored in the ccm-data named volume, mounted at /home/ccm/.claude-code-mux inside the container. This ensures data persists across container restarts.
Configure Claude Code to use the proxy:
export ANTHROPIC_BASE_URL="http://localhost:13456"
export ANTHROPIC_API_KEY="any-string"
claudeOr in your Claude Code config:
{
"anthropicBaseUrl": "http://localhost:13456",
"anthropicApiKey": "any-string"
}docker compose psdocker compose logs -f ccmdocker compose exec ccm curl http://localhost:13456/api/config/jsondocker compose down -v
docker compose up -dEnsure ./config/config.toml exists and has valid TOML syntax:
docker compose exec ccm ccm --version
docker compose exec ccm cat /config/config.tomlIf port 13456 is in use, modify compose.yml:
ports:
- "8080:13456"Then set ANTHROPIC_BASE_URL=http://localhost:8080
- OAuth tokens stored in named volume
/home/ccm/.claude-code-muxwith permissions 0600 - Container runs as non-root user
ccm(UID 1000) - Only port 13456 exposed
- Config files readable only by container user
Web interface available at: http://localhost:13456
Features:
- Provider management
- Model configuration
- Router setup
- Live testing
- OAuth token management
- Image size: ~10MB (Alpine + musl binary)
- Memory: ~6MB RAM
- Startup: <100ms
- Routing overhead: <1ms per request
Original Project:
This Docker Wrapper:
- Docker-specific issues: Create Issue
This Docker wrapper is provided as-is. Claude Code Mux is licensed under MIT - see the original project for details.