ChatCompletionRequest

@Serializable
class ChatCompletionRequest(val messages: List<ChatMessage>, val model: ChatModel, val frequencyPenalty: Double? = null, val maxTokens: Int? = null, val presencePenalty: Double? = null, val responseFormat: ResponseFormat? = null, val stop: StopReason? = null, val stream: Boolean? = null, val streamOptions: StreamOptions? = null, val temperature: Double? = null, val topP: Double? = null, val tools: List<Tool>? = null, val toolChoice: ToolChoice? = null, val logprobs: Boolean? = null, val topLogprobs: Int? = null)

Represents the Chat Completion request

Constructors

Link copied to clipboard
constructor(messages: List<ChatMessage>, model: ChatModel, frequencyPenalty: Double? = null, maxTokens: Int? = null, presencePenalty: Double? = null, responseFormat: ResponseFormat? = null, stop: StopReason? = null, stream: Boolean? = null, streamOptions: StreamOptions? = null, temperature: Double? = null, topP: Double? = null, tools: List<Tool>? = null, toolChoice: ToolChoice? = null, logprobs: Boolean? = null, topLogprobs: Int? = null)

Types

Link copied to clipboard
class Builder
Link copied to clipboard
Link copied to clipboard

Properties

Link copied to clipboard

Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.

Link copied to clipboard
val logprobs: Boolean? = null

Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message.

Link copied to clipboard
val maxTokens: Int? = null

Integer between 1 and 8192. The maximum number of tokens that can be generated in the chat completion.

Link copied to clipboard

A list of messages comprising the conversation so far.

Link copied to clipboard

ID of the model to use. You can use deepseek-chat.

Link copied to clipboard
val presencePenalty: Double? = null

Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.

Link copied to clipboard

An object specifying the format that the model must output. Setting to { "type": "json_object" } enables JSON Output, which guarantees the message the model generates is valid JSON.

Link copied to clipboard
val stop: StopReason? = null

Up to 16 sequences where the API will stop generating further tokens.

Link copied to clipboard
val stream: Boolean? = null

If set, partial message deltas will be sent. Tokens will be sent as data-only server-sent events (SSE) as they become available, with the stream terminated by a data: [DONE]

Link copied to clipboard

Options for streaming response. Only set this when you set stream: true.

Link copied to clipboard
val temperature: Double? = null

What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

Link copied to clipboard
val toolChoice: ToolChoice? = null

Controls which (if any) tool is called by the model.

Link copied to clipboard
val tools: List<Tool>? = null

A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported.

Link copied to clipboard
val topLogprobs: Int? = null

An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used.

Link copied to clipboard
val topP: Double? = null

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String