ChatCompletionRequest

@Serializable
class ChatCompletionRequest(val model: ModelId, val messages: List<ChatMessage>, val temperature: Double? = null, val topP: Double? = null, val n: Int? = null, val stop: List<String>? = null, val maxTokens: Int? = null, val presencePenalty: Double? = null, val frequencyPenalty: Double? = null, val logitBias: Map<String, Int>? = null, val user: String? = null, val functions: List<ChatCompletionFunction>? = null, val functionCall: FunctionMode? = null, val responseFormat: ChatResponseFormat? = null, val tools: List<Tool>? = null, val toolChoice: ToolChoice? = null, val seed: Int? = null, val logprobs: Boolean? = null, val topLogprobs: Int? = null, val instanceId: String? = null, val streamOptions: StreamOptions? = null)

Creates a completion for the chat message.

Constructors

Link copied to clipboard
constructor(model: ModelId, messages: List<ChatMessage>, temperature: Double? = null, topP: Double? = null, n: Int? = null, stop: List<String>? = null, maxTokens: Int? = null, presencePenalty: Double? = null, frequencyPenalty: Double? = null, logitBias: Map<String, Int>? = null, user: String? = null, functions: List<ChatCompletionFunction>? = null, functionCall: FunctionMode? = null, responseFormat: ChatResponseFormat? = null, tools: List<Tool>? = null, toolChoice: ToolChoice? = null, seed: Int? = null, logprobs: Boolean? = null, topLogprobs: Int? = null, instanceId: String? = null, streamOptions: StreamOptions? = null)

Properties

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

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
@SerialName(value = "function_call")
val functionCall: FunctionMode? = null

Controls how the model responds to function calls. FunctionMode.None means the model does not call a function, and responds to the end-user. FunctionMode.Auto means the model can pick between an end-user or calling a function. Specifying a particular function via FunctionMode.Named forces the model to call that function. FunctionMode.None is the default when no functions are present. FunctionMode.Auto is the default if functions are present.

Link copied to clipboard
@SerialName(value = "functions")
val functions: List<ChatCompletionFunction>? = null

A list of functions the model may generate JSON inputs for.

Link copied to clipboard
@SerialName(value = "instance_id")
val instanceId: String? = null

A unique identifier representing the Multi LORA reserved instance.

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

Modify the likelihood of specified tokens appearing in the completion.

Link copied to clipboard
@SerialName(value = "logprobs")
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
@SerialName(value = "max_tokens")
val maxTokens: Int? = null

The maximum number of tokens allowed for the generated answer. By default, the number of tokens the model can return will be (4096 - prompt tokens).

Link copied to clipboard
@SerialName(value = "messages")
val messages: List<ChatMessage>

The messages to generate chat completions for.

Link copied to clipboard
@SerialName(value = "model")
val model: ModelId

ID of the model to use.

Link copied to clipboard
@SerialName(value = "n")
val n: Int? = null

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

Link copied to clipboard
@SerialName(value = "presence_penalty")
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
@SerialName(value = "response_format")
val responseFormat: ChatResponseFormat? = null

An object specifying the format that the model must output.

Link copied to clipboard
@SerialName(value = "seed")
val seed: Int? = null

If specified, our system will make the best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed, and you should refer to the systemFingerprint response parameter to monitor changes in the backend.

Link copied to clipboard
@SerialName(value = "stop")
val stop: List<String>? = null

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

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

Options for streaming response. Only used when in streaming mode.

Link copied to clipboard
@SerialName(value = "temperature")
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
@SerialName(value = "tool_choice")
val toolChoice: ToolChoice? = null

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

Link copied to clipboard
@SerialName(value = "tools")
val tools: List<Tool>? = null

A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for.

Link copied to clipboard
@SerialName(value = "top_logprobs")
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
@SerialName(value = "top_p")
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.

Link copied to clipboard
@SerialName(value = "user")
val user: String? = null

A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.