Running Claude Code with Non-Anthropic Models Using Bifrost CLI
Bifrost CLI lets you run Claude Code with models from OpenAI, Google, Mistral, and 20+ providers through a single command. No client modifications required.
Claude Code is one of the most capable terminal-based AI coding agents available today. It handles file operations, runs terminal commands, edits code, and reasons through complex engineering tasks directly from the command line. But it ships with a hard constraint: Claude Code only works with Anthropic's models out of the box. For engineering teams that need provider flexibility, cost optimization, or model-specific strengths for different tasks, this creates a real bottleneck. Bifrost CLI solves this by routing Claude Code through the Bifrost AI gateway, enabling access to non-Anthropic models without modifying the Claude Code client.
Why Run Claude Code with Non-Anthropic Models
Different models excel at different tasks. GPT-4o may perform better for certain codebases, Gemini offers larger context windows for monorepo work, and Groq-hosted Llama models deliver faster inference for lightweight operations. Without an intermediary layer, switching between these models requires manual reconfiguration for every session.
There are also operational concerns. Relying on a single provider introduces risks around rate limits, regional outages, and cost spikes. Teams running Claude Code across dozens of developers need centralized governance, failover redundancy, and usage visibility that a single-provider setup cannot provide.
Bifrost, the open-source AI gateway by Maxim AI, addresses these problems at the infrastructure layer. It sits between Claude Code and any LLM provider, translating Anthropic-formatted API requests to the target provider's format and returning responses in Anthropic's format. Claude Code never knows the difference.
How Bifrost CLI Works with Claude Code
Bifrost CLI is an interactive terminal tool that automates the connection between Claude Code and the Bifrost gateway. Instead of manually exporting environment variables and configuring provider paths, you run a single command:
npx @anthropic-ai/bifrost-cli
The CLI walks you through a structured setup:
- Gateway URL: Enter the base URL of your Bifrost instance (typically
http://localhost:8080for local setups) - Virtual key: If your gateway uses virtual key authentication, provide it here. Bifrost stores this securely in your OS keyring.
- Harness selection: Choose Claude Code from the available options (Bifrost also supports Codex CLI, Gemini CLI, and others)
- Model selection: The CLI fetches available models from your gateway's
/v1/modelsendpoint and presents a searchable list. Pick any model from any configured provider.
Once confirmed, Claude Code launches with all necessary environment variables configured automatically. No manual export ANTHROPIC_BASE_URL commands required.
Overriding Claude Code Model Tiers
Claude Code organizes its model usage into three tiers: Sonnet (default for most tasks), Opus (complex reasoning), and Haiku (fast, lightweight operations). With Bifrost, you can override any of these tiers to use models from entirely different providers using the provider/model-name format:
export ANTHROPIC_DEFAULT_SONNET_MODEL="openai/gpt-5"
export ANTHROPIC_DEFAULT_OPUS_MODEL="gemini/gemini-2.5-pro"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="groq/llama-3.3-70b-versatile"
Bifrost automatically translates Anthropic API requests to the target provider, so this works without any SDK or client changes. You can also switch models mid-session using the /model command:
/model openai/gpt-5
/model mistral/mistral-large-latest
/model xai/grok-3
Bifrost supports 20+ providers including OpenAI, Azure, Google (Gemini and Vertex), AWS Bedrock, Mistral, Groq, Cerebras, Cohere, xAI, Ollama, and more.
Tool Use Compatibility: What to Know
One critical requirement when routing Claude Code to non-Anthropic models: the alternative model must support tool use capabilities. Claude Code relies heavily on tool calling for its core operations, including file edits, terminal commands, and code generation workflows. Models without proper tool use support will fail on these operations.
Additionally, Claude-specific features like extended thinking, web search, and computer use are not available when using non-Anthropic models. Core functionality (chat, streaming, and tool use) works across most providers.
It is also worth noting that some proxy providers may not handle streaming correctly. Bifrost's documentation flags that providers like OpenRouter may not stream function call arguments properly, which can cause tool calls to return with empty arguments. If you encounter this, switching to a direct provider in your Bifrost configuration resolves the issue.
Production Benefits Beyond Model Switching
Routing Claude Code through Bifrost is not just about swapping models. It opens up enterprise-grade infrastructure capabilities:
- Automatic failover: If your primary provider goes down or returns errors, Bifrost reroutes traffic to a configured fallback automatically
- Observability: Every request gets logged with token usage, latency, and full request/response data. The built-in dashboard provides real-time visibility, with Prometheus metrics and OpenTelemetry support for production monitoring
- Governance and cost control: Virtual keys enable per-developer budgets, rate limiting, and access control, preventing runaway costs across teams
- MCP tool injection: MCP tools configured in Bifrost automatically become available to Claude Code. Bifrost injects tools into the request's tools array before forwarding, so Claude Code can use filesystem tools, web search, or database queries without client-side configuration
- Semantic caching: Semantic caching matches requests by meaning rather than exact text, reducing redundant API calls and delivering sub-millisecond cache retrieval
Getting Started with Bifrost CLI
Setup takes under a minute. Install and run the Bifrost gateway locally:
npx @anthropic-ai/bifrost-cli
Then launch Bifrost CLI, select Claude Code as your harness, choose your model, and start coding. The Bifrost GitHub repository contains full documentation and configuration guides.
For teams evaluating Bifrost for production Claude Code deployments at scale, book a demo to explore enterprise features like clustering, guardrails, vault support, and in-VPC deployments.