fimCompletion

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

This function handles the low-level API communication for FIM completions, which allow the model to complete text given a prompt (and optionally a suffix).

Example:

val request = FIMCompletionRequest(
model = "deepseek-chat",
prompt = "def calculate_area(radius):",
suffix = "# End of function"
)
val completion = client.fimCompletion(request)
println(completion.choices.first().text)

Return

A FIMCompletion containing the model's response

Parameters

request

The FIM completion request containing all parameters


Creates a fully customizable FIM completion request using a builder pattern.

This approach gives you complete control over all aspects of the FIM request, including prompt, suffix, and generation parameters.

Example:

val completion = client.fimCompletion {
model = "deepseek-chat"
prompt = "public class Calculator {"
suffix = "}"
temperature = 0.8
maxTokens = 500
}
println(completion.choices.first().text)

Return

A FIMCompletion containing the model's response

Parameters

block

A builder block for constructing the complete request


Streams a fully customizable FIM completion using a builder pattern.

This approach gives you complete control over all aspects of the streaming FIM request through a dedicated builder pattern.

Example:

client.fimCompletion {
model = "deepseek-chat"
prompt = "public interface DataProcessor {"
suffix = "}"
temperature = 0.8
maxTokens = 300
}.collect { chunk ->
print(chunk.choices.firstOrNull()?.text ?: "")
}

Return

A Flow of FIMCompletion objects representing the streaming response

Parameters

block

A builder block for constructing the complete streaming request