Connect Claude Code
Claude Code can use the Arena Gateway as its Anthropic endpoint. Point Claude Code at https://api.preview.arena.ai (the gateway root, not /v1), pass your Arena key as the Anthropic auth token, and Claude Code will route every /v1/messages call through Arena's billing, logging, and rate-limit pipeline.
1. Create a gateway key
- Open the Keys page and create a new key.
- Copy the key — you won't be able to see it again after closing the dialog.
2. Set the Anthropic environment variables
Claude Code reads its endpoint, auth token, and default models from environment variables. The defaults below pin Claude Code to Arena-supported model IDs so it doesn't fall back to upstream Anthropic names.
export ANTHROPIC_BASE_URL=https://api.preview.arena.ai
export ANTHROPIC_AUTH_TOKEN=<your-arena-key>
export ANTHROPIC_MODEL=claude-sonnet-4-6
export ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-4-6
export ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-4-5-20251001
export ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-4-6ANTHROPIC_AUTH_TOKEN is sent as Authorization: Bearer; the gateway also accepts the Anthropic-native x-api-key header if you prefer (set ANTHROPIC_API_KEY instead).
3. Launch Claude Code
With the env vars set, just run Claude Code. It will pick up the gateway URL automatically.
claude4. Verify the gateway connection
Before debugging Claude Code itself, confirm your key reaches the gateway and a Claude model responds end-to-end.
curl https://api.preview.arena.ai/v1/messages \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-H "x-api-key: $ANTHROPIC_AUTH_TOKEN" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 64,
"messages": [
{"role": "user", "content": "Say hello in exactly five words"}
]
}'A successful response is an Anthropic-shaped envelope with "type": "message" and a content array. The same call works against https://api.preview.arena.ai/anthropic/v1/messages if you have an existing client wired to the alias path.
5. Routing modes
Set ANTHROPIC_MODEL to a routing alias (auto, fast) instead of a fixed Claude model to let the gateway pick the best Claude variant per turn. Direct model IDs (e.g. claude-sonnet-4-6) bypass routing.
Tips
- Use
ANTHROPIC_BASE_URLwith the gateway root URL, not a/v1suffix — Claude Code appends/v1/messagesitself. ANTHROPIC_DEFAULT_*_MODELoverrides Claude Code's tier defaults so its sonnet/haiku/opus selectors map to Arena-supported IDs.- Streaming, tool calling, prompt caching, and multimodal content blocks all flow through unchanged. Usage and spend show up in your dashboard the same as any other gateway request.