musistudio/claude-code-router
Local model gateway for routing coding agents across providers
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
Claude Code Router (CCR) is a local model gateway with a management UI. Agent profiles configure clients to use a stable endpoint. For each request, routing rules resolve the upstream provider, model, and account, allowing those choices to change without reconfiguring every agent. In the default desktop and CLI setup, the model gateway listens on port 3456; the CLI management UI is served separately on port 3458.
The TypeScript monorepo includes Electron desktop builds and a Node.js CLI that serves the web UI without Electron. The root manifest lists @the-next-ai/ai-gateway, undici, openai, and the native better-sqlite3 module. Wrapper and core gateway plugins, local routes, and virtual models provide extension points in the request path. Fusion, ToolHub, and MCP integration let the gateway add capabilities beyond forwarding model requests.
Key Capabilities & Differentiators
CCR supports OpenAI Chat and Responses, Anthropic Messages, and Gemini Generate Content and Interactions, alongside provider presets such as OpenRouter, DeepSeek, and Moonshot and custom compatible endpoints. Provider configuration includes protocol probing, model discovery, connectivity checks, and credential pools. Routing can match headers or bodies, apply prefixes or rewrites, retry requests, and move through an ordered list of fallback models.
Agent profiles can apply model overrides and environment settings across clients such as Claude Code, Codex, and OpenCode. Separate CCR client keys can expire and enforce local request, token, and image limits. Logs show the resolved provider, model, and credential alongside status, latency, usage, estimated cost, and tool activity. Fusion vision, web search, and MCP tools extend the workflow, but protocol compatibility alone does not establish native feature parity across agents and providers.
Trade-offs & Limitations
For one agent and one provider, direct configuration avoids an extra service, routing rules, and a separate credential store to manage. A generic API gateway is worth considering if the only requirement is a shared model endpoint. CCR is more compelling when agent-specific profiles, fallback policies, and centralized logs replace duplicated configuration across several clients. Validate fallback models against the actual client workflow: returning text through a compatible API does not prove that tool calls or native image features will behave the same way.
Retries and fallbacks can improve availability, but they may increase end-to-end latency and upstream usage. Local hosting gives you control over the routing layer; it does not make inference local, remove API charges, or prevent data from reaching an upstream provider. Treat provider credentials, client keys, and request and response logs as sensitive. Keep the loopback default unless remote access is needed and you can control who reaches the management interface.
Hardware & Deployment Guide
Use the desktop app on macOS, Windows, or Linux for graphical setup. For a headless install, the npm CLI requires Node.js 22 or newer: install @musistudio/claude-code-router and run ccr ui, then open http://127.0.0.1:3458. Docker Compose instead serves management and gateway routes behind Nginx through the loopback mapping 127.0.0.1:3458:8080 and persists /data in the ccr-data volume. Internal listeners are not published by that Compose configuration, and the local gateway still needs connectivity to whichever upstream services you configure.
For desktop source builds, run npm ci under Node.js 22 or newer; Windows x64 packaging must run on Windows x64 because of the native better-sqlite3 Electron module. v3.1.4 fixed the Docker path that exposed the management token to unauthenticated clients. v3.1.5 addressed credential fallback and provider-qualified routing, among other fixes. v3.1.6 added provider balance and usage in Codex desktop and native image generation and editing through a configured Images API provider.
Developers or teams running several supported coding agents who need to switch providers, configure fallback routes, and verify where requests went without maintaining separate routing configurations for each client.
One agent connects reliably to one provider, or your primary need is an offline inference server or a guarantee of native feature parity across providers.
Quick Start & Installation
npm install -g @musistudio/claude-code-router@latest ccr ui
Comparison vs. Top Coding, Skills & MCP Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| claude-code-router ★ | 38.5k | +101 | TypeScript | MIT | Local model gateway for routing coding agents across providers |
| cc-switch | 159.1k | +1.7k | Rust | MIT | Tauri desktop manager for AI coding providers, local routing, and MCP config |
| herdr | 54.1k | +871 | Rust | Apache-2.0 | Rust terminal multiplexer for persistent, multi-machine coding-agent workspaces |
| magpie | 45.5k | +2.9k | Go | MIT | A local API gateway that pools model subscriptions across coding agents |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/musistudio/claude-code-router.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about claude-code-router
How do I connect an agent and verify which upstream it actually used?
Does self-hosting CCR require a GPU or a large machine?
Can a company self-host CCR, and what does that cover?
When is CCR better than direct configuration or a generic API gateway?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy