DeepSeekClientStream

Client for streaming interactions with the DeepSeek API.

Use the DeepSeekClientStream top-level function to create instances. The client layers the Ktor SSE plugin on top of the default HTTP client configuration and exposes streaming chat and FIM endpoints as extension functions that return a kotlinx.coroutines.flow.Flow of response chunks.

Example:

val client = DeepSeekClientStream(System.getenv("DEEPSEEK_API_KEY"))
client.chat("Write a haiku").collect { chunk ->
print(chunk.choices.firstOrNull()?.delta?.content ?: "")
}

Types

Link copied to clipboard
class Builder(token: String? = null) : DeepSeekClientBase.Builder

Builder for configuring and creating DeepSeekClientStream instances.

Properties

Link copied to clipboard

Configuration options for the DeepSeek client

Functions

Link copied to clipboard

Streams chat responses using default parameters and a message builder DSL.

Streams chat responses for a single user message.

Streams chat responses using default parameters.

Streams chat responses using custom parameters and a message builder DSL.

Streams chat responses using custom parameters and messages.

Link copied to clipboard

Sends a chat completion request to the DeepSeek API.

Streams a fully customizable chat completion request.

Link copied to clipboard

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

Link copied to clipboard
open fun close()

Closes the underlying HTTP client and releases its resources.

Link copied to clipboard
open suspend fun closeAndJoin()

Closes the underlying HTTP client and suspends until its coroutine scope completes.

Link copied to clipboard

Streams FIM completions with default parameters.

Streams FIM completions using custom parameters and a prompt.

Link copied to clipboard

Sends a Fill-In-the-Middle (FIM) completion request to the DeepSeek API.

Streams a fully customizable FIM completion using a builder pattern.

Link copied to clipboard

Streams Fill-In-the-Middle (FIM) completions chunk by chunk from the DeepSeek API.

Link copied to clipboard

Retrieves the list of DeepSeek models available for the current API key.

Link copied to clipboard

Retrieves the current user's available API balance.