ChatCompletionRequest

data class ChatCompletionRequest(val messages: List<Message>, val model: String, val store: Boolean = false, val reasoningEffort: String = "medium", val metadata: Metadata? = null, val maxCompletionTokens: Int? = null, val frequencyPenalty: Double? = 0.0, val presencePenalty: Double? = 0.0, val responseFormat: ResponseFormat? = null, val temperature: Double = 1.0, val topP: Double? = 1.0, val n: Int? = 1, val stop: List<String>? = null, val logitBias: Map<String, Int>? = null, val user: String? = null, val seed: Int? = null, val stream: Boolean = false, val streamOptions: ChatCompletionStreamOptions? = null, val tools: List<Tool>? = null, val toolChoice: ToolChoice? = null)(source)

Represents a request for generating a chat-based completions in an OpenAI-like environment. See Create chat completions.

This data class is used for serialization and defines the parameters required to send a chat completions request, including the input messages, model to use, and various tuning parameters.

Author

Konstantin Pavlov

Constructors

Link copied to clipboard
constructor(messages: List<Message>, model: String, store: Boolean = false, reasoningEffort: String = "medium", metadata: Metadata? = null, maxCompletionTokens: Int? = null, frequencyPenalty: Double? = 0.0, presencePenalty: Double? = 0.0, responseFormat: ResponseFormat? = null, temperature: Double = 1.0, topP: Double? = 1.0, n: Int? = 1, stop: List<String>? = null, logitBias: Map<String, Int>? = null, user: String? = null, seed: Int? = null, stream: Boolean = false, streamOptions: ChatCompletionStreamOptions? = null, tools: List<Tool>? = null, toolChoice: ToolChoice? = null)

Properties

Link copied to clipboard
@SerialName(value = "frequency_penalty")
val frequencyPenalty: Double?

The penalty value for repetitive token usage in the response.

Link copied to clipboard
@SerialName(value = "logit_bias")
val logitBias: Map<String, Int>?

Modify the likelihood of specified tokens appearing in the completion.

Link copied to clipboard
@SerialName(value = "max_completion_tokens")
val maxCompletionTokens: Int?

The maximum number of tokens allowed in the generated completions.

Link copied to clipboard

A list of input messages that define the conversation context, each with a role and content.

Link copied to clipboard

Optional metadata associated with the request, such as tags.

Link copied to clipboard

The identifier of the language model to be used for generating the completions.

Link copied to clipboard
val n: Int?

How many chat completion choices to generate for each input message.

Link copied to clipboard
@SerialName(value = "presence_penalty")
val presencePenalty: Double?

The penalty value for new token usage in the response.

Link copied to clipboard
@SerialName(value = "reasoning_effort")
val reasoningEffort: String

Specifies the level of computational effort to apply during reasoning ("low", "medium", "high").

Link copied to clipboard
@SerialName(value = "response_format")
val responseFormat: ResponseFormat?

Defines the response format, including optional JSON schema support.

Link copied to clipboard
val seed: Int?

Can be used to produce deterministic responses in testing.

Link copied to clipboard

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

Link copied to clipboard

A flag indicating whether the conversation context should be stored for further use.

Link copied to clipboard

Whether to stream the response.

Link copied to clipboard
@SerialName(value = "stream_options")
val streamOptions: ChatCompletionStreamOptions?

Options for streaming responses.

Link copied to clipboard

A value between 0.0 and 1.0 that controls the randomness of the generated response.

Link copied to clipboard
@SerialName(value = "tool_choice")
val toolChoice: ToolChoice?

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

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

List of tools the model may call.

Link copied to clipboard
@SerialName(value = "top_p")
val topP: Double?

An alternative to sampling with temperature, called nucleus sampling.

Link copied to clipboard
val user: String?

A unique identifier representing your end-user.