Claude Code (gateway)
Claude Code (gateway)
Claude Code (gateway)
Route Claude Code’s LLM calls through the Respan gateway for automatic logging, caching, and model switching. Only your RESPAN_API_KEY is needed.
Add to your shell profile (.bashrc, .zshrc, or PowerShell $PROFILE):
Use ANTHROPIC_API_KEY, not ANTHROPIC_AUTH_TOKEN, for Claude Code through the Respan Anthropic gateway. Claude prefers ANTHROPIC_AUTH_TOKEN when both are set.
Add to ~/.claude/settings.json for global config, or .claude/settings.local.json in your project for repo-local config:
Setting ANTHROPIC_AUTH_TOKEN to an empty string clears any inherited token so Claude Code prefers ANTHROPIC_API_KEY. Run Claude Code as usual — all LLM calls will route through Respan.
The Anthropic gateway path is /api/anthropic/ (with trailing slash). For interactive Claude Code sessions, prefer shell env vars or ~/.claude/settings.json. If ANTHROPIC_AUTH_TOKEN is exported by your shell or terminal app, Claude may still prefer it, so unset or remove it first. On first interactive launch, Claude may prompt: Detected a custom API key in your environment. Choose Yes to use the Respan API key. If you skipped it earlier, run /config, search for custom, and enable Use custom API key. Non-interactive claude -p and claude --print use ANTHROPIC_API_KEY automatically.
Once routed through the gateway, you can use any Claude model.
See the full model list.
To route Claude Code to your Vertex AI throughput (or any other provider) without changing the model slug, set the X-Respan-Route-Provider header. Claude Code keeps using its standard slug and the gateway resolves the provider transparently:
For a fallback across providers (e.g. primary Vertex, fall back to Anthropic on failure), use fallback_models instead. See Reliability for fallback_models and load_balance_group, and Providers & models for inline router controls (models, exclude_models, exclude_providers).