1. Docs
  2. API reference
  3. Chat Completions

Chat Completions

POSThttps://api.airoutly.com/v1/chat/completions

Generate a model reply to a conversation. Compatible with the OpenAI Chat Completions API, and works with every chat model on Airoutly, including Claude and Gemini.

Authentication

Send your API key as a Bearer token. The OpenAI SDKs do this for you when you pass api_key.

header
Authorization: Bearer $AIROUTLY_API_KEY

Request body

ParameterDescription
modelstringrequiredModel ID from the models page, such as gpt-5 or claude-sonnet-4-5.
messagesarrayrequiredThe conversation so far. Each message has a role (system, user, assistant or tool) and content. For multimodal models, content can be an array of text and image_url parts.
streambooleanReturn the reply as server-sent events. Recommended for long outputs.
stream_optionsobjectSet {"include_usage": true} to get token usage in the last chunk of a stream.
max_tokensintegerUpper limit on generated tokens. OpenAI reasoning models use max_completion_tokens instead.
temperaturenumberSampling temperature, 0 to 2. Some reasoning models only accept the default.
toolsarrayFunctions the model may call. Use with tool_choice (auto, none, required or a specific function).
response_formatobject{"type": "json_object"} or a JSON schema, on models that support structured output.

Other OpenAI parameters are passed through to the model. Whether they take effect depends on the model.

Example request

curl https://api.airoutly.com/v1/chat/completions \
  -H "Authorization: Bearer $AIROUTLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello!"}
    ]
  }'

Response

200 OK
{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1762300800,
  "model": "gpt-5",
  "choices": [{
    "index": 0,
    "message": { "role": "assistant", "content": "Hello! How can I help?" },
    "finish_reason": "stop"
  }],
  "usage": { "prompt_tokens": 19, "completion_tokens": 8, "total_tokens": 27 }
}

You are billed for the usage shown here, at the model’s price on the models page.

Streaming

With "stream": true, the reply arrives as a series of data: lines and ends with data: [DONE]. Add stream_options to get usage in the last chunk.

text/event-stream
data: {"object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Hel"}}]}

data: {"object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"lo!"}}]}

data: {"object":"chat.completion.chunk","choices":[],"usage":{"prompt_tokens":19,"completion_tokens":8,"total_tokens":27}}

data: [DONE]

Errors

Errors use the OpenAI error shape. Rely on the HTTP status and code; the message ends with a request ID to quote when you contact support. See error codes for what each one means.

503
{
  "error": {
    "message": "No available channel for model gpt-6 (request id: 20261105...)",
    "type": "new_api_error",
    "code": "model_not_found"
  }
}