Claude Code Router (ccr) is an MIT-licensed local gateway, 36,730 GitHub stars in August 2026, that sits between Claude Code and any provider you configure. Its config.json lives at ~/.claude-code-router/config.json and maps four request classes (default, background, think, longContext, with a 60,000-token threshold) onto specific provider and model pairs. It is genuinely useful and it is unofficial: 1,090 open issues, a translation layer that has to track two moving API shapes, and no support contract. The alternatives are a bare ANTHROPIC_BASE_URL override, a LiteLLM proxy with an Anthropic-shaped endpoint, OpenRouter, and a maintained hosted endpoint such as Continuum.
- It is a local gateway on 127.0.0.1, not a patch to Claude Code. Claude Code just points at it.
- Routing is per request class: default, background, think, longContext. Not per prompt.
longContextThresholddefaults to 60,000 tokens. That single rule does most of the saving.- MIT, 36,730 stars, 1,090 open issues in August 2026. Popular and busy, in both senses.
- The simplest alternative is two environment variables and no software at all.
- Whatever you route to, the small fast model is what breaks first. Pin it.
What the tool actually is
Claude Code Router runs a small server on your machine, by default on http://127.0.0.1:3456, that speaks the Anthropic Messages API on the front and whatever the target provider speaks on the back. Claude Code is pointed at it and behaves normally; every turn is translated, routed, and forwarded. A management UI runs separately on http://127.0.0.1:3458.
| Field | Value |
|---|---|
| Repository | musistudio/claude-code-router |
| Licence | MIT |
| Stars | 36,730 |
| Open issues | 1,090 |
| First commit | February 2025 |
| Last push | 19 August 2026 |
# CLI, requires Node.js 22+
npm install -g @musistudio/claude-code-router
ccr ui # opens the management interface
# or the desktop app from GitHub releases
# or Docker
docker compose up -d --build
The project has grown well beyond its name. Its own description in August 2026 is "one local control plane for every AI agent", and it now fronts Codex, Grok CLI, and Kimi CLI as well as Claude Code, with credential pools and profile switching. That is worth knowing before you evaluate it: you are adopting a control plane, not a shim.
How its routing works
Configuration lives at ~/.claude-code-router/config.json and has two blocks that matter: Providers, an array describing where models come from, and Router, which maps request classes onto them.
{
"Router": {
"default": "openrouter,anthropic/claude-sonnet-5",
"background": "openrouter,google/gemini-flash",
"think": "openrouter,anthropic/claude-opus-5",
"longContext": "openrouter,google/gemini-pro",
"longContextThreshold": 60000
}
}
| Class | What lands here | What to put in it |
|---|---|---|
default | Ordinary coding turns | Your workhorse. This is 80% of your spend. |
background | Titles, summaries, diff descriptions | The cheapest thing that can write a sentence. |
think | Reasoning-heavy turns | Your strongest model. Fires rarely; do not economise here. |
longContext | Anything over the threshold | A large-window model. Default trigger is 60,000 tokens. |
The honest risk list
- It is unofficial, and it sits in the middle of your credentials. A local proxy holding provider keys is a supply-chain surface. Read the release you install, pin the version, and do not run it on a machine where a compromise would be expensive.
- Two moving API shapes. The tool translates between what Claude Code emits and what each provider accepts. Both change. 1,090 open issues is not an indictment of the project, it is an accurate picture of how much surface that translation has.
- Non-Anthropic models in Claude Code are not the same product. Claude Code's prompting, tool definitions, and agent loop are tuned for Claude. A model that benchmarks well elsewhere can behave noticeably worse inside this harness, especially on multi-step tool use, and the failure looks like the tool being broken rather than the model being a poor fit. Check a candidate against our coding-model leaderboard before you slot it into
default, and treat the score as a floor rather than a promise inside this harness. - Terms of service deserve five minutes of your own reading. Anthropic documents base-URL overrides and third-party endpoints such as Bedrock and Vertex, so a custom endpoint is a supported configuration. What is a different question is routing an Anthropic subscription credential through third-party software, or using a subscription rail for automated traffic it was not sold for. Check your own agreement rather than a forum post.
- No support contract. When it breaks mid-sprint, you are reading TypeScript. For a personal machine that is fine. For twenty engineers it is a bus factor.
The four alternatives, in order of how little you have to run
1. Just the environment variables
Claude Code reads its endpoint from the environment. If your target already serves an Anthropic-shaped API, there is nothing to install and no process to keep alive.
export ANTHROPIC_BASE_URL="https://your-gateway.example.com"
export ANTHROPIC_AUTH_TOKEN="your-key"
export ANTHROPIC_MODEL="claude-opus-5"
export ANTHROPIC_SMALL_FAST_MODEL="claude-sonnet-5"
claude
Inside the session, /status prints the base URL in use, which is the fastest way to prove the variables reached the process. The catch is that this gives you one model, not four routing classes.
2. LiteLLM in front
LiteLLM serves an Anthropic-compatible surface as well as an OpenAI one, so it can be the thing ANTHROPIC_BASE_URL points at while translating to any of a hundred providers behind it. You get real fallbacks, budgets, and logs, and you get a service to operate. See the self-hosting guide.
3. OpenRouter
One key, hundreds of models, nothing to run, automatic provider fallback. You pay 5.5% on credit purchases (minimum $0.80, checked August 2026) and your prompts cross a third party. Fine for personal work, a procurement conversation for a company.
4. A maintained hosted endpoint
| Route | Install | Routing rules | Maintained by |
|---|---|---|---|
| Environment variables | Nothing | None | Anthropic (documented config) |
| claude-code-router | Node service or app | Four classes, yours | A community project |
| LiteLLM | A service you operate | Full, yours | You, plus the LiteLLM team |
| OpenRouter or Continuum | Nothing | Vendor router | The vendor |
Questions people ask
What is Claude Code Router?
An MIT-licensed open-source tool (github.com/musistudio/claude-code-router, 36,730 stars in August 2026) that runs a local gateway on 127.0.0.1:3456 and routes each Claude Code request to a model you configured for that request class. Claude Code points at it through its base URL and otherwise behaves normally.
How do I route Claude Code to another model?
Set ANTHROPIC_BASE_URL to an endpoint that serves an Anthropic-shaped API, ANTHROPIC_AUTH_TOKEN to that endpoint's key, and ANTHROPIC_MODEL to a model it serves. Also pin ANTHROPIC_SMALL_FAST_MODEL, because Claude Code's background requests default to a model id most gateways do not host. Tools like claude-code-router add per-request-class routing on top of that.
Where is the claude-code-router config file?
~/.claude-code-router/config.json. The two blocks that matter are Providers, an array of where models come from, and Router, which maps the default, background, think, and longContext classes onto provider and model pairs. longContextThreshold defaults to 60,000 tokens.
Is claude-code-router against Anthropic terms of service?
Base-URL overrides are a documented Claude Code configuration, and Anthropic supports third-party endpoints such as Bedrock and Vertex, so pointing the CLI elsewhere is not itself unusual. The question worth checking against your own agreement is whether you are routing a subscription credential through third-party software or using a subscription rail for traffic it was not sold for.
Does Claude Code work well with non-Anthropic models?
Variably. The CLI's prompts, tool schemas, and agent loop are tuned for Claude, so a model that scores well on public benchmarks can still handle multi-step tool use badly inside this specific harness. Test on your own repository before you move a team, and expect the failure to look like a broken tool rather than a mismatched model.
Sources
Every figure above was read from these pages on August 2026. Vendors reprice without notice; if you find a stale number, tell us.
- musistudio/claude-code-router on GitHub 36,730 stars, MIT, read 19 August 2026
- Claude Code Router configuration docs
- Claude Code settings and environment variables
- OpenRouter FAQ (credit fee)