Skip to content

Claude Code

Claude Code is Anthropic’s terminal/IDE coding agent. It speaks the Anthropic Messages API, so it talks to ru-llm’s Anthropic-compatible surface by overriding two environment variables.

Configure

Set the gateway base URL and your sk-ru-… key, then run claude as usual.

Terminal window
export ANTHROPIC_BASE_URL="https://api.ru-llm.relay2.xyz"
export ANTHROPIC_AUTH_TOKEN="sk-ru-YOUR_KEY"
claude

To make the setting permanent, add the two export lines to your shell profile (~/.zshrc, ~/.bashrc) or to Claude Code’s settings.json env block.

Select a model

ru-llm serves Claude models by their catalog IDs. Choose one with ANTHROPIC_MODEL, or switch inside a session with the /model command:

Terminal window
export ANTHROPIC_MODEL="claude-sonnet-4-6"
# faster/cheaper background tasks:
export ANTHROPIC_SMALL_FAST_MODEL="claude-haiku-4-5-20251001"

Available Claude IDs include claude-opus-4-8, claude-opus-4-7, claude-sonnet-4-6, and claude-haiku-4-5-20251001. See Models & Pricing for the full list.

Verify

Confirm the gateway answers the Anthropic surface before launching the agent:

Terminal window
curl https://api.ru-llm.relay2.xyz/v1/messages \
-H "x-api-key: sk-ru-YOUR_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 64,
"messages": [{"role": "user", "content": "Reply with the single word: ok"}]
}'

A 200 with a content array containing ok means Claude Code will connect.

Troubleshooting

SymptomCauseFix
401 UnauthorizedKey missing or wrongCheck ANTHROPIC_AUTH_TOKEN holds a valid sk-ru-… key.
402 Payment RequiredZero balanceTop up in the console → Billing.
400 unknown modelModel ID not in catalogSet ANTHROPIC_MODEL to a listed Claude ID (GET /v1/models).
Connects to api.anthropic.comANTHROPIC_BASE_URL not exported in this shellRe-export it; verify with echo $ANTHROPIC_BASE_URL.