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: 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. No row
after a turn that otherwise looked normal usually means an existing
subscription sign-in won instead -- see Common gotchas below.
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, but it resolves ahead of
family-lock rather than under it: the capability's own default
provider wins, and that is Anthropic for some capabilities and a
different provider for others. The response still comes back in
Anthropic shape either way. See the capability aliases
docs for the per-capability defaults.
Common gotchas
If Claude Code has ever been signed in with /login (a Claude Pro or
Max subscription), that session lives in the OS keychain and takes
priority over ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN --
silently. The turn goes straight to Anthropic on your personal
subscription, never reaches the gateway, and leaves no row in
/requests. Setting the two variables is not enough to override an
existing sign-in.
To guarantee the gateway wins, give Claude Code a config directory that has never been signed in, and point every variable at it instead of exporting globally:
iqclaude() {
CLAUDE_CONFIG_DIR="$HOME/.claude-iq" \
ANTHROPIC_BASE_URL="https://gateway.iq-routing.com" \
ANTHROPIC_AUTH_TOKEN="$IQ_GATEWAY_KEY" \
claude "$@"
}
CLAUDE_CONFIG_DIR keeps this credential isolated from your default
~/.claude; symlink settings.json and any skills back in if you want
preferences to carry over, since only the sign-in needs to stay
separate. Never run /login inside that isolated directory -- it
writes a fresh subscription session there too, and the override goes
silent again. If Claude Code has never been signed in on a machine (a
fresh install, or one used only with an API key), the plain export at
the top of this page is enough on its own.
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.