Overview
Streaming allows you to receive model responses incrementally as they’re generated, rather than waiting for the complete response. This is implemented using Server-Sent Events (SSE) and is useful for real-time user interfaces.Enabling Streaming
Setstream: true in your chat completions request:
Stream Response Format
Initial Chunk
The first chunk contains the role:Content Chunks
Subsequent chunks contain content deltas:Final Chunk
The last chunk has an empty delta and a finish_reason:Stream Termination
Response Fields
string
Always
"chat.completion.chunk" for streaming responsesobject
Incremental content update:
role: Present in first chunk onlycontent: Text content delta (not cumulative)
string | null
Null during generation, then one of:
"stop": Natural completion"length": Reached max_length