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):
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"
claudeWindows PowerShell:
$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"
claudeTo make it permanent, put the same values in the env block of ~/.claude/settings.json (or the project's .claude/settings.json):
{
"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"
}
}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
| Variable | What it controls | Suggested value |
|---|---|---|
ANTHROPIC_MODEL | Main model for conversations and edits | claude-opus-5-5 |
ANTHROPIC_SMALL_FAST_MODEL | Cheap helper model for background tasks | claude-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:
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
| Symptom | Cause | Fix |
|---|---|---|
401 | Key is wrong, disabled, or the balance is empty | Check the key in the console and top up |
404 model not found | The model is not in the key's group | Create a key for a group that lists the model, or change ANTHROPIC_MODEL |
Requests go to api.anthropic.com | The variables were set in another shell or overridden by settings.json | Run claude from the same shell, or move the values into settings.json |
Slow first token on thinking models | Expected: the model reasons before it streams | Timeout guide |