griffin

Griffin / Claude Code pricing / Claude Code Router

Claude Code Router: setup, routing rules and what it saves

By Ilya Volodarsky · updated · sources checked · Winding AI makes Griffin

The Griffin eagle pointing requests down different paths on a map

Short answer: Claude Code Router (CCR) is a free, MIT-licensed local gateway that sits between Claude Code and your model providers and decides which model serves each request.1 Install it with npm install -g @musistudio/claude-code-router@latest, run ccr ui, add a provider and a Claude Code profile, and launch Claude Code from CCR.13 On RouteBench, a fixed cheap model often matched per-prompt routers at a fraction of the cost, so route by role, not by message.5

What is Claude Code Router?

Claude Code Router is an open-source local model gateway, at github.com/musistudio/claude-code-router, that gives Claude Code and other coding agents one local endpoint while it sends each request to the provider and model you configured.1 It had 38,294 GitHub stars and released version 3.1.6 on November 21, 2026.2

  • Agents: Claude Code (CLI and app), Codex, Kimi CLI, Kilo Code, OpenCode, Grok CLI, Pi, ZCode, WorkBuddy and Claude Design.1
  • Providers: Anthropic, OpenAI, Gemini, OpenRouter, DeepSeek, Moonshot and Kimi Code, Z.AI, Mistral, SiliconFlow, Bailian and any compatible endpoint.1
  • Extras: retries, key pools and rotation, ordered fallback models, request logs with tokens and estimated cost, and client keys with their own limits.1

How do I set up Claude Code Router?

You set up Claude Code Router by installing the desktop app or the npm CLI, adding a provider, starting the local server and creating a Claude Code profile.13 The CLI needs Node.js 22 or newer:1

npm install -g @musistudio/claude-code-router@latest
ccr ui          # management UI at http://127.0.0.1:3458
                # model gateway at http://127.0.0.1:3456
  1. Providers → Add Provider: pick a preset such as DeepSeek or OpenRouter, paste the API key, choose the models.1
  2. Server → Start: the gateway listens on port 3456.1
  3. Agent Config → Add profile → Claude Code: set the default model, for example DeepSeek/deepseek-flash, and optionally a different model for each of the Fable, Opus, Sonnet and Haiku tiers.3
  4. Launch: open Claude Code from CCR, or run ccr "<profile name>" in a terminal.3
  5. Verify: send one message, then open CCR's request logs to see which provider and model answered; /model in Claude Code lists the models CCR exposes.3

How does Claude Code Router decide which model gets a request?

Claude Code Router sends the main session to the profile's model, lets each Claude Code tier map to its own model, and routes subagent and workflow requests with a tag that names the model, chosen from the descriptions you give your models.34

Claude Code Router's routing tools (CCR docs, checked November 21, 2026).
ToolWhat it does
Profile modelServes main requests when Claude Code names no model CCR recognizes
Tier overridesOpus, Sonnet, Haiku and Fable requests each go to a model you pick
Subagent tagsCCR injects your model descriptions so subagents pick, for example, a fast low-cost model for search and a strong model for review
Custom rulesMatch a request header or body field and rewrite the model or parameters
Script rulesA Node.js file returns the model, rewrites and fallback; errors fail open to the next rule
FallbackOff, retry the same model, or a chain of backup models
Semantic routingOptional: classifies requests sent as auto with TypeSafe's Jev model

The semantic option sends up to 8,192 characters of your latest message to the classifier service, so leave it off for private code unless you host the classifier yourself.4

A fallback chain in a rule or script result looks like this, and tries each backup in order when the chosen model fails:4

{ "mode": "model-chain", "models": ["Provider/backup-one", "Provider/backup-two"], "retryCount": 0 }

Which routing split saves the most?

The split that saves the most keeps the main session on a strong mid-price model and sends subagents and background work to a cheap one, because on our benchmark the cheap models held up on exactly that kind of task.5

A role split for Claude Code Router, priced from RouteBench's six pooled runs (October 12 to November 16, 2026).
Claude Code roleModelPassed$ per 1,000 coding tasks
Main session (Sonnet tier)Claude Sonnet 5.5 or GPT-6.1 Sol100% · 100%$2.27 · $0.87
Subagents and search (Haiku tier)DeepSeek V4.1 Flash or Claude Haiku 5.598.9% · 99.2%$0.17 · $0.13
Planning and hard bugs (Opus tier)Claude Opus 5.599.1%$4.78

Claude Code already supports this split on Claude models without a router: opusplan for planning and CLAUDE_CODE_SUBAGENT_MODEL for subagents.9 CCR earns its place when the tiers live at different providers. What each split does to a monthly bill is in Claude Code pricing.

Do routers pick cheaper models than a fixed choice?

Per-prompt routers didn't beat a fixed cheap model on RouteBench's graded tasks: always using DeepSeek V4.1 Flash cost $0.24 per 1,000 on average across six runs, while OpenRouter Auto averaged $0.95 and TypeSafe's Jev router $2.22.56

RouteBench, all graded tasks, six weekly runs (October 12 to November 16, 2026): pass-rate range · average and range of $ per 1,000 tasks.
RouterPassedAverage $ per 1,000Range
Always Opus 5.599.1–100%$5.19$5.14–$5.26
Always Sonnet 5.5100%$2.26$2.23–$2.30
TypeSafe Jev Router97.2–100%$2.22$1.74–$2.77
OpenRouter Auto97.2–100%$0.95$0.14–$2.81
Griffin (ours)96.3–99.1%$1.03$0.13–$5.19
Always DeepSeek V4.1 Flash97.2–100%$0.24$0.19–$0.35
Always Haiku 5.598.1–100%$0.16$0.16–$0.17

Griffin is our router, so weigh our numbers accordingly. It cost the same as Opus in the first run because it keeps calls on the frontier model until a cheaper one has passed, then $0.13 to $0.26; its lowest pass rate, 96.3%, came in the latest run.5 RouteBench routes app tasks one call at a time, which is closer to Claude Code's subagent calls than to a long main session.6

Does routing each request break Claude Code's prompt cache?

Routing each request to a different model breaks the prompt cache, because every model keeps its own cache and the first request on a new model re-reads the whole conversation at full price.7 Coding-agent sessions are long chains of tool calls that lean on caching, so changing model mid-flight is costly, as one Hacker News commenter put it on a model-router launch.8 Route by role and keep each role on one model for the session.

What is a Claude Code proxy, and do I need one?

A Claude Code proxy is any endpoint that speaks Anthropic's Messages API and that Claude Code reaches through ANTHROPIC_BASE_URL; you need one only to reach a provider without an Anthropic-compatible API or to split requests across providers.10 DeepSeek, Z.ai's GLM Coding Plan and Kimi Code all offer Anthropic-compatible endpoints, so each works with environment variables alone: see our DeepSeek, GLM and Kimi guides.

What are the alternatives to Claude Code Router?

The main alternatives to Claude Code Router are Claude Code's own model settings, a hosted gateway such as OpenRouter, a self-hosted gateway such as LiteLLM, and other routing projects.910

  • Claude Code settings: opusplan, tier variables and a subagent model cover Claude-only splits. See changing the model in Claude Code.9
  • OpenRouter: one key for hundreds of models, set straight in ANTHROPIC_BASE_URL; see OpenRouter with Claude Code.
  • LiteLLM and other gateways: self-hosted, with spend tracking per key; Claude Code's docs cover connecting one.10 Our gateway comparison lists ten.
  • Arch's Claude Code router: Katanemo's Arch Gateway routes code generation, code review, architecture and debugging to different models.11
  • Skill routers: Claude skills such as Math Router send requests to the right tool inside Claude; they don't switch models.12

For routers that pick models for an app's own AI features rather than a coding agent, see our best LLM routers and LLM router guides.

Is Claude Code Router safe to run?

Claude Code Router runs on your machine and keeps provider keys there, and it can issue separate client keys with expiry dates and request, token and image limits.1 Its docs warn you to read the Docker guide before exposing CCR to a network.1

Sources

  1. GitHub: musistudio/claude-code-router (README) · checked
  2. GitHub: Claude Code Router v3.1.6 release · checked
  3. CCR docs: Claude Code profile · checked
  4. CCR docs: routing · checked
  5. Griffin: RouteBench coding results, six runs pooled (our data) · checked
  6. Griffin: RouteBench, method and weekly runs (our benchmark) · checked
  7. Claude Code docs: how Claude Code uses prompt caching · checked
  8. Hacker News: "Smart model routing directly in Claude, Codex and Cursor" discussion · checked
  9. Claude Code docs: model configuration · checked
  10. Claude Code docs: connect Claude Code to an LLM gateway · checked
  11. Hacker News: "Show HN: Claude Code 2.0 router" · checked
  12. Skills Directory: Math Router skill · checked

FAQ

Is Claude Code Router free?

Yes. It is open source under the MIT license; you pay only your model providers.

What is the ccr command?

The Claude Code Router CLI. ccr ui opens the management UI, and ccr followed by a profile name launches Claude Code through that profile.

Can Claude Code Router use DeepSeek or GLM?

Yes. DeepSeek, Z.AI, Moonshot and Kimi Code, OpenRouter and others are built-in provider presets.

Does Claude Code Router work with Codex?

Yes. CCR has agent profiles for Codex, OpenCode, Kimi CLI, Kilo Code and others, all served from the same local gateway.

Do I need Claude Code Router to use another model?

No, if the provider has an Anthropic-compatible endpoint: set ANTHROPIC_BASE_URL and the model variables. You need a router to mix providers.

Route only what passed.

For the AI in your app, Griffin grades cheaper models on your own calls and routes a feature only after one passed, with fallback. Watching is free.

Start free