CompletionRequest

@Serializable
class CompletionRequest(    val model: ModelId,     val prompt: String? = null,     val maxTokens: Int? = null,     val temperature: Double? = null,     val topP: Double? = null,     val n: Int? = null,     val logprobs: Int? = null,     val echo: Boolean? = null,     val stop: List<String>? = null,     val presencePenalty: Double? = null,     val frequencyPenalty: Double? = null,     val bestOf: Int? = null,     val logitBias: Map<String, Int>? = null,     val user: String? = null,     val suffix: String? = null)

A request for OpenAI to generate a predicted completion for a prompt. All fields are Optional.

documentation

Constructors

Link copied to clipboard
constructor(    model: ModelId,     prompt: String? = null,     maxTokens: Int? = null,     temperature: Double? = null,     topP: Double? = null,     n: Int? = null,     logprobs: Int? = null,     echo: Boolean? = null,     stop: List<String>? = null,     presencePenalty: Double? = null,     frequencyPenalty: Double? = null,     bestOf: Int? = null,     logitBias: Map<String, Int>? = null,     user: String? = null,     suffix: String? = null)

Properties

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

Generates bestOf completions server-side and returns the "best" (the one with the lowest log probability per token). Results cannot be streamed.

Link copied to clipboard
@SerialName(value = "echo")
val echo: Boolean? = null

Echo back the prompt in addition to the completion.

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

Number between 0 and 1 (default 0) that penalizes new tokens based on their existing frequency in the text so far. Decreases the model's likelihood to repeat the same line verbatim.

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: Int? = null

Include the log probabilities on the logprobs most likely tokens, as well the chosen tokens. For example, if logprobs is 10, the API will return a list of the 10 most likely tokens. The API will always return the logprob of the sampled token, so there may be up to logprobs+1 elements in the response.

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

The maximum number of tokens to generate. Requests can use up to 2048 tokens shared between prompt and completion. (One token is roughly 4 characters for normal English text)

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 completions to generate for each prompt.

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

Number between 0 and 1 (default 0) that penalizes new tokens based on whether they appear in the text so far. Increases the model's likelihood to talk about new topics.

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

The prompt(s) to generate completions for, encoded as a string, a list of strings, or a list of token lists.

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

Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.

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

The suffix that comes after a completion of inserted text.

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

What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer.

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 will help OpenAI to monitor and detect abuse.