Claude Code
Connect Claude Code to local or Cloud BitRouter, configure a Claude-only model pool, and verify the serving route.
Keep Claude Code's interface, tools, and permission controls while BitRouter handles its model requests. This guide covers the Claude Code CLI.
Prerequisites & launch
Install Claude Code and BitRouter. Connect a Claude inference source with BYOK & Subscriptions, and confirm that it has a working route. Then run from your project:
bro claudeThe launcher configures the child process and can start the local daemon if needed. It leaves your normal Claude Code settings file in place. Without a model override, Claude Code keeps its own model selection. Native launch does not create a BRO Goal; see the shared launch guide for additional options.
Proxy configuration
Claude Code's official gateway configuration uses ANTHROPIC_BASE_URL and a gateway credential. The examples below use BitRouter's bearer-token authentication. The BitRouter key authenticates the client to the router; upstream provider credentials are configured separately.
Local
Start the local router with bro start, then run these commands in the shell where you launch Claude Code:
export ANTHROPIC_BASE_URL="http://127.0.0.1:4356"
export ANTHROPIC_AUTH_TOKEN="${BITROUTER_API_KEY:-bitrouter-local}"
export ANTHROPIC_MODEL="anthropic:claude-sonnet-5"
claudebitrouter-local works only when the local router allows unauthenticated requests. If authentication is enabled, export a valid BITROUTER_API_KEY first. Use the base URL without /v1/messages; Claude Code adds the request path.
Cloud
Obtain a BitRouter Cloud API key, make it available as BITROUTER_API_KEY, and select a Claude route enabled for your Cloud account:
export ANTHROPIC_BASE_URL="https://api.bitrouter.ai"
export ANTHROPIC_AUTH_TOKEN="$BITROUTER_API_KEY"
export ANTHROPIC_MODEL="anthropic:claude-sonnet-5"
claudeThe model ID is an example: confirm account access before using it. A Cloud key does not import your local Claude subscription. Configure Cloud BYOK when bringing an API key; see pricing for Cloud fees. Self-hosted routing has no BitRouter fee.
Environment changes apply to newly launched processes. Claude Desktop uses a different third-party inference setup.
Default model pool & customization
Use a Claude-only starting pool. These are explicit example pins, rather than aliases for the newest release or a promise of account availability:
| Claude Code choice | BitRouter model selector | Starting role |
|---|---|---|
sonnet | anthropic:claude-sonnet-5 | Default coding model |
opus | anthropic:claude-opus-4-8 | Complex work |
haiku | anthropic:claude-haiku-4-5 | Smaller tasks |
Set the mappings before launching Claude Code, using either connection above:
export ANTHROPIC_DEFAULT_SONNET_MODEL="anthropic:claude-sonnet-5"
export ANTHROPIC_DEFAULT_OPUS_MODEL="anthropic:claude-opus-4-8"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="anthropic:claude-haiku-4-5"
export ANTHROPIC_MODEL="$ANTHROPIC_DEFAULT_SONNET_MODEL"
claudeUse /model to select a configured choice. The official model configuration explains alias resolution and model precedence. These mappings select models; they do not install an automatic routing policy or a fallback chain. bro claude alone does not install this pool.
To customize it, replace a mapping with another accessible Claude model. Inspect your local sources first:
bro models --provider anthropic
bro route anthropic:claude-sonnet-5The examples pin the anthropic API-key source. A logical ID such as anthropic/claude-sonnet-5 can instead use eligible connected providers. After separately connecting the claude-code subscription provider, set a mapping to claude-code:claude-sonnet-5 to require that source. Subscription access and limits remain account-dependent. See subscriptions and model selectors.
Keep every mapping in this pool on a Claude model, including any additional family or subagent overrides in your existing settings. For policy-driven selection, configure a Claude-only policy in Auto Router before requesting bitrouter/auto.
Verify & troubleshoot
For a local launcher check, run:
bro claude --model anthropic:claude-sonnet-5 --checkThen verify the actual session:
- Run
/statusin Claude Code and inspect the active model and connection. - Ask it to list the files in a small test directory using its tools, then summarize one file in a follow-up turn. Review any permission request normally.
- For local routing, run
bro requests --limit 10and match the request time, serving model, and provider. For Cloud, inspect the account's request records. See Request receipts.
A successful reply or launcher check alone does not prove the serving route. Verify streaming, tools, and follow-up turns on the client and source versions you use.
| Symptom | What to check |
|---|---|
| Connection refused | Start the local daemon; check the host and port. A remote shell's 127.0.0.1 refers to that remote machine. |
401 or an unexpected login prompt | Check that the gateway token reaches the Claude process. Separate gateway authentication from upstream authentication; review conflicting credentials using the official troubleshooting guide. |
| Model not found | Check the exact selector, provider activation, account access, and the model mappings. Use bro route for the local route. |
| Wrong model after changing settings | Restart Claude Code and inspect /status; check --model, environment variables, and settings precedence. |
| Tools, thinking, or later turns fail | Check the source's Messages compatibility and beta-field handling against the gateway compatibility guide. Keep the model fixed while diagnosing the failure. |
| No matching request record | Confirm the session's base URL and the BitRouter instance being inspected; another already-running session may retain its original connection. |
How is this guide?