Claude Code
Claude Code is an Anthropic-shape client. It reads its endpoint and credential from two environment variables, so there is no config file to edit. Point it at the gateway origin, give it a gateway key, and every Claude Code turn routes through IQ. Because the request is Anthropic-shape, family-lock keeps routing inside the Anthropic family, so tool use, prompt caching, and extended thinking all keep working.
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: the
most-recent row is the Claude Code request, with the chosen model and
cache-hit status. The x-iq-routing response header carries
chosen_provider, chosen_model, and cache_hit for the turn.
Staying inside the family
Claude Code sends Anthropic model ids (a Sonnet or Opus id, for
example). Family-lock means the gateway routes those within the
Anthropic family only, picking the tier that fits each step and never
falling through to another vendor. Leave Claude Code's model
selection as-is, or hand routing to the classifier by setting the model
to auto:
export ANTHROPIC_MODEL="auto"
A cap:<name> capability alias works here too; under family-lock it
resolves to a concrete Anthropic model. See the capability aliases
docs.
Common gotchas
Use ANTHROPIC_AUTH_TOKEN (Bearer) for the gateway key, not
ANTHROPIC_API_KEY. If both are set, clear ANTHROPIC_API_KEY so Claude
Code does not send a second credential header.
Keep ANTHROPIC_BASE_URL as the bare origin. A trailing /v1 produces
/v1/v1/messages and the request 404s.
Long agent sessions can spend fast. If a turn returns 429, the gateway
budget or rate cap is exhausted; Claude Code surfaces the error and
retries after the cooldown. Watch your /dashboard spend bar during long
sessions.
Streaming, tool use, and prompt caching pass through unchanged. Because family-lock never leaves the Anthropic family, the Anthropic-specific features Claude Code depends on keep working exactly as they do direct.
Verify it routed
Each Claude Code turn appears as a row in /requests with the model the
gateway picked and the cost. Run one turn, then open the requests view to
confirm routing is live.