Class ResponseCreateParams.Builder
-
- All Implemented Interfaces:
public final class ResponseCreateParams.Builder
A builder for ResponseCreateParams.
-
-
Method Summary
-
-
Method Detail
-
body
final ResponseCreateParams.Builder body(ResponseCreateParams.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:
-
input
final ResponseCreateParams.Builder input(ResponseCreateParams.Input input)
Text, image, or file inputs to the model, used to generate a response.
Learn more:
-
input
final ResponseCreateParams.Builder input(JsonField<ResponseCreateParams.Input> input)
Sets Builder.input to an arbitrary JSON value.
You should usually call Builder.input with a well-typed Input value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
input
final ResponseCreateParams.Builder input(String text)
Alias for calling input with
Input.ofText(text)
.
-
inputOfResponse
final ResponseCreateParams.Builder inputOfResponse(List<ResponseInputItem> response)
Alias for calling input with
Input.ofResponse(response)
.
-
model
final ResponseCreateParams.Builder model(ResponsesModel 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 ResponseCreateParams.Builder model(JsonField<ResponsesModel> model)
Sets Builder.model to an arbitrary JSON value.
You should usually call Builder.model with a well-typed ResponsesModel value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
model
final ResponseCreateParams.Builder model(String string)
Alias for calling model with
ResponsesModel.ofString(string)
.
-
model
final ResponseCreateParams.Builder model(ChatModel chat)
Alias for calling model with
ResponsesModel.ofChat(chat)
.
-
model
final ResponseCreateParams.Builder model(ResponsesModel.ResponsesOnlyModel only)
Alias for calling model with
ResponsesModel.ofOnly(only)
.
-
include
final ResponseCreateParams.Builder include(List<ResponseIncludable> include)
Specify additional output data to include in the model response. Currently supported values are:
file_search_call.results
: Include the search results of the file search tool call.message.input_image.image_url
: Include image urls from the input message.computer_call_output.output.image_url
: Include image urls from the computer call output.reasoning.encrypted_content
: Includes an encrypted version of reasoning tokens in reasoning item outputs. This enables reasoning items to be used in multi-turn conversations when using the Responses API statelessly (like when thestore
parameter is set tofalse
, or when an organization is enrolled in the zero data retention program).
-
include
final ResponseCreateParams.Builder include(Optional<List<ResponseIncludable>> include)
Alias for calling Builder.include with
include.orElse(null)
.
-
include
final ResponseCreateParams.Builder include(JsonField<List<ResponseIncludable>> include)
Sets Builder.include to an arbitrary JSON value.
You should usually call Builder.include with a well-typed
List<ResponseIncludable>
value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
addInclude
final ResponseCreateParams.Builder addInclude(ResponseIncludable include)
Adds a single ResponseIncludable to Builder.include.
-
instructions
final ResponseCreateParams.Builder instructions(String instructions)
Inserts a system (or developer) message as the first item in the model's context.
When using along with
previous_response_id
, the instructions from a previous response will not be carried over to the next response. This makes it simple to swap out system (or developer) messages in new responses.
-
instructions
final ResponseCreateParams.Builder instructions(Optional<String> instructions)
Alias for calling Builder.instructions with
instructions.orElse(null)
.
-
instructions
final ResponseCreateParams.Builder instructions(JsonField<String> instructions)
Sets Builder.instructions to an arbitrary JSON value.
You should usually call Builder.instructions with a well-typed String value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
maxOutputTokens
final ResponseCreateParams.Builder maxOutputTokens(Long maxOutputTokens)
An upper bound for the number of tokens that can be generated for a response, including visible output tokens and reasoning tokens.
-
maxOutputTokens
final ResponseCreateParams.Builder maxOutputTokens(Long maxOutputTokens)
Alias for Builder.maxOutputTokens.
This unboxed primitive overload exists for backwards compatibility.
-
maxOutputTokens
final ResponseCreateParams.Builder maxOutputTokens(Optional<Long> maxOutputTokens)
Alias for calling Builder.maxOutputTokens with
maxOutputTokens.orElse(null)
.
-
maxOutputTokens
final ResponseCreateParams.Builder maxOutputTokens(JsonField<Long> maxOutputTokens)
Sets Builder.maxOutputTokens to an arbitrary JSON value.
You should usually call Builder.maxOutputTokens 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 ResponseCreateParams.Builder metadata(ResponseCreateParams.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 ResponseCreateParams.Builder metadata(Optional<ResponseCreateParams.Metadata> metadata)
Alias for calling Builder.metadata with
metadata.orElse(null)
.
-
metadata
final ResponseCreateParams.Builder metadata(JsonField<ResponseCreateParams.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.
-
parallelToolCalls
final ResponseCreateParams.Builder parallelToolCalls(Boolean parallelToolCalls)
Whether to allow the model to run tool calls in parallel.
-
parallelToolCalls
final ResponseCreateParams.Builder parallelToolCalls(Boolean parallelToolCalls)
Alias for Builder.parallelToolCalls.
This unboxed primitive overload exists for backwards compatibility.
-
parallelToolCalls
final ResponseCreateParams.Builder parallelToolCalls(Optional<Boolean> parallelToolCalls)
Alias for calling Builder.parallelToolCalls with
parallelToolCalls.orElse(null)
.
-
parallelToolCalls
final ResponseCreateParams.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.
-
previousResponseId
final ResponseCreateParams.Builder previousResponseId(String previousResponseId)
The unique ID of the previous response to the model. Use this to create multi-turn conversations. Learn more about conversation state.
-
previousResponseId
final ResponseCreateParams.Builder previousResponseId(Optional<String> previousResponseId)
Alias for calling Builder.previousResponseId with
previousResponseId.orElse(null)
.
-
previousResponseId
final ResponseCreateParams.Builder previousResponseId(JsonField<String> previousResponseId)
Sets Builder.previousResponseId to an arbitrary JSON value.
You should usually call Builder.previousResponseId with a well-typed String value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
reasoning
final ResponseCreateParams.Builder reasoning(Reasoning reasoning)
o-series models only
Configuration options for reasoning models.
-
reasoning
final ResponseCreateParams.Builder reasoning(Optional<Reasoning> reasoning)
Alias for calling Builder.reasoning with
reasoning.orElse(null)
.
-
reasoning
final ResponseCreateParams.Builder reasoning(JsonField<Reasoning> reasoning)
Sets Builder.reasoning to an arbitrary JSON value.
You should usually call Builder.reasoning with a well-typed Reasoning value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
serviceTier
final ResponseCreateParams.Builder serviceTier(ResponseCreateParams.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 ResponseCreateParams.Builder serviceTier(Optional<ResponseCreateParams.ServiceTier> serviceTier)
Alias for calling Builder.serviceTier with
serviceTier.orElse(null)
.
-
serviceTier
final ResponseCreateParams.Builder serviceTier(JsonField<ResponseCreateParams.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.
-
store
final ResponseCreateParams.Builder store(Boolean store)
Whether to store the generated model response for later retrieval via API.
-
store
final ResponseCreateParams.Builder store(Boolean store)
Alias for Builder.store.
This unboxed primitive overload exists for backwards compatibility.
-
store
final ResponseCreateParams.Builder store(Optional<Boolean> store)
Alias for calling Builder.store with
store.orElse(null)
.
-
store
final ResponseCreateParams.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.
-
temperature
final ResponseCreateParams.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 ResponseCreateParams.Builder temperature(Double temperature)
Alias for Builder.temperature.
This unboxed primitive overload exists for backwards compatibility.
-
temperature
final ResponseCreateParams.Builder temperature(Optional<Double> temperature)
Alias for calling Builder.temperature with
temperature.orElse(null)
.
-
temperature
final ResponseCreateParams.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.
-
text
final ResponseCreateParams.Builder text(ResponseTextConfig text)
Configuration options for a text response from the model. Can be plain text or structured JSON data. Learn more:
-
text
final ResponseCreateParams.Builder text(JsonField<ResponseTextConfig> text)
Sets Builder.text to an arbitrary JSON value.
You should usually call Builder.text with a well-typed ResponseTextConfig value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
text
@JvmOverloads() final <T extends Any> StructuredResponseCreateParams.Builder<T> text(Class<T> responseType, JsonSchemaLocalValidation localValidation)
Sets the text configuration's format to a JSON schema derived from the structure of the given class. This changes the builder to a type-safe StructuredResponseCreateParams.Builder that will build a StructuredResponseCreateParams instance when
build()
is called.- Parameters:
responseType
- A class from which a JSON schema will be derived to define the text configuration's format.localValidation
- 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 JsonSchemaLocalValidation.NO to skip local validation and rely only on remote validation.
-
text
@JvmOverloads() final <T extends Any> StructuredResponseCreateParams.Builder<T> text(Class<T> responseType)
Sets the text configuration's format to a JSON schema derived from the structure of the given class. This changes the builder to a type-safe StructuredResponseCreateParams.Builder that will build a StructuredResponseCreateParams instance when
build()
is called.- Parameters:
responseType
- A class from which a JSON schema will be derived to define the text configuration's format.
-
toolChoice
final ResponseCreateParams.Builder toolChoice(ResponseCreateParams.ToolChoice toolChoice)
How the model should select which tool (or tools) to use when generating a response. See the
tools
parameter to see how to specify which tools the model can call.
-
toolChoice
final ResponseCreateParams.Builder toolChoice(JsonField<ResponseCreateParams.ToolChoice> toolChoice)
Sets Builder.toolChoice to an arbitrary JSON value.
You should usually call Builder.toolChoice with a well-typed ToolChoice value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
toolChoice
final ResponseCreateParams.Builder toolChoice(ToolChoiceOptions options)
Alias for calling toolChoice with
ToolChoice.ofOptions(options)
.
-
toolChoice
final ResponseCreateParams.Builder toolChoice(ToolChoiceTypes types)
Alias for calling toolChoice with
ToolChoice.ofTypes(types)
.
-
toolChoice
final ResponseCreateParams.Builder toolChoice(ToolChoiceFunction function)
Alias for calling toolChoice with
ToolChoice.ofFunction(function)
.
-
tools
final ResponseCreateParams.Builder tools(List<Tool> tools)
An array of tools the model may call while generating a response. You can specify which tool to use by setting the
tool_choice
parameter.The two categories of tools you can provide the model are:
Built-in tools: Tools that are provided by OpenAI that extend the model's capabilities, like web search or file search. Learn more about built-in tools.
Function calls (custom tools): Functions that are defined by you, enabling the model to call your own code. Learn more about function calling.
-
tools
final ResponseCreateParams.Builder tools(JsonField<List<Tool>> tools)
Sets Builder.tools to an arbitrary JSON value.
You should usually call Builder.tools with a well-typed
List<Tool>
value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
addTool
final ResponseCreateParams.Builder addTool(Tool tool)
-
addTool
final ResponseCreateParams.Builder addTool(FileSearchTool fileSearch)
Alias for calling addTool with
Tool.ofFileSearch(fileSearch)
.
-
addTool
final ResponseCreateParams.Builder addTool(FunctionTool function)
Alias for calling addTool with
Tool.ofFunction(function)
.
-
addTool
final ResponseCreateParams.Builder addTool(WebSearchTool webSearch)
Alias for calling addTool with
Tool.ofWebSearch(webSearch)
.
-
addTool
final ResponseCreateParams.Builder addTool(ComputerTool computerUsePreview)
Alias for calling addTool with
Tool.ofComputerUsePreview(computerUsePreview)
.
-
addFileSearchTool
final ResponseCreateParams.Builder addFileSearchTool(List<String> vectorStoreIds)
Alias for calling addTool with the following:
FileSearchTool.builder() .vectorStoreIds(vectorStoreIds) .build()
-
topP
final ResponseCreateParams.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 ResponseCreateParams.Builder topP(Double topP)
Alias for Builder.topP.
This unboxed primitive overload exists for backwards compatibility.
-
topP
final ResponseCreateParams.Builder topP(Optional<Double> topP)
Alias for calling Builder.topP with
topP.orElse(null)
.
-
topP
final ResponseCreateParams.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.
-
truncation
final ResponseCreateParams.Builder truncation(ResponseCreateParams.Truncation truncation)
The truncation strategy to use for the model response.
auto
: If the context of this response and previous ones exceeds the model's context window size, the model will truncate the response to fit the context window by dropping input items in the middle of the conversation.disabled
(default): If a model response will exceed the context window size for a model, the request will fail with a 400 error.
-
truncation
final ResponseCreateParams.Builder truncation(Optional<ResponseCreateParams.Truncation> truncation)
Alias for calling Builder.truncation with
truncation.orElse(null)
.
-
truncation
final ResponseCreateParams.Builder truncation(JsonField<ResponseCreateParams.Truncation> truncation)
Sets Builder.truncation to an arbitrary JSON value.
You should usually call Builder.truncation with a well-typed Truncation value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
user
final ResponseCreateParams.Builder user(String user)
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.
-
user
final ResponseCreateParams.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.
-
additionalBodyProperties
final ResponseCreateParams.Builder additionalBodyProperties(Map<String, JsonValue> additionalBodyProperties)
-
putAdditionalBodyProperty
final ResponseCreateParams.Builder putAdditionalBodyProperty(String key, JsonValue value)
-
putAllAdditionalBodyProperties
final ResponseCreateParams.Builder putAllAdditionalBodyProperties(Map<String, JsonValue> additionalBodyProperties)
-
removeAdditionalBodyProperty
final ResponseCreateParams.Builder removeAdditionalBodyProperty(String key)
-
removeAllAdditionalBodyProperties
final ResponseCreateParams.Builder removeAllAdditionalBodyProperties(Set<String> keys)
-
additionalHeaders
final ResponseCreateParams.Builder additionalHeaders(Headers additionalHeaders)
-
additionalHeaders
final ResponseCreateParams.Builder additionalHeaders(Map<String, Iterable<String>> additionalHeaders)
-
putAdditionalHeader
final ResponseCreateParams.Builder putAdditionalHeader(String name, String value)
-
putAdditionalHeaders
final ResponseCreateParams.Builder putAdditionalHeaders(String name, Iterable<String> values)
-
putAllAdditionalHeaders
final ResponseCreateParams.Builder putAllAdditionalHeaders(Headers additionalHeaders)
-
putAllAdditionalHeaders
final ResponseCreateParams.Builder putAllAdditionalHeaders(Map<String, Iterable<String>> additionalHeaders)
-
replaceAdditionalHeaders
final ResponseCreateParams.Builder replaceAdditionalHeaders(String name, String value)
-
replaceAdditionalHeaders
final ResponseCreateParams.Builder replaceAdditionalHeaders(String name, Iterable<String> values)
-
replaceAllAdditionalHeaders
final ResponseCreateParams.Builder replaceAllAdditionalHeaders(Headers additionalHeaders)
-
replaceAllAdditionalHeaders
final ResponseCreateParams.Builder replaceAllAdditionalHeaders(Map<String, Iterable<String>> additionalHeaders)
-
removeAdditionalHeaders
final ResponseCreateParams.Builder removeAdditionalHeaders(String name)
-
removeAllAdditionalHeaders
final ResponseCreateParams.Builder removeAllAdditionalHeaders(Set<String> names)
-
additionalQueryParams
final ResponseCreateParams.Builder additionalQueryParams(QueryParams additionalQueryParams)
-
additionalQueryParams
final ResponseCreateParams.Builder additionalQueryParams(Map<String, Iterable<String>> additionalQueryParams)
-
putAdditionalQueryParam
final ResponseCreateParams.Builder putAdditionalQueryParam(String key, String value)
-
putAdditionalQueryParams
final ResponseCreateParams.Builder putAdditionalQueryParams(String key, Iterable<String> values)
-
putAllAdditionalQueryParams
final ResponseCreateParams.Builder putAllAdditionalQueryParams(QueryParams additionalQueryParams)
-
putAllAdditionalQueryParams
final ResponseCreateParams.Builder putAllAdditionalQueryParams(Map<String, Iterable<String>> additionalQueryParams)
-
replaceAdditionalQueryParams
final ResponseCreateParams.Builder replaceAdditionalQueryParams(String key, String value)
-
replaceAdditionalQueryParams
final ResponseCreateParams.Builder replaceAdditionalQueryParams(String key, Iterable<String> values)
-
replaceAllAdditionalQueryParams
final ResponseCreateParams.Builder replaceAllAdditionalQueryParams(QueryParams additionalQueryParams)
-
replaceAllAdditionalQueryParams
final ResponseCreateParams.Builder replaceAllAdditionalQueryParams(Map<String, Iterable<String>> additionalQueryParams)
-
removeAdditionalQueryParams
final ResponseCreateParams.Builder removeAdditionalQueryParams(String key)
-
removeAllAdditionalQueryParams
final ResponseCreateParams.Builder removeAllAdditionalQueryParams(Set<String> keys)
-
build
final ResponseCreateParams build()
Returns an immutable instance of ResponseCreateParams.
Further updates to this Builder will not mutate the returned instance.
The following fields are required:
.input() .model()
-
-
-
-