| Crates.io | claude-code-mux |
| lib.rs | claude-code-mux |
| version | 0.6.3 |
| created_at | 2025-11-19 10:14:19.974323+00 |
| updated_at | 2025-11-19 19:37:09.456532+00 |
| description | High-performance, intelligent Claude Code router built in Rust |
| homepage | |
| repository | https://github.com/9j/claude-code-mux |
| max_upload_size | |
| id | 1939831 |
| size | 1,560,110 |
OpenRouter met Claude Code Router. They had a baby.
Now your coding assistant can use GLM 4.6 for one task, Kimi K2 Thinking for another, and Minimax M2 for a third. All in the same session. When your primary provider goes down, it falls back to your backup automatically.
⚡️ Multi-model intelligence with provider resilience
A lightweight, Rust-powered proxy that provides intelligent model routing, provider failover, streaming support, and full Anthropic API compatibility for Claude Code.
Claude Code → Claude Code Mux → Multiple AI Providers
(Anthropic API) (OpenAI/Anthropic APIs + Streaming)
claude-* to default model)CCM-SUBAGENT-MODEL tags
Main dashboard with router configuration and provider management
Add and manage multiple AI providers with automatic format translation
Configure models with priority-based fallback routing
Set up intelligent routing rules for different task types
Test your configuration with live API requests and responses
18+ AI providers with automatic format translation, streaming, and failover:
Download the latest release for your platform from GitHub Releases.
# Download and extract (glibc)
curl -L https://github.com/9j/claude-code-mux/releases/latest/download/ccm-linux-x86_64.tar.gz | tar xz
# Or download musl version (static linking, more portable)
curl -L https://github.com/9j/claude-code-mux/releases/latest/download/ccm-linux-x86_64-musl.tar.gz | tar xz
# Move to PATH
sudo mv ccm /usr/local/bin/
# Download and extract
curl -L https://github.com/9j/claude-code-mux/releases/latest/download/ccm-macos-x86_64.tar.gz | tar xz
# Move to PATH
sudo mv ccm /usr/local/bin/
# Download and extract
curl -L https://github.com/9j/claude-code-mux/releases/latest/download/ccm-macos-aarch64.tar.gz | tar xz
# Move to PATH
sudo mv ccm /usr/local/bin/
ccm.exe to your PATHccm --version
If you have Rust installed, you can install directly from crates.io:
cargo install claude-code-mux
This will download, compile, and install the ccm binary to your cargo bin directory (usually ~/.cargo/bin/).
ccm --version
# Clone the repository
git clone https://github.com/9j/claude-code-mux
cd claude-code-mux
# Build the release binary
cargo build --release
# The binary will be available at target/release/ccm
# Copy to /usr/local/bin for global access
sudo cp target/release/ccm /usr/local/bin/
# Or add to your shell profile (e.g., ~/.zshrc or ~/.bashrc)
export PATH="$PATH:/path/to/claude-code-mux/target/release"
# From the project directory
cargo run --release -- start
ccm start
The server will start on http://127.0.0.1:13456 with a web-based admin UI.
💡 First-time users: A default configuration file will be automatically created at:
- Unix/Linux/macOS:
~/.claude-code-mux/config.toml- Windows:
%USERPROFILE%\.claude-code-mux\config.toml
Navigate to:
http://127.0.0.1:13456
You'll see a modern admin interface with these tabs:
Set Claude Code to use the proxy:
export ANTHROPIC_BASE_URL="http://127.0.0.1:13456"
export ANTHROPIC_API_KEY="any-string"
claude
That's it! Your setup is complete.
Navigate to Providers tab → Click "Add Provider"
claude-max💡 Pro Tip: Claude Pro/Max subscribers get unlimited API access for FREE via OAuth!
zenmuxyour-zenmux-api-keyopenaisk-...zaiyour-zai-api-keygemini-pro💡 Pro Tip: Google AI Pro/Ultra subscribers get unlimited API access for FREE via OAuth!
vertex-aiyour-gcp-project-idus-central1 (or your preferred region)Note: Vertex AI uses Application Default Credentials (ADC). Make sure you've run
gcloud auth application-default loginfirst.
Supported Providers:
Navigate to Models tab → Click "Add Model"
minimax-m2minimaxMiniMax M21Why Minimax M2? - $0.30/$1.20 per M tokens (8% of Claude Sonnet 4.5 cost), 100 TPS throughput, MoE architecture
glm-4.6zaiglm-4.61openrouterz-ai/glm-4.62How Fallback Works: If
zaiprovider fails, automatically falls back toopenrouterGLM-4.6 Pricing: $0.60/$2.20 per M tokens (90% cheaper than Claude Sonnet 4.5), 200K context window
Navigate to Router tab
Configure routing rules (auto-saves on change!):
minimax-m2 (general tasks - ultra-fast, 8% of Claude cost)kimi-k2 (plan mode with reasoning - 256K context)glm-4.5-air (simple background tasks)glm-4.6 (web search tasks)^claude- (transform Claude models before routing)(?i)claude.*haiku (detect background tasks)Navigate to Settings tab for centralized regex management:
Auto-mapping Pattern: Regex to match models for transformation (e.g., ^claude-)
Background Task Pattern: Regex to detect background tasks (e.g., (?i)claude.*haiku)
Click "💾 Save to Server" to save configuration to disk, or "🔄 Save & Restart" to save and restart the server.
Note: Router configuration auto-saves to localStorage on change, but you need to click "Save to Server" to persist to disk.
Navigate to Test tab:
minimax-m2 or glm-4.6)Hello, test messageFlow: Auto-map (transform) → WebSearch > Subagent > Think > Background > Default
auto_map_regex patternmodel="claude-4-5-sonnet" and regex ^claude-claude-4-5-sonnet → minimax-m2 (default model)Key Point: Auto-mapping is NOT a routing decision - it transforms the model name BEFORE routing logic is applied.
web_search tool in tools arraywebsearch model (e.g., GLM-4.6)<CCM-SUBAGENT-MODEL>model-name</CCM-SUBAGENT-MODEL> tagthinking field with type: "enabled"/plan)think model (e.g., Kimi K2 Thinking, Claude Opus)background_regex pattern(?i)claude.*haiku (case-insensitive)model="claude-4-5-haiku" (checked BEFORE auto-mapping)background model (e.g., GLM-4.5-air)Important: Background detection uses the ORIGINAL model name, not the auto-mapped one.
Request: model="claude-4-5-haiku", tools=[web_search]
Config: auto_map_regex="^claude-", background_regex="(?i)claude.*haiku", websearch="glm-4.6"
Flow:
1. Auto-map: "claude-4-5-haiku" → "minimax-m2" (transformed)
2. WebSearch check: tools has web_search → Route to "glm-4.6"
Result: glm-4.6 (websearch model)
Request: model="claude-4-5-haiku"
Config: auto_map_regex="^claude-", background_regex="(?i)claude.*haiku", background="glm-4.5-air"
Flow:
1. Auto-map: "claude-4-5-haiku" → "minimax-m2" (transformed)
2. WebSearch check: No web_search tool
3. Think check: No thinking field
4. Background check on ORIGINAL: "claude-4-5-haiku" matches "(?i)claude.*haiku" → Route to "glm-4.5-air"
Result: glm-4.5-air (background model)
Request: model="claude-4-5-sonnet", thinking={type:"enabled"}
Config: auto_map_regex="^claude-", think="kimi-k2-thinking"
Flow:
1. Auto-map: "claude-3-5-sonnet" → "minimax-m2" (transformed)
2. WebSearch check: No web_search tool
3. Think check: thinking.type="enabled" → Route to "kimi-k2-thinking"
Result: kimi-k2-thinking (think model)
Request: model="glm-4.6"
Config: auto_map_regex="^claude-", default="minimax-m2"
Flow:
1. Auto-map: "glm-4.6" doesn't match "^claude-" → No transformation
2. WebSearch check: No web_search tool
3. Think check: No thinking field
4. Background check: "glm-4.6" doesn't match background regex
5. Default: Use model name as-is
Result: glm-4.6 (original model name, routed through model mappings)
Providers:
Models:
minimax-m2 → Minimax (MiniMax M2) — $0.30/$1.20 per M tokensglm-4.6 → z.ai (glm-4.6) with OpenRouter fallback — $0.60/$2.20 per M tokensglm-4.5-air → z.ai (glm-4.5-air) — Lower cost than GLM-4.6kimi-k2-thinking → Kimi (kimi-k2-thinking) — Reasoning optimized, 256K contextRouting:
minimax-m2 (8% of Claude cost, 100 TPS)kimi-k2-thinking (thinking model with 256K context)glm-4.5-air (simple tasks)glm-4.6 (web search + reasoning)^claude- (transform Claude models to minimax-m2)(?i)claude.*haiku (detect Haiku models for background)Cost Comparison (per 1M tokens):
Providers:
Models:
claude-sonnet-4-5 → Anthropic nativeclaude-opus-4-1 → Anthropic nativeRouting:
claude-sonnet-4-5claude-opus-4-1claude-haiku-4-5claude-sonnet-4-5Providers:
Models:
minimax-m2:
MiniMax-M2minimax/minimax-m2 (if available)glm-4.6:
glm-4.6z-ai/glm-4.6Routing:
minimax-m2 (falls back to OpenRouter if Minimax fails)glm-4.6 (with OpenRouter fallback)glm-4.5-airglm-4.6Claude Pro/Max, ChatGPT Plus/Pro, and Google AI Pro/Ultra subscribers can use their respective APIs completely free via OAuth 2.0 authentication.
Via Web UI (Recommended):
For Claude Pro/Max:
claude-max)For ChatGPT Plus/Pro:
chatgpt-codex)For Google AI Pro/Ultra:
gemini-pro)💡 Supported Models:
- Claude OAuth: All Claude models (Opus, Sonnet, Haiku)
- ChatGPT OAuth: GPT-5.1, GPT-5.1 Codex (with reasoning blocks converted to thinking)
- Gemini OAuth: All Gemini models via Code Assist API (Pro, Flash, Ultra)
Via CLI Tool:
# Run OAuth login tool
cargo run --example oauth_login
# Or if installed
./examples/oauth_login
The tool will:
~/.claude-code-mux/oauth_tokens.jsonNavigate to Settings tab → OAuth Tokens section to:
Token Features:
Security Notes:
0600 permissions (owner read/write only)oauth_tokens.json to version controlFor advanced integrations:
POST /api/oauth/authorize - Get authorization URLPOST /api/oauth/exchange - Exchange code for tokensGET /api/oauth/tokens - List all tokensPOST /api/oauth/tokens/refresh - Refresh a tokenPOST /api/oauth/tokens/delete - Delete a tokenSee docs/OAUTH_TESTING.md for detailed API documentation.
Automatically transform model names before routing logic is applied:
^claude-claude-* models will be transformed to your default modelUse Cases:
^claude-^(claude-|gpt-)^(claude-sonnet|claude-opus)Example:
Config: auto_map_regex="^claude-", default="minimax-m2", websearch="glm-4.6"
Request: model="claude-sonnet", tools=[web_search]
Flow:
1. Transform: "claude-sonnet" → "minimax-m2"
2. Route: WebSearch detected → "glm-4.6"
Result: glm-4.6 model
Automatically detect and route background tasks using regex patterns:
(?i)claude.*haikuUse Cases:
(?i)claude.*haiku(?i)(haiku|flash|mini)Important: Background detection checks the ORIGINAL model name (before auto-mapping)
Full Server-Sent Events (SSE) streaming support:
curl -X POST http://127.0.0.1:13456/v1/messages \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "minimax-m2",
"max_tokens": 1000,
"stream": true,
"messages": [{"role": "user", "content": "Hello"}]
}'
Supported Providers:
Automatic failover with priority-based routing:
[[models]]
name = "glm-4.6"
[[models.mappings]]
actual_model = "glm-4.6"
priority = 1
provider = "zai"
[[models.mappings]]
actual_model = "z-ai/glm-4.6"
priority = 2
provider = "openrouter"
If z.ai fails, automatically falls back to OpenRouter. Works with all providers!
# Start with default config (~/.claude-code-mux/config.toml)
# Config file is automatically created if it doesn't exist
ccm start
# Start with custom config
ccm start --config path/to/config.toml
# Start on custom port
ccm start --port 8080
Default Config Location:
~/.claude-code-mux/config.toml%USERPROFILE%\.claude-code-mux\config.toml (e.g., C:\Users\<username>\.claude-code-mux\config.toml)# Start in background
nohup ccm start > ccm.log 2>&1 &
# Check if running
ps aux | grep ccm
# Stop the server
pkill ccm
Create /etc/systemd/system/ccm.service:
[Unit]
Description=Claude Code Mux
After=network.target
[Service]
Type=simple
User=your-username
WorkingDirectory=/path/to/claude-code-mux
ExecStart=/path/to/claude-code-mux/target/release/ccm start
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
Then:
# Reload systemd
sudo systemctl daemon-reload
# Enable on boot
sudo systemctl enable ccm
# Start service
sudo systemctl start ccm
# Check status
sudo systemctl status ccm
# View logs
sudo journalctl -u ccm -f
Create ~/Library/LaunchAgents/com.ccm.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ccm</string>
<key>ProgramArguments</key>
<array>
<string>/path/to/claude-code-mux/target/release/ccm</string>
<string>start</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/tmp/ccm.log</string>
<key>StandardErrorPath</key>
<string>/tmp/ccm.error.log</string>
</dict>
</plist>
Then:
# Load and start
launchctl load ~/Library/LaunchAgents/com.ccm.plist
# Stop
launchctl unload ~/Library/LaunchAgents/com.ccm.plist
# Check status
launchctl list | grep ccm
# Show version
ccm --version
# Show help
ccm --help
/v1/messages)/v1/messages/count_tokens)curl http://127.0.0.1:13456/api/config/json
Set environment variable:
RUST_LOG=debug ccm start
Or update your config file (~/.claude-code-mux/config.toml):
[server]
log_level = "debug"
curl -X POST http://127.0.0.1:13456/v1/messages \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "minimax-m2",
"max_tokens": 100,
"messages": [{"role": "user", "content": "Hello"}]
}'
# If running with RUST_LOG
RUST_LOG=info ccm start
# Check system logs
tail -f ~/.claude-code-mux/ccm.log
Yes! Just set two environment variables:
export ANTHROPIC_BASE_URL="http://127.0.0.1:13456"
export ANTHROPIC_API_KEY="any-string"
claude
The proxy returns an error response with details about the failover chain and which providers were attempted. Check the logs for debugging information.
Yes! Claude Code Mux supports OAuth 2.0 authentication for all three providers:
All three provide FREE unlimited API access to subscribers!
Check the routing order:
web_search tool<CCM-SUBAGENT-MODEL> tagthinking fieldEnable debug logging with RUST_LOG=debug ccm start to see routing decisions.
Priority-based provider fallback - if your primary provider fails, automatically route to backup:
[[models]]
name = "glm-4.6"
[[models.mappings]]
actual_model = "glm-4.6"
priority = 1
provider = "zai"
[[models.mappings]]
actual_model = "z-ai/glm-4.6"
priority = 2
provider = "openrouter"
If zai fails → automatically falls back to openrouter. No manual intervention needed.
💡 Why This Matters: Claude Code Router doesn't have failover - if a provider goes down, your workflow stops. With Claude Code Mux, you get uninterrupted coding even during provider outages.
| Feature | Claude Code Router | Claude Code Mux |
|---|---|---|
| UI Access | ccr ui (separate launch) |
Built-in at http://localhost:13456 |
| Config Format | JSON + Transformers | TOML (simpler) |
| Memory Usage | ~156MB (Node.js) | ~6MB (Rust) - 25x lighter |
| Failover | ❌ Not supported | ✅ Priority-based automatic failover |
| Claude Pro/Max | API Key only | ✅ OAuth 2.0 supported |
| Router Auto-save | Manual save only | Auto-saves to localStorage |
| Config Sharing | Share JSON file | Share URL (?tab=router) |
Reliability: Automatic failover keeps you coding when providers go down. (CCR lacks this)
Faster Setup: Built-in UI (no ccr ui needed) + simpler TOML config.
Performance: 25x more memory efficient (6MB vs 156MB).
Claude Pro/Max Compatible: OAuth 2.0 authentication supported (CCR requires API key only).
Simplicity: TOML is easier than JSON with complex transformer configurations.
See CHANGELOG.md for detailed release history or view GitHub Releases for downloads.
We love contributions! Here's how you can help:
Found a bug? Open an issue with:
Have an idea? Start a discussion or open an issue with:
git checkout -b feature/amazing-feature)cargo testcargo fmtcargo clippySee CONTRIBUTING.md for detailed guidelines.
MIT License - see LICENSE
Made with ⚡️ in Rust