Claude Configuration
1. What Claude Code is
Section titled “1. What Claude Code is”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
2. Step 1: Install Claude Code
Section titled “2. Step 1: Install Claude Code”Install the CLI
Section titled “Install the CLI”macOS / Linux / WSL:
curl -fsSL https://claude.ai/install.sh | bashWindows PowerShell:
irm https://claude.ai/install.ps1 | iexOn native Windows, Git for Windows is usually required first.
Verify installation
Section titled “Verify installation”claude --versionA version number means the CLI is installed.
3. Step 2: Configure RouteAPI
Section titled “3. Step 2: Configure RouteAPI”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.
3.1 Find the configuration file
Section titled “3.1 Find the configuration file”- macOS / Linux:
~/.claude/settings.json - Windows:
%USERPROFILE%\.claude\settings.json
3.2 Write RouteAPI access information
Section titled “3.2 Write RouteAPI access information”{ "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/v1ANTHROPIC_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:
export ANTHROPIC_BASE_URL="https://your-routeapi-domain"export ANTHROPIC_AUTH_TOKEN="your RouteAPI key"If you use Windows PowerShell:
$env:ANTHROPIC_BASE_URL="https://your-routeapi-domain"$env:ANTHROPIC_AUTH_TOKEN="your RouteAPI key"After configuration, reopen a terminal window before starting claude.
4. Step 3: Select your model
Section titled “4. Step 3: Select your model”Claude Code has two common model selection modes.
Option A: Pin one default model
Section titled “Option A: Pin one default model”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:
claudeThen enter in the session:
/modelYou can then select the model tier for the current Claude Code session.