Skip to content

Claude Code Router: run Claude Code on other providers, with routing rules and setup

Better Design

Direct answer

Claude Code Router is a free, MIT-licensed local gateway that sends Claude Code's requests to the providers you choose, such as OpenRouter, DeepSeek or Gemini. It routes each request with rules, lets subagents pick models, and retries or fails over when a provider errors. This guide covers setup, the CLI, routing, troubleshooting and safety, from the project's own README and docs.

A hand-drawn browser window with Claude Code Router written in it and a short list of what it does.

What Claude Code Router does

Claude Code Router, or CCR, is a free, MIT-licensed local gateway for coding agents. It gives Claude Code, Codex, OpenCode and other agents one local address, and you choose which model provider answers behind it.

It is a community project by musistudio on GitHub, not an Anthropic product. Teams use it to run Claude Code on other providers, to send different kinds of request to different models, and to keep working when a provider fails.

How a request flows through Claude Code Router

The agent talks to CCR on port 3456. CCR applies your profiles, routing rules and credentials, then forwards the request to the chosen provider and model:

From the README
Claude Code · Codex · OpenCode · other agents
                 │
                 ▼
      Claude Code Router :3456
  Profiles · Routing · Credentials · Tools · Logs
                 │
                 ▼
   Selected provider, model and account

Install Claude Code Router

There are three ways to run it. The desktop app is the recommended one; the CLI needs Node.js 22 or newer:

Terminal
npm install -g @musistudio/claude-code-router
ccr ui              # start in the background and open the management UI
ccr ui --no-open    # the same, for SSH or headless machines
Desktop app
How you start it

Download the release for macOS, Windows or Linux

Where you manage it

The app; gateway on port 3456

npm CLI
How you start it

ccr ui

Where you manage it

A browser UI at http://127.0.0.1:3458

Docker
How you start it

npm run docker:compose:up from the repository

Where you manage it

The management URL with ccr_web_token that docker compose logs -f ccr prints; everything goes through port 3458

Set it up in five steps

The CLI docs give this order:

  • Add a provider and at least one model.
  • Create a CCR client key on the API Keys page, so agents can reach the gateway.
  • Set the default model, routing rules and fallbacks.
  • Check on the Server page that the gateway is running.
  • Point the agent's base URL at the gateway address the UI shows and set its API key to the CCR client key from step 2, or apply a Claude Code profile under Agent Config.

Claude Code Router in four steps

The four steps, in the order you take them.

A hand-drawn four-step path: Install CCR, Add a provider, Start the server, Apply the profile.
  1. Step 1: Install CCR
  2. Step 2: Add a provider
  3. Step 3: Start the server
  4. Step 4: Apply the profile

CLI commands

ccr start
What it does

Starts the management service and gateway, and prints the signed-in management address

Use it when

You want CCR running in the background

ccr ui
What it does

Reuses or starts the background service and opens a browser

Use it when

You want to configure providers and routes

ccr serve
What it does

Runs in the current terminal

Use it when

You want to watch logs or use a process manager

ccr stop
What it does

Stops the background service started by start or ui

Use it when

You are done; a foreground serve is stopped from its own terminal

How routing works

CCR picks a model for each request in three ways:

  • Built-in Claude Code route: Claude Code requests go to your default model. You set it on CCR's Agent Config page, and it applies when Claude Code has not picked a known model.
  • Subagent auto-routing: when your models have descriptions, CCR tells Claude Code about them, so each subagent it spawns can pick a model. CCR reads the chosen model from a tag at the start of the prompt and removes the tag.
  • Custom rules: a rule matches on a request header or body field, can rewrite request parameters, and can set its own fallback when a request fails. Rules can also be Node.js scripts, which fail open: an error lets the request continue to the next rule.

Write model descriptions so subagents choose well

The description field switches subagent auto-routing on. The docs suggest describing what each model is good at, its speed, cost and limits, for example:

Model descriptions
Fast model:  Good for code search, file triage, summaries, small edits
             and low-cost parallel subagents.
Strong model: Good for complex architecture analysis, large refactor planning,
             cross-file reasoning and high-risk code review.
Long model:  Good for reading large logs, long documents and
             repository-scale context gathering.

Providers and protocols

CCR detects each provider's protocol automatically, and you can set it by hand when detection misses. For teams, a credential pool rotates several keys by priority, weight and limits.

OpenAI Chat Completions
Use it for

Most OpenAI-compatible services

How CCR picks it

Detected automatically; set it by hand in Advanced settings if detection misses

OpenAI Responses
Use it for

Services that support the Responses API

How CCR picks it

Detected automatically; set it by hand in Advanced settings if detection misses

Anthropic Messages
Use it for

Anthropic or Anthropic-compatible services

How CCR picks it

Detected automatically; set it by hand in Advanced settings if detection misses

Gemini
Use it for

Gemini or Gemini-compatible services

How CCR picks it

Detected automatically; set it by hand in Advanced settings if detection misses

Gemini Interactions
Use it for

Services that support that protocol

How CCR picks it

Detected automatically; set it by hand in Advanced settings if detection misses

When something goes wrong

The agent ignores CCR
Likely cause

It was opened directly, not from CCR

What to check

The service is running, the agent was launched from CCR, and the profile covers the project

Authentication errors
Likely cause

A credential problem, not routing

What to check

The API key, base URL, protocol and any extra headers, then the connectivity check

Model not found
Likely cause

Routing resolved a model the provider lacks

What to check

The provider's model list, the routed model and the Agent Config model all match

Requests time out
Likely cause

Upstream latency or tool time

What to check

The duration and error in the request logs

No logs appear
Likely cause

Observability is off

What to check

Settings, Logs & Observability: turn on request logs, then start a new task

Keep Claude Code Router safe

  • Your provider API keys live in the router, so keep the machine and its CCR client keys private.
  • The management token protects the UI, and client keys protect the model gateway. They are separate credentials.
  • Routing scripts receive the full request, including headers that can carry API keys and cookies, so only run scripts you wrote or reviewed.
  • Read the Docker deployment guide before you expose the gateway beyond your own machine.
  • Download CCR only from the project's GitHub releases.

Steal this workflow

Run this guide in your own assistant. The prompt carries the guide link and the workflow summary, so the assistant can adapt it to your project.

Read the guide "Claude Code Router: run Claude Code on other providers, with routing rules and setup" at https://better-design.com/blog/claude-code-router and help me apply it to my project.

Claude Code Router is a free, MIT-licensed local gateway that sends Claude Code's requests to the providers you choose, such as OpenRouter, DeepSeek or Gemini. It routes each request with rules, lets subagents pick models, and retries or fails over when a provider errors. This guide covers setup, the CLI, routing, troubleshooting and safety, from the project's own README and docs.

Start by asking what I am building and which tools I use. Then walk me through the workflow step by step, adapted to my answers.

Claude and ChatGPT open with the prompt filled in. Gemini copies the prompt to your clipboard first, so paste it when the app opens.

Questions

Is Claude Code Router made by Anthropic?

No. It is a community project by musistudio on GitHub, under the MIT license.

Which providers does Claude Code Router support?

OpenAI-compatible, Anthropic and Gemini APIs, including OpenRouter, DeepSeek, SiliconFlow, Moonshot, Kimi Code, Mistral, Z.AI, Bailian and custom compatible providers.

What port does Claude Code Router use?

The model gateway listens on 127.0.0.1:3456. The management UI is on port 3458.

How do subagents use different models?

Add a description to each model. CCR then tells Claude Code about them, and each spawned subagent can pick a model, which CCR reads from a tag in the prompt.

How do I stop Claude Code Router?

Run ccr stop for a background service. A foreground ccr serve is stopped from its own terminal.

Where these Claude Code Router facts come from

Each fact comes from the pages listed here, read on November 13, 2026. Products change, so check those pages for the current version.

Build the interface in your own code instead

A coding agent such as Claude Code, Cursor or Codex can build your interface in your own code. Better Design gives that agent a design system, interface principles and review rules, so the result looks designed.