Skip to content
IQ

curl

Two flags change. The Authorization header carries your gateway key; the URL carries the gateway origin. Every other request and response shape matches the upstream provider exactly. Use this recipe to verify connectivity from a shell or a CI pipeline without an SDK in scope.

Drop-in switch

-H "Authorization: Bearer gw_live_xxxxxxxx"
https://gateway.iq-routing.com/v1/chat/completions

The body shape is the OpenAI /v1/chat/completions shape. The Anthropic shape lives at /v1/messages with the same authorization header.

Verify it routes

#!/usr/bin/env bash
set -euo pipefail

: "${IQ_API_KEY:?set IQ_API_KEY}"

iq_response_file=$(mktemp)
trap 'rm -f "$iq_response_file"' EXIT

curl -sS -i https://gateway.iq-routing.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${IQ_API_KEY}" \
  -d '{
    "model": "auto",
    "messages": [{"role": "user", "content": "Summarise: routing-aware gateway."}],
    "max_tokens": 64
  }' | tee "$iq_response_file"

echo
echo "Request id:"
grep -i '^x-request-id:' "$iq_response_file" | tr -d '\r'

The -i flag prints headers; the grep line surfaces the X-Request-Id value. Paste that into /requests/<uuid> to see the routing decision.

For the Anthropic surface:

curl -sS -i https://gateway.iq-routing.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: ${IQ_API_KEY}" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-haiku-5-5",
    "max_tokens": 64,
    "messages": [{"role": "user", "content": "Say hello."}]
  }'

The Anthropic surface accepts both Authorization: Bearer <key> and x-api-key: <key> for compatibility with the official Anthropic SDK default.

Using capability aliases

Pass cap:<name> in the model field to request a capability; inspect the response model to see which model answered and manage your organization's overrides at /settings/capabilities.

curl -sS -i https://gateway.iq-routing.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${IQ_API_KEY}" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "cap:reason-heavy",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Plan the migration in three phases."}]
  }'

The resolved provider plus model surface in the x-iq-routing response header (a JSON-encoded payload with chosen_provider and chosen_model fields, among others), so the shell consumer can grep the headers to see which concrete model handled the request. See the capability aliases docs for the full list of default capabilities and how to override them. You can override the default capability mapping for your org via the capabilities dashboard editor at /settings/capabilities.

Common gotchas

The gateway allows up to 600 seconds per provider attempt and 1800 seconds across the fallback loop; streaming limits cover upstream stream readiness rather than the full token stream, so set an explicit client timeout if you need a shorter limit.

The --retry family of flags retries on the entire request. The gateway's rate-limit and daily-budget 429s carry Retry-After; monthly-budget and spend-ceiling 429s do not. Use --retry 0 and have your shell loop respect the header explicitly when it is present:

curl -sS -i --max-time 60 --retry 0 https://gateway.iq-routing.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${IQ_API_KEY}" \
  -d '{"model":"auto","messages":[{"role":"user","content":"Say hello."}],"max_tokens":64}'

When every upstream provider in the fallback chain is exhausted before the timeout above is hit, the gateway returns 503 with an overloaded_error type in the response body, and no Retry-After header -- back off on your own schedule for that case. Rate-limit and daily-budget 429s carry Retry-After; monthly-budget and spend-ceiling 429s do not. Read Retry-After when it is present and apply your own backoff rather than relying on --retry.

Use jq -n or a heredoc for bodies that contain user content; single quotes work only for fixed bodies.

The CI/CD pattern: store IQ_API_KEY as a secret (GitHub Actions secrets, Vercel env vars, etc.); never inline it. The gateway revokes keys via the dashboard's /keys page; a leaked key is an operator-actionable revocation, not a redeploy.

Try this in the playground

Run this snippet against your gateway key →