The fastest LLM gateway in the world

Integrating Claude Code with Bifrost Gateway

Integrating Claude Code with Bifrost Gateway

Claude Code brings Anthropic's Claude Sonnet 4.5 directly to the terminal with agentic coding capabilities. While powerful on its own, integrating it with Bifrost Gateway unlocks additional capabilities like multi-model access, MCP tools, and observability without modifying the Claude Code client.

Bifrost acts as an API gateway that provides compatible endpoints for Anthropic, OpenAI, and Gemini APIs. By routing Claude Code through Bifrost, you intercept API calls at the transport layer, enabling features like model switching, tool injection, and traffic monitoring without requiring changes to the Claude Code binary.

The integration works by:

  1. Setting environment variables to redirect Claude Code's API calls to Bifrost's local endpoint
  2. Bifrost receives requests, applies configured transformations, and forwards them to the actual provider
  3. Responses flow back through Bifrost, where they're logged and optionally modified

Setup

1. Install Claude Code

npm install -g @anthropic-ai/claude-code

2. Configure Environment Variables

export ANTHROPIC_API_KEY=dummy-key  *# Only set when using API key authentication*
export ANTHROPIC_BASE_URL=http://localhost:8080/anthropic

3. Run Claude Code

claude

Environment Variable Breakdown

ANTHROPIC_API_KEY: Set to dummy-key when using API key authentication. Bifrost handles the actual authentication to providers. The setup automatically detects if you're using an Anthropic MAX account instead of API key authentication - in that case, this variable may not be needed as Claude Code uses session-based auth. Bifrost integrates out of the box with MAX account without any additional configuration.

ANTHROPIC_BASE_URL: Points Claude Code to Bifrost's local gateway instead of Anthropic's production endpoint. Note the path is /anthropic (not /v1/anthropic), which routes requests to Bifrost's Anthropic-compatible handler.

Once configured, all Claude Code traffic flows through Bifrost, giving you access to any provider/model configured in your Bifrost setup, plus MCP tools and observability.

Key Capabilities

Universal Model Access

Bifrost enables model substitution through its configuration. You can configure Claude Code to use any model Bifrost has available, not just Claude models. This works because Bifrost translates between different provider API formats - Claude Code sends Anthropic-formatted requests, Bifrost converts them to the target provider's format, and translates responses back to Anthropic's format.

For example, you could configure Bifrost to route requests to:

  • GPT-4 or other OpenAI models
  • Gemini models
  • Different Claude variants (Opus, Sonnet, Haiku)
  • Custom or local models

The model selection is handled in Bifrost's configuration, keeping the Claude Code client setup simple and consistent.

MCP Tools Integration

Model Context Protocol (MCP) tools configured in Bifrost automatically become available to Claude Code. When Bifrost receives a request, it injects MCP tools into the tools array before forwarding to the model provider.

For example, if you've configured MCP tools for filesystem access or web search, Claude Code can use these without knowing they exist. The workflow:

  1. Claude Code sends a coding request
  2. Bifrost injects MCP tools into the request
  3. The model can invoke MCP tools via standard tool calling
  4. Bifrost executes the MCP tool and returns results
  5. The model incorporates tool results into its response

This is transparent to Claude Code - it simply sees tool calls and results in the standard Anthropic message format.

Observability

Bifrost logs all traffic passing through the gateway. The web interface at http://localhost:8080/logs provides:

  • Real-time streaming of requests and responses
  • Token usage tracking per request
  • Latency measurements
  • Filtering by provider, model, or conversation content
  • Full request/response inspection

This is particularly useful for debugging Claude Code sessions, understanding token consumption, or analyzing how the model uses tools.

Configuration Requirements

Before using Claude Code with Bifrost, ensure your Bifrost instance has:

  1. Provider Configuration: At minimum, configure the Anthropic provider with your API key. Additional providers can be configured to enable model switching.
  2. MCP Tools (optional): Configure MCP servers in Bifrost's config to make tools available to Claude Code. Common tools include filesystem access, database queries, and web search.
  3. Bifrost Running: The gateway must be running on localhost:8080 (or update ANTHROPIC_BASE_URL to match your deployment).

Conclusion

Integrating Claude Code with Bifrost transforms it into a multi-model, observable coding agent without modifying the client. The environment variable-based configuration makes it trivial to experiment with different models, add tooling capabilities, and monitor agent behavior - all while maintaining full compatibility with Claude Code's native functionality.