Class CompletionCreateParams.Body.Builder
-
- All Implemented Interfaces:
public final class CompletionCreateParams.Body.Builder
A builder for Body.
-
-
Method Summary
-
-
Method Detail
-
model
final CompletionCreateParams.Body.Builder model(CompletionCreateParams.Model model)
ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.
-
model
final CompletionCreateParams.Body.Builder model(JsonField<CompletionCreateParams.Model> model)
Sets Builder.model to an arbitrary JSON value.
You should usually call Builder.model with a well-typed Model value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
model
final CompletionCreateParams.Body.Builder model(String value)
Sets model to an arbitrary String.
You should usually call model with a well-typed Model constant instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
prompt
final CompletionCreateParams.Body.Builder prompt(CompletionCreateParams.Prompt prompt)
The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.
Note that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document.
-
prompt
final CompletionCreateParams.Body.Builder prompt(Optional<CompletionCreateParams.Prompt> prompt)
Alias for calling Builder.prompt with
prompt.orElse(null)
.
-
prompt
final CompletionCreateParams.Body.Builder prompt(JsonField<CompletionCreateParams.Prompt> prompt)
Sets Builder.prompt to an arbitrary JSON value.
You should usually call Builder.prompt with a well-typed Prompt value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
prompt
final CompletionCreateParams.Body.Builder prompt(String string)
Alias for calling prompt with
Prompt.ofString(string)
.
-
promptOfArrayOfStrings
final CompletionCreateParams.Body.Builder promptOfArrayOfStrings(List<String> arrayOfStrings)
Alias for calling prompt with
Prompt.ofArrayOfStrings(arrayOfStrings)
.
-
promptOfArrayOfTokens
final CompletionCreateParams.Body.Builder promptOfArrayOfTokens(List<Long> arrayOfTokens)
Alias for calling prompt with
Prompt.ofArrayOfTokens(arrayOfTokens)
.
-
promptOfArrayOfTokenArrays
final CompletionCreateParams.Body.Builder promptOfArrayOfTokenArrays(List<List<Long>> arrayOfTokenArrays)
Alias for calling prompt with
Prompt.ofArrayOfTokenArrays(arrayOfTokenArrays)
.
-
bestOf
final CompletionCreateParams.Body.Builder bestOf(Long bestOf)
Generates
best_of
completions server-side and returns the "best" (the one with the highest log probability per token). Results cannot be streamed.When used with
n
,best_of
controls the number of candidate completions andn
specifies how many to return –best_of
must be greater thann
.Note: Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for
max_tokens
andstop
.
-
bestOf
final CompletionCreateParams.Body.Builder bestOf(Long bestOf)
Alias for Builder.bestOf.
This unboxed primitive overload exists for backwards compatibility.
-
bestOf
final CompletionCreateParams.Body.Builder bestOf(Optional<Long> bestOf)
Alias for calling Builder.bestOf with
bestOf.orElse(null)
.
-
bestOf
final CompletionCreateParams.Body.Builder bestOf(JsonField<Long> bestOf)
Sets Builder.bestOf to an arbitrary JSON value.
You should usually call Builder.bestOf with a well-typed Long value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
echo
final CompletionCreateParams.Body.Builder echo(Boolean echo)
Echo back the prompt in addition to the completion
-
echo
final CompletionCreateParams.Body.Builder echo(Boolean echo)
Alias for Builder.echo.
This unboxed primitive overload exists for backwards compatibility.
-
echo
final CompletionCreateParams.Body.Builder echo(Optional<Boolean> echo)
Alias for calling Builder.echo with
echo.orElse(null)
.
-
echo
final CompletionCreateParams.Body.Builder echo(JsonField<Boolean> echo)
Sets Builder.echo to an arbitrary JSON value.
You should usually call Builder.echo with a well-typed Boolean value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
frequencyPenalty
final CompletionCreateParams.Body.Builder frequencyPenalty(Double frequencyPenalty)
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.
See more information about frequency and presence * penalties.
-
frequencyPenalty
final CompletionCreateParams.Body.Builder frequencyPenalty(Double frequencyPenalty)
Alias for Builder.frequencyPenalty.
This unboxed primitive overload exists for backwards compatibility.
-
frequencyPenalty
final CompletionCreateParams.Body.Builder frequencyPenalty(Optional<Double> frequencyPenalty)
Alias for calling Builder.frequencyPenalty with
frequencyPenalty.orElse(null)
.
-
frequencyPenalty
final CompletionCreateParams.Body.Builder frequencyPenalty(JsonField<Double> frequencyPenalty)
Sets Builder.frequencyPenalty to an arbitrary JSON value.
You should usually call Builder.frequencyPenalty with a well-typed Double value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
logitBias
final CompletionCreateParams.Body.Builder logitBias(CompletionCreateParams.LogitBias logitBias)
Modify the likelihood of specified tokens appearing in the completion.
Accepts a JSON object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this /tokenizer?view=bpe to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.
As an example, you can pass
{"50256": -100}
to prevent the <|endoftext|> token from being generated.
-
logitBias
final CompletionCreateParams.Body.Builder logitBias(Optional<CompletionCreateParams.LogitBias> logitBias)
Alias for calling Builder.logitBias with
logitBias.orElse(null)
.
-
logitBias
final CompletionCreateParams.Body.Builder logitBias(JsonField<CompletionCreateParams.LogitBias> logitBias)
Sets Builder.logitBias to an arbitrary JSON value.
You should usually call Builder.logitBias with a well-typed LogitBias value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
logprobs
final CompletionCreateParams.Body.Builder logprobs(Long logprobs)
Include the log probabilities on the
logprobs
most likely output tokens, as well the chosen tokens. For example, iflogprobs
is 5, the API will return a list of the 5 most likely tokens. The API will always return thelogprob
of the sampled token, so there may be up tologprobs+1
elements in the response.The maximum value for
logprobs
is 5.
-
logprobs
final CompletionCreateParams.Body.Builder logprobs(Long logprobs)
Alias for Builder.logprobs.
This unboxed primitive overload exists for backwards compatibility.
-
logprobs
final CompletionCreateParams.Body.Builder logprobs(Optional<Long> logprobs)
Alias for calling Builder.logprobs with
logprobs.orElse(null)
.
-
logprobs
final CompletionCreateParams.Body.Builder logprobs(JsonField<Long> logprobs)
Sets Builder.logprobs to an arbitrary JSON value.
You should usually call Builder.logprobs with a well-typed Long value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
maxTokens
final CompletionCreateParams.Body.Builder maxTokens(Long maxTokens)
The maximum number of /tokenizer that can be generated in the completion.
The token count of your prompt plus
max_tokens
cannot exceed the model's context length. Example Python code for counting tokens.
-
maxTokens
final CompletionCreateParams.Body.Builder maxTokens(Long maxTokens)
Alias for Builder.maxTokens.
This unboxed primitive overload exists for backwards compatibility.
-
maxTokens
final CompletionCreateParams.Body.Builder maxTokens(Optional<Long> maxTokens)
Alias for calling Builder.maxTokens with
maxTokens.orElse(null)
.
-
maxTokens
final CompletionCreateParams.Body.Builder maxTokens(JsonField<Long> maxTokens)
Sets Builder.maxTokens to an arbitrary JSON value.
You should usually call Builder.maxTokens with a well-typed Long value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
n
final CompletionCreateParams.Body.Builder n(Long n)
How many completions to generate for each prompt.
Note: Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for
max_tokens
andstop
.
-
n
final CompletionCreateParams.Body.Builder n(Long n)
Alias for Builder.n.
This unboxed primitive overload exists for backwards compatibility.
-
n
final CompletionCreateParams.Body.Builder n(Optional<Long> n)
Alias for calling Builder.n with
n.orElse(null)
.
-
n
final CompletionCreateParams.Body.Builder n(JsonField<Long> n)
Sets Builder.n to an arbitrary JSON value.
You should usually call Builder.n with a well-typed Long value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
presencePenalty
final CompletionCreateParams.Body.Builder presencePenalty(Double presencePenalty)
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.
See more information about frequency and presence * penalties.
-
presencePenalty
final CompletionCreateParams.Body.Builder presencePenalty(Double presencePenalty)
Alias for Builder.presencePenalty.
This unboxed primitive overload exists for backwards compatibility.
-
presencePenalty
final CompletionCreateParams.Body.Builder presencePenalty(Optional<Double> presencePenalty)
Alias for calling Builder.presencePenalty with
presencePenalty.orElse(null)
.
-
presencePenalty
final CompletionCreateParams.Body.Builder presencePenalty(JsonField<Double> presencePenalty)
Sets Builder.presencePenalty to an arbitrary JSON value.
You should usually call Builder.presencePenalty with a well-typed Double value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
seed
final CompletionCreateParams.Body.Builder seed(Long seed)
If specified, our system will make a 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
system_fingerprint
response parameter to monitor changes in the backend.
-
seed
final CompletionCreateParams.Body.Builder seed(Long seed)
Alias for Builder.seed.
This unboxed primitive overload exists for backwards compatibility.
-
seed
final CompletionCreateParams.Body.Builder seed(Optional<Long> seed)
Alias for calling Builder.seed with
seed.orElse(null)
.
-
seed
final CompletionCreateParams.Body.Builder seed(JsonField<Long> seed)
Sets Builder.seed to an arbitrary JSON value.
You should usually call Builder.seed with a well-typed Long value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
stop
final CompletionCreateParams.Body.Builder stop(CompletionCreateParams.Stop stop)
Not supported with latest reasoning models
o3
ando4-mini
.Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
-
stop
final CompletionCreateParams.Body.Builder stop(Optional<CompletionCreateParams.Stop> stop)
Alias for calling Builder.stop with
stop.orElse(null)
.
-
stop
final CompletionCreateParams.Body.Builder stop(JsonField<CompletionCreateParams.Stop> stop)
Sets Builder.stop to an arbitrary JSON value.
You should usually call Builder.stop with a well-typed Stop value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
stop
final CompletionCreateParams.Body.Builder stop(String string)
Alias for calling stop with
Stop.ofString(string)
.
-
stopOfStrings
final CompletionCreateParams.Body.Builder stopOfStrings(List<String> strings)
Alias for calling stop with
Stop.ofStrings(strings)
.
-
streamOptions
final CompletionCreateParams.Body.Builder streamOptions(ChatCompletionStreamOptions streamOptions)
Options for streaming response. Only set this when you set
stream: true
.
-
streamOptions
final CompletionCreateParams.Body.Builder streamOptions(Optional<ChatCompletionStreamOptions> streamOptions)
Alias for calling Builder.streamOptions with
streamOptions.orElse(null)
.
-
streamOptions
final CompletionCreateParams.Body.Builder streamOptions(JsonField<ChatCompletionStreamOptions> streamOptions)
Sets Builder.streamOptions to an arbitrary JSON value.
You should usually call Builder.streamOptions with a well-typed ChatCompletionStreamOptions value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
suffix
final CompletionCreateParams.Body.Builder suffix(String suffix)
The suffix that comes after a completion of inserted text.
This parameter is only supported for
gpt-3.5-turbo-instruct
.
-
suffix
final CompletionCreateParams.Body.Builder suffix(Optional<String> suffix)
Alias for calling Builder.suffix with
suffix.orElse(null)
.
-
suffix
final CompletionCreateParams.Body.Builder suffix(JsonField<String> suffix)
Sets Builder.suffix to an arbitrary JSON value.
You should usually call Builder.suffix with a well-typed String value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
temperature
final CompletionCreateParams.Body.Builder temperature(Double temperature)
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.
We generally recommend altering this or
top_p
but not both.
-
temperature
final CompletionCreateParams.Body.Builder temperature(Double temperature)
Alias for Builder.temperature.
This unboxed primitive overload exists for backwards compatibility.
-
temperature
final CompletionCreateParams.Body.Builder temperature(Optional<Double> temperature)
Alias for calling Builder.temperature with
temperature.orElse(null)
.
-
temperature
final CompletionCreateParams.Body.Builder temperature(JsonField<Double> temperature)
Sets Builder.temperature to an arbitrary JSON value.
You should usually call Builder.temperature with a well-typed Double value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
topP
final CompletionCreateParams.Body.Builder topP(Double topP)
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.
We generally recommend altering this or
temperature
but not both.
-
topP
final CompletionCreateParams.Body.Builder topP(Double topP)
Alias for Builder.topP.
This unboxed primitive overload exists for backwards compatibility.
-
topP
final CompletionCreateParams.Body.Builder topP(Optional<Double> topP)
Alias for calling Builder.topP with
topP.orElse(null)
.
-
topP
final CompletionCreateParams.Body.Builder topP(JsonField<Double> topP)
Sets Builder.topP to an arbitrary JSON value.
You should usually call Builder.topP with a well-typed Double value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
user
final CompletionCreateParams.Body.Builder user(String user)
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.
-
user
final CompletionCreateParams.Body.Builder user(JsonField<String> user)
Sets Builder.user to an arbitrary JSON value.
You should usually call Builder.user with a well-typed String value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
additionalProperties
final CompletionCreateParams.Body.Builder additionalProperties(Map<String, JsonValue> additionalProperties)
-
putAdditionalProperty
final CompletionCreateParams.Body.Builder putAdditionalProperty(String key, JsonValue value)
-
putAllAdditionalProperties
final CompletionCreateParams.Body.Builder putAllAdditionalProperties(Map<String, JsonValue> additionalProperties)
-
removeAdditionalProperty
final CompletionCreateParams.Body.Builder removeAdditionalProperty(String key)
-
removeAllAdditionalProperties
final CompletionCreateParams.Body.Builder removeAllAdditionalProperties(Set<String> keys)
-
build
final CompletionCreateParams.Body build()
Returns an immutable instance of Body.
Further updates to this Builder will not mutate the returned instance.
The following fields are required:
.model() .prompt()
-
-
-
-