Class ChatCompletionCreateParams.Builder
-
- All Implemented Interfaces:
public final class ChatCompletionCreateParams.Builder
A builder for ChatCompletionCreateParams.
-
-
Method Summary
-
-
Method Detail
-
body
final ChatCompletionCreateParams.Builder body(ChatCompletionCreateParams.Body body)
Sets the entire request body.
This is generally only useful if you are already constructing the body separately. Otherwise, it's more convenient to use the top-level setters instead:
-
messages
final ChatCompletionCreateParams.Builder messages(List<ChatCompletionMessageParam> messages)
A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, images, and audio.
-
messages
final ChatCompletionCreateParams.Builder messages(JsonField<List<ChatCompletionMessageParam>> messages)
Sets Builder.messages to an arbitrary JSON value.
You should usually call Builder.messages with a well-typed
List<ChatCompletionMessageParam>
value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
addMessage
final ChatCompletionCreateParams.Builder addMessage(ChatCompletionMessageParam message)
Adds a single ChatCompletionMessageParam to messages.
-
addMessage
final ChatCompletionCreateParams.Builder addMessage(ChatCompletionDeveloperMessageParam developer)
Alias for calling addMessage with
ChatCompletionMessageParam.ofDeveloper(developer)
.
-
addMessage
final ChatCompletionCreateParams.Builder addMessage(ChatCompletionSystemMessageParam system)
Alias for calling addMessage with
ChatCompletionMessageParam.ofSystem(system)
.
-
addMessage
final ChatCompletionCreateParams.Builder addMessage(ChatCompletionUserMessageParam user)
Alias for calling addMessage with
ChatCompletionMessageParam.ofUser(user)
.
-
addMessage
final ChatCompletionCreateParams.Builder addMessage(ChatCompletionAssistantMessageParam assistant)
Alias for calling addMessage with
ChatCompletionMessageParam.ofAssistant(assistant)
.
-
addMessage
final ChatCompletionCreateParams.Builder addMessage(ChatCompletionMessage assistant)
Alias for calling addMessage with
assistant.toParam()
.
-
addMessage
final ChatCompletionCreateParams.Builder addMessage(ChatCompletionToolMessageParam tool)
Alias for calling addMessage with
ChatCompletionMessageParam.ofTool(tool)
.
-
addMessage
@Deprecated(message = "deprecated") final ChatCompletionCreateParams.Builder addMessage(ChatCompletionFunctionMessageParam function)
Alias for calling addMessage with
ChatCompletionMessageParam.ofFunction(function)
.
-
addDeveloperMessage
final ChatCompletionCreateParams.Builder addDeveloperMessage(ChatCompletionDeveloperMessageParam.Content content)
Alias for calling addMessage with the following:
ChatCompletionDeveloperMessageParam.builder() .content(content) .build()
-
addDeveloperMessage
final ChatCompletionCreateParams.Builder addDeveloperMessage(String text)
Alias for calling addDeveloperMessage with
ChatCompletionDeveloperMessageParam.Content.ofText(text)
.
-
addDeveloperMessageOfArrayOfContentParts
final ChatCompletionCreateParams.Builder addDeveloperMessageOfArrayOfContentParts(List<ChatCompletionContentPartText> arrayOfContentParts)
Alias for calling addDeveloperMessage with
ChatCompletionDeveloperMessageParam.Content.ofArrayOfContentParts(arrayOfContentParts)
.
-
addSystemMessage
final ChatCompletionCreateParams.Builder addSystemMessage(ChatCompletionSystemMessageParam.Content content)
Alias for calling addMessage with the following:
ChatCompletionSystemMessageParam.builder() .content(content) .build()
-
addSystemMessage
final ChatCompletionCreateParams.Builder addSystemMessage(String text)
Alias for calling addSystemMessage with
ChatCompletionSystemMessageParam.Content.ofText(text)
.
-
addSystemMessageOfArrayOfContentParts
final ChatCompletionCreateParams.Builder addSystemMessageOfArrayOfContentParts(List<ChatCompletionContentPartText> arrayOfContentParts)
Alias for calling addSystemMessage with
ChatCompletionSystemMessageParam.Content.ofArrayOfContentParts(arrayOfContentParts)
.
-
addUserMessage
final ChatCompletionCreateParams.Builder addUserMessage(ChatCompletionUserMessageParam.Content content)
Alias for calling addMessage with the following:
ChatCompletionUserMessageParam.builder() .content(content) .build()
-
addUserMessage
final ChatCompletionCreateParams.Builder addUserMessage(String text)
Alias for calling addUserMessage with
ChatCompletionUserMessageParam.Content.ofText(text)
.
-
addUserMessageOfArrayOfContentParts
final ChatCompletionCreateParams.Builder addUserMessageOfArrayOfContentParts(List<ChatCompletionContentPart> arrayOfContentParts)
Alias for calling addUserMessage with
ChatCompletionUserMessageParam.Content.ofArrayOfContentParts(arrayOfContentParts)
.
-
model
final ChatCompletionCreateParams.Builder model(ChatModel model)
Model ID used to generate the response, like
gpt-4o
oro3
. OpenAI offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the model guide to browse and compare available models.
-
model
final ChatCompletionCreateParams.Builder model(JsonField<ChatModel> model)
Sets Builder.model to an arbitrary JSON value.
You should usually call Builder.model with a well-typed ChatModel value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
model
final ChatCompletionCreateParams.Builder model(String value)
Sets model to an arbitrary String.
You should usually call model with a well-typed ChatModel constant instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
audio
final ChatCompletionCreateParams.Builder audio(ChatCompletionAudioParam audio)
Parameters for audio output. Required when audio output is requested with
modalities: ["audio"]
. Learn more.
-
audio
final ChatCompletionCreateParams.Builder audio(Optional<ChatCompletionAudioParam> audio)
Alias for calling Builder.audio with
audio.orElse(null)
.
-
audio
final ChatCompletionCreateParams.Builder audio(JsonField<ChatCompletionAudioParam> audio)
Sets Builder.audio to an arbitrary JSON value.
You should usually call Builder.audio with a well-typed ChatCompletionAudioParam value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
frequencyPenalty
final ChatCompletionCreateParams.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.
-
frequencyPenalty
final ChatCompletionCreateParams.Builder frequencyPenalty(Double frequencyPenalty)
Alias for Builder.frequencyPenalty.
This unboxed primitive overload exists for backwards compatibility.
-
frequencyPenalty
final ChatCompletionCreateParams.Builder frequencyPenalty(Optional<Double> frequencyPenalty)
Alias for calling Builder.frequencyPenalty with
frequencyPenalty.orElse(null)
.
-
frequencyPenalty
final ChatCompletionCreateParams.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.
-
functionCall
@Deprecated(message = "deprecated") final ChatCompletionCreateParams.Builder functionCall(ChatCompletionCreateParams.FunctionCall functionCall)
Deprecated in favor of
tool_choice
.Controls which (if any) function is called by the model.
none
means the model will not call a function and instead generates a message.auto
means the model can pick between generating a message or calling a function.Specifying a particular function via
{"name": "my_function"}
forces the model to call that function.none
is the default when no functions are present.auto
is the default if functions are present.
-
functionCall
@Deprecated(message = "deprecated") final ChatCompletionCreateParams.Builder functionCall(JsonField<ChatCompletionCreateParams.FunctionCall> functionCall)
Sets Builder.functionCall to an arbitrary JSON value.
You should usually call Builder.functionCall with a well-typed FunctionCall value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
functionCall
@Deprecated(message = "deprecated") final ChatCompletionCreateParams.Builder functionCall(ChatCompletionCreateParams.FunctionCall.FunctionCallMode mode)
Alias for calling functionCall with
FunctionCall.ofMode(mode)
.
-
functionCall
@Deprecated(message = "deprecated") final ChatCompletionCreateParams.Builder functionCall(ChatCompletionFunctionCallOption functionCallOption)
Alias for calling functionCall with
FunctionCall.ofFunctionCallOption(functionCallOption)
.
-
functions
@Deprecated(message = "deprecated") final ChatCompletionCreateParams.Builder functions(List<ChatCompletionCreateParams.Function> functions)
Deprecated in favor of
tools
.A list of functions the model may generate JSON inputs for.
-
functions
@Deprecated(message = "deprecated") final ChatCompletionCreateParams.Builder functions(JsonField<List<ChatCompletionCreateParams.Function>> functions)
Sets Builder.functions to an arbitrary JSON value.
You should usually call Builder.functions with a well-typed
List<Function>
value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
addFunction
@Deprecated(message = "deprecated") final ChatCompletionCreateParams.Builder addFunction(ChatCompletionCreateParams.Function function)
-
logitBias
final ChatCompletionCreateParams.Builder logitBias(ChatCompletionCreateParams.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 tokenizer) to an associated bias value from -100 to 100. 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.
-
logitBias
final ChatCompletionCreateParams.Builder logitBias(Optional<ChatCompletionCreateParams.LogitBias> logitBias)
Alias for calling Builder.logitBias with
logitBias.orElse(null)
.
-
logitBias
final ChatCompletionCreateParams.Builder logitBias(JsonField<ChatCompletionCreateParams.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 ChatCompletionCreateParams.Builder logprobs(Boolean logprobs)
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
ofmessage
.
-
logprobs
final ChatCompletionCreateParams.Builder logprobs(Boolean logprobs)
Alias for Builder.logprobs.
This unboxed primitive overload exists for backwards compatibility.
-
logprobs
final ChatCompletionCreateParams.Builder logprobs(Optional<Boolean> logprobs)
Alias for calling Builder.logprobs with
logprobs.orElse(null)
.
-
logprobs
final ChatCompletionCreateParams.Builder logprobs(JsonField<Boolean> logprobs)
Sets Builder.logprobs to an arbitrary JSON value.
You should usually call Builder.logprobs with a well-typed Boolean value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
maxCompletionTokens
final ChatCompletionCreateParams.Builder maxCompletionTokens(Long maxCompletionTokens)
An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.
-
maxCompletionTokens
final ChatCompletionCreateParams.Builder maxCompletionTokens(Long maxCompletionTokens)
Alias for Builder.maxCompletionTokens.
This unboxed primitive overload exists for backwards compatibility.
-
maxCompletionTokens
final ChatCompletionCreateParams.Builder maxCompletionTokens(Optional<Long> maxCompletionTokens)
Alias for calling Builder.maxCompletionTokens with
maxCompletionTokens.orElse(null)
.
-
maxCompletionTokens
final ChatCompletionCreateParams.Builder maxCompletionTokens(JsonField<Long> maxCompletionTokens)
Sets Builder.maxCompletionTokens to an arbitrary JSON value.
You should usually call Builder.maxCompletionTokens with a well-typed Long value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
maxTokens
@Deprecated(message = "deprecated") final ChatCompletionCreateParams.Builder maxTokens(Long maxTokens)
The maximum number of /tokenizer that can be generated in the chat completion. This value can be used to control costs for text generated via API.
This value is now deprecated in favor of
max_completion_tokens
, and is not compatible with o-series models.
-
maxTokens
@Deprecated(message = "deprecated") final ChatCompletionCreateParams.Builder maxTokens(Long maxTokens)
Alias for Builder.maxTokens.
This unboxed primitive overload exists for backwards compatibility.
-
maxTokens
@Deprecated(message = "deprecated") final ChatCompletionCreateParams.Builder maxTokens(Optional<Long> maxTokens)
Alias for calling Builder.maxTokens with
maxTokens.orElse(null)
.
-
maxTokens
@Deprecated(message = "deprecated") final ChatCompletionCreateParams.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.
-
metadata
final ChatCompletionCreateParams.Builder metadata(ChatCompletionCreateParams.Metadata metadata)
Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
-
metadata
final ChatCompletionCreateParams.Builder metadata(Optional<ChatCompletionCreateParams.Metadata> metadata)
Alias for calling Builder.metadata with
metadata.orElse(null)
.
-
metadata
final ChatCompletionCreateParams.Builder metadata(JsonField<ChatCompletionCreateParams.Metadata> metadata)
Sets Builder.metadata to an arbitrary JSON value.
You should usually call Builder.metadata with a well-typed Metadata value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
modalities
final ChatCompletionCreateParams.Builder modalities(List<ChatCompletionCreateParams.Modality> modalities)
Output types that you would like the model to generate. Most models are capable of generating text, which is the default:
["text"]
The
gpt-4o-audio-preview
model can also be used to generate audio. To request that this model generate both text and audio responses, you can use:["text", "audio"]
-
modalities
final ChatCompletionCreateParams.Builder modalities(Optional<List<ChatCompletionCreateParams.Modality>> modalities)
Alias for calling Builder.modalities with
modalities.orElse(null)
.
-
modalities
final ChatCompletionCreateParams.Builder modalities(JsonField<List<ChatCompletionCreateParams.Modality>> modalities)
Sets Builder.modalities to an arbitrary JSON value.
You should usually call Builder.modalities with a well-typed
List<Modality>
value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
addModality
final ChatCompletionCreateParams.Builder addModality(ChatCompletionCreateParams.Modality modality)
Adds a single Modality to modalities.
-
n
final ChatCompletionCreateParams.Builder n(Long n)
How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep
n
as1
to minimize costs.
-
n
final ChatCompletionCreateParams.Builder n(Long n)
Alias for Builder.n.
This unboxed primitive overload exists for backwards compatibility.
-
n
final ChatCompletionCreateParams.Builder n(Optional<Long> n)
Alias for calling Builder.n with
n.orElse(null)
.
-
n
final ChatCompletionCreateParams.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.
-
parallelToolCalls
final ChatCompletionCreateParams.Builder parallelToolCalls(Boolean parallelToolCalls)
Whether to enable parallel function calling during tool use.
-
parallelToolCalls
final ChatCompletionCreateParams.Builder parallelToolCalls(JsonField<Boolean> parallelToolCalls)
Sets Builder.parallelToolCalls to an arbitrary JSON value.
You should usually call Builder.parallelToolCalls with a well-typed Boolean value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
prediction
final ChatCompletionCreateParams.Builder prediction(ChatCompletionPredictionContent prediction)
Static predicted output content, such as the content of a text file that is being regenerated.
-
prediction
final ChatCompletionCreateParams.Builder prediction(Optional<ChatCompletionPredictionContent> prediction)
Alias for calling Builder.prediction with
prediction.orElse(null)
.
-
prediction
final ChatCompletionCreateParams.Builder prediction(JsonField<ChatCompletionPredictionContent> prediction)
Sets Builder.prediction to an arbitrary JSON value.
You should usually call Builder.prediction with a well-typed ChatCompletionPredictionContent value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
presencePenalty
final ChatCompletionCreateParams.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.
-
presencePenalty
final ChatCompletionCreateParams.Builder presencePenalty(Double presencePenalty)
Alias for Builder.presencePenalty.
This unboxed primitive overload exists for backwards compatibility.
-
presencePenalty
final ChatCompletionCreateParams.Builder presencePenalty(Optional<Double> presencePenalty)
Alias for calling Builder.presencePenalty with
presencePenalty.orElse(null)
.
-
presencePenalty
final ChatCompletionCreateParams.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.
-
reasoningEffort
final ChatCompletionCreateParams.Builder reasoningEffort(ReasoningEffort reasoningEffort)
o-series models only
Constrains effort on reasoning for reasoning models. Currently supported values are
low
,medium
, andhigh
. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.
-
reasoningEffort
final ChatCompletionCreateParams.Builder reasoningEffort(Optional<ReasoningEffort> reasoningEffort)
Alias for calling Builder.reasoningEffort with
reasoningEffort.orElse(null)
.
-
reasoningEffort
final ChatCompletionCreateParams.Builder reasoningEffort(JsonField<ReasoningEffort> reasoningEffort)
Sets Builder.reasoningEffort to an arbitrary JSON value.
You should usually call Builder.reasoningEffort with a well-typed ReasoningEffort value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
responseFormat
final ChatCompletionCreateParams.Builder responseFormat(ChatCompletionCreateParams.ResponseFormat responseFormat)
An object specifying the format that the model must output.
Setting to
{ "type": "json_schema", "json_schema": {...} }
enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the Structured Outputs guide.Setting to
{ "type": "json_object" }
enables the older JSON mode, which ensures the message the model generates is valid JSON. Usingjson_schema
is preferred for models that support it.
-
responseFormat
final ChatCompletionCreateParams.Builder responseFormat(JsonField<ChatCompletionCreateParams.ResponseFormat> responseFormat)
Sets Builder.responseFormat to an arbitrary JSON value.
You should usually call Builder.responseFormat with a well-typed ResponseFormat value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
responseFormat
final ChatCompletionCreateParams.Builder responseFormat(ResponseFormatText text)
Alias for calling responseFormat with
ResponseFormat.ofText(text)
.
-
responseFormat
final ChatCompletionCreateParams.Builder responseFormat(ResponseFormatJsonSchema jsonSchema)
Alias for calling responseFormat with
ResponseFormat.ofJsonSchema(jsonSchema)
.
-
responseFormat
final ChatCompletionCreateParams.Builder responseFormat(ResponseFormatJsonObject jsonObject)
Alias for calling responseFormat with
ResponseFormat.ofJsonObject(jsonObject)
.
-
responseFormat
@JvmOverloads() final <T extends Any> StructuredChatCompletionCreateParams.Builder<T> responseFormat(Class<T> responseType, JsonSchemaLocalValidation localValidation)
Sets the response format to a JSON schema derived from the structure of the given class. This changes the builder to a type-safe StructuredChatCompletionCreateParams.Builder that will build a StructuredChatCompletionCreateParams instance when
build()
is called.- Parameters:
responseType
- A class from which a JSON schema will be derived to define the response format.localValidation
- com.openai.core.JsonSchemaLocalValidation.YES (the default) to validate the JSON schema locally when it is generated by this method to confirm that it adheres to the requirements and restrictions on JSON schemas imposed by the OpenAI specification; or com.openai.core.JsonSchemaLocalValidation.NO to skip local validation and rely only on remote validation.
-
responseFormat
@JvmOverloads() final <T extends Any> StructuredChatCompletionCreateParams.Builder<T> responseFormat(Class<T> responseType)
Sets the response format to a JSON schema derived from the structure of the given class. This changes the builder to a type-safe StructuredChatCompletionCreateParams.Builder that will build a StructuredChatCompletionCreateParams instance when
build()
is called.- Parameters:
responseType
- A class from which a JSON schema will be derived to define the response format.
-
seed
final ChatCompletionCreateParams.Builder seed(Long seed)
This feature is in Beta. 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 thesystem_fingerprint
response parameter to monitor changes in the backend.
-
seed
final ChatCompletionCreateParams.Builder seed(Long seed)
Alias for Builder.seed.
This unboxed primitive overload exists for backwards compatibility.
-
seed
final ChatCompletionCreateParams.Builder seed(Optional<Long> seed)
Alias for calling Builder.seed with
seed.orElse(null)
.
-
seed
final ChatCompletionCreateParams.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.
-
serviceTier
final ChatCompletionCreateParams.Builder serviceTier(ChatCompletionCreateParams.ServiceTier serviceTier)
Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service:
If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted.
If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee.
If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee.
If set to 'flex', the request will be processed with the Flex Processing service tier. Learn more.
When not set, the default behavior is 'auto'.
When this parameter is set, the response body will include the
service_tier
utilized.
-
serviceTier
final ChatCompletionCreateParams.Builder serviceTier(Optional<ChatCompletionCreateParams.ServiceTier> serviceTier)
Alias for calling Builder.serviceTier with
serviceTier.orElse(null)
.
-
serviceTier
final ChatCompletionCreateParams.Builder serviceTier(JsonField<ChatCompletionCreateParams.ServiceTier> serviceTier)
Sets Builder.serviceTier to an arbitrary JSON value.
You should usually call Builder.serviceTier with a well-typed ServiceTier value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
stop
final ChatCompletionCreateParams.Builder stop(ChatCompletionCreateParams.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 ChatCompletionCreateParams.Builder stop(Optional<ChatCompletionCreateParams.Stop> stop)
Alias for calling Builder.stop with
stop.orElse(null)
.
-
stop
final ChatCompletionCreateParams.Builder stop(JsonField<ChatCompletionCreateParams.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 ChatCompletionCreateParams.Builder stop(String string)
Alias for calling stop with
Stop.ofString(string)
.
-
stopOfStrings
final ChatCompletionCreateParams.Builder stopOfStrings(List<String> strings)
Alias for calling stop with
Stop.ofStrings(strings)
.
-
store
final ChatCompletionCreateParams.Builder store(Boolean store)
Whether or not to store the output of this chat completion request for use in our model distillation or evals products.
-
store
final ChatCompletionCreateParams.Builder store(Boolean store)
Alias for Builder.store.
This unboxed primitive overload exists for backwards compatibility.
-
store
final ChatCompletionCreateParams.Builder store(Optional<Boolean> store)
Alias for calling Builder.store with
store.orElse(null)
.
-
store
final ChatCompletionCreateParams.Builder store(JsonField<Boolean> store)
Sets Builder.store to an arbitrary JSON value.
You should usually call Builder.store with a well-typed Boolean value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
streamOptions
final ChatCompletionCreateParams.Builder streamOptions(ChatCompletionStreamOptions streamOptions)
Options for streaming response. Only set this when you set
stream: true
.
-
streamOptions
final ChatCompletionCreateParams.Builder streamOptions(Optional<ChatCompletionStreamOptions> streamOptions)
Alias for calling Builder.streamOptions with
streamOptions.orElse(null)
.
-
streamOptions
final ChatCompletionCreateParams.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.
-
temperature
final ChatCompletionCreateParams.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 ChatCompletionCreateParams.Builder temperature(Double temperature)
Alias for Builder.temperature.
This unboxed primitive overload exists for backwards compatibility.
-
temperature
final ChatCompletionCreateParams.Builder temperature(Optional<Double> temperature)
Alias for calling Builder.temperature with
temperature.orElse(null)
.
-
temperature
final ChatCompletionCreateParams.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.
-
toolChoice
final ChatCompletionCreateParams.Builder toolChoice(ChatCompletionToolChoiceOption toolChoice)
Controls which (if any) tool is called by the model.
none
means the model will not call any tool and instead generates a message.auto
means the model can pick between generating a message or calling one or more tools.required
means the model must call one or more tools. Specifying a particular tool via{"type": "function", "function": {"name": "my_function"}}
forces the model to call that tool.none
is the default when no tools are present.auto
is the default if tools are present.
-
toolChoice
final ChatCompletionCreateParams.Builder toolChoice(JsonField<ChatCompletionToolChoiceOption> toolChoice)
Sets Builder.toolChoice to an arbitrary JSON value.
You should usually call Builder.toolChoice with a well-typed ChatCompletionToolChoiceOption value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
toolChoice
final ChatCompletionCreateParams.Builder toolChoice(ChatCompletionToolChoiceOption.Auto auto)
Alias for calling toolChoice with
ChatCompletionToolChoiceOption.ofAuto(auto)
.
-
toolChoice
final ChatCompletionCreateParams.Builder toolChoice(ChatCompletionNamedToolChoice namedToolChoice)
Alias for calling toolChoice with
ChatCompletionToolChoiceOption.ofNamedToolChoice(namedToolChoice)
.
-
tools
final ChatCompletionCreateParams.Builder tools(List<ChatCompletionTool> tools)
A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported.
-
tools
final ChatCompletionCreateParams.Builder tools(JsonField<List<ChatCompletionTool>> tools)
Sets Builder.tools to an arbitrary JSON value.
You should usually call Builder.tools with a well-typed
List<ChatCompletionTool>
value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
addTool
final ChatCompletionCreateParams.Builder addTool(ChatCompletionTool tool)
Adds a single ChatCompletionTool to tools.
-
topLogprobs
final ChatCompletionCreateParams.Builder topLogprobs(Long topLogprobs)
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 totrue
if this parameter is used.
-
topLogprobs
final ChatCompletionCreateParams.Builder topLogprobs(Long topLogprobs)
Alias for Builder.topLogprobs.
This unboxed primitive overload exists for backwards compatibility.
-
topLogprobs
final ChatCompletionCreateParams.Builder topLogprobs(Optional<Long> topLogprobs)
Alias for calling Builder.topLogprobs with
topLogprobs.orElse(null)
.
-
topLogprobs
final ChatCompletionCreateParams.Builder topLogprobs(JsonField<Long> topLogprobs)
Sets Builder.topLogprobs to an arbitrary JSON value.
You should usually call Builder.topLogprobs with a well-typed Long value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
topP
final ChatCompletionCreateParams.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 ChatCompletionCreateParams.Builder topP(Double topP)
Alias for Builder.topP.
This unboxed primitive overload exists for backwards compatibility.
-
topP
final ChatCompletionCreateParams.Builder topP(Optional<Double> topP)
Alias for calling Builder.topP with
topP.orElse(null)
.
-
topP
final ChatCompletionCreateParams.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 ChatCompletionCreateParams.Builder user(String user)
A stable identifier for your end-users. Used to boost cache hit rates by better bucketing similar requests and to help OpenAI detect and prevent abuse. Learn more.
-
user
final ChatCompletionCreateParams.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.
-
webSearchOptions
final ChatCompletionCreateParams.Builder webSearchOptions(ChatCompletionCreateParams.WebSearchOptions webSearchOptions)
This tool searches the web for relevant results to use in a response. Learn more about the web search tool.
-
webSearchOptions
final ChatCompletionCreateParams.Builder webSearchOptions(JsonField<ChatCompletionCreateParams.WebSearchOptions> webSearchOptions)
Sets Builder.webSearchOptions to an arbitrary JSON value.
You should usually call Builder.webSearchOptions with a well-typed WebSearchOptions value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
additionalBodyProperties
final ChatCompletionCreateParams.Builder additionalBodyProperties(Map<String, JsonValue> additionalBodyProperties)
-
putAdditionalBodyProperty
final ChatCompletionCreateParams.Builder putAdditionalBodyProperty(String key, JsonValue value)
-
putAllAdditionalBodyProperties
final ChatCompletionCreateParams.Builder putAllAdditionalBodyProperties(Map<String, JsonValue> additionalBodyProperties)
-
removeAdditionalBodyProperty
final ChatCompletionCreateParams.Builder removeAdditionalBodyProperty(String key)
-
removeAllAdditionalBodyProperties
final ChatCompletionCreateParams.Builder removeAllAdditionalBodyProperties(Set<String> keys)
-
additionalHeaders
final ChatCompletionCreateParams.Builder additionalHeaders(Headers additionalHeaders)
-
additionalHeaders
final ChatCompletionCreateParams.Builder additionalHeaders(Map<String, Iterable<String>> additionalHeaders)
-
putAdditionalHeader
final ChatCompletionCreateParams.Builder putAdditionalHeader(String name, String value)
-
putAdditionalHeaders
final ChatCompletionCreateParams.Builder putAdditionalHeaders(String name, Iterable<String> values)
-
putAllAdditionalHeaders
final ChatCompletionCreateParams.Builder putAllAdditionalHeaders(Headers additionalHeaders)
-
putAllAdditionalHeaders
final ChatCompletionCreateParams.Builder putAllAdditionalHeaders(Map<String, Iterable<String>> additionalHeaders)
-
replaceAdditionalHeaders
final ChatCompletionCreateParams.Builder replaceAdditionalHeaders(String name, String value)
-
replaceAdditionalHeaders
final ChatCompletionCreateParams.Builder replaceAdditionalHeaders(String name, Iterable<String> values)
-
replaceAllAdditionalHeaders
final ChatCompletionCreateParams.Builder replaceAllAdditionalHeaders(Headers additionalHeaders)
-
replaceAllAdditionalHeaders
final ChatCompletionCreateParams.Builder replaceAllAdditionalHeaders(Map<String, Iterable<String>> additionalHeaders)
-
removeAdditionalHeaders
final ChatCompletionCreateParams.Builder removeAdditionalHeaders(String name)
-
removeAllAdditionalHeaders
final ChatCompletionCreateParams.Builder removeAllAdditionalHeaders(Set<String> names)
-
additionalQueryParams
final ChatCompletionCreateParams.Builder additionalQueryParams(QueryParams additionalQueryParams)
-
additionalQueryParams
final ChatCompletionCreateParams.Builder additionalQueryParams(Map<String, Iterable<String>> additionalQueryParams)
-
putAdditionalQueryParam
final ChatCompletionCreateParams.Builder putAdditionalQueryParam(String key, String value)
-
putAdditionalQueryParams
final ChatCompletionCreateParams.Builder putAdditionalQueryParams(String key, Iterable<String> values)
-
putAllAdditionalQueryParams
final ChatCompletionCreateParams.Builder putAllAdditionalQueryParams(QueryParams additionalQueryParams)
-
putAllAdditionalQueryParams
final ChatCompletionCreateParams.Builder putAllAdditionalQueryParams(Map<String, Iterable<String>> additionalQueryParams)
-
replaceAdditionalQueryParams
final ChatCompletionCreateParams.Builder replaceAdditionalQueryParams(String key, String value)
-
replaceAdditionalQueryParams
final ChatCompletionCreateParams.Builder replaceAdditionalQueryParams(String key, Iterable<String> values)
-
replaceAllAdditionalQueryParams
final ChatCompletionCreateParams.Builder replaceAllAdditionalQueryParams(QueryParams additionalQueryParams)
-
replaceAllAdditionalQueryParams
final ChatCompletionCreateParams.Builder replaceAllAdditionalQueryParams(Map<String, Iterable<String>> additionalQueryParams)
-
removeAdditionalQueryParams
final ChatCompletionCreateParams.Builder removeAdditionalQueryParams(String key)
-
removeAllAdditionalQueryParams
final ChatCompletionCreateParams.Builder removeAllAdditionalQueryParams(Set<String> keys)
-
build
final ChatCompletionCreateParams build()
Returns an immutable instance of ChatCompletionCreateParams.
Further updates to this Builder will not mutate the returned instance.
The following fields are required:
.messages() .model()
-
-
-
-