
Claude Code Router
CLI本地模型网关:把 Claude Code、Codex 等编码 agent 的请求路由到 DeepSeek、Kimi、Gemini、OpenRouter 等模型供应商,支持失败切换、按规则路由与请求日志。需自备各家 API Key。
Claude Code Router
Manage every agent and provider from one place.
Connect Claude Code, Claude Design, Codex, Grok CLI, Kimi CLI, Kilo Code, OpenCode, Pi, ZCode, WorkBuddy, and compatible API clients to the providers you choose—then route, fail over, extend, and observe every request from one app.
Why use Claude Code Router?
Claude Code Router (CCR) is a local model gateway and control plane for coding agents. It gives Claude Code, Claude Design, Codex, Grok CLI, Kimi CLI, Kilo Code, OpenCode, Pi, ZCode, WorkBuddy, and compatible API clients one stable local endpoint, while you manage the providers, models, accounts, routing rules, and tools behind it from one place.
Use CCR to:
- Manage all agents and providers together instead of maintaining a separate model configuration for every client.
- Switch providers or models without changing your workflow or repeatedly editing agent configuration files.
- Keep requests running with retries, credential pools, key rotation, and ordered fallback models.
- Add capabilities to existing models with Fusion vision, web search, MCP tools, and ToolHub.
- See what actually happened through request logs, resolved routes, latency, token usage, cost estimates, and account status.
CCR supports OpenAI Chat / Responses, Anthropic Messages, Gemini Generate Content / Interactions, OpenRouter, DeepSeek, SiliconFlow, Moonshot, Kimi Code, Mistral, Z.AI, Bailian, and custom compatible providers.
Supported Agents
Quick Start
Desktop app (recommended)
-
Download Claude Code Router for macOS, Windows, or Linux, then launch the app.
-
Open Providers → Add Provider. Choose a built-in preset or a custom endpoint, enter the API key, select the protocol and models, then save.
-
Open Server and click Start. The local model gateway listens on
http://127.0.0.1:3456by default. -
Open Agent Config, choose Claude Code, Claude Design, Codex, Grok CLI, Kimi CLI, Kilo Code, OpenCode, Pi, ZCode, or WorkBuddy, select a model, and apply the profile.
-
Start using your agent. Open Logs to confirm the resolved provider, model, status, tokens, latency, and errors.
Your agent is now connected to CCR. To add conditions, retries, request rewrites, or fallback models, open Routing.
CLI
The npm CLI requires Node.js 22 or newer. It starts the same gateway and a browser-based management UI without Electron:
npm install -g @musistudio/claude-code-router
ccr ui
Open http://127.0.0.1:3458, then follow the same Providers → Server → Agent Profiles flow above. The model gateway remains at http://127.0.0.1:3456. See the CLI reference for service modes, authentication, and profile commands.
Docker
npm run docker:compose:up
Docker exposes the management UI and gateway routes through http://127.0.0.1:3458 by default. The npm script prepares the local plugin-capable ai-gateway runtime before building the image when ../../next-ai/gateway exists. Read the Docker deployment guide before exposing CCR remotely.
Build desktop apps
Install Node.js 22+, then run npm ci.
| Target | Command | Output |
|---|---|---|
| macOS local DMG/ZIP | npm run build:app:mac | release-local/ |
| Windows local NSIS installer | npm run build:app:win | release-local/ |
Windows app packaging must run on Windows x64 because better-sqlite3 ships a native Electron module. The release workflow builds macOS on macOS runners and Windows on windows-latest when a v* tag is pushed.
How it works
Claude Code · Claude Design · Codex · Grok CLI · Kimi CLI · Kilo Code · OpenCode · Pi · ZCode · WorkBuddy · Compatible API clients
│
▼
Claude Code Router :3456
Profiles · Routing · Credentials · Tools · Logs
│
▼
Selected provider, model, and account
Core capabilities
| Area | Highlights |
|---|---|
| Agents | Profiles for Claude Code, Claude Design, Codex, Grok CLI, Kimi CLI, Kilo Code, OpenCode, Pi, ZCode, and WorkBuddy; model overrides; scopes; environment settings; CLI and app launch entries; multi-instance workflows |
| Providers | Presets and custom endpoints; protocol probing; model discovery; connectivity checks; local login import where supported; single keys and credential pools |
| Models & routing | Searchable catalog; model descriptions for task selection; conditions on headers and bodies; prefixes; rewrites; retries; ordered fallbacks |
| Tools & extensions | Fusion models; ToolHub; built-in browser automation; Chrome login-state import; wrapper and core gateway plugins; local routes and virtual models |
| Access & quotas | Separate CCR client keys with expiration and local request, token, and image limits |
| Observability | Request and response details; resolved provider, model, and credential; status; latency; tokens; estimated cost; tool calls; agent traces |
| AgentClaw | Agent relay through Weixin iLink, WeCom, Slack, Discord, Telegram, LINE, Feishu, and DingTalk |
Go deeper when you are ready
The complete documentation lives at ccrdesk.top.
- Install and launch CCR
- Configure providers
- Explore routing and configuration
- Use the CLI
- Deploy with Docker
- Troubleshoot common issues
Support & Sponsoring
If you find this project helpful, please consider sponsoring its development. Your support is greatly appreciated.
|
One-time support via Ko-fi |
International sponsorship |
Alipay
|
WeChat Pay
|
Our Sponsors
A huge thank you to all our sponsors for their generous support.
|
Z智谱 |
AIHubmix |
BurnCloud |
302.AI |
|
RunAPI |
TeamoRouter |
code0.ai |
claudeapi |
|
Qiniu Cloud AI |
Fenno.ai |
Unity2.Ai |
无限星河 |
Community Sponsors
| @Simon Leischnig | @duanshuaimin | @vrgitadmin | @*o | @ceilwoo | @*说 |
| @*更 | @K*g | @R*R | @bobleer | @*苗 | @*划 |
| @Clarence-pan | @carter003 | @S*r | @*晖 | @*敏 | @Z*z |
| @*然 | @cluic | @*苗 | @PromptExpert | @*应 | @yusnake |
| @*飞 | @董* | @*汀 | @*涯 | @*:-) | @**磊 |
| @*琢 | @*成 | @Z*o | @*琨 | @congzhangzh | @*_ |
| @Z*m | @*鑫 | @c*y | @*昕 | @witsice | @b*g |
| @*亿 | @*辉 | @JACK | @*光 | @W*l | @kesku |
| @biguncle | @二吉吉 | @a*g | @*林 | @*咸 | @*明 |
| @S*y | @f*o | @*智 | @F*t | @r*c | @qierkang |
| @*军 | @snrise-z | @*王 | @greatheart1000 | @*王 | @zcutlip |
| @Peng-YM | @*更 | @*. | @F*t | @*政 | @*铭 |
| @*叶 | @七*o | @*青 | @**晨 | @*远 | @*霄 |
| @**吉 | @**飞 | @**驰 | @x*g | @**东 | @*落 |
| @哆*k | @*涛 | @苗大 | @*呢 | @d*u | @crizcraig |
| s*s | *火 | *勤 | **锟 | *涛 | **明 |
| *知 | *语 | *瓜 | **新 |
If your name is masked, please contact me via my homepage email to update it with your GitHub username.
License
This project is licensed under the MIT License.
相关资源

ZCF (Zero-Config Code Flow)
CLI零配置一键设置 Claude Code 与 Codex 环境的命令行:用交互式菜单完成安装、导入工作流、配置 API 与 CCR 代理、安装常用 MCP 服务,支持模型服务商预设与中英文双语配置。
UfoMiao/zcf6.1k
Ollama
CLI在本机一条命令下载并运行 Gemma 等开源大模型,提供 REST API 与 Python / JS 库,还能用 ollama launch 让 Claude Code、Codex 等 agent 改用本地模型。
ollama/ollama183k
llama.cpp
CLI纯 C/C++ 实现的本地大模型推理引擎,自带命令行对话与 OpenAI 兼容的 HTTP 服务,可直接从 Hugging Face 拉取 GGUF 模型运行;支持 Apple Silicon、CUDA、Vulkan 等多种硬件与低比特量化。
ggml-org/llama.cpp131k
LM Studio CLI (lms)
CLILM Studio 官方命令行:列出、加载与卸载本地模型,启停本地 API 服务,查看运行状态与日志,ls、ps 等命令支持 --json 输出,便于脚本与 agent 调用。需先安装 LM Studio 桌面应用。
lmstudio-ai/lms5.4k
Claude API
SkillClaude API 与 Anthropic SDK 参考:模型选择与定价、流式输出、工具调用、提示缓存、Managed Agents 等,并提供模型迁移与提示词审计流程。Anthropic 官方技能。
anthropics/skills182k
Plugin Dev
Plugin开发 Claude Code 插件的工具包:7 个技能覆盖插件结构、钩子、MCP 集成、命令、子代理与技能编写,附八阶段引导式创建命令,以及代理生成、插件校验、技能评审三个子代理。Anthropic 官方维护。
anthropics/claude-code151k