Claude Code
Claude Code is Anthropic's command-line coding assistant. Point it at CodingRouter with environment variables or a config file.
Preparation
- Install or upgrade Claude Code to the latest version:
npm install -g @anthropic-ai/claude-code - In the console, create a token in the
claudegroup.
Option 1: environment variables
bash
export ANTHROPIC_BASE_URL="https://api.codingrouter.ai"
export ANTHROPIC_AUTH_TOKEN="sk-your-token"
claudepowershell
$env:ANTHROPIC_BASE_URL = "https://api.codingrouter.ai"
$env:ANTHROPIC_AUTH_TOKEN = "sk-your-token"
claudeTo make this permanent, add the two export lines to ~/.zshrc or ~/.bashrc.
Option 2: settings.json
Edit ~/.claude/settings.json (on Windows %USERPROFILE%\.claude\settings.json) so you do not have to set environment variables each time:
json
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.codingrouter.ai",
"ANTHROPIC_AUTH_TOKEN": "sk-your-token"
}
}To use it in one project only, put the same content in the project's .claude/settings.local.json.
Choosing a model
After starting, type /model to switch, or set the default model with an environment variable:
bash
export ANTHROPIC_MODEL="claude-opus-5-5"You can also specify it at startup: claude --model claude-sonnet-5-5.
Verify
bash
claude -p "Reply with exactly: CODINGROUTER OK"If the output is CODINGROUTER OK, the setup works, and this call appears in the console usage log.
Troubleshooting
| Symptom | What to do |
|---|---|
| It asks you to log in to an Anthropic account after starting | Make sure the environment variables are set in the same terminal that starts claude; if you logged in to an official account before, run /logout first |
ANTHROPIC_API_KEY is also set | Remove it and keep only ANTHROPIC_AUTH_TOKEN, so the wrong key is not used |
| Warning that the model “isn't described by this version's model catalog” | Your Claude Code version is old and does not recognize the new model name; it works normally, and the warning goes away after upgrading to the latest version |
| Returns 404 or HTML | Do not add /v1 at the end of the Base URL |
| Returns 403 or 503 | The token's group is not claude, the model name is wrong, or the balance is insufficient |
