createResponseStream

Streams a Responses API call as semantic server-sent events.

Unlike the chat stream, which repeats the whole envelope in every chunk, the Responses API narrates the response as it is assembled — see ResponseStreamEvent. There is no [DONE] marker: the flow ends after ResponseCompletedEvent, ResponseIncompleteEvent or ResponseFailedEvent, each carrying the finished ModelResponse with its usage.

Example:

val request = responseStreamParams { model = ChatModel.DEEPSEEK_FLASH }
.createRequest("Write a haiku about Kotlin")

client.createResponseStream(request).collect { event ->
if (event is OutputTextDeltaEvent) print(event.delta)
}

Return

A Flow of the events the API emits, in order

Parameters

request

The request to stream; its stream flag is expected to be set

Throws

from the returned Flow's collector if the API returns a non-2xx status