Claude Code
Set ANTHROPIC_BASE_URL to the gateway origin and
ANTHROPIC_AUTH_TOKEN to your IQ API key to route Claude Code model calls
through IQ. Named Anthropic models stay on Anthropic by default; Bedrock
routing, if turned on, can serve them through AWS. auto and capability
aliases can use other connected providers.
Drop-in switch
Export the gateway origin and your gateway key, then run Claude Code:
export ANTHROPIC_BASE_URL="https://gateway.iq-routing.com"
export ANTHROPIC_AUTH_TOKEN="gw_live_xxxxxxxx"
claude
Use the bare origin for ANTHROPIC_BASE_URL (no /v1 suffix): the
Anthropic SDK inside Claude Code appends /v1/messages itself.
ANTHROPIC_AUTH_TOKEN sends your key as Authorization: Bearer, which
is what the gateway expects.
To make it permanent, add the two variables to your shell profile, or
put them in ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "https://gateway.iq-routing.com",
"ANTHROPIC_AUTH_TOKEN": "gw_live_xxxxxxxx"
}
}
Verify it routes
Run claude in a scratch repo and ask it something small
(“summarize this file”). The turn completes with the
gateway's standard latency. Open your dashboard at /requests: each
Claude Code turn is its own row, with the chosen model, the cost, and
the cache-hit status. The x-iq-routing response header carries
chosen_provider, chosen_model, and cache_hit for the turn, and an
X-Request-Id header lets you paste that value into /requests/<uuid>
to pull up one specific turn. An invalid key returns 401; a revoked
key (from /keys) returns 403 API key revoked. If a request record is missing, check your endpoint and credential
configuration using Claude Code's gateway docs.
Staying inside the family
Keep a named Anthropic model to stay on Anthropic by default, or set the
model to auto to allow other connected providers:
export ANTHROPIC_MODEL="auto"
A cap:<name> alias can use another connected provider while returning
an Anthropic-shaped response; see the capability docs
for available aliases and organization overrides.
Common gotchas
An ANTHROPIC_AUTH_TOKEN set in the environment outranks a saved
/login session; set it with ANTHROPIC_BASE_URL to use the gateway.
To keep gateway credentials separate from your default configuration, use an optional wrapper with its own config directory:
iqclaude() {
CLAUDE_CONFIG_DIR="$HOME/.claude-iq" \
ANTHROPIC_BASE_URL="https://gateway.iq-routing.com" \
ANTHROPIC_AUTH_TOKEN="$IQ_API_KEY" \
claude "$@"
}
CLAUDE_CONFIG_DIR gives the wrapper a separate configuration and
sign-in; see Claude Code's authentication docs
for credential precedence.
Use ANTHROPIC_AUTH_TOKEN for the gateway key sent as Bearer; see
Claude Code's authentication docs
for how it chooses between credentials.
Use the bare origin for ANTHROPIC_BASE_URL because the client appends
/v1/messages itself.
Long agent sessions can spend fast. If a turn returns 429, check the
X-RateLimit-Scope header to see which cap fired: rps, rpm, and
tpm carry a Retry-After window Claude Code can back off and retry
against (rps is a one-second window, rpm/tpm are sixty-second),
while daily_budget resets at midnight UTC, monthly_budget resets
at the start of the next month, and key_spend_ceiling needs a manual
budget increase. Watch your
/dashboard spend bar during long sessions. See the
FAQ for the full list of scopes.
Keep a named Anthropic model when your workload depends on Claude-specific request features.