Skip to content

Claude Configuration

Claude Code is Anthropic’s official terminal coding agent. It can understand code, edit files, run commands, and work with IDEs such as VS Code and JetBrains.

When you use Claude Code through RouteAPI, you still use the Anthropic protocol, but Claude Code sends requests to your RouteAPI endpoint. This is better for unified key, quota, and model management.

Before you start, prepare:

  • A working terminal environment
  • Claude Code CLI installed
  • Your RouteAPI site address
  • Your RouteAPI key
  • A Claude protocol model ID available in the RouteAPI console

macOS / Linux / WSL:

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

Windows PowerShell:

Terminal window
irm https://claude.ai/install.ps1 | iex

On native Windows, Git for Windows is usually required first.

Terminal window
claude --version

A version number means the CLI is installed.

Claude Code can read the endpoint and key from environment variables. To share the same configuration between terminal and IDE, write them into settings.json.

  • macOS / Linux: ~/.claude/settings.json
  • Windows: %USERPROFILE%\.claude\settings.json
{
"env": {
"ANTHROPIC_BASE_URL": "https://www.routeapi.ai/",
"ANTHROPIC_AUTH_TOKEN": "your RouteAPI key"
}
}

In this configuration:

  • ANTHROPIC_BASE_URL: your RouteAPI site root address, usually without /v1
  • ANTHROPIC_AUTH_TOKEN: your RouteAPI key, suitable for Bearer Token authentication

For temporary testing, you can set environment variables in the current terminal session.

If you use bash, zsh, or sh on macOS / Linux / WSL:

Terminal window
export ANTHROPIC_BASE_URL="https://your-routeapi-domain"
export ANTHROPIC_AUTH_TOKEN="your RouteAPI key"

If you use Windows PowerShell:

Terminal window
$env:ANTHROPIC_BASE_URL="https://your-routeapi-domain"
$env:ANTHROPIC_AUTH_TOKEN="your RouteAPI key"

After configuration, reopen a terminal window before starting claude.

Claude Code has two common model selection modes.

If all sessions should use one model by default, set ANTHROPIC_MODEL:

{
"env": {
"ANTHROPIC_BASE_URL": "https://your-routeapi-domain",
"ANTHROPIC_AUTH_TOKEN": "your RouteAPI key",
"ANTHROPIC_MODEL": "your model name"
}
}

This is the simplest setup for teams that want one default model.

Option B: Keep Opus / Sonnet / Haiku choices

Section titled “Option B: Keep Opus / Sonnet / Haiku choices”

If you want to keep Claude Code’s tiered model selection, specify defaults for the three tiers:

{
"env": {
"ANTHROPIC_BASE_URL": "https://your-routeapi-domain",
"ANTHROPIC_AUTH_TOKEN": "your RouteAPI key",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "your high-performance model ID",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "your primary model ID",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "your lightweight model ID"
}
}

After configuration, start Claude Code:

Terminal window
claude

Then enter in the session:

Terminal window
/model

You can then select the model tier for the current Claude Code session.