The response is a text stream of Server-Sent Events (SSE). Each event is a
JSON object prefixed with data: , terminated by a final data: [DONE]
sentinel.
data: {"id":"cmpl-12345","object":"chat.completion.chunk","created":1699044968,"model":"green-l","choices":[{"index":0,"delta":{"role":"assistant","content":"Hello"},"finish_reason":null}]}data: {"id":"cmpl-12345","object":"chat.completion.chunk","created":1699044968,"model":"green-l","choices":[{"index":0,"delta":{"content":"! How"},"finish_reason":null}]}data: {"id":"cmpl-12345","object":"chat.completion.chunk","created":1699044968,"model":"green-l","choices":[{"index":0,"delta":{"content":" can I help you today?"},"finish_reason":null}]}data: {"id":"cmpl-12345","object":"chat.completion.chunk","created":1699044968,"model":"green-l","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}data: [DONE]
Reading the stream
Each chat.completion.chunk carries an incremental delta. Concatenate
delta.content across chunks to assemble the full assistant message. The
final non-[DONE] chunk includes a finish_reason ("stop",
"length", etc.) and no further content.