Claude Code
Claude Code is Anthropic's official CLI tool. It speaks the Anthropic Messages API (not OpenAI). PrimeRouter supports both — for Claude Code, point it at /v1/messages (Claude Code appends the path itself).
Get an API key first — see Common setup.
Install
bash
# All platforms (needs Node 18+)
npm install -g @anthropic-ai/claude-code
claude --versionSet environment variables
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1skips non-essential requests (telemetry, error reporting, update checks) — recommended alongside the other two.
bash
# Clear any conflicting official key first
unset ANTHROPIC_API_KEY
export ANTHROPIC_BASE_URL="https://primerouter.ai"
export ANTHROPIC_AUTH_TOKEN="sk-your-primerouter-key"
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
claudebash
# zsh users
cat >> ~/.zshrc <<'EOF'
unset ANTHROPIC_API_KEY
export ANTHROPIC_BASE_URL="https://primerouter.ai"
export ANTHROPIC_AUTH_TOKEN="sk-your-primerouter-key"
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
EOF
source ~/.zshrc
# bash users: replace ~/.zshrc with ~/.bashrcpowershell
Remove-Item Env:ANTHROPIC_API_KEY -ErrorAction SilentlyContinue
$env:ANTHROPIC_BASE_URL = "https://primerouter.ai"
$env:ANTHROPIC_AUTH_TOKEN = "sk-your-primerouter-key"
$env:CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1"
claudepowershell
notepad $PROFILE
# Append at end of file:
# Remove-Item Env:ANTHROPIC_API_KEY -ErrorAction SilentlyContinue
# $env:ANTHROPIC_BASE_URL = "https://primerouter.ai"
# $env:ANTHROPIC_AUTH_TOKEN = "sk-your-primerouter-key"
# $env:CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1"
# Save and reopen PowerShell.cmd
set ANTHROPIC_API_KEY=
set ANTHROPIC_BASE_URL=https://primerouter.ai
set ANTHROPIC_AUTH_TOKEN=sk-your-primerouter-key
set CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
claudecmd
:: From an elevated shell
setx ANTHROPIC_BASE_URL "https://primerouter.ai"
setx ANTHROPIC_AUTH_TOKEN "sk-your-primerouter-key"
setx CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC "1"
:: Then in Control Panel → System → Advanced → Environment Variables, delete ANTHROPIC_API_KEY if present.Launch
bash
claude
# Inside Claude Code use /model to switch
# Or pass on launch: claude --model claude-opus-4-7Gotchas
Two common traps
ANTHROPIC_BASE_URLdoes not include/v1— Claude Code appends/v1/messagesitself- You must
unset/Remove-ItemANTHROPIC_API_KEYfirst, otherwise Claude Code prefers it and bypasses PrimeRouter
Recommended models
| Scenario | Model ID |
|---|---|
| Default | claude-sonnet-4-6 |
| Stable Opus for complex tasks | claude-opus-4-6 |
| Complex refactor / Plan mode | claude-opus-4-7 |
