Claude Code is Anthropic’s terminal-based AI coding assistant designed for developers who want to integrate AI directly into their development workflow. By default, Claude Code connects directly to Anthropic’s API and uses Claude models for all interactions.
While this setup works well for many developers, production engineering teams often need more flexibility. Teams may want to route requests through different LLM providers, enforce governance policies, monitor usage across agents, or dynamically choose models based on cost and performance.
Bifrost solves this problem by acting as a fully compatible Anthropic API endpoint that sits between Claude Code and any LLM provider. With a single configuration change, developers can route Claude Code traffic through Bifrost and gain access to more than 20 providers including OpenAI, AWS Bedrock, Google Vertex AI, Azure, Groq, and Mistral.
This guide walks through the full setup process, including installation, model overrides, MCP tool integration, and observability.
Why Use Bifrost With Claude Code?
Running Claude Code directly against Anthropic’s API limits teams to a single provider and reduces visibility into how agents interact with models. Bifrost introduces a gateway layer that unlocks several production-grade capabilities.
Key benefits include:
- Multi-provider routing for LLM requests
- Centralized observability for all agent interactions
- Governance controls such as virtual keys and budget limits
- Load balancing and automatic fallbacks across providers
- Semantic caching to reduce repeated token costs
Because Bifrost exposes a fully compatible Anthropic endpoint, Claude Code can use it without any changes to how the CLI operates.
Prerequisites
Before connecting Claude Code to Bifrost, ensure you have the following installed:
- Node.js
- Claude Code CLI
- A running Bifrost instance
Install Claude Code globally:
npm install -g @anthropic-ai/claude-code
Start Bifrost locally using the zero-configuration quickstart:
npx -y @maximhq/bifrost
Once running, Bifrost’s dashboard will be available at:
http://localhost:8080
You can configure provider API keys either in the web interface or through the configuration file.
Step 1: Point Claude Code to the Bifrost Gateway
Bifrost exposes a fully compatible Anthropic API endpoint at /anthropic. Claude Code determines where to send requests using two environment variables.
Set the following variables:
export ANTHROPIC_API_KEY=dummy-key
export ANTHROPIC_BASE_URL=http://localhost:8080/anthropic
If Bifrost manages provider credentials internally, the API key can simply be a placeholder value. When governance features such as virtual keys are enabled, you should use the corresponding Bifrost key instead.
Launch Claude Code:
claude
All Claude Code requests will now pass through the Bifrost gateway.
Step 2: Override Claude Model Tiers
Claude Code organizes models into three tiers:
- Sonnet for general development tasks
- Opus for advanced reasoning
- Haiku for lightweight or fast operations
Bifrost allows each of these tiers to be mapped to models from any provider.
Configure model overrides with environment variables:
export ANTHROPIC_DEFAULT_SONNET_MODEL="openai/gpt-5"
export ANTHROPIC_DEFAULT_OPUS_MODEL="anthropic/claude-opus-4-5-20251101"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="azure/claude-haiku-4-5"
The provider/model format tells Bifrost which backend provider should serve each request.
Supported providers include OpenAI, Azure OpenAI, AWS Bedrock, Google Vertex AI, Groq, Ollama for local models, and many others.
One important requirement is tool-calling support. Claude Code relies heavily on tool execution for file editing, terminal operations, and repository interactions. Models that do not support tool calling will not function correctly.
You can also launch Claude Code with a specific model:
claude --model claude-opus-4-5-20251101
Or start with a faster model:
claude --model claude-haiku-4-5-20251001
Step 3: Switch Models During a Session
Claude Code allows model switching inside an active session using the /model command.
Examples:
/model opus
/model sonnet
/model haiku
You can also switch using full model names:
/model claude-opus-4-5-20251101
/model claude-sonnet-4-5-20250929
Because Bifrost handles routing, you can even switch across providers dynamically:
/model vertex/claude-haiku-4-5
/model azure/claude-sonnet-4-5
/model bedrock/claude-sonnet-4-5
The transition happens instantly while preserving the current conversation context.
Step 4: Connect MCP Tools Through Bifrost
Bifrost functions as both an MCP client and server. It can connect to multiple external MCP tool servers and expose them through a single endpoint.
Claude Code can then access these aggregated tools through Bifrost.
Add Bifrost as an MCP server:
claude mcp add --transport http bifrost http://localhost:8080/mcp
If virtual key authentication is enabled, use JSON configuration:
claude mcp add-json bifrost '{"type":"http","url":"http://localhost:8080/mcp","headers":{"Authorization":"Bearer bf-virtual-key"}}'
Once configured, Claude Code will only have access to the MCP tools permitted by that key’s policy configuration.
This setup enables centralized governance of tool permissions across all agents.
Step 5: Monitor Claude Code Activity
Every request routed through Bifrost is automatically logged with full metadata including:
- Prompt inputs
- Model parameters
- Provider details
- Token usage
- Latency
- Cost metrics
You can view these interactions in real time using the observability dashboard:
http://localhost:8080/logs
For production environments, Bifrost also supports:
- Prometheus metrics via the
/metricsendpoint - OpenTelemetry integration
- Distributed tracing with platforms such as Grafana, Datadog, and New Relic
This provides a complete view of how AI agents operate in production systems.
Provider Compatibility Considerations
Not all providers work equally well with Claude Code. Because the CLI relies heavily on tool execution, providers must properly support streaming tool call arguments.
Some proxy providers may not fully implement the Anthropic API specification for streaming tool calls, which can cause failures when Claude Code attempts to perform file or terminal operations.
When issues occur, switching to a direct provider endpoint such as Anthropic, OpenAI, Azure, Bedrock, or Vertex AI typically resolves the problem.
Complete Configuration Example
Below is a full example configuration for running Claude Code through Bifrost with custom model tiers.
export ANTHROPIC_API_KEY=your-bifrost-virtual-key
export ANTHROPIC_BASE_URL=http://localhost:8080/anthropic
export ANTHROPIC_DEFAULT_SONNET_MODEL="anthropic/claude-sonnet-4-5-20250929"
export ANTHROPIC_DEFAULT_OPUS_MODEL="openai/gpt-5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="azure/claude-haiku-4-5"
claude
You can add these environment variables to your .bashrc or .zshrc file to persist the configuration across terminal sessions.
Final Thoughts
Using Bifrost with Claude Code gives engineering teams a powerful gateway layer for managing AI infrastructure. Instead of being locked into a single model provider, teams gain the ability to route requests dynamically, enforce governance policies, monitor agent activity, and optimize cost and performance across providers.
With just a few environment variables, Claude Code becomes a flexible multi-provider AI development environment suitable for both individual developers and production engineering teams.
Top comments (0)