cURL

Reference syntax. Use it to test, debug, and copy headers into Postman/Insomnia.

Chat completion

curl "$AIROUTER_BASE_URL/v1/chat/completions" \
  -H "authorization: Bearer $AIROUTER_API_KEY" \
  -H "content-type: application/json" \
  -H "x-airouter-end-user: user_123" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role":"user","content":"hello"}]
  }' -i

-i shows the response headers so you can grab x-airouter-request-id.

Streaming

curl -N "$AIROUTER_BASE_URL/v1/chat/completions" \
  -H "authorization: Bearer $AIROUTER_API_KEY" \
  -H "content-type: application/json" \
  -H "x-airouter-end-user: user_123" \
  -d '{
    "model": "gpt-4o-mini",
    "stream": true,
    "messages": [{"role":"user","content":"count to 3"}]
  }'

Managed prompt

curl "$AIROUTER_BASE_URL/v1/chat/completions" \
  -H "authorization: Bearer $AIROUTER_API_KEY" \
  -H "content-type: application/json" \
  -H "x-airouter-end-user: user_123" \
  -d '{
    "model": "gpt-4o-mini",
    "prompt": {
      "slug": "welcome-email",
      "label": "production",
      "variables": { "name": "Ada" }
    }
  }'

Embeddings

curl "$AIROUTER_BASE_URL/v1/embeddings" \
  -H "authorization: Bearer $AIROUTER_API_KEY" \
  -H "content-type: application/json" \
  -H "x-airouter-end-user: user_123" \
  -d '{ "model": "text-embedding-3-small", "input": "hello world" }'

Anthropic /v1/messages

curl "$AIROUTER_BASE_URL/v1/messages" \
  -H "authorization: Bearer $AIROUTER_API_KEY" \
  -H "content-type: application/json" \
  -H "x-airouter-end-user: user_123" \
  -d '{
    "model": "claude-3-5-sonnet-latest",
    "max_tokens": 256,
    "messages": [{"role":"user","content":"hi"}]
  }'

odnoga translates to/from OpenAI shape internally.