Claude Code
Route Anthropic's Claude Code through BitRouter — every model in the registry, behind the Anthropic Messages API it already speaks.
Claude Code talks to an Anthropic Messages endpoint. Point it at BitRouter instead of api.anthropic.com and every request flows through the registry — so the same agent can run on Anthropic, OpenAI, Google, or an open model, with provider selection and fallback underneath.
Prerequisites
-
BitRouter running — local proxy at
http://127.0.0.1:4356, or BitRouter Cloud athttps://api.bitrouter.ai. -
Claude Code installed:
npm install -g @anthropic-ai/claude-code # or the native installer: curl -fsSL https://claude.ai/install.sh | bash
Point Claude Code at BitRouter
Claude Code reads three environment variables. Set the base URL to BitRouter's host root — it appends /v1/messages itself.
export ANTHROPIC_BASE_URL=http://127.0.0.1:4356
export ANTHROPIC_AUTH_TOKEN=local-placeholder # sent as a bearer token
export ANTHROPIC_MODEL=anthropic/claude-sonnet-4-6
claudePrefer a file? Put the same values in .claude/settings.json so they apply per-project without exporting:
{
"env": {
"ANTHROPIC_BASE_URL": "http://127.0.0.1:4356",
"ANTHROPIC_AUTH_TOKEN": "local-placeholder",
"ANTHROPIC_MODEL": "anthropic/claude-sonnet-4-6"
}
}Pick a model
ANTHROPIC_MODEL takes any registry id in provider/model form — anthropic/claude-sonnet-4-6, openai/gpt-4o, google/gemini-2.5-pro. Add a :cost or :latency suffix to bias provider selection for the session. Switch mid-session with /model <id>, or at launch with claude --model <id>. See Models for the full id scheme.
Verify
Launch claude, ask it anything, and confirm the response. To see which provider actually answered, read BitRouter's request finished log line (~/.bitrouter/bitrouter.log for a local install) — it records the provider and model that served the request.
Learn more
- Claude Code — LLM gateway config
- Model fallback — pass an ordered model list and walk it on failure.
- OpenTelemetry — trace every Claude Code request.
How is this guide?