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.
export ANTHROPIC_BASE_URL="https://api.ru-llm.relay2.xyz"export ANTHROPIC_AUTH_TOKEN="sk-ru-YOUR_KEY"
claude$env:ANTHROPIC_BASE_URL = "https://api.ru-llm.relay2.xyz"$env:ANTHROPIC_AUTH_TOKEN = "sk-ru-YOUR_KEY"
claudeTo 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:
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:
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
| Symptom | Cause | Fix |
|---|---|---|
401 Unauthorized | Key missing or wrong | Check ANTHROPIC_AUTH_TOKEN holds a valid sk-ru-… key. |
402 Payment Required | Zero balance | Top up in the console → Billing. |
400 unknown model | Model ID not in catalog | Set ANTHROPIC_MODEL to a listed Claude ID (GET /v1/models). |
| Connects to api.anthropic.com | ANTHROPIC_BASE_URL not exported in this shell | Re-export it; verify with echo $ANTHROPIC_BASE_URL. |