Use RouterBrain as the model backend for AI coding in Claude Code.
Claude Code is Anthropic's official terminal-native coding agent powered by Claude. Point the API endpoint at RouterBrain's Anthropic-compatible surface to use console keys and the shared model catalog.
Install Claude Code
Follow the official Claude Code setup guide.
Before wiring RouterBrain, create an inference API key in the console (API keys) and pick a catalog id (List models).
Configure RouterBrain API
Important
Clear environment variables that still point at Anthropic or another proxy before applying config:
unset ANTHROPIC_AUTH_TOKEN unset ANTHROPIC_API_KEY unset ANTHROPIC_BASE_URLIf these are exported in
~/.bashrcor~/.zshrc, remove those lines too—new shells will re-inject them otherwise.
Step 1 — Edit config files (recommended)
1. Edit settings.json
Create or edit Claude Code settings (macOS / Linux: ~/.claude/settings.json; Windows: %USERPROFILE%\.claude\settings.json).
Replace YOUR_ROUTERBRAIN_KEY and YOUR_MODEL_ID with your key and catalog id. Shell ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL override this file.
{
"env": {
"ANTHROPIC_BASE_URL": "https://51kik.com/anthropic",
"ANTHROPIC_AUTH_TOKEN": "YOUR_ROUTERBRAIN_KEY",
"API_TIMEOUT_MS": "3000000",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
"ANTHROPIC_MODEL": "YOUR_MODEL_ID",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "YOUR_MODEL_ID",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "YOUR_MODEL_ID",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "YOUR_MODEL_ID",
"CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1"
}
}
| Variable | Purpose |
|---|---|
ANTHROPIC_BASE_URL | Gateway Anthropic root (no /v1 suffix) |
ANTHROPIC_AUTH_TOKEN | RouterBrain inference key (ANTHROPIC_API_KEY also works) |
ANTHROPIC_MODEL | Default catalog id |
ANTHROPIC_DEFAULT_*_MODEL | Sonnet / Opus / Haiku aliases—set to the same id unless you split tiers |
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY | Populate /model from the gateway |
2. Onboarding flag
Create or edit ~/.claude.json (Windows: %USERPROFILE%\.claude.json) so startup skips first-party login:
{
"hasCompletedOnboarding": true
}
Step 2 — Launch Claude Code
From your project directory:
claude
Step 3 — Trust the workspace
When prompted, choose Trust This Folder so Claude Code can read and write project files.
Verify configuration
Inside the claude TUI, run:
/status
/model
Expected:
/statusshowsANTHROPIC_BASE_URLathttps://51kik.com/anthropic(rendered to your live gateway URL on this site)./modelshowsYOUR_MODEL_IDor models returned by the gateway.
Quick CLI check:
claude -p "reply with ok only"
Tools and MCP
Third-party ANTHROPIC_BASE_URL disables MCP tool search by default. If your gateway forwards tool_reference, add to env:
"ENABLE_TOOL_SEARCH": "true"
See Claude Code docs for MCP servers; gateway tools: Messages API.
Optional curl check
curl -sS "https://51kik.com/anthropic/v1/messages" \
-H "x-api-key: YOUR_ROUTERBRAIN_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"max_tokens": 64,
"messages": [{ "role": "user", "content": "reply with ok only" }]
}'
Troubleshooting
| Symptom | Check |
|---|---|
Still hits api.anthropic.com | Shell env overrides settings; launch VS Code from a configured terminal |
| 401 / 403 | RouterBrain key, not Anthropic vendor key |
| Unknown model | model must be catalog id |
| Login loop | hasCompletedOnboarding: true in ~/.claude.json |