OpenAIChatCompletionRequestBuilder

DSL builder for OpenAIChatCompletionRequest.

The model are required; every other setting is optional and defaults to null (omitted from the JSON payload), except tools which defaults to an empty list.

See also

Samples

return openAIChatCompletionRequest(model = "gpt-5.6-sol") {
    messages {
        system("You are a helpful assistant.")
        user("What's the weather like in London?")
    }
}

Properties

Link copied to clipboard

Audio output parameters for audio generation. null disables audio output.

Link copied to clipboard

Number of chat completion choices to generate for each input message.

Link copied to clipboard

Penalty for token frequency (-2.0 to 2.0).

Link copied to clipboard

Modifies the likelihood of specified tokens appearing in the completion.

Link copied to clipboard

Whether to return log probabilities of the output tokens.

Link copied to clipboard

Upper bound for tokens generated in a completion.

Link copied to clipboard

Maximum number of tokens that can be generated. Deprecated in favor of maxCompletionTokens.

Link copied to clipboard

Set of up to 16 key-value pairs attached to the request object.

Link copied to clipboard

Output modalities to generate. Defaults to [text], plus [audio] when audio is set.

Link copied to clipboard

Whether to enable parallel function calling during tool use.

Link copied to clipboard

Penalty for token presence (-2.0 to 2.0).

Link copied to clipboard

Reasoning effort level. null uses provider default.

Link copied to clipboard

An object specifying the format that the model must output.

Link copied to clipboard

A stable identifier for users of your application. Max 64 characters.

Link copied to clipboard
var seed: Long?

Beta. Best-effort deterministic sampling seed.

Link copied to clipboard

Specifies the processing type used for serving the request.

Link copied to clipboard

Sequences where the API stops generating further tokens.

Link copied to clipboard

Whether to store the output of this request for distillation or evals.

Link copied to clipboard

Options for streaming responses. Only set this for streaming requests.

Link copied to clipboard

Sampling temperature (0.0–2.0).

Link copied to clipboard

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

Link copied to clipboard

Maximum number of most likely tokens to return at each position (0–20).

Link copied to clipboard
var topP: Double?

Nucleus sampling parameter (0.0–1.0).

Link copied to clipboard
var user: String?

Deprecated. A stable identifier for end-users.

Link copied to clipboard

Constrains the verbosity of the model's response.

Functions

Link copied to clipboard

Appends a single message parameter to the request.

Link copied to clipboard

Appends multiple message parameters using a builder DSL.

fun messages(vararg params: OpenAIMessageParam)

Appends multiple message parameters to the request.

Link copied to clipboard

Appends a single tool definition to the request.

Link copied to clipboard

Appends multiple tool definitions to the request.