Claude Code
Claude Code can use an Anthropic-compatible gateway. Configure the gateway URL as R9S and authenticate with your R9S API key.
Environment Variables
Section titled “Environment Variables”export R9S_API_KEY="<R9S_API_KEY>"export ANTHROPIC_BASE_URL="https://api.r9s.ai/"export ANTHROPIC_AUTH_TOKEN="$R9S_API_KEY"If your local Claude Code setup expects an API key variable instead of a bearer token variable, use:
export ANTHROPIC_API_KEY="$R9S_API_KEY"Run Claude Code
Section titled “Run Claude Code”claude --model claude-sonnet-4.5You can also use any Anthropic-compatible model available in your R9S account, such as:
claude --model claude-opus-4.5Persistent Shell Setup
Section titled “Persistent Shell Setup”Add the same variables to your shell profile if you want Claude Code to use R9S by default:
export R9S_API_KEY="<R9S_API_KEY>"export ANTHROPIC_BASE_URL="https://api.r9s.ai/"export ANTHROPIC_AUTH_TOKEN="$R9S_API_KEY"Restart your shell after updating the profile.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Check |
|---|---|
| Authentication error | Confirm that ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY contains your R9S API key. |
| Model not found | Confirm the model name in the R9S console or call /v1/models. |
| Requests still go to Anthropic directly | Confirm ANTHROPIC_BASE_URL is exported in the same shell session that starts Claude Code. |