Skip to main content
Streaming lets you display AI responses as they’re generated, instead of waiting for the full response. This creates a much better user experience for chat interfaces. ShuttleAI uses Server-Sent Events (SSE) — the same streaming format as OpenAI.

Basic streaming

Set stream: true in your request to enable streaming:

Async streaming (Python)

For async applications, use the async client:

Stream with usage stats

To receive token usage statistics with your stream, enable stream_options:
The final chunk in the stream will include a usage object with prompt_tokens, completion_tokens, and total_tokens.

SSE format

Each streamed chunk is a JSON object sent as an SSE event:
The stream ends with data: [DONE].