Skip to content

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 --version

Set environment variables

CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 skips 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

claude
bash
# 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 ~/.bashrc
powershell
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"

claude
powershell
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

claude
cmd
:: 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-7

Gotchas

Two common traps

  • ANTHROPIC_BASE_URL does not include /v1 — Claude Code appends /v1/messages itself
  • You must unset / Remove-Item ANTHROPIC_API_KEY first, otherwise Claude Code prefers it and bypasses PrimeRouter
ScenarioModel ID
Defaultclaude-sonnet-4-6
Stable Opus for complex tasksclaude-opus-4-6
Complex refactor / Plan modeclaude-opus-4-7

Built for transparent, auditable, crypto-native AI inference. About · Terms · Privacy