Claude Code Router · 2026 walkthrough

Claude Code Router Tutorial: Route Claude Code to DeepSeek, Gemini or Any Model

The open-source router keeps the Claude Code experience you like but sends each request to cheaper models — DeepSeek, Kimi, Gemini or a local Ollama model. Install it with npm, wire providers in the ccr ui console, set per-scenario routes, then run a real task to prove it works. 15 steps with screenshots.

TL;DR — what Claude Code Router does

  • Claude Code Router (CCR) is a free, open-source proxy: Claude Code keeps its UI, system prompt and tools, but the model calls go to whatever you configure — DeepSeek, Kimi K2, Gemini, OpenRouter or a local Ollama model.
  • Install is one npm command (npm install -g @musistudio/claude-code-router) and the ccr ui web console edits ~/.claude-code-router/config.json for you — no hand-editing JSON required.
  • Routing is per scenario: the default, background, think (Plan Mode reasoning), longContext (auto-engages past a 60,000-token threshold) and webSearch slots each get their own model.
  • ccr code starts a routed session with the base URL pointed at http://127.0.0.1:3456; plain claude still works untouched. Known quirk: /cost stays at $0, so track spend in your provider dashboard.

Claude Code Router: Use Gemini 2.5 Pro FREE API in Claude Code

Video walkthrough:AI With Nathan10:52

Open

claude-code-router — official README

Product facts:musistudio on GitHubDocs

Open

Steps and screenshots follow the video walkthrough; config.json field names, router roles and transformer behavior are cross-checked against the official README.

Frames are credited screenshots from the source video, each deep-linked to its timestamp. This guide's text is original — not a transcript.

Set up Claude Code Router, step by step

1 · Point Claude Code at cheaper models

  1. 1

    See why Claude Code needs a router

    Claude Code is tied to Claude models, and they are pricey: Opus 4.1 lists at $15 per million input tokens and $75 per million output. Claude Code Router (CCR), an open-source project, keeps the Claude Code experience but routes each request to a model you choose — DeepSeek, Kimi, Gemini or a local Ollama model.

    Anthropic API pricing page showing Claude Opus 4.1 at 15 dollars per million input tokens and 75 dollars per million output tokens, the cost Claude Code Router helps you avoid
    Anthropic's list pricing before the switch — this is the bill CCR avoids.Watch at 0:30
  2. 2

    Install Claude Code, then the router

    CCR assumes Claude Code is already installed: npm install -g @anthropic-ai/claude-code. Then install the router: npm install -g @musistudio/claude-code-router. Your provider config will live in ~/.claude-code-router/config.json.

    Claude Code Router README Getting Started section listing npm install -g @anthropic-ai/claude-code and npm install -g @musistudio/claude-code-router
    The two npm installs from the official README — the router never replaces Claude Code.Watch at 3:36
  3. 3

    Let npm finish the global install

    npm pulls the router's dependencies (a node-domexception deprecation warning is normal to see). When it finishes you have the ccr command available everywhere.

    Terminal output while npm installs @musistudio/claude-code-router globally with cached package fetches and a node-domexception deprecation warning
    npm fetching packages during the global @musistudio/claude-code-router install.Watch at 3:49

2 · Add providers in the ccr ui console

  1. 4

    Open the config console with ccr ui

    Instead of editing JSON by hand, run ccr ui. A browser tab opens on 127.0.0.1:3456: providers are managed on the left, the Router section on the right assigns models to scenarios, and Custom Transformers sits below.

    Claude Code Router web console from ccr ui on first launch with an empty Providers list and Default, Background, and Think router slots
    First launch of the ccr ui console — Providers empty, router slots waiting.Watch at 4:08
  2. 5

    Add a provider from a template

    Click Add Provider and pick a template — the video uses OpenRouter, and presets exist for deepseek, gemini, dashscope, modelscope, siliconflow and volcengine too. The template pre-fills the API URL and a default model list, and you can leave the transformer empty.

    Add Provider template dropdown in the Claude Code Router console listing dashscope, deepseek, gemini, modelscope, openrouter, siliconflow, and volcengine presets
    Provider templates in ccr ui — pick one and the URL plus models fill in automatically.Watch at 4:30
  3. 6

    Paste the API key and pick your models

    Three fields really matter: the API URL (already pre-filled), the secret key, and the models list. The walkthrough adds DeepSeek R1 and Kimi K2 under OpenRouter, then saves — the provider appears in the left panel ready to assign.

    Edit Provider dialog for the openrouter template showing the pre-filled API Full URL https://openrouter.ai/api/v1/chat/completions, a masked API key field, and the models list
    The Edit Provider form: URL, key, models — everything else can stay default.Watch at 4:53
  4. 7

    Let transformers handle API differences

    Transformers rewrite request and response payloads so third-party APIs stay compatible with Claude Code. CCR ships sensible defaults — for example a deepseek transformer for api.deepseek.com and a tooluse transformer for deepseek-chat — so you rarely write your own.

    Claude Code Router README transformer section with a Model-Specific Transformer example applying the deepseek transformer to the api.deepseek.com provider and deepseek-chat model
    Global and model-specific transformer examples from the README, including the DeepSeek preset.Watch at 3:54
  5. 8

    Add a free Gemini key for reasoning tasks

    Add a second provider from the Gemini template and create a free API key in Google AI Studio (Get API key → Create API key). Paste it, save — you'll assign this provider to the thinking, long-context and web-search slots shortly.

    Google AI Studio Create API key dialog used to generate the free Gemini API key for the Claude Code Router think and longContext routes
    Creating the free Gemini API key in Google AI Studio for the CCR provider.Watch at 5:45

3 · Set the routing rules

  1. 9

    Understand the five router roles

    default handles general tasks (and everything you don't assign). background runs background jobs — a small or local model saves cost here. think covers reasoning-heavy work like Plan Mode. longContext engages automatically past longContextThreshold (60,000 tokens by default), and webSearch needs a model that supports the feature — on OpenRouter, append :online to the model name. /model switches models mid-session.

    Claude Code Router README describing the Router roles default, background, think, longContext with a 60000 token longContextThreshold, and webSearch with the :online suffix
    The Router object in the README: every role, the 60K threshold, and the :online suffix.Watch at 1:06
  2. 10

    Assign a model to every scenario

    In the Router section, pick from your saved providers' models: the video sets DeepSeek R1 as default, Kimi K2 for general use, Gemini 2.5 Pro (1M context window) for longContext, and fast Gemini Flash for webSearch. Hit Save and Restart in the top right when done.

    Claude Code Router console setting openrouter,deepseek/deepseek-r1-0528 as the Default model with the model picker dropdown open over the saved openrouter provider
    Filling the Default slot with deepseek/deepseek-r1-0528 from the saved provider.Watch at 5:15
  3. 11

    Start the routed session with ccr code

    Back in the terminal, run ccr code. The Claude Code welcome screen lists Overrides (via env) — API Base URL http://127.0.0.1:3456 — proving requests now flow through the router. The plain claude command still starts an unrouted session, no uninstall needed.

    Claude Code session launched with ccr code showing Overrides via env with API Base URL http://127.0.0.1:3456, proving requests route through Claude Code Router
    The Overrides block on the welcome screen: your traffic now goes through CCR's local proxy.Watch at 6:45

4 · Run a real task and verify

  1. 12

    Give it a real coding task

    Prompt as usual — the video asks for a neon brick breaker game with modern animations. Claude Code plans a todo list and executes it step by step through the routed models. Expect cosmetic quirks: the input-token counter may sit at zero.

    Claude Code executing a neon brick breaker game todo list inside a session proxied by Claude Code Router
    Claude Code working through its todo list while CCR routes the model calls.Watch at 7:06
  2. 13

    Review the finished result

    The agent wraps up with a feature summary — visual effects, responsive design, controls, game mechanics — and the files land in your project (index.html, style.css, script.js). Open the HTML in a browser to test the result yourself.

    Claude Code completion summary for a neon brick breaker game listing visual effects, responsive design, touch controls, and game mechanics
    Claude Code's completion summary for the neon brick breaker game.Watch at 7:30
  3. 14

    Verify real usage in the provider dashboard

    OpenRouter's Your Activity page is the source of truth: it shows the routed calls — repeated Kimi K2 requests and the DeepSeek call — with token counts and spend. That's how you confirm CCR is actually using your cheaper models.

    OpenRouter Your Activity dashboard showing spend, token, and request charts with a Kimi K2 request row after routing Claude Code through Claude Code Router
    OpenRouter usage after the session: the routed models show up with real request counts.Watch at 7:45
  4. 15

    Know the rough edges before you rely on it

    Run /cost in a routed session and it reports $0.0000, with usage-by-model showing claude-sonnet at zero — cost accounting isn't wired to external providers yet. Routing itself works fine; just track spend in your provider dashboard for now.

    Claude Code /cost command reporting a 0.0000 dollar total and claude-sonnet zero-token usage, the known accounting gap when models are routed externally
    The known /cost gap in routed sessions — provider dashboards are your real meter.Watch at 9:25

Claude Code Router FAQ

Keep exploring