Engineering Guide

Claude Code Router: Route Claude Code to Any Model

Claude Code Router (CCR) is a small local proxy that intercepts Claude Code's Anthropic-formatted API calls and forwards them to any model you want — DeepSeek, Qwen, GLM, Kimi, Mistral, Ollama, or a gateway. The pitch is cost: cheap models run 20-50x below Claude Sonnet per token. The open question everyone hedges on is quality. So we ran a real generate-code-then-run-hidden-tests benchmark across 13 models — and 10 of 13, including the two cheapest at about $0.10-0.13 per 1,000 tasks, scored a perfect 9/9. This guide explains how CCR works, how to set it up, and exactly which cheap models are safe to route to.

Claude Code Router routes Claude Code requests to DeepSeek, Qwen, GLM and other cheaper models

What Claude Code Router is

Claude Code Router (CCR) is an open-source, MIT-licensed local proxy that lets Claude Code run against non-Anthropic models. The canonical project is musistudio/claude-code-router, which had roughly 25k+ GitHub stars as of mid-2026 — up from about 26k in early 2026, a sign of fast-rising adoption. It sits between Claude Code and Anthropic, catches the requests Claude Code would send to the API, and redirects them to a provider of your choice: DeepSeek, Qwen, GLM/Z.AI, Kimi/Moonshot, Mistral, OpenRouter, or a local Ollama model.

The reason people reach for it is almost always cost. Claude Code is excellent, but its default models are premium-priced, and an agent that reads files, plans, edits and re-runs tests burns tokens fast. If most of that work can be done by a model that costs a fraction as much, the savings compound. The catch — the thing every existing write-up hedges on — is whether the cheaper model is good enough. We put a hard number on that below.

Watch the name. The canonical project is musistudio/claude-code-router. Several forks and lookalikes exist (open-claude-router, openrouter-code, and others); the setup and behavior here describe the musistudio repo. Star count and pricing are as of July 2026 and move over time.

How it works: proxy, transformers, routing

The mechanism is simple and clever. Claude Code decides which API to call from the ANTHROPIC_BASE_URL environment variable. CCR starts a local endpoint, sets ANTHROPIC_BASE_URL to that address plus a dummy ANTHROPIC_API_KEY, and spawns Claude Code pointed at it. Claude Code sends its normal Anthropic-formatted requests believing it is talking to Anthropic — but they land on the local proxy instead.

From there, two things happen:

Supported providers include any OpenAI-compatible API, Anthropic Messages, Gemini, OpenRouter, DeepSeek, SiliconFlow, Moonshot/Kimi, Mistral, Z.AI (GLM), Bailian/Qwen, Ollama for local models, and custom endpoints. That OpenAI-compatible support is the seam we exploit in the gateway section below. If translating request formats between provider APIs sounds familiar, it is the same problem an OpenAI-compatible API layer solves at the server side.

Setup: CLI vs desktop

CCR comes in two forms, and it matters which one you are following in a tutorial because the endpoints differ.

AspectCLI proxy (classic)Desktop app (newer)
Installnpm install -g @musistudio/claude-code-routerGitHub Releases build (macOS/Windows/Linux)
Launchccr codeOpen the control-panel app
Local endpointhttp://127.0.0.1:3456a local UI port
Configconfig.json (Router + Providers)Visual control panel
Best forScriptable, server, CIPoint-and-click, discoverability

Both do the same core thing — stand up a local endpoint and set ANTHROPIC_BASE_URL to it. The CLI is not obsolete; the desktop app is a friendlier front end for the same idea. If you want the fastest path, install the CLI, drop your provider keys into config.json, set your Router.default model, and run ccr code exactly where you would normally run claude. For a fuller walkthrough of Claude Code itself, see our guide to using Claude Code, and for the GLM path specifically, Claude Code with GLM 5.

Do cheap models hold up? Our benchmark

Here is the part no one else brings data to. The common advice — route simple tasks to a free or cheap model, keep the flagship for hard stuff — is usually asserted, not measured. So we ran a first-party executed benchmark in July 2026: 13 models, 9 tasks, each task a generate-code-then-run-hidden-tests problem. The model writes code; we run its output against tests it never saw. No vibes, no leaderboard scrape.

The headline: 10 of 13 models scored a perfect 9/9 — and the cost for identical quality spanned 88x.

Same 9/9 score, 88x cost spread ($ per 1,000 tasks)DataLLM Lab benchmark, July 2026 — all models below scored a perfect 9/9Qwen3 Coder Next$0.10DeepSeek V4-Flash$0.13Mistral Medium 3.5$0.87Kimi K2.7-Code$1.34Claude Sonnet 5$1.67Claude Opus 4.8$4.05GPT-5.5$8.83
Chart: DataLLM Lab — cost per 1,000 tasks for models that all scored a perfect 9/9, July 2026. The two cheapest (highlighted), Qwen3 Coder Next and DeepSeek V4-Flash, matched GPT-5.5's quality at roughly 1/88th the cost.

The two cheapest models in the field were also the two cheapest to run and still perfect: Qwen3 Coder Next at $0.10 per 1,000 tasks (9/9, 0 reasoning tokens) and DeepSeek V4-Flash at $0.13 (9/9). At the other end, GPT-5.5 also scored 9/9 — for $8.83, 88x more. Claude Opus 4.8 was 9/9 at $4.05. A second finding worth routing on: Mistral Medium 3.5, a non-reasoning dense model, was the fastest in the whole test at 2.9s per task — non-reasoning models generally beat the heavy reasoners on both latency and cost per task.

What this means for CCR: the exact work a router pushes off Anthropic — routine, well-specified coding tasks — is precisely where cheap models converge on flagship quality. You are not trading quality for price on that tier; you are just paying less. Full results and methodology are in our best cheap LLM for coding writeup and the linked benchmark page.

One key, 300+ models, cheap-first routing

Point Claude Code Router at DataLLM Lab and switch between DeepSeek, Qwen, GLM, Mistral, Claude and GPT by name — no per-provider keys or transformers to juggle.

Point it at one gateway

CCR's power is also its friction: to route across many providers you configure a separate API key, base URL, and transformer for each one. That is a lot of moving parts to keep current. Because CCR speaks to any OpenAI-compatible endpoint, there is a cleaner arrangement — point the router at a single LLM gateway and let the gateway fan out to the underlying models.

DataLLM Lab is exactly that: one OpenAI-compatible endpoint fronting 300+ models on one key. In CCR you register it as a single provider and then select DeepSeek, Qwen, GLM 5.2, Mistral, Claude or GPT by model name with /model — the gateway handles the provider-specific routing. That collapses per-provider key management into one credential and makes the cheap-first-with-escalation pattern trivial to express: cheap model as default and background, a stronger model on think and longContext. For the broader cost strategy behind this, see cutting token costs on coding agents.

Where cheap models fall short

To keep this honest: the benchmark proves cheap models are viable on standard tasks, not that they are equal everywhere. Three documented trade-offs matter when you route.

The practical takeaway is the routing pattern CCR is built for: default to a cheap model, escalate the hard cases. The benchmark tells you the cheap tier is safe on the majority; the caveats tell you to keep an escalation path for the minority.

FAQ

What is Claude Code Router?

An open-source, MIT-licensed local proxy (musistudio/claude-code-router, ~25k+ stars mid-2026) that lets Claude Code run against non-Anthropic models like DeepSeek, Qwen, GLM, Kimi, Mistral, OpenRouter or Ollama.

How does Claude Code Router work?

It starts a local endpoint, sets ANTHROPIC_BASE_URL to it plus a dummy key, and spawns Claude Code pointed at it. A transformers pipeline translates each request/response, and a router picks the model by scenario (default, background, think, longContext, webSearch, image).

Does Claude Code Router save money?

Yes. DeepSeek V4-Flash is about $0.14 in / $0.28 out per million tokens vs $3 / $15 for Claude Sonnet. On simple tasks that is 20-50x cheaper; on a real mixed workflow, blended savings are closer to 3-5x.

Are cheap models good enough for Claude Code?

On standard tasks, yes. In our July 2026 benchmark, 10 of 13 models scored 9/9 on generate-code-then-run-hidden-tests problems, including Qwen3 Coder Next ($0.10/1k) and DeepSeek V4-Flash ($0.13/1k). Complex multi-file work and weak tool-calling are the exceptions.

What port does Claude Code Router use?

It depends on the variant. The CLI proxy (npm, ccr code) listens on http://127.0.0.1:3456; the newer desktop app uses a local UI port. Both set ANTHROPIC_BASE_URL to their local endpoint.

Can it point at one gateway instead of many providers?

Yes. Because CCR supports OpenAI-compatible endpoints, you can point it at a single gateway like DataLLM Lab (300+ models, one key) and switch models by name with /model, instead of configuring a key and transformer per provider.

Written by
Kevin Fan

Founder of DataLLM Lab, the unified LLM gateway. Kevin tests models the boring way — same prompts, real costs, unedited outputs — and writes up what the runs actually show.

One API for every model

One API, every model.

Get a single API key for Claude Opus 4.7, GPT-5.4, and 300+ more — with automatic price comparison and routing to the best model for every request.