Router API

Router API

Connect

export BASE_URL="https://api.zairouter.com"
export API_KEY="sk-Xvs..."

Every request except GET /x-pricing requires:

Authorization: Bearer sk-Xvs...

Model APIs

The Router preserves the request and response formats used by mainstream SDKs. In most cases, you only need to change base_url and api_key.

OpenAI-compatible

CapabilityStable path
Chat CompletionsPOST /v1/chat/completions
ResponsesPOST /v1/responses
Response compactionPOST /v1/responses/compact
EmbeddingsPOST /v1/embeddings
Image generation and editsPOST /v1/images/generations, POST /v1/images/edits
Image variationsPOST /v1/images/variations
Video generationPOST /v1/videos/generations
Audio transcription and translationPOST /v1/audio/transcriptions, POST /v1/audio/translations
ModerationsPOST /v1/moderations
Files and Threads/v1/files, /v1/threads
RealtimeGET /v1/realtime (WebSocket)
Realtime client secretsPOST /v1/realtime/client_secrets
Model listGET /v1/models

Response retrieval, cancellation, and subresources use /v1/responses/{id}. Compatibility aliases /chat/completions, /responses, /embeddings, and /models remain available; new integrations should use /v1/*.

Anthropic-compatible

CapabilityStable path
MessagesPOST /v1/messages
Token countingPOST /v1/messages/count_tokens

Native Gemini format

Gemini SDK model paths are supported:

POST /v1beta/models/{model}:generateContent
POST /v1beta/models/{model}:streamGenerateContent?alt=sse

Chat Completions example

curl "$BASE_URL/v1/chat/completions" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5-nano",
    "messages": [{"role": "user", "content": "Reply with OK only"}],
    "stream": false
  }'

For streaming output, set "stream": true and consume the SSE data: events line by line.

OpenAI SDK

from openai import OpenAI

client = OpenAI(base_url="https://api.zairouter.com/v1", api_key="sk-Xvs...")
response = client.responses.create(model="gpt-5-nano", input="Reply with OK only")
print(response.output_text)

Query APIs

Method and pathDescriptionAuthentication
GET /v1/modelsModels available to the current accountAPI Key
GET /x-pricingPublic pricing catalogOptional
GET /dashboard/statusAccount status, balance, and management capabilityAPI Key
GET /dashboard/infoAccount configuration and limitsAPI Key

When /x-pricing is called with an API Key, it includes the effective prices for that account. Without a key, it returns public prices.

See the Usage API for query parameters, response structures, and examples.

Common status codes

StatusMeaning
400Invalid request body, model, or parameter
401Missing or invalid API Key
403Account, model, IP, or endpoint access is restricted
413Request body is too large
429Request, token, or credit limit reached
502 / 503Upstream temporarily unavailable; retry with backoff

Retry guidance

  • Retry only 429, 502, 503, and network failures, with a finite limit.
  • Use exponential backoff with jitter.
  • Do not automatically replay non-idempotent image or video generation requests.
  • Log the HTTP status and response body, never a complete API Key.