Claude Code Router: three ways to run Claude Code on any model (2026)

By Felix Wunderlich -

Updated August 11, 2026. Commands and project statuses verified at publish time.

TL;DR: the fastest path is two commands, npx @opperai/cli login then opper launch claude, which puts Claude Code on any of 700+ models through one hosted gateway, switchable per session with --model. Prefer to run your own gateway? The open-source claude-code-router is the best self-hosted option. Both are covered below, trade-offs included.

Claude Code is the best agentic coding harness around, and it is wired to one vendor's API by default. That combination is why "Claude Code router" became a whole category of tooling: developers want the harness with a different engine, whether that is a cheaper model for routine work, a specific model that suits their stack, a local model for offline use, or an EU-hosted deployment for compliance. This guide covers all three ways to get there, the raw mechanism Claude Code itself supports, the open-source claude-code-router project most searches for this term are looking for, and the hosted one-command route, with the trade-offs of each stated honestly.

One disambiguation up front, because the terms get mixed: a Claude Code proxy usually means a local process that translates requests into another provider's format, a Claude Code router decides which model serves each request, and both rely on the same underlying switch. Corporate network proxies (the HTTPS_PROXY kind) are a separate, unrelated configuration.

The three paths at a glance

PathWhat you runModelsBillingEU option
claude-code-router (open source)A local Node 22+ gateway you configure and maintain10+ named providers, your keys per providerSeparate bill per providerBuild it yourself
Direct or local backendsNothing extraOne backend at a timeThat backend's billDepends on the backend
opper launch claude (hosted)Nothing700+ models, one keyOne bill at provider ratesEU routes end to end

How Claude Code talks to a model

Everything in this guide is sugar over one documented mechanism: Claude Code reads a handful of environment variables, and anything that speaks the Anthropic Messages API can stand behind them. The four that matter, per Anthropic's model configuration docs:

export ANTHROPIC_BASE_URL="https://your-gateway.example"  # where requests go
export ANTHROPIC_AUTH_TOKEN="your-gateway-key"            # auth for that endpoint
export ANTHROPIC_MODEL="full-model-id"                    # the main model
export ANTHROPIC_DEFAULT_HAIKU_MODEL="full-model-id"      # the background model
flowchart LR CC["Claude Code"] -->|"ANTHROPIC_BASE_URL"| R{"Where does it point?"} R -->|"default"| A["api.anthropic.com<br/>Claude models, subscription or API"] R -->|"local router"| CCR["claude-code-router<br/>a gateway on your machine"] R -->|"hosted gateway"| OP["Opper<br/>one key, 700+ models"] CCR --> P["OpenAI, Google, DeepSeek, ...<br/>your per-provider keys"] OP --> Q["OpenAI, Anthropic, Google, ...<br/>EU routes available"]

Two precisions before the options, because they trip everyone up. Billing follows the credential: once a gateway auth token is active, sessions are billed by that backend as API usage, not by a Claude Pro or Max subscription. And model aliases like sonnet resolve to Anthropic model IDs, so they keep working when a gateway proxies to Claude, while non-Claude backends need their own full model IDs. One honesty note for the whole guide: Anthropic documents this gateway mechanism and states plainly that it does not support routing Claude Code to non-Claude models, so everything below is well-trodden but officially unsupported territory, and polish varies with the backend.

Option 1: claude-code-router, the open-source local gateway

The claude-code-router project (36k+ GitHub stars, MIT-licensed, actively shipping, v3 landed this month) is what most people searching this term want: a local gateway that intercepts Claude Code's Anthropic-format requests and re-routes them to OpenAI, Gemini, DeepSeek, OpenRouter, Mistral, Moonshot and more, with routing rules that pick a model per request based on conditions you define, custom scripts included, plus fallback chains.

npm install -g @musistudio/claude-code-router
ccr ui   # opens the v3 dashboard; launch Claude Code from an agent profile

Note that v3 changed the workflow: the old ccr code command and the simple config-file routing many older tutorials describe are gone, replaced by a dashboard (a desktop app is now the recommended install) with agent profiles, condition rules and script rules. Its real strengths: free, fully local, works with offline models via custom OpenAI-compatible endpoints such as Ollama, and endlessly customizable. Its real costs: it is a Node 22+ stack you install, configure and keep running, the configuration surface is genuinely involved, you still bring and manage separate API keys and billing for every provider you route to, and the project has grown from a simple router into a full control-plane app, with the maintenance surface to match, close to nine hundred open issues at the time of writing. None of that is a criticism of an impressive project; it is the operational reality of running your own gateway.

Option 2: direct connections and DIY proxies

A few backends speak the Anthropic format natively, so you can skip the router entirely. OpenRouter works with just the env vars, including its documented quirk that ANTHROPIC_API_KEY must be set to an empty string, not unset, though its own cookbook cautions that Claude Code is optimized for Anthropic models and may not work correctly with others. Local runtimes caught up too: Ollama and LM Studio both serve Anthropic-compatible endpoints now, which makes fully offline Claude Code sessions possible on a capable machine. Teams sometimes stand up LiteLLM as a shared proxy with virtual keys and spend tracking, which works, and means operating LiteLLM.

The cautionary data point in this lane is the DIY proxy graveyard: y-router, a popular Cloudflare Worker translator, is archived; the best-known claude-code-proxy has sat unmaintained for months. Translation proxies rot fast because they chase two moving APIs at once, so if you go DIY, prefer maintained projects over clever one-file solutions.

Option 3: a hosted router in one command

If you want the outcome, Claude Code on any model, without operating anything, that is what the Opper Agent CLI is for. It performs the same env-var wiring as everything above, ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN, but points them at a hosted gateway, so there is no local process, no per-provider keys, and one bill at provider rates with no markup on inference:

npx @opperai/cli login          # one OAuth sign-in
opper launch claude             # Claude Code, routed through Opper

Switching the engine is a flag, using full model IDs from the 700+ model catalog:

opper launch claude --model openai/gpt-5.5
opper launch claude --model anthropic/claude-opus-4-7

Because the gateway sits behind the same endpoint, you also get what a local router cannot give you: automatic fallbacks if a provider has an outage, per-call cost and latency accounting for every session, and EU-hosted routes end to end when compliance requires them, the same EU residency machinery the rest of the Opper platform runs on. The trade-off runs the other way from claude-code-router's: less infinite customizability, nothing to run.

Which models actually hold up inside Claude Code

Claude Code leans hard on tool calling, so raw benchmark scores predict less than tool-use quality. The practical shortlist: the frontier models from OpenAI, Anthropic and Google all hold up, and among open-weight models the strong tool-callers, Kimi and DeepSeek's recent releases in particular, have become genuinely usable engines for routine work at a fraction of the cost. We maintain per-model setup pages for exactly this, for example Claude Code on Kimi K3, Claude Code on GPT-5 and Claude Code on DeepSeek V4 Pro, and the model directory lists current per-token prices for all of them. Latency through a gateway is smaller than most people expect; we measured it rather than guessing.

What changes when you leave api.anthropic.com

The honest fine print, which applies to every option here. Billing follows the credential, so once a gateway token is active a Claude Pro or Max subscription does not apply to those sessions. Aliases like sonnet resolve to Anthropic model IDs, fine behind a Claude-proxying gateway, while non-Claude backends need their own full model IDs. Some Anthropic-endpoint conveniences, prompt caching among them, depend on the backend you route to, and custom models can be surfaced in the /model picker via environment variables. And your data path is whatever the backend makes it, which is the reason to know where your gateway runs and what it retains before you point a coding agent full of proprietary source at it.


Claude Code router FAQ

Is claude-code-router an official Anthropic tool?+

No. It is a third-party, MIT-licensed open-source project. The underlying mechanism, environment variables like ANTHROPIC_BASE_URL pointing Claude Code at an Anthropic-compatible endpoint, is documented by Anthropic and used by gateway, Bedrock and Vertex configurations alike, though Anthropic states it does not support routing Claude Code to non-Claude models.

Can I use my Claude Pro or Max subscription through a router?+

No. Once a gateway credential is active, sessions are billed as API usage by whatever backend serves them, and the subscription does not apply. Subscriptions cover only sessions where Claude Code talks to Anthropic with its own account.

Does switching models break Claude Code's tool calling?+

It depends on the model, not the router. Claude Code exercises tool calling heavily, and models with weak tool use will fumble edits and shell commands regardless of how they are routed. Frontier models and the strongest open-weight tool-callers hold up well; test a model on a real task before standardizing on it.

Can Claude Code run fully offline with local models?+

Yes, with a local backend. Ollama and LM Studio both serve Anthropic-compatible endpoints, so Claude Code can point at them directly, and claude-code-router can reach Ollama as a custom OpenAI-compatible endpoint. Capability depends entirely on how strong a model your hardware can run.

What is the difference between a Claude Code proxy and a Claude Code router?+

A proxy translates Claude Code's Anthropic-format requests so another provider can serve them; a router additionally decides which model handles each request, by task type, cost or availability. claude-code-router does both locally, and a hosted gateway does both server-side with nothing to run.

How do I keep Claude Code inference in the EU?+

Route it through a gateway with EU-hosted model deployments. opper launch claude runs Claude Code through Opper's Stockholm-hosted platform, where EU routes keep inference in the EU end to end, including Claude itself on AWS Bedrock EU regions. Which gateways offer real EU residency, and which only claim it, is covered in our European AI gateways comparison.

Pick your lane

Run your own gateway if you want maximal control and are happy operating it: claude-code-router is the best project in that lane. Point directly at OpenRouter or a local runtime if your needs are simple. And if you want any of 700+ models behind Claude Code with one login, fallbacks, spend visibility and EU routes, install the Opper CLI and you are one opper launch claude away, or create a free account first and browse the models it unlocks.