---
description: Bifrost is an open-source AI gateway that connects Claude Code to any LLM provider, including Cerebras, through a single unified endpoint.
title: Route Claude Code Through Cerebras Using Bifrost
image: https://storage.ghost.io/c/84/03/8403f2f6-141c-411a-8f55-a32d4291533e/content/images/size/w1200/2026/07/route-claude-code-through-cerebras-using-bifrost-bifrost-strata.optimized.png
---

Try Bifrost Enterprise free for 14 days. [Request access](https://www.getmaxim.ai/#enterprise-trial)

[Bifrost](https://www.getmaxim.ai/bifrost) is an open-source [AI gateway](https://www.getmaxim.ai/articles/top-5-llm-gateways-in-2026-a-production-ready-comparison/) that connects Claude Code to any LLM provider, including Cerebras, through a single unified endpoint. This guide walks through the full setup, from adding the Cerebras provider to pinning models in Claude Code's settings.

Claude Code depends on fast model responses to feel productive. The tool-call loop that drives file edits, bash execution, and code generation can produce dozens of round trips per session, and waiting on slow completions breaks the working rhythm. Cerebras, running on its wafer-scale hardware, delivers [1,000 to 3,000 tokens per second](https://www.cerebras.ai/blog/introducing-cerebras-inference-ai-at-instant-speed) on open-weight models, compared to 50 to 100 tokens per second typical of GPU-based inference clouds, [as independently benchmarked by Artificial Analysis](https://artificialanalysis.ai/). Routing Claude Code through Cerebras via [Bifrost](https://www.getmaxim.ai/bifrost), the [open-source AI gateway](https://github.com/maximhq/bifrost) built in Go by Maxim AI, gives teams access to that speed without changing how Claude Code is configured at the SDK level.

## Why Route Claude Code Through Bifrost

Bifrost exposes 100% compatible endpoints for the Anthropic, OpenAI, and Gemini APIs, meaning Claude Code can connect to it without any SDK changes. Point the `ANTHROPIC_BASE_URL` environment variable at Bifrost, provide a virtual key, and Claude Code routes its requests through the gateway without knowing the difference.

From there, Bifrost handles the provider conversion. Claude Code sends requests using the Anthropic message format. Bifrost translates them to whatever format the target provider expects and converts the response back. For Cerebras, which is a fully OpenAI-compatible provider, Bifrost delegates to the OpenAI provider implementation, passes all standard parameters through, and returns a normalized response to Claude Code.

Beyond provider compatibility, routing through Bifrost gives you:

- [**Provider fallbacks**](https://docs.getbifrost.ai/features/retries-and-fallbacks): if Cerebras returns a rate limit error or an outage occurs, Bifrost can automatically retry against another configured provider
- [**Virtual keys with budgets and rate limits**](https://docs.getbifrost.ai/features/governance/virtual-keys): issue per-developer or per-team keys that cap spend and enforce usage policies
- [**Built-in observability**](https://docs.getbifrost.ai/features/observability/default): every request Claude Code sends appears in the Bifrost log stream with model, token count, latency, and provider
- [**Semantic caching**](https://docs.getbifrost.ai/features/semantic-caching): repeated or similar queries can return cached responses, reducing both latency and cost

## What Cerebras Support Looks Like in Bifrost

Cerebras is a [supported provider](https://docs.getbifrost.ai/providers/supported-providers/cerebras) in Bifrost. It operates as a fully OpenAI-compatible endpoint, which means Bifrost passes chat completion requests, streaming, tool calls, and text completions through without any additional translation overhead.

Supported operations include:

- Chat completions (streaming and non-streaming)
- Text completions
- Responses API (converted internally to chat completions format)
- Model listing

Operations not supported by the Cerebras API itself, including embeddings, image generation, speech, transcription, and batch, return `UnsupportedOperationError`. One minor caveat: the Cerebras provider silently drops user field values longer than 64 characters, so keep user identifiers short when logging per-user requests.

Reasoning parameters are handled through the standard OpenAI-compatible convention: `reasoning.effort` values map accordingly, and `reasoning.max_tokens` is cleared during conversion.

## Setting Up Cerebras as a Provider in Bifrost

### Step 1: Start Bifrost

Start the Bifrost gateway with Docker:

```bash
docker run -d \
  -p 8080:8080 \
  -e CEREBRAS_API_KEY=your-cerebras-api-key \
  ghcr.io/maximhq/bifrost:latest
```

Or via npx:

```bash
npx -y @maximhq/bifrost
```

For production deployments, see the [Kubernetes deployment guide](https://docs.getbifrost.ai/deployment-guides/k8s).

### Step 2: Add the Cerebras Provider

Navigate to the Bifrost dashboard at `http://localhost:8080`, go to **Model Providers**, and add Cerebras with your API key.

Or configure it via the API:

```bash
curl -X POST <http://localhost:8080/api/providers> \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "cerebras",
    "keys": [
      {
        "name": "cerebras-key-1",
        "value": "env.CEREBRAS_API_KEY",
        "models": ["*"],
        "weight": 1.0
      }
    ]
  }'
```

Or add it to your `config.json` directly:

```json
{
  "providers": {
    "cerebras": {
      "keys": [
        {
          "name": "cerebras-key-1",
          "value": "env.CEREBRAS_API_KEY",
          "models": ["*"],
          "weight": 1.0
        }
      ]
    }
  }
}
```

Once added, Bifrost can forward requests to Cerebras using the standard `cerebras/` model prefix.

### Step 3: Create a Virtual Key

[Virtual keys](https://docs.getbifrost.ai/features/governance/virtual-keys) are how Bifrost authenticates Claude Code. Create one scoped to the Cerebras provider:

```bash
curl -X POST <http://localhost:8080/api/governance/virtual-keys> \
  -H "Content-Type: application/json" \
  -d '{
    "name": "claude-code-cerebras",
    "is_active": true,
    "provider_configs": [
      {
        "provider": "cerebras",
        "allowed_models": ["*"],
        "weight": 1.0
      }
    ]
  }'
```

The response returns a key value in the `sk-bf-*` format. Copy it for use in the next step.

## Configuring Claude Code to Use Bifrost

With the Bifrost gateway running and Cerebras configured, there are two ways to wire up Claude Code: editing `settings.json` manually, or using the [Bifrost CLI](https://docs.getbifrost.ai/quickstart/cli/getting-started) to handle the configuration without touching environment variables.

### Option A: Manual settings.json

Claude Code reads provider configuration from `~/.claude/settings.json` (or a project-level `.claude/settings.json`), as detailed in the [Claude Code documentation](https://code.claude.com/docs/en/overview). Update the `env` block to point Claude Code at Bifrost:

```json
"env": {
  "ANTHROPIC_BASE_URL": "<http://localhost:8080/anthropic>",
  "ANTHROPIC_AUTH_TOKEN": "sk-bf-your-virtual-key",
  "ANTHROPIC_DEFAULT_HAIKU_MODEL": "cerebras/llama-3.3-70b",
  "ANTHROPIC_DEFAULT_SONNET_MODEL": "cerebras/llama-3.3-70b"
}
```

The `ANTHROPIC_AUTH_TOKEN` value is your Bifrost virtual key. Claude Code passes this in the `Authorization: Bearer` header, and Bifrost uses it to authenticate and route the request. No Anthropic account credentials are required with this setup.

The `ANTHROPIC_DEFAULT_HAIKU_MODEL` and `ANTHROPIC_DEFAULT_SONNET_MODEL` fields pin Claude Code's lightweight and default model slots to a specific Cerebras model. Adjust the model name to match whichever Cerebras model you want to use. You can check available models by calling `http://localhost:8080/v1/models` after configuring the provider.

### Option B: Bifrost CLI (no environment variable editing needed)

The [Bifrost CLI](https://docs.getbifrost.ai/quickstart/cli/getting-started) is an interactive terminal tool that connects Claude Code to your running Bifrost gateway without any manual environment variable or config file changes. It requires Node.js 18+ and a gateway already running.

In a second terminal (with the gateway running), launch the CLI:

```bash
npx -y @maximhq/bifrost-cli
```

The CLI walks you through a short setup flow:

1. **Base URL** — enter your Bifrost gateway URL (default: `http://localhost:8080`)
2. **Virtual key** — enter the virtual key created in Step 3, or skip if auth is disabled
3. **Harness** — select Claude Code; the CLI sets all Anthropic provider paths and auto-attaches Bifrost's MCP server
4. **Model** — the CLI fetches available models from your gateway; type `cerebras/` to filter and select a model

After confirming the summary screen, the CLI launches Claude Code with all environment variables set automatically. Virtual keys are stored in your OS keyring (never plaintext on disk). Subsequent runs remember your last configuration so you can re-launch with a single Enter keypress.

### Verifying the Connection

Whether you used manual config or the CLI, open the Bifrost logs dashboard at `http://localhost:8080/logs` and send a request from Claude Code. The request should appear in the stream with `provider: cerebras` and the model name.

For manual setups: after updating `settings.json`, run `/logout` inside Claude Code and restart it. No Anthropic account login is required when using `ANTHROPIC_AUTH_TOKEN`.

If Claude Code displays an unexpected model, run `/config` inside Claude Code, search for "model," and confirm the correct model is selected.

## Using Routing Rules for Model Aliasing

For teams that want flexibility to swap the underlying model without updating every developer's `settings.json`, Bifrost's [routing rules](https://docs.getbifrost.ai/features/governance/routing) support dynamic aliasing. You create an alias like `sonnet-model`, configure a routing rule that maps requests for that alias to a specific provider and model, and Claude Code simply sends requests using the alias name.

This approach is particularly useful for A/B testing across providers or for gradually migrating from one model to another without touching client configuration.

Add the following to `settings.json`:

```json
"env": {
  "ANTHROPIC_BASE_URL": "<http://localhost:8080/anthropic>",
  "ANTHROPIC_AUTH_TOKEN": "sk-bf-your-virtual-key",
  "ANTHROPIC_DEFAULT_HAIKU_MODEL": "haiku-model",
  "ANTHROPIC_DEFAULT_SONNET_MODEL": "sonnet-model"
}
```

Then configure routing rules in the Bifrost dashboard that map `sonnet-model` to `cerebras/llama-3.3-70b` (or any other model on any provider Bifrost supports). When you want to switch models, update the routing rule rather than every developer's local config.

## Adding Fallback Providers

Cerebras is a high-throughput inference service, but production AI workloads should not depend on a single provider. Bifrost's [automatic fallbacks](https://docs.getbifrost.ai/features/retries-and-fallbacks) let you configure secondary providers that Bifrost tries if the primary request fails, times out, or hits a rate limit.

A common pattern for Claude Code routing is to set Cerebras as the primary provider for speed and configure Anthropic or another provider as a fallback for reliability. The [Bifrost Benchmarks page](https://www.getmaxim.ai/bifrost/resources/benchmarks) shows measured overhead and latency data from Bifrost itself (11µs at 5,000 RPS), so the gateway layer does not add meaningful latency to either the primary or fallback path.

## Model Selection Considerations for Claude Code

Claude Code relies on tool calling for core operations: file edits, bash commands, web search, and code generation. Any model routed through Bifrost to Claude Code must fully support tool use for these operations to work correctly. Cerebras models based on Llama 3.x and similar open-weight architectures support tool calling and streaming, which covers the core Claude Code workflow.

Claude-specific server-side tools (such as computer use) are only available on Claude-family models on providers that expose them. If your team's workflow depends on those capabilities specifically, route the Sonnet slot to a Claude-family model on a provider that supports them, and use Cerebras for the Haiku slot or for tasks that do not require Claude-specific tools.

Bifrost supports switching models mid-session using Claude Code's `/model` command. Any provider and model combination configured in Bifrost can be targeted at runtime:

```bash
/model cerebras/llama-3.3-70b
/model anthropic/claude-sonnet-4-6
```

## Observability for Claude Code Sessions

All requests Claude Code sends through Bifrost appear in the log stream at `http://localhost:8080/logs`. The dashboard shows provider, model, token counts, latency, and conversation content, filterable by each dimension.

For teams that need structured telemetry export, Bifrost supports [OpenTelemetry/OTLP](https://docs.getbifrost.ai/features/observability/otel) and [Prometheus metrics](https://docs.getbifrost.ai/features/observability/prometheus). These integrations work transparently: no changes to Claude Code or the Cerebras integration are required.

Enterprise teams can also use the [Datadog connector](https://docs.getbifrost.ai/enterprise/datadog-connector) for APM-level tracing across all agent and model traffic.

## Next Steps

Routing Claude Code through Cerebras via Bifrost is a provider configuration and a `settings.json` update. Once in place, every Claude Code session routes through the gateway, picking up observability, governance, and fallback capabilities without any changes to how developers use the tool.

The same Bifrost configuration also governs [MCP tool access](https://docs.getbifrost.ai/mcp/overview), [budget limits](https://docs.getbifrost.ai/features/governance/budget-and-limits), and multi-provider routing for other agents and applications in your stack. For teams managing multiple developers or deploying Claude Code at scale, the [Bifrost resources hub](https://www.getmaxim.ai/bifrost/resources) covers enterprise deployment patterns, governance setup, and the full capability matrix.

To see how Bifrost fits into your AI infrastructure, [book a demo](https://getmaxim.ai/bifrost/book-a-demo) with the Bifrost team.

## Read next

[![Top 5 AI Gateways for Controlling Shadow AI in 2026](https://storage.ghost.io/c/84/03/8403f2f6-141c-411a-8f55-a32d4291533e/content/images/size/w720/2026/10/top-5-ai-gateways-for-controlling-shadow-ai-bifrost-isometric.png) Shadow AI is the use of AI tools, models, and MCP servers that security teams have not approved and cannot see. This guide ranks five AI gateways for controlling it, including Bifrost with Bifrost Edge, Kong AI Gateway, Cloudflare AI Gateway, and Gravitee.](https://www.getmaxim.ai/articles/top-5-ai-gateways-for-controlling-shadow-ai/)

[![Top 5 AI Gateways for SSO and RBAC in 2026](https://storage.ghost.io/c/84/03/8403f2f6-141c-411a-8f55-a32d4291533e/content/images/size/w720/2026/10/top-5-ai-gateways-for-sso-and-rbac-in-2026-bifrost-isometric.png) AI gateways with SSO and RBAC let enterprises tie every model request and every configuration change to a corporate identity. This guide compares Bifrost, Kong AI Gateway, Azure API Management, Gravitee, and Cloudflare AI Gateway on identity, roles, provisioning, and audit.](https://www.getmaxim.ai/articles/top-5-ai-gateways-for-sso-and-rbac-in-2026/)

[![Semantic Caching: The Top 5 AI Gateways in 2026](https://storage.ghost.io/c/84/03/8403f2f6-141c-411a-8f55-a32d4291533e/content/images/size/w720/2026/10/semantic-caching-the-top-5-ai-gateways-in-2026-bifrost-isometric.png) Semantic caching serves a stored LLM response when a new prompt means the same thing as an earlier one. This guide compares Bifrost, Kong AI Gateway, Azure API Management, and Cloudflare AI Gateway on match modes, vector stores, thresholds, TTLs, and cache scoping.](https://www.getmaxim.ai/articles/semantic-caching-the-top-5-ai-gateways-in-2026/)

```json
{
    "@context": "https://schema.org",
    "@type": "Article",
    "publisher": {
        "@type": "Organization",
        "name": "Maxim Articles",
        "url": "https://www.getmaxim.ai/articles/",
        "logo": {
            "@type": "ImageObject",
            "url": "https://storage.ghost.io/c/84/03/8403f2f6-141c-411a-8f55-a32d4291533e/content/images/size/w256h256/2025/08/thumbnail.png",
            "width": 60,
            "height": 60
        }
    },
    "author": {
        "@type": "Person",
        "name": "Kuldeep Paul",
        "image": {
            "@type": "ImageObject",
            "url": "https://storage.ghost.io/c/84/03/8403f2f6-141c-411a-8f55-a32d4291533e/content/images/2025/08/1727978381919.jpeg",
            "width": 800,
            "height": 800
        },
        "url": "https://www.getmaxim.ai/articles/author/kuldeep/",
        "sameAs": []
    },
    "headline": "Route Claude Code Through Cerebras Using Bifrost",
    "url": "https://www.getmaxim.ai/articles/route-claude-code-through-cerebras-using-bifrost/",
    "datePublished": "2026-06-12T14:07:00.000Z",
    "dateModified": "2026-10-08T15:45:33.000Z",
    "image": {
        "@type": "ImageObject",
        "url": "https://storage.ghost.io/c/84/03/8403f2f6-141c-411a-8f55-a32d4291533e/content/images/size/w1200/2026/07/route-claude-code-through-cerebras-using-bifrost-bifrost-strata.optimized.png",
        "width": 1200,
        "height": 630
    },
    "keywords": "AI Gateway",
    "description": "Bifrost is an open-source AI gateway that connects Claude Code to any LLM provider, including Cerebras, through a single unified endpoint. This guide walks through the full setup, from adding the Cerebras provider to pinning models in Claude Code's settings.\n\nClaude Code depends on fast model responses to feel productive. The tool-call loop that drives file edits, bash execution, and code generation can produce dozens of round trips per session, and waiting on slow completions breaks the working",
    "mainEntityOfPage": "https://www.getmaxim.ai/articles/route-claude-code-through-cerebras-using-bifrost/"
}
```
