Documentation / API

Streaming

Add stream: true to a chat completion request to receive server-sent events as output is generated.

Request body
{
  "model": "YOUR_AVAILABLE_MODEL",
  "messages": [{"role": "user", "content": "Hello!"}],
  "stream": true
}

Read the event stream

Process each data: event and append content deltas. Stop when the provider sends a completion event, and surface connection failures to the user.

Open Chat