Skip to main content
Streaming message chunks are returned by the API when stream=true is set in the request.

Request Headers

string
required
The API key to use for the request.
string
required
The content type of the request. Should be application/json.

Request Body

array
required
An array of messages of the conversation so far.
string
required
The model to use for the UI completion. Should be one of the models listed in the Models page.
number
The temperature to use for the UI completion. Should be between 0 and 1.
number
The top-p value to use for the UI completion. Should be between 0 and 1.
integer
The maximum number of tokens to use for the UI completion.
integer
The number of completions to generate.
integer
Should be unset or set to 1.
boolean
Whether to stream the response. Should be true for streaming.
The parameters above are commonly used with the Messages API. For a comprehensive list of all supported parameters and their compatibility across different model providers (OpenAI vs Anthropic), see the Supported API Parameters table.

SSE Event Stream

string
A identifier for this event.
object
One of the following objects:

Completion Chunk

string
required
A unique identifier for the UI completion. Will be the same in all events for a given completion.
string
required
The object type, which is always chat.completion.chunk
integer
required
Timestamp for when the chunk was created.
string
required
The model used to generate the UI completion.
object
An object containing the usage statistics for the UI completion Only present if the generation is complete.
array
An array of completions. Will always contain exactly one object.