RelayRouterRelayRouter
HomeModelsPricingDocsGuides
Get API Key →

Docs / Integrations / Claude Code

Claude Code with RelayRouter

Claude Code talks to any endpoint that implements the Anthropic Messages API. RelayRouter does, at https://relayrouter.io/v1/messages, so the whole setup is two environment variables: the base URL and your key. Billing is per token from your prepaid balance, failed requests are not charged.

#1. Create a key for a Claude group

In the console create an API key and choose a group that lists the Claude models you want. The models page shows every group with its rate; claude-opus-5-5 and claude-sonnet-4-6 are the usual picks for coding.

#2. Set the environment variables

macOS or Linux (bash, zsh):

terminalbash
export ANTHROPIC_BASE_URL="https://relayrouter.io"
export ANTHROPIC_AUTH_TOKEN="sk-your-relayrouter-key"
export ANTHROPIC_MODEL="claude-opus-5-5"
export ANTHROPIC_SMALL_FAST_MODEL="claude-haiku-4-5"
claude

Windows PowerShell:

PowerShellpowershell
$env:ANTHROPIC_BASE_URL = "https://relayrouter.io"
$env:ANTHROPIC_AUTH_TOKEN = "sk-your-relayrouter-key"
$env:ANTHROPIC_MODEL = "claude-opus-5-5"
$env:ANTHROPIC_SMALL_FAST_MODEL = "claude-haiku-4-5"
claude

To make it permanent, put the same values in the env block of ~/.claude/settings.json (or the project's .claude/settings.json):

~/.claude/settings.jsonjson
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://relayrouter.io",
    "ANTHROPIC_AUTH_TOKEN": "sk-your-relayrouter-key",
    "ANTHROPIC_MODEL": "claude-opus-5-5",
    "ANTHROPIC_SMALL_FAST_MODEL": "claude-haiku-4-5"
  }
}
Use ANTHROPIC_AUTH_TOKEN, not ANTHROPIC_API_KEY, when you want the key sent as a Bearer token; both headers are accepted by RelayRouter. Leave ANTHROPIC_BASE_URL without /v1: Claude Code appends the path itself.

#3. Pick the models

VariableWhat it controlsSuggested value
ANTHROPIC_MODELMain model for conversations and editsclaude-opus-5-5
ANTHROPIC_SMALL_FAST_MODELCheap helper model for background tasksclaude-haiku-4-5

Any model id from your group works; the ids are exactly the ones shown on the models page. Inside a session /model switches the main model too.

#4. Verify outside Claude Code

If anything fails, test the same key and model with one request first:

terminalbash
curl https://relayrouter.io/v1/messages \
  -H "x-api-key: sk-your-relayrouter-key" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-opus-5-5","max_tokens":64,"messages":[{"role":"user","content":"ping"}]}'

#Troubleshooting

SymptomCauseFix
401Key is wrong, disabled, or the balance is emptyCheck the key in the console and top up
404 model not foundThe model is not in the key's groupCreate a key for a group that lists the model, or change ANTHROPIC_MODEL
Requests go to api.anthropic.comThe variables were set in another shell or overridden by settings.jsonRun claude from the same shell, or move the values into settings.json
Slow first token on thinking modelsExpected: the model reasons before it streamsTimeout guide