Try Bifrost Enterprise free for 14 days. Request access

Claude Code Router vs. an AI Gateway: 5 Ways to Run Claude Code on Any Model

Claude Code Router is the most popular way to run Claude Code on non-Anthropic models from a laptop. This guide compares it with Bifrost, LiteLLM, OpenRouter, and Ollama, and explains when a team needs a shared AI gateway instead of a local router.

Claude Code Router vs. an AI Gateway: 5 Ways to Run Claude Code on Any Model

TL;DR

  • Claude Code Router is an open-source local proxy that lets one developer run Claude Code on models from OpenAI, Gemini, DeepSeek, OpenRouter, and other providers.
  • Every option works the same way: Claude Code sends Anthropic Messages requests to whatever sits at ANTHROPIC_BASE_URL, and that layer translates and routes them.
  • A local router suits personal setups. Teams that need shared provider keys, budgets, logs, and failover need a self-hosted AI gateway such as Bifrost.
  • Anthropic does not support routing Claude Code to non-Claude models, so pick models with strong tool calling and test them before rolling out.

Claude Code Router is the most searched way to run Claude Code on models other than Claude, and it works well on a single machine. Bifrost, the open-source AI gateway built by Maxim AI, takes the same idea to the team level and is the best choice for enterprises running mission-critical AI workloads that require best-in-class performance, scalability, and reliability. This guide compares five ways to point Claude Code at any model: Bifrost, Claude Code Router, LiteLLM, OpenRouter, and Ollama.

What Is Claude Code Router?

Claude Code Router (CCR) is an open-source, MIT-licensed local model gateway for coding agents. It runs on a developer's machine, listens on http://127.0.0.1:3456 by default, and forwards Claude Code requests to the provider and model you choose. The project has more than 37,000 GitHub stars and ships as a desktop app and an npm CLI.

CCR has grown beyond Claude Code. Its current release manages profiles for Claude Code, Codex, OpenCode, Kimi CLI, and other agents, with routing conditions, retries, ordered fallbacks, and request logs. For the broader category it belongs to, our explainer on the Claude Code gateway covers routing, governance, and cost control in one place.

How Claude Code Runs on Non-Anthropic Models

Claude Code runs on non-Anthropic models by sending its normal Anthropic Messages API requests to a different base URL. The ANTHROPIC_BASE_URL variable points Claude Code at a router or gateway, which translates each request into the target provider's format and streams the response back. Anthropic documents this pattern in its LLM gateway guide for Claude Code.

Claude Code sends Anthropic Messages requests to ANTHROPIC_BASE_URL, where a router or gateway translates and forwards them to Anthropic, Bedrock, OpenAI, Gemini, or local models

Figure 1: Every option in this guide works the same way: Claude Code talks to whatever sits at ANTHROPIC_BASE_URL.

Claude Code maps its sonnet, opus, and haiku aliases through ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_OPUS_MODEL, and ANTHROPIC_DEFAULT_HAIKU_MODEL. Setting those variables to a non-Claude model is how you run Claude Code with OpenAI models or Claude Code with Gemini models.

Two caveats apply to every option below:

  • Support: Anthropic states that it doesn't support routing Claude Code to non-Claude models through any gateway. Treat non-Claude setups as your own to test and maintain.
  • Tool calling: Claude Code depends on tool use for file edits, shell commands, and search. A model with weak or badly streamed tool calls will fail on file operations, and Claude-specific server-side tools such as web search may be missing.

Claude Code Router vs. an AI Gateway

The difference between Claude Code Router and an AI gateway is scope. A router runs on one laptop with that developer's own provider keys. An AI gateway runs as shared infrastructure, holds provider keys server-side, and applies the same budgets, access rules, and logs to every developer and CI job. Our guide to Claude Code at enterprise scale explains why that shift matters once usage grows.

On the left, one developer runs Claude Code Router on a laptop with personal provider keys; on the right, many developers send Claude Code traffic to one Bifrost gateway that holds provider keys, budgets, and logs

Figure 2: A local router serves one machine. A shared gateway serves a whole team from one control point.

Concern Local router (CCR) Shared AI gateway (Bifrost)
Where it runs Each developer's machine One deployment for the whole team
Provider keys Stored on each laptop Held by the gateway; developers get virtual keys
Budgets and limits Local client key limits Per-key, per-team, and per-customer budgets and rate limits
Logs and cost Local request logs Central logs across every user and agent
Offboarding Rotate every personal key Revoke one virtual key
Failover Ordered fallbacks per machine Gateway-wide fallbacks and load balancing

The comparison is not about which tool is better. A solo developer experimenting with DeepSeek or Kimi rarely needs central governance, while a platform team rolling Claude Code out to hundreds of engineers almost always does. The hidden cost of Claude Code at enterprise scale usually shows up only once traffic is centralized and measured.

5 Ways to Run Claude Code on Any Model at a Glance

The table compares the five options by where they run and what they add on top of model routing. Entries for third-party tools reflect each project's published documentation, read in October 2026. For a longer list focused only on gateways, see our roundup of AI gateways for Claude Code with non-Anthropic models.

Option Type Deployment Team governance License
Bifrost AI gateway Self-hosted (VPC, on-prem, air-gapped) Virtual keys, budgets, rate limits, logs Apache 2.0
Claude Code Router Local router Developer machine or Docker Local client keys and limits MIT
LiteLLM Proxy server Self-hosted Python service Master key, virtual keys, spend tracking MIT (outside its enterprise directory)
OpenRouter Hosted API Managed service Credit limits and usage analytics Proprietary service
Ollama Local model runtime Developer machine, plus cloud models Not published MIT

1. Bifrost

The Bifrost AI gateway is an open-source, Apache 2.0 licensed AI gateway written in Go. Claude Code connects to it through Bifrost's Anthropic-compatible /anthropic endpoint, and Bifrost routes each request to any of 25+ providers and 10,000+ models while adding 11 microseconds of overhead at 5,000 RPS (benchmarks).

Best for: Bifrost is built for enterprises running mission-critical AI workloads that require best-in-class performance, scalability, and reliability. It serves as a centralized AI gateway to route, govern, and secure all AI traffic across models and environments with ultra low latency. Bifrost unifies LLM gateway, MCP gateway, and Agents gateway capabilities into a single platform. Designed for regulated industries and strict enterprise requirements, it supports air-gapped deployments, VPC isolation, and on-prem infrastructure. It provides full control over data, access, and execution, along with robust security, policy enforcement, and governance capabilities.

How Bifrost routes Claude Code traffic

Each Claude Code request carries a virtual key. Bifrost checks which models and providers that key allows, applies its budget and rate limits, resolves the model name, and forwards the request. If the primary provider fails, automatic fallbacks send it to the next one.

A Claude Code request reaches the Bifrost anthropic endpoint, passes a virtual key check, has its model alias resolved by a routing rule, goes to the primary provider, and falls back to a second provider on failure

Figure 3: Claude Code sends a model name; Bifrost decides which provider and key actually serve it.

The fastest start is the Bifrost CLI, which launches Claude Code with the gateway URL, credential, and model already set for that session, without editing ~/.claude/settings.json:

npx -y @maximhq/bifrost-cli
bifrost context add production --base-url https://bifrost.example.com --use
printf '%s\n' "$BIFROST_VIRTUAL_KEY" | bifrost auth set-virtual-key --stdin
bifrost claude --model openai/gpt-5

To configure Claude Code directly, set the base URL and a virtual key, then pin each alias to any provider with a provider/model prefix:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://bifrost.example.com/anthropic",
    "ANTHROPIC_AUTH_TOKEN": "sk-bf-your-virtual-key",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "vertex/gemini-3.1-pro",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "openai/gpt-5.5"
  }
}

Inside a session, /model openai/gpt-5.5 or /model bedrock/global.anthropic.claude-sonnet-4-6 switches to any model configured in Bifrost. Our walkthrough on running Claude Code with non-Anthropic models using Bifrost CLI covers the full setup.

What Bifrost adds beyond routing

  • Routing rules and aliases: a routing rule can map a label such as sonnet-model to any provider and model at request time, so the platform team changes models without touching developer machines.
  • Session affinity: Claude Code sends x-claude-code-session-id on every request, and Bifrost's session affinity keeps each session on the provider and key that served it, so prompt caches stay warm.
  • Governance: virtual keys with budgets and rate limits attribute every request to a developer or team, which is the basis of Claude Code cost management.
  • Subscriptions: developers can keep a Claude Pro, Max, Team, or Enterprise subscription and send the virtual key in an x-bf-vk header, so Bifrost logs and governs traffic without changing billing.
  • MCP gateway: Claude Code can add Bifrost's /mcp endpoint as one MCP server that aggregates every connected tool. See how to connect Claude Code to an MCP gateway.
  • Enterprise SSO (Enterprise): an apiKeyHelper that runs bifrost auth print-token attributes each request to the signed-in user with no long-lived secret in Claude Code settings.

For laptops where developers might bypass the gateway, AI Gateway + Bifrost Edge (alpha) routes desktop and coding-agent traffic through Bifrost at the endpoint.

2. Claude Code Router

Claude Code Router is a local, MIT-licensed router for developers who want to run Claude Code on other models from their own machine. Setup takes a few minutes: install the desktop app or the npm CLI, add providers, start the server, and apply a Claude Code profile.

npm install -g @musistudio/claude-code-router
ccr ui

The CLI requires Node.js 22 or newer and opens a management UI at http://127.0.0.1:3458, while the model gateway stays on port 3456. Published capabilities include:

  • Providers: presets for OpenAI, Gemini, OpenRouter, DeepSeek, Moonshot, Mistral, and custom compatible endpoints, with credential pools and key rotation.
  • Routing: conditions on request headers and bodies, model rewrites, retries, and ordered fallback models.
  • Extensions: vision and web search add-ons for models that lack them, plus MCP tools through ToolHub.
  • Observability: local request logs with the resolved provider, model, latency, tokens, and estimated cost.

Best for: individual developers and small teams who want flexible, local model switching across several coding agents without running shared infrastructure.

CCR keeps provider keys and logs on each machine, so it does not give a platform team central budgets, access control, or audit trails. Teams that outgrow it typically move to a self-hosted open-source LLM gateway.

3. LiteLLM

LiteLLM is an open-source Python proxy that exposes many providers behind one API, including an Anthropic-compatible endpoint that Claude Code can use. Its core is MIT-licensed, with code in its enterprise/ directory under a separate license. LiteLLM publishes Claude Code guides covering quickstart, non-Anthropic models, MCP, and cost tracking.

Setup means writing a config.yaml with a model_list, setting a master key, starting the proxy, and pointing ANTHROPIC_BASE_URL at it. Each model_name in the config becomes a name Claude Code can request.

Best for: Python-centric teams that already run LiteLLM for application traffic and want Claude Code on the same proxy.

Teams weighing LiteLLM for production coding-agent traffic should compare throughput and governance features; our list of LiteLLM alternatives for enterprise teams and the best LiteLLM alternatives cover the trade-offs.

4. OpenRouter

OpenRouter is a hosted API that gives one key access to models from many providers. Claude Code connects by setting ANTHROPIC_BASE_URL to https://openrouter.ai/api, putting an OpenRouter key in ANTHROPIC_AUTH_TOKEN, and setting ANTHROPIC_API_KEY to an empty string. OpenRouter documents failover between Anthropic providers, credit limits, and usage analytics.

OpenRouter's own documentation warns that Claude Code is only guaranteed to work with the Anthropic first-party provider, and recommends making that provider the top priority. As of October 2026, OpenRouter did not stream function-call arguments correctly for some models, which breaks Claude Code file operations on those models.

Best for: individual developers who want hosted, pay-per-token access to Claude through one account, without running any infrastructure.

Because it is a hosted service, OpenRouter sends all traffic through a third party and cannot run inside your VPC. Teams that need data residency usually look at self-hosted OpenRouter alternatives or the wider list of OpenRouter alternatives.

5. Ollama

Ollama is an MIT-licensed runtime for local models that now exposes an Anthropic-compatible API, so Claude Code can talk to it directly. A single command launches Claude Code against an Ollama model:

ollama launch claude --model gemma4:cloud

Ollama supports local models and hosted cloud models, and its documentation lists tool calling, subagents, web search, vision, and thinking controls for compatible models. It recommends a context window of 64k tokens or more for larger repositories.

Best for: developers who want Claude Code on local open-weight models for offline work, privacy, or experimentation at zero per-token cost.

Local models trade quality for control. Smaller models often struggle with Claude Code's long, tool-heavy sessions, and Ollama alone does not add team budgets or logs. For local models behind a shared control point, see our guide to LLM gateways for vLLM, SGLang, and Ollama.

How to Choose a Way to Run Claude Code on Any Model

Choose by who uses Claude Code and where models run. One developer can use a local router or runtime; a team needs a shared gateway with central keys, budgets, and logs. The enterprise gateway guide for Claude Code with non-Anthropic models walks through that rollout.

Decision flow asking whether Claude Code serves one developer or a team, and whether models are local or hosted, leading to Ollama, Claude Code Router, OpenRouter, LiteLLM, or Bifrost

Figure 4: Personal setups favor a local router; team rollouts need a shared gateway with keys, budgets, and logs.

  • Local models only: use Ollama for the simplest path to open-weight models on your own hardware.
  • Mixed providers on one laptop: use Claude Code Router for flexible per-machine routing and fallbacks.
  • Hosted access with no infrastructure: use OpenRouter, keeping the Anthropic first-party provider first.
  • A team or enterprise rollout: use Bifrost to hold provider keys, enforce budgets, and log every request. Anthropic's gateway compatibility guide lists what a gateway must forward for Claude Code features to keep working.
  • An existing Python proxy: extend LiteLLM if your team already operates it.

For multi-provider resilience, read our comparison of AI gateways for multi-provider failover and load balancing.

Frequently Asked Questions

What is Claude Code Router?

Claude Code Router is an open-source, MIT-licensed local gateway that sits between Claude Code and model providers. It runs on a developer's machine on port 3456 and routes Claude Code requests to providers such as OpenAI, Gemini, DeepSeek, and OpenRouter, with fallbacks, retries, and local request logs.

How do I use Claude Code with a proxy?

Set ANTHROPIC_BASE_URL to the proxy's Anthropic-compatible endpoint and put the proxy's credential in ANTHROPIC_AUTH_TOKEN. Then pin models with ANTHROPIC_DEFAULT_SONNET_MODEL and related variables. With Bifrost, the base URL ends in /anthropic and the credential is a virtual key. Our guide to running Claude Code with Bifrost CLI for multi-model routing shows each step.

Can Claude Code use OpenAI or Gemini models?

Yes, through a router or gateway that translates Anthropic Messages requests into each provider's format. Anthropic does not support this configuration, and non-Claude models may lack Claude-specific server-side tools, so choose models with strong tool calling and test file edits before relying on them.

Is Claude Code Router safe for teams?

Claude Code Router is designed for local use, so each developer holds their own provider keys and logs stay on their machine. That works for individuals, but teams lose central budgets, revocation, and audit trails. A shared gateway with virtual key governance fills that gap.

Can Claude Code run on local models?

Yes. Ollama exposes an Anthropic-compatible API, and ollama launch claude starts Claude Code against a local or cloud Ollama model. Choose a model with tool calling and a context window of at least 64k tokens for larger repositories.

Does an AI gateway slow Claude Code down?

A well-built gateway adds negligible latency compared with model inference. Bifrost adds 11 microseconds of overhead per request at 5,000 RPS and streams responses event by event, which Claude Code needs to avoid stalls.

Run Claude Code on Any Model with Bifrost

Claude Code Router is a strong choice for one developer; a team needs the same model flexibility with shared keys, budgets, failover, and logs. Bifrost gives Claude Code access to 25+ providers and 10,000+ models through one /anthropic endpoint, governed by virtual keys and backed by an MCP gateway built for Claude Code. To see it on your own Claude Code traffic, book a demo with the Bifrost team.