API Reference

Streaming Responses

Handle real-time streaming responses from AI models

Streaming API

Streaming allows you to receive partial responses as they are generated, providing a more responsive user experience.

Enable Streaming

Add stream: true to your request:

{
  "model": "gpt-4o",
  "messages": [...],
  "stream": true
}

Processing Stream

Each chunk is formatted as Server-Sent Events (SSE):

data: {"choices":[{"delta":{"content":"Hello"}}]}
data: {"choices":[{"delta":{"content":" world"}}]}
data: [DONE]