# Claude Code

[Claude Code](https://code.claude.com/docs) is Anthropic's official AI coding agent. You can use it in the terminal, and it also provides extensions for IDEs such as VS Code and JetBrains. Claude Code uses the **Anthropic Messages** API format, which BeeRoute supports natively, so you only need to change the API URL and key.

## 1. Get an API Key

1. Open the [API Keys](https://beeroute.ai/keys) page and click **Create API Key**.
2. Set **Group** to `ClaudeCode`, save, and copy the key (it starts with `sk-`).

?> The `ClaudeCode` group is dedicated to Claude Code. It has lower prices, includes only Claude models, and can only be used in the Claude Code client.

## 2. Install Claude Code

The official native install script is recommended. Installations made this way update automatically:

**macOS / Linux / WSL:**

```bash
curl -fsSL https://claude.ai/install.sh | bash
```

**Windows PowerShell:**

```powershell
irm https://claude.ai/install.ps1 | iex
```

**Windows CMD:**

```bat
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
```

You can also install it in other ways (none of these update automatically):

| Method | Command |
| :--- | :--- |
| Homebrew (macOS) | `brew install --cask claude-code` |
| WinGet (Windows) | `winget install Anthropic.ClaudeCode` |
| npm (requires Node.js 22 or later) | `npm install -g @anthropic-ai/claude-code` |

Windows users should also install [Git for Windows](https://git-scm.com/downloads/win), which Claude Code uses to run commands.

After installation, open a new terminal window and verify:

```bash
claude --version
```

## 3. Configure BeeRoute

Edit the user-level settings file (create it if it does not exist):

- macOS / Linux: `~/.claude/settings.json`
- Windows: `%USERPROFILE%\.claude\settings.json`

Add the following content, replacing `sk-xxx` with your key:

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://beeroute.ai",
    "ANTHROPIC_AUTH_TOKEN": "sk-xxx",
    "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"
  }
}
```

| Setting | Description |
| :--- | :--- |
| `ANTHROPIC_BASE_URL` | The BeeRoute URL. Do **not** include `/v1`; Claude Code appends `/v1/messages` automatically |
| `ANTHROPIC_AUTH_TOKEN` | Your BeeRoute key, sent in the `Authorization: Bearer` request header |
| `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` | Stops sending experimental beta features, which prevents some requests from returning 400 |

- If the file already contains other settings, just merge these entries into `env`.
- Do **not** put your key in `.claude/settings.json` inside your project directory. That file is usually committed to the code repository.
- Do not also set the `ANTHROPIC_API_KEY` environment variable. Otherwise, Claude Code warns about two conflicting credentials at startup.

### One-Click Setup Script (Optional)

You can also run the script provided by BeeRoute and enter your key when prompted to write the configuration. The script first backs up your existing `settings.json`, then **completely overwrites** it.

- Windows: [Download win_claude_setup.bat](https://beeroute.ai/static/cli/win_claude_setup.bat) and double-click it to run.
- macOS / Linux:

```bash
bash <(curl -fsSL https://beeroute.ai/static/cli/linux_claude_setup.sh)
```

## 4. Launch and Verify

Go to your project directory and start Claude Code:

```bash
cd /path/to/your-project
claude
```

Once `ANTHROPIC_AUTH_TOKEN` is configured in `~/.claude/settings.json`, Claude Code no longer asks you to log in to an Anthropic account (the first launch may still show the theme picker and a security notice; just follow the prompts).

After it starts, enter `/status` and confirm that:

- the `Anthropic base URL` line shows `https://beeroute.ai`;
- the credentials line shows `ANTHROPIC_AUTH_TOKEN`.

Then send any message. If you get a normal reply, the connection works.

## 5. Choose a Model

- Enter `/model` in Claude Code to switch models;
- Or specify a model at startup: `claude --model claude-opus-5-5`.

If you want the `opus`, `sonnet`, and `haiku` aliases to always use specific models, add the following to `env`:

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://beeroute.ai",
    "ANTHROPIC_AUTH_TOKEN": "sk-xxx",
    "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5-5",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5-5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5-5"
  }
}
```

`ANTHROPIC_DEFAULT_HAIKU_MODEL` also determines the model that Claude Code uses for background tasks (such as generating session titles). See the [Pricing](https://beeroute.ai/modellist/) page for the models available in the `ClaudeCode` group.

## 6. Use in VS Code, Cursor, and Other Editors

1. Search for the **Claude Code** extension in the extension marketplace and install it.
2. Press `Ctrl+Shift+P` (`Cmd+Shift+P` on macOS), run **Preferences: Open User Settings (JSON)**, and add:

```json
{
  "claudeCode.environmentVariables": [
    { "name": "ANTHROPIC_BASE_URL", "value": "https://beeroute.ai" },
    { "name": "ANTHROPIC_AUTH_TOKEN", "value": "sk-xxx" },
    { "name": "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS", "value": "1" }
  ],
  "claudeCode.disableLoginPrompt": true
}
```

?> The extension checks these settings before it starts, so even if `~/.claude/settings.json` is already configured, we recommend configuring them in the extension as well.

## 7. FAQ

**Still asked to log in after launching?**

- Make sure the key is in the user-level `~/.claude/settings.json`, not in `.claude/settings.json` inside your project directory.
- If you previously logged in with an Anthropic account, run `/logout` in Claude Code to clear the old login.
- If it still does not work, run the skip-login script: on Windows, [download skip_claude_login.bat](https://beeroute.ai/static/cli/skip_claude_login.bat); on macOS / Linux, run `bash <(curl -fsSL https://beeroute.ai/static/cli/skip_claude_login.sh)`.

**Getting a 400 error with `Extra inputs are not permitted` or `invalid beta flag`?**

Make sure `env` contains `"CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"`.

**Getting a 403 error, or a message that the client version is too old?**

- Make sure the key belongs to the `ClaudeCode` group;
- The `ClaudeCode` group requires a recent version of Claude Code. Upgrade it: for a native install, run `claude update`; for an npm install, run `npm install -g @anthropic-ai/claude-code` again.

**Seeing `auth may not work as expected`, or a credential conflict?**

Multiple credentials are present at the same time (for example, `ANTHROPIC_API_KEY` is set on your system, or you previously logged in with an Anthropic account). Remove the extra environment variable, or run `/logout`.

**Remote Control or voice input not available?**

This is an official Claude Code limitation: when you use a third-party API URL, these two features depend on an Anthropic account and cannot be used.

For more troubleshooting, see the official Claude Code documentation: [Connect Claude Code to an LLM gateway](https://code.claude.com/docs/en/llm-gateway-connect).
