Chat completions

Generate a model response for a conversation. Supports streaming, vision, and reasoning.

POST/v1/chat/completions

Request body#

FieldTypeDescription
modelrequiredstringA model id from GET /v1/models.
messagesrequiredarrayThe conversation so far. Each message has a role and content.
streambooleanWhen true, partial deltas are streamed as Server-Sent Events. Default false.
max_tokensintegerHard cap on the number of tokens generated.
reasoning_effortstringlow | medium | high — reasoning depth for thinking-capable models.

Message format

Each message has a role (system, user, or assistant) and content. Content is either a string or — for vision — an array of parts.

Basic example#

bash
curl https://api.studio.whalli.com/v1/chat/completions \
  -H "Authorization: Bearer $WHALLI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [
      { "role": "system", "content": "You are concise." },
      { "role": "user", "content": "Explain entanglement in one sentence." }
    ]
  }'

Response

json
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1782000000,
  "model": "gpt-5.5",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "Two particles share one quantum state..." },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 24, "completion_tokens": 18, "total_tokens": 42 }
}

Streaming#

Set stream: true to receive Server-Sent Events. Each event is a chat.completion.chunk whose choices[0].delta.content holds the next piece of text. The stream ends with a literal data: [DONE].

bash
curl https://api.studio.whalli.com/v1/chat/completions \
  -H "Authorization: Bearer $WHALLI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "model": "gpt-5.5", "messages": [{"role":"user","content":"hi"}], "stream": true }'
text
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant"}}]}

data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"He"}}]}

data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{...}}

data: [DONE]

Vision (image input)#

Send an array of content parts. Image parts accept a data URI or a public URL — the same shape as the OpenAI API.

json
{
  "model": "gpt-5.5",
  "messages": [{
    "role": "user",
    "content": [
      { "type": "text", "text": "What's in this image?" },
      { "type": "image_url", "image_url": { "url": "https://example.com/cat.jpg" } }
    ]
  }]
}
Vision requires a model with image input. Check a model's capabilities in the Console.

Reasoning#

For thinking-capable models, set reasoning_effort to low, medium, or high to trade latency and cost for depth. It is ignored by models that don't support reasoning.