Claude Code Router (CCR) is the tool that makes “run Claude Code on any model” actually work. It’s a small open-source proxy that intercepts Claude Code’s requests and forwards them to whatever provider you point it at — DeepSeek, Qwen, GLM, Kimi, a local Ollama model, or OpenRouter — and it can route different kinds of work to different models. This is the setup most cost-cutting guides are built on.
Here’s the full install and config on Windows, the routing rules that save the most money, and the errors people hit. For the bigger picture of why you’d do this, see use cheap AI models with Claude Code.
Install
CCR runs on Node. Install Claude Code first, then the router:
npm install -g @anthropic-ai/claude-code
npm install -g @musistudio/claude-code-router
On Windows this works in PowerShell, but the shell scripting around it is smoother in WSL — if you go that route, see the WSL install guide.
Configure
CCR reads ~/.claude-code-router/config.json — on Windows that’s C:\Users\YourName\.claude-code-router\config.json. A minimal config that routes everything to DeepSeek looks like this:
{
"Providers": [
{
"name": "deepseek",
"api_base_url": "https://api.deepseek.com/chat/completions",
"api_key": "sk-your-deepseek-key",
"models": ["deepseek-chat", "deepseek-reasoner"],
"transformer": { "use": ["deepseek"] }
}
],
"Router": {
"default": "deepseek,deepseek-chat",
"think": "deepseek,deepseek-reasoner"
}
}
Each provider needs a name, the api_base_url (the full chat-completions URL), your api_key, the models list, and an optional transformer that adapts the request format. Built-in transformers exist for deepseek, gemini, openrouter, groq, and more.
Run it
Start Claude Code through the router:
ccr code
That’s ccr code, not claude. After any config edit, reload:
ccr restart
There’s also a web UI for editing the config visually:
ccr ui
Route different tasks to different models
This is where CCR earns its keep. The Router section maps task types to models, so you can spend cheaply where quality doesn’t matter and pay up where it does:
Router keys
| default | General requests |
|---|---|
| background | Cheap/local model for background tasks |
| think | Reasoning-heavy work like Plan Mode |
| longContext | Model with a large context window |
| longContextThreshold | Token count that triggers longContext |
| webSearch | Model handling web search |
A multi-provider example — local model for background, DeepSeek for the rest:
{
"Providers": [
{
"name": "deepseek",
"api_base_url": "https://api.deepseek.com/chat/completions",
"api_key": "$DEEPSEEK_API_KEY",
"models": ["deepseek-chat", "deepseek-reasoner"],
"transformer": { "use": ["deepseek"] }
},
{
"name": "ollama",
"api_base_url": "http://localhost:11434/v1/chat/completions",
"api_key": "ollama",
"models": ["qwen2.5-coder:latest"]
}
],
"Router": {
"default": "deepseek,deepseek-chat",
"background": "ollama,qwen2.5-coder:latest",
"think": "deepseek,deepseek-reasoner",
"longContextThreshold": 60000
}
}
Switch models on the fly
Inside Claude Code you don’t have to commit to one model. The /model command swaps providers live:
/model deepseek,deepseek-reasoner
The format is always provider_name,model_name, matching what’s in your config.
Common problems
ccr: command not found— the global npm bin isn’t on your PATH. Reopen the terminal, or checknpm config get prefix.- Requests hang in automation — set
"NON_INTERACTIVE_MODE": truein the config for CI, Docker, or scripted runs. - Tool calls fail on some models — add the
tooluseorenhancetooltransformer for that model to harden tool-call handling. - Wrong model answering — confirm the
Router.defaultvalue and that you reloaded withccr restart.
Wrapping up
Claude Code Router is the bridge that lets one config file point Claude Code at any model — and route background, thinking, and long-context work to different ones. Install both packages, drop a config.json in ~/.claude-code-router/, launch with ccr code, and reload with ccr restart after edits.
From here, pick a backend: DeepSeek for the lowest pay-per-token cost, GLM for a flat coding plan, or Qwen3-Coder for big context. Prefer fewer moving parts? Some providers skip the proxy entirely — see anthropic-compatible endpoints.