File size: 6,023 Bytes
8baf122 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | ---
title: "Claude Code"
description: "Use Claude Code with Bifrost to route through any provider and unlock advanced features like MCP tools and observability."
icon: "star-of-life"
---
[Claude Code](https://www.claude.com/product/claude-code) brings AI-powered coding capabilities directly to your terminal.
<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
npm install -g @anthropic-ai/claude-code
```
## Configuring Claude Code to work with Bifrost
Claude Code supports multiple authentication methods. Choose the one that matches your account type.
1. **Set environment variables**
```bash
export ANTHROPIC_API_KEY=your-bifrost-virtual-key # or "dummy" if virtual keys are not enabled
export ANTHROPIC_BASE_URL=http://localhost:8080/anthropic
```
2. **Run Claude Code**
```bash
claude
```
## Amazon Bedrock via Bifrost
### Setup
Configure environment variables
```bash
export ANTHROPIC_API_KEY=bifrost-virtual-key
export ANTHROPIC_BASE_URL=http://localhost:8080/anthropic
```
### Pin model versions (recommended)
```bash
export ANTHROPIC_DEFAULT_SONNET_MODEL="bedrock/global.anthropic.claude-sonnet-4-6"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="bedrock/global.anthropic.claude-haiku-4-5-20251001-v1:0"
```
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="/media/cli/claude-bedrock-pinning.png" alt="Claude bedrock pinning" />
</Frame>
### Start Claude Code
```
claude
```
<Warning>
Always pin model versions with `ANTHROPIC_DEFAULT_*_MODEL` when using Bedrock. Without pinning, Claude Code aliases resolve to the latest version, which may not be enabled in your Bedrock account.
</Warning>
## Google Vertex AI via Bifrost
### Setup
Configure environment variables
```bash
export ANTHROPIC_API_KEY=bifrost-virtual-key
export ANTHROPIC_BASE_URL=http://localhost:8080/anthropic
```
### Pin model versions (recommended)
```bash
export ANTHROPIC_DEFAULT_SONNET_MODEL="vertex/claude-sonnet-4-6"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="vertex/claude-haiku-4-5"
```
### Start Claude Code
```
claude
```
## Azure via Bifrost
### Setup
Configure environment variables
```bash
export ANTHROPIC_API_KEY=bifrost-virtual-key
export ANTHROPIC_BASE_URL=http://localhost:8080/anthropic
```
### Pin model versions (recommended)
```bash
export ANTHROPIC_DEFAULT_SONNET_MODEL="azure/claude-sonnet-4-6"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="azure/claude-haiku-4-5"
```
You will also have to map these model names to actual deployment names on Bifrost dashboard.
<Frame>
<img src="/media/cli/claude-azure-pinning.png" alt="Claude bedrock pinning" />
</Frame>
### Start Claude Code
```
claude
```
<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.
**Override Default Models:**
Set environment variables to replace Claude Code's default model tiers with any Bifrost-configured model:
```bash
# Replace Sonnet tier with GPT-5
export ANTHROPIC_DEFAULT_SONNET_MODEL="openai/gpt-5"
# Replace Opus tier with Claude Opus 4.5
export ANTHROPIC_DEFAULT_OPUS_MODEL="anthropic/claude-opus-4-5-20251101"
# Replace Haiku tier with Azure-hosted Claude
export ANTHROPIC_DEFAULT_HAIKU_MODEL="azure/claude-haiku-4-5"
```
<Warning>
Alternative models must support **tool use capabilities** for file operations, terminal commands, and code editing to work properly with Claude Code.
</Warning>
**Start with a Specific Model:**
Launch Claude Code with a specific model using the `--model` flag:
```bash
# 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
# 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> |