chatCompletionStream

Streams chat completion responses chunk by chunk from the DeepSeek API.

This function handles the low-level communication with the Server-Sent Events (SSE) endpoint, allowing you to receive and process model responses in real-time as they're generated.

Example:

val request = chatCompletionStreamParams { model = ChatModel.DEEPSEEK_CHAT }
.createRequest(listOf(UserMessage("Write a story")))

client.chatCompletionStream(request).collect { chunk ->
print(chunk.choices.firstOrNull()?.delta?.content ?: "")
}

Return

A Flow of ChatCompletionChunk objects representing incremental updates

Parameters

request

The chat completion request with streaming enabled

Throws

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