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 = ChatCompletionRequest(
model = "deepseek-chat",
messages = listOf(UseMessage("Write a story")),
stream = true
)

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