> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getbifrost.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude Code

> Use Claude Code with Bifrost to route through any provider and unlock advanced features like MCP tools and observability.

[Claude Code](https://www.claude.com/product/claude-code) brings AI-powered coding capabilities directly to your terminal.

**Tested on Claude Code versions:**

| Version | Released   |
| ------- | ---------- |
| 2.1.132 | 2026-05-06 |
| 2.1.131 | 2026-05-06 |
| 2.1.129 | 2026-05-05 |
| 2.1.128 | 2026-05-04 |

<Note>
  If your Allowed Headers are already set to `*`, you can skip this note. If not and you face issues integrating Bifrost
  with Claude Code, try switching to `*` or adding the specific headers required by your client. By default, Bifrost
  whitelists: `Content-Type`, `Authorization`, `X-Requested-With`, `X-Stainless-Timeout`, and `X-Api-Key`.
</Note>

## To install Claude code

```bash theme={null}
npm install -g @anthropic-ai/claude-code
```

## Configuring Claude Code to work with Bifrost

<Note>
  **To avoid getting into different caching issues of Claude code** -

  * Ensure there is no `model` field in `settings.json`. If it's present remove it. This overwrites the `env` model selection.
  * Once you update the `settings.json`, start claude, and execute /logout. And restart - select use API key even if its not recommended.
      <Frame>
        <img src="https://mintcdn.com/bifrost/LUwbqo235gExQvy8/media/cli/select-api-claude-code.png?fit=max&auto=format&n=LUwbqo235gExQvy8&q=85&s=55b72fcaa34b10678e6ddd3aa55ab025" alt="Claude cli API selection" width="3498" height="2234" data-path="media/cli/select-api-claude-code.png" />
      </Frame>
</Note>

Claude Code supports multiple authentication methods. Choose the one that matches your account type.

1. **Update settings.json**

Global `settings.json` is placed in your home folder.

* macOS / Linux / WSL (User Global): `~/.claude/settings.json`
* Windows (User Global): `%USERPROFILE%\.claude\settings.json`
* Project-Specific: `.claude/settings.json` (located within your individual project's root directory)
* Local Overrides: `.claude/settings.local.json` (also in the project root, used for personal preferences that aren't shared via Git)

You will need to update the most granular `settings.json`.

### 1. Using alias

1. Add following routing rules in Bifrost

**`sonnet-model` route**

* Keep it a global level and assign priority you want to assign
* Add model condition as `model` `=` `sonnet-model`. This option is not available out of the box - so type this string and select `Create sonnet-model`
* And add second header condition; to check if the `user-agent` starts with `claude-cli`.
* And then you can map this model to any model you want. In the configuration given - we are using `vertex/claude-sonnet-4-6`.

<Frame>
  <img src="https://mintcdn.com/bifrost/LUwbqo235gExQvy8/media/cli/sonnet-model-mapping.png?fit=max&auto=format&n=LUwbqo235gExQvy8&q=85&s=53bc451cf99576178169cbef58070803" alt="sonnet-model routing example" width="2852" height="3219" data-path="media/cli/sonnet-model-mapping.png" />
</Frame>

**`haiku-model` route**

* Repeat the above steps by replacing `sonnet-model` with `haiku-model`.

2. Update `settings.json`

<Note>
  The JSON snippets below show only the `env` key. Merge them into your existing `settings.json` top-level
  object - do not paste them as a standalone file, or you will overwrite other settings like `permissions`,
  `model`, and `apiKeyHelper`.
</Note>

```json theme={null}
"env": {
  "ANTHROPIC_BASE_URL": "http://localhost:8080/anthropic",
  "ANTHROPIC_API_KEY": "your-virtual-key",
  "ANTHROPIC_DEFAULT_HAIKU_MODEL": "haiku-model",
  "ANTHROPIC_DEFAULT_SONNET_MODEL": "sonnet-model"
}
```

### 2. Using provider-specific model pinning

#### Anthropic

Update `settings.json` to pick Anthropic models. For Anthropic models, you don't need to prefix models with provider name.

```json theme={null}
"env": {
  "ANTHROPIC_BASE_URL": "http://localhost:8080/anthropic",
  "ANTHROPIC_API_KEY": "your-virtual-key",
  "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-6",
  "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4-6"
}
```

#### Bedrock

Update `settings.json` to pick Anthropic models on Bedrock.

```json theme={null}
"env": {
  "ANTHROPIC_BASE_URL": "http://localhost:8080/anthropic",
  "ANTHROPIC_API_KEY": "your-virtual-key",
  "ANTHROPIC_DEFAULT_HAIKU_MODEL": "bedrock/global.anthropic.claude-haiku-4-6",
  "ANTHROPIC_DEFAULT_SONNET_MODEL": "bedrock/global.anthropic.claude-sonnet-4-6"
}
```

If you don't pin using CLI - you can pin these in UI. Go to Dashboard > Models > Model Providers > AWS Bedrock > Key. And add deployments

<Frame>
  <img src="https://mintcdn.com/bifrost/1DtqPkHgCpNaU3hi/media/cli/claude-bedrock-pinning.png?fit=max&auto=format&n=1DtqPkHgCpNaU3hi&q=85&s=24a21ee0bc4ef1c1209ae9d850263024" alt="Claude bedrock pinning" width="3362" height="2328" data-path="media/cli/claude-bedrock-pinning.png" />
</Frame>

#### Vertex

Update `settings.json` to pick Anthropic models on Vertex.

```json theme={null}
"env": {
  "ANTHROPIC_BASE_URL": "http://localhost:8080/anthropic",
  "ANTHROPIC_API_KEY": "your-virtual-key",
  "ANTHROPIC_DEFAULT_HAIKU_MODEL": "vertex/claude-haiku-4-6",
  "ANTHROPIC_DEFAULT_SONNET_MODEL": "vertex/claude-sonnet-4-6"
}
```

#### Azure

Update `settings.json` to pick Anthropic models on Azure.

```json theme={null}
"env": {
  "ANTHROPIC_BASE_URL": "http://localhost:8080/anthropic",
  "ANTHROPIC_API_KEY": "your-virtual-key",
  "ANTHROPIC_DEFAULT_HAIKU_MODEL": "azure/claude-haiku-4-6",
  "ANTHROPIC_DEFAULT_SONNET_MODEL": "azure/claude-sonnet-4-6"
}
```

<Frame>
  <img src="https://mintcdn.com/bifrost/1DtqPkHgCpNaU3hi/media/cli/claude-azure-pinning.png?fit=max&auto=format&n=1DtqPkHgCpNaU3hi&q=85&s=0a46a5f0accf094e1d9ac7a4e374f62d" alt="Azure model  pinning" width="3268" height="2602" data-path="media/cli/claude-azure-pinning.png" />
</Frame>

<Warning>
  Azure-hosted models must support **tool use capabilities** for Claude Code to function properly. Verify tool calling
  support before configuring Azure models.
</Warning>

## Model Configuration

Claude Code uses three model tiers: **Sonnet** (default), **Opus** (complex tasks), and **Haiku** (fast, lightweight). With Bifrost, you can override these defaults to use any model from any provider.

**Start with a Specific Model:**

Launch Claude Code with a specific model using the `--model` flag:

```bash theme={null}
# Start with Opus
claude --model claude-opus-4-5-20251101

# Start with Haiku for lightweight tasks
claude --model claude-haiku-4-5-20251001
```

## Switching Models Mid-Session

Use the `/model` command to switch models during an active session:

```bash theme={null}
# Using full model names
/model claude-opus-4-5-20251101 # This will be used from anthropic provider
/model claude-sonnet-4-5-20250929 # This will be used from anthropic provider

# Using different providers dynamically via Bifrost
/model vertex/claude-haiku-4-5
/model azure/claude-sonnet-4-5
/model bedrock/claude-sonnet-4-5
```

<Tip>
  Run `/model` without arguments to check your current model. The switch is instantaneous and Claude Code seamlessly
  continues your conversation context with the new model.
</Tip>

<Warning>
  If you use Claude-specific features like **web search**, **computer use**, or **citations**, ensure the model you
  switch to also supports these capabilities. Non-Claude models or Claude models on certain providers may not support
  all features.
</Warning>

## Provider Compatibility

<Warning>
  **Not all providers work well with Claude Code**. Since Claude Code heavily relies on tool calling for file operations, terminal commands, and code editing, providers must properly support and stream tool call arguments.

  **Known Issues:**

  * **OpenRouter**: Does not stream function call arguments properly. Tool calls return with empty `arguments` fields, causing Claude Code to fail when attempting file operations or other tool-based actions.
  * **Some proxy providers**: May not fully implement the Anthropic API streaming specification for tool calls.

  If you experience issues with tool calls not executing properly, try switching to a different provider in your Bifrost configuration.
</Warning>

## Checklist

1. Ensure the model selected is same as you configured in the `settings.json`.

<Frame>
  <img src="https://mintcdn.com/bifrost/LUwbqo235gExQvy8/media/cli/claude-cli-model-selection.png?fit=max&auto=format&n=LUwbqo235gExQvy8&q=85&s=8167f5000f9d94c7ddfdd605cea26108" alt="Selected model in Claude cli" width="3508" height="2232" data-path="media/cli/claude-cli-model-selection.png" />
</Frame>

If this is not the case -

1. Select model using /config
2. Execute `/config`
3. Search for model
4. Select the correct model

<Frame>
  <img src="https://mintcdn.com/bifrost/LUwbqo235gExQvy8/media/cli/claude-code-config-model-selection.png?fit=max&auto=format&n=LUwbqo235gExQvy8&q=85&s=9e99d5c63fb40b0c9e2733fac730c3e1" alt="Claude code model selection using /config" width="3498" height="2234" data-path="media/cli/claude-code-config-model-selection.png" />
</Frame>

2. Or pass the model using `/model <model_name>` e.g., `/model sonnet-model`
