Skip to content
IQ Routing

Quickstart

Point the OpenAI Python SDK at the IQ Routing gateway. Three lines change.

from openai import OpenAI

client = OpenAI(
    base_url="https://gateway.iq-routing.com/v1",
    api_key="gw_live_xxxxxxxx",
)

response = client.chat.completions.create(
    model="auto",
    messages=[{"role": "user", "content": "Summarise this contract."}],
)

The model="auto" ask routes through the classifier; the classifier picks the cheapest provider and model that meets the prompt's complexity. Pin a specific model (for example claude-haiku-4-5) when you need a deterministic choice.

Correlating gateway errors to requests

Every response carries an X-Request-Id header with the gateway's request id. The same id appears in the JSON body's request_id field on error responses. Search the requests browser at /requests for that id to see the full pipeline trace, including classifier output, fallback hops, and the provider's raw response.

curl -i https://gateway.iq-routing.com/v1/chat/completions \
  -H "Authorization: Bearer gw_live_xxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"model":"auto","messages":[{"role":"user","content":"hi"}]}'

The response includes X-Request-Id: <uuid>. Paste that into /requests?request_id=<uuid> to inspect the routing decision.

Anthropic SDK

The Anthropic SDK works the same way against /v1/messages:

from anthropic import Anthropic

client = Anthropic(
    base_url="https://gateway.iq-routing.com",
    api_key="gw_live_xxxxxxxx",
)

message = client.messages.create(
    model="claude-haiku-4-5",
    max_tokens=256,
    messages=[{"role": "user", "content": "Say hi."}],
)

Use the bare origin for the Anthropic base URL (no /v1); the SDK appends /v1/messages itself.