AI Gateway support for Claude Code

Authors

1 min read

You can now use Claude Code through Vercel AI Gateway via its Anthropic-compatible API endpoint.

Route Claude Code requests through AI Gateway to centralize usage and spend, view traces in observability, and benefit from failover between providers for your model of choice.

Log out if you're already logged in, then set these environment variables to configure Claude Code to use AI Gateway:

claude /logout
export ANTHROPIC_BASE_URL="https://ai-gateway.vercel.sh"
export ANTHROPIC_AUTH_TOKEN="your-ai-gateway-api-key"
export ANTHROPIC_API_KEY=""

Setting ANTHROPIC_API_KEY to an empty string is required. Claude Code checks this variable first, and if it's set to a non-empty value, it will use that instead of ANTHROPIC_AUTH_TOKEN.

Start Claude Code. Requests will route through AI Gateway:

claude

See the Claude Code documentation for details.