Class Response.Builder
-
- All Implemented Interfaces:
public final class Response.BuilderA builder for Response.
-
-
Method Summary
Modifier and Type Method Description final Response.Builderid(String id)Unique identifier for this Response. final Response.Builderid(JsonField<String> id)Sets Builder.id to an arbitrary JSON value. final Response.BuildercreatedAt(Double createdAt)Unix timestamp (in seconds) of when this Response was created. final Response.BuildercreatedAt(JsonField<Double> createdAt)Sets Builder.createdAt to an arbitrary JSON value. final Response.Buildererror(ResponseError error)An error object returned when the model fails to generate a Response. final Response.Buildererror(Optional<ResponseError> error)Alias for calling Builder.error with error.orElse(null).final Response.Buildererror(JsonField<ResponseError> error)Sets Builder.error to an arbitrary JSON value. final Response.BuilderincompleteDetails(Response.IncompleteDetails incompleteDetails)Details about why the response is incomplete. final Response.BuilderincompleteDetails(Optional<Response.IncompleteDetails> incompleteDetails)Alias for calling Builder.incompleteDetails with incompleteDetails.orElse(null).final Response.BuilderincompleteDetails(JsonField<Response.IncompleteDetails> incompleteDetails)Sets Builder.incompleteDetails to an arbitrary JSON value. final Response.Builderinstructions(Response.Instructions instructions)A system (or developer) message inserted into the model's context. final Response.Builderinstructions(Optional<Response.Instructions> instructions)Alias for calling Builder.instructions with instructions.orElse(null).final Response.Builderinstructions(JsonField<Response.Instructions> instructions)Sets Builder.instructions to an arbitrary JSON value. final Response.Builderinstructions(String string)Alias for calling instructions with Instructions.ofString(string).final Response.BuilderinstructionsOfInputItemList(List<ResponseInputItem> inputItemList)Alias for calling instructions with Instructions.ofInputItemList(inputItemList).final Response.Buildermetadata(Response.Metadata metadata)Set of 16 key-value pairs that can be attached to an object. final Response.Buildermetadata(Optional<Response.Metadata> metadata)Alias for calling Builder.metadata with metadata.orElse(null).final Response.Buildermetadata(JsonField<Response.Metadata> metadata)Sets Builder.metadata to an arbitrary JSON value. final Response.Buildermodel(ResponsesModel model)Model ID used to generate the response, like gpt-4ooro3.final Response.Buildermodel(JsonField<ResponsesModel> model)Sets Builder.model to an arbitrary JSON value. final Response.Buildermodel(String string)Alias for calling model with ResponsesModel.ofString(string).final Response.Buildermodel(ChatModel chat)Alias for calling model with ResponsesModel.ofChat(chat).final Response.Buildermodel(ResponsesModel.ResponsesOnlyModel only)Alias for calling model with ResponsesModel.ofOnly(only).final Response.Builderobject_(JsonValue object_)Sets the field to an arbitrary JSON value. final Response.Builderoutput(List<ResponseOutputItem> output)An array of content items generated by the model. final Response.Builderoutput(JsonField<List<ResponseOutputItem>> output)Sets Builder.output to an arbitrary JSON value. final Response.BuilderaddOutput(ResponseOutputItem output)Adds a single ResponseOutputItem to Builder.output. final Response.BuilderaddOutput(ResponseOutputMessage message)Alias for calling addOutput with ResponseOutputItem.ofMessage(message).final Response.BuilderaddOutput(ResponseFileSearchToolCall fileSearchCall)Alias for calling addOutput with ResponseOutputItem.ofFileSearchCall(fileSearchCall).final Response.BuilderaddOutput(ResponseFunctionToolCall functionCall)Alias for calling addOutput with ResponseOutputItem.ofFunctionCall(functionCall).final Response.BuilderaddOutput(ResponseFunctionWebSearch webSearchCall)Alias for calling addOutput with ResponseOutputItem.ofWebSearchCall(webSearchCall).final Response.BuilderaddOutput(ResponseComputerToolCall computerCall)Alias for calling addOutput with ResponseOutputItem.ofComputerCall(computerCall).final Response.BuilderaddOutput(ResponseReasoningItem reasoning)Alias for calling addOutput with ResponseOutputItem.ofReasoning(reasoning).final Response.BuilderaddOutput(ResponseOutputItem.ImageGenerationCall imageGenerationCall)Alias for calling addOutput with ResponseOutputItem.ofImageGenerationCall(imageGenerationCall).final Response.BuilderaddOutput(ResponseCodeInterpreterToolCall codeInterpreterCall)Alias for calling addOutput with ResponseOutputItem.ofCodeInterpreterCall(codeInterpreterCall).final Response.BuilderaddOutput(ResponseOutputItem.LocalShellCall localShellCall)Alias for calling addOutput with ResponseOutputItem.ofLocalShellCall(localShellCall).final Response.BuilderaddOutput(ResponseOutputItem.McpCall mcpCall)Alias for calling addOutput with ResponseOutputItem.ofMcpCall(mcpCall).final Response.BuilderaddOutput(ResponseOutputItem.McpListTools mcpListTools)Alias for calling addOutput with ResponseOutputItem.ofMcpListTools(mcpListTools).final Response.BuilderaddOutput(ResponseOutputItem.McpApprovalRequest mcpApprovalRequest)Alias for calling addOutput with ResponseOutputItem.ofMcpApprovalRequest(mcpApprovalRequest).final Response.BuilderaddOutput(ResponseCustomToolCall customToolCall)Alias for calling addOutput with ResponseOutputItem.ofCustomToolCall(customToolCall).final Response.BuilderparallelToolCalls(Boolean parallelToolCalls)Whether to allow the model to run tool calls in parallel. final Response.BuilderparallelToolCalls(JsonField<Boolean> parallelToolCalls)Sets Builder.parallelToolCalls to an arbitrary JSON value. final Response.Buildertemperature(Double temperature)What sampling temperature to use, between 0 and 2. final Response.Buildertemperature(Double temperature)Alias for Builder.temperature. final Response.Buildertemperature(Optional<Double> temperature)Alias for calling Builder.temperature with temperature.orElse(null).final Response.Buildertemperature(JsonField<Double> temperature)Sets Builder.temperature to an arbitrary JSON value. final Response.BuildertoolChoice(Response.ToolChoice toolChoice)How the model should select which tool (or tools) to use when generating a response. final Response.BuildertoolChoice(JsonField<Response.ToolChoice> toolChoice)Sets Builder.toolChoice to an arbitrary JSON value. final Response.BuildertoolChoice(ToolChoiceOptions options)Alias for calling toolChoice with ToolChoice.ofOptions(options).final Response.BuildertoolChoice(ToolChoiceAllowed allowed)Alias for calling toolChoice with ToolChoice.ofAllowed(allowed).final Response.BuildertoolChoice(ToolChoiceTypes types)Alias for calling toolChoice with ToolChoice.ofTypes(types).final Response.BuildertoolChoice(ToolChoiceFunction function)Alias for calling toolChoice with ToolChoice.ofFunction(function).final Response.BuildertoolChoice(ToolChoiceMcp mcp)Alias for calling toolChoice with ToolChoice.ofMcp(mcp).final Response.BuildertoolChoice(ToolChoiceCustom custom)Alias for calling toolChoice with ToolChoice.ofCustom(custom).final Response.Buildertools(List<Tool> tools)An array of tools the model may call while generating a response. final Response.Buildertools(JsonField<List<Tool>> tools)Sets Builder.tools to an arbitrary JSON value. final Response.BuilderaddTool(Tool tool)Adds a single Tool to tools. final Response.BuilderaddTool(FunctionTool function)Alias for calling addTool with Tool.ofFunction(function).final Response.BuilderaddTool(FileSearchTool fileSearch)Alias for calling addTool with Tool.ofFileSearch(fileSearch).final Response.BuilderaddTool(WebSearchTool webSearch)Alias for calling addTool with Tool.ofWebSearch(webSearch).final Response.BuilderaddTool(ComputerTool computerUsePreview)Alias for calling addTool with Tool.ofComputerUsePreview(computerUsePreview).final Response.BuilderaddTool(Tool.Mcp mcp)Alias for calling addTool with Tool.ofMcp(mcp).final Response.BuilderaddTool(Tool.CodeInterpreter codeInterpreter)Alias for calling addTool with Tool.ofCodeInterpreter(codeInterpreter).final Response.BuilderaddTool(Tool.ImageGeneration imageGeneration)Alias for calling addTool with Tool.ofImageGeneration(imageGeneration).final Response.BuilderaddTool(CustomTool custom)Alias for calling addTool with Tool.ofCustom(custom).final Response.BuilderaddFileSearchTool(List<String> vectorStoreIds)Alias for calling addTool with the following: FileSearchTool.builder() .vectorStoreIds(vectorStoreIds) .build()final Response.BuilderaddCodeInterpreterTool(Tool.CodeInterpreter.Container container)Alias for calling addTool with the following: Tool.CodeInterpreter.builder() .container(container) .build()final Response.BuilderaddCodeInterpreterTool(String string)Alias for calling addCodeInterpreterTool with Tool.CodeInterpreter.Container.ofString(string).final Response.BuilderaddCodeInterpreterTool(Tool.CodeInterpreter.Container.CodeInterpreterToolAuto codeInterpreterToolAuto)Alias for calling addCodeInterpreterTool with Tool.CodeInterpreter.Container.ofCodeInterpreterToolAuto(codeInterpreterToolAuto).final Response.BuilderaddToolLocalShell()Alias for calling addTool with Tool.ofLocalShell().final Response.BuilderaddCustomTool(String name)Alias for calling addTool with the following: CustomTool.builder() .name(name) .build()final Response.BuildertopP(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. final Response.BuildertopP(Double topP)Alias for Builder.topP. final Response.BuildertopP(Optional<Double> topP)Alias for calling Builder.topP with topP.orElse(null).final Response.BuildertopP(JsonField<Double> topP)Sets Builder.topP to an arbitrary JSON value. final Response.Builderbackground(Boolean background)Whether to run the model response in the background. final Response.Builderbackground(Boolean background)Alias for Builder.background. final Response.Builderbackground(Optional<Boolean> background)Alias for calling Builder.background with background.orElse(null).final Response.Builderbackground(JsonField<Boolean> background)Sets Builder.background to an arbitrary JSON value. final Response.BuildermaxOutputTokens(Long maxOutputTokens)An upper bound for the number of tokens that can be generated for a response, including visible output tokens and reasoning tokens. final Response.BuildermaxOutputTokens(Long maxOutputTokens)Alias for Builder.maxOutputTokens. final Response.BuildermaxOutputTokens(Optional<Long> maxOutputTokens)Alias for calling Builder.maxOutputTokens with maxOutputTokens.orElse(null).final Response.BuildermaxOutputTokens(JsonField<Long> maxOutputTokens)Sets Builder.maxOutputTokens to an arbitrary JSON value. final Response.BuildermaxToolCalls(Long maxToolCalls)The maximum number of total calls to built-in tools that can be processed in a response. final Response.BuildermaxToolCalls(Long maxToolCalls)Alias for Builder.maxToolCalls. final Response.BuildermaxToolCalls(Optional<Long> maxToolCalls)Alias for calling Builder.maxToolCalls with maxToolCalls.orElse(null).final Response.BuildermaxToolCalls(JsonField<Long> maxToolCalls)Sets Builder.maxToolCalls to an arbitrary JSON value. final Response.BuilderpreviousResponseId(String previousResponseId)The unique ID of the previous response to the model. final Response.BuilderpreviousResponseId(Optional<String> previousResponseId)Alias for calling Builder.previousResponseId with previousResponseId.orElse(null).final Response.BuilderpreviousResponseId(JsonField<String> previousResponseId)Sets Builder.previousResponseId to an arbitrary JSON value. final Response.Builderprompt(ResponsePrompt prompt)Reference to a prompt template and its variables. final Response.Builderprompt(Optional<ResponsePrompt> prompt)Alias for calling Builder.prompt with prompt.orElse(null).final Response.Builderprompt(JsonField<ResponsePrompt> prompt)Sets Builder.prompt to an arbitrary JSON value. final Response.BuilderpromptCacheKey(String promptCacheKey)Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. final Response.BuilderpromptCacheKey(JsonField<String> promptCacheKey)Sets Builder.promptCacheKey to an arbitrary JSON value. final Response.Builderreasoning(Reasoning reasoning)o-series models onlyConfiguration options for reasoning models. final Response.Builderreasoning(Optional<Reasoning> reasoning)Alias for calling Builder.reasoning with reasoning.orElse(null).final Response.Builderreasoning(JsonField<Reasoning> reasoning)Sets Builder.reasoning to an arbitrary JSON value. final Response.BuildersafetyIdentifier(String safetyIdentifier)A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies. final Response.BuildersafetyIdentifier(JsonField<String> safetyIdentifier)Sets Builder.safetyIdentifier to an arbitrary JSON value. final Response.BuilderserviceTier(Response.ServiceTier serviceTier)Specifies the processing type used for serving the request. final Response.BuilderserviceTier(Optional<Response.ServiceTier> serviceTier)Alias for calling Builder.serviceTier with serviceTier.orElse(null).final Response.BuilderserviceTier(JsonField<Response.ServiceTier> serviceTier)Sets Builder.serviceTier to an arbitrary JSON value. final Response.Builderstatus(ResponseStatus status)The status of the response generation. final Response.Builderstatus(JsonField<ResponseStatus> status)Sets Builder.status to an arbitrary JSON value. final Response.Buildertext(ResponseTextConfig text)Configuration options for a text response from the model. final Response.Buildertext(JsonField<ResponseTextConfig> text)Sets Builder.text to an arbitrary JSON value. final Response.BuildertopLogprobs(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. final Response.BuildertopLogprobs(Long topLogprobs)Alias for Builder.topLogprobs. final Response.BuildertopLogprobs(Optional<Long> topLogprobs)Alias for calling Builder.topLogprobs with topLogprobs.orElse(null).final Response.BuildertopLogprobs(JsonField<Long> topLogprobs)Sets Builder.topLogprobs to an arbitrary JSON value. final Response.Buildertruncation(Response.Truncation truncation)The truncation strategy to use for the model response. final Response.Buildertruncation(Optional<Response.Truncation> truncation)Alias for calling Builder.truncation with truncation.orElse(null).final Response.Buildertruncation(JsonField<Response.Truncation> truncation)Sets Builder.truncation to an arbitrary JSON value. final Response.Builderusage(ResponseUsage usage)Represents token usage details including input tokens, output tokens, a breakdown of output tokens, and the total tokens used. final Response.Builderusage(JsonField<ResponseUsage> usage)Sets Builder.usage to an arbitrary JSON value. final Response.Builderuser(String user)This field is being replaced by safety_identifierandprompt_cache_key.final Response.Builderuser(JsonField<String> user)Sets Builder.user to an arbitrary JSON value. final Response.BuilderadditionalProperties(Map<String, JsonValue> additionalProperties)final Response.BuilderputAdditionalProperty(String key, JsonValue value)final Response.BuilderputAllAdditionalProperties(Map<String, JsonValue> additionalProperties)final Response.BuilderremoveAdditionalProperty(String key)final Response.BuilderremoveAllAdditionalProperties(Set<String> keys)final Responsebuild()Returns an immutable instance of Response. -
-
Method Detail
-
id
final Response.Builder id(String id)
Unique identifier for this Response.
-
id
final Response.Builder id(JsonField<String> id)
Sets Builder.id to an arbitrary JSON value.
You should usually call Builder.id with a well-typed String value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
createdAt
final Response.Builder createdAt(Double createdAt)
Unix timestamp (in seconds) of when this Response was created.
-
createdAt
final Response.Builder createdAt(JsonField<Double> createdAt)
Sets Builder.createdAt to an arbitrary JSON value.
You should usually call Builder.createdAt with a well-typed Double value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
error
final Response.Builder error(ResponseError error)
An error object returned when the model fails to generate a Response.
-
error
final Response.Builder error(Optional<ResponseError> error)
Alias for calling Builder.error with
error.orElse(null).
-
error
final Response.Builder error(JsonField<ResponseError> error)
Sets Builder.error to an arbitrary JSON value.
You should usually call Builder.error with a well-typed ResponseError value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
incompleteDetails
final Response.Builder incompleteDetails(Response.IncompleteDetails incompleteDetails)
Details about why the response is incomplete.
-
incompleteDetails
final Response.Builder incompleteDetails(Optional<Response.IncompleteDetails> incompleteDetails)
Alias for calling Builder.incompleteDetails with
incompleteDetails.orElse(null).
-
incompleteDetails
final Response.Builder incompleteDetails(JsonField<Response.IncompleteDetails> incompleteDetails)
Sets Builder.incompleteDetails to an arbitrary JSON value.
You should usually call Builder.incompleteDetails with a well-typed IncompleteDetails value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
instructions
final Response.Builder instructions(Response.Instructions instructions)
A system (or developer) message inserted into 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 Response.Builder instructions(Optional<Response.Instructions> instructions)
Alias for calling Builder.instructions with
instructions.orElse(null).
-
instructions
final Response.Builder instructions(JsonField<Response.Instructions> instructions)
Sets Builder.instructions to an arbitrary JSON value.
You should usually call Builder.instructions with a well-typed Instructions value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
instructions
final Response.Builder instructions(String string)
Alias for calling instructions with
Instructions.ofString(string).
-
instructionsOfInputItemList
final Response.Builder instructionsOfInputItemList(List<ResponseInputItem> inputItemList)
Alias for calling instructions with
Instructions.ofInputItemList(inputItemList).
-
metadata
final Response.Builder metadata(Response.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 Response.Builder metadata(Optional<Response.Metadata> metadata)
Alias for calling Builder.metadata with
metadata.orElse(null).
-
metadata
final Response.Builder metadata(JsonField<Response.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.
-
model
final Response.Builder model(ResponsesModel model)
Model ID used to generate the response, like
gpt-4ooro3. 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 Response.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 Response.Builder model(String string)
Alias for calling model with
ResponsesModel.ofString(string).
-
model
final Response.Builder model(ChatModel chat)
Alias for calling model with
ResponsesModel.ofChat(chat).
-
model
final Response.Builder model(ResponsesModel.ResponsesOnlyModel only)
Alias for calling model with
ResponsesModel.ofOnly(only).
-
object_
final Response.Builder object_(JsonValue object_)
Sets the field to an arbitrary JSON value.
It is usually unnecessary to call this method because the field defaults to the following:
JsonValue.from("response")This method is primarily for setting the field to an undocumented or not yet supported value.
-
output
final Response.Builder output(List<ResponseOutputItem> output)
An array of content items generated by the model.
The length and order of items in the
outputarray is dependent on the model's response.Rather than accessing the first item in the
outputarray and assuming it's anassistantmessage with the content generated by the model, you might consider using theoutput_textproperty where supported in SDKs.
-
output
final Response.Builder output(JsonField<List<ResponseOutputItem>> output)
Sets Builder.output to an arbitrary JSON value.
You should usually call Builder.output with a well-typed
List<ResponseOutputItem>value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
addOutput
final Response.Builder addOutput(ResponseOutputItem output)
Adds a single ResponseOutputItem to Builder.output.
-
addOutput
final Response.Builder addOutput(ResponseOutputMessage message)
Alias for calling addOutput with
ResponseOutputItem.ofMessage(message).
-
addOutput
final Response.Builder addOutput(ResponseFileSearchToolCall fileSearchCall)
Alias for calling addOutput with
ResponseOutputItem.ofFileSearchCall(fileSearchCall).
-
addOutput
final Response.Builder addOutput(ResponseFunctionToolCall functionCall)
Alias for calling addOutput with
ResponseOutputItem.ofFunctionCall(functionCall).
-
addOutput
final Response.Builder addOutput(ResponseFunctionWebSearch webSearchCall)
Alias for calling addOutput with
ResponseOutputItem.ofWebSearchCall(webSearchCall).
-
addOutput
final Response.Builder addOutput(ResponseComputerToolCall computerCall)
Alias for calling addOutput with
ResponseOutputItem.ofComputerCall(computerCall).
-
addOutput
final Response.Builder addOutput(ResponseReasoningItem reasoning)
Alias for calling addOutput with
ResponseOutputItem.ofReasoning(reasoning).
-
addOutput
final Response.Builder addOutput(ResponseOutputItem.ImageGenerationCall imageGenerationCall)
Alias for calling addOutput with
ResponseOutputItem.ofImageGenerationCall(imageGenerationCall).
-
addOutput
final Response.Builder addOutput(ResponseCodeInterpreterToolCall codeInterpreterCall)
Alias for calling addOutput with
ResponseOutputItem.ofCodeInterpreterCall(codeInterpreterCall).
-
addOutput
final Response.Builder addOutput(ResponseOutputItem.LocalShellCall localShellCall)
Alias for calling addOutput with
ResponseOutputItem.ofLocalShellCall(localShellCall).
-
addOutput
final Response.Builder addOutput(ResponseOutputItem.McpCall mcpCall)
Alias for calling addOutput with
ResponseOutputItem.ofMcpCall(mcpCall).
-
addOutput
final Response.Builder addOutput(ResponseOutputItem.McpListTools mcpListTools)
Alias for calling addOutput with
ResponseOutputItem.ofMcpListTools(mcpListTools).
-
addOutput
final Response.Builder addOutput(ResponseOutputItem.McpApprovalRequest mcpApprovalRequest)
Alias for calling addOutput with
ResponseOutputItem.ofMcpApprovalRequest(mcpApprovalRequest).
-
addOutput
final Response.Builder addOutput(ResponseCustomToolCall customToolCall)
Alias for calling addOutput with
ResponseOutputItem.ofCustomToolCall(customToolCall).
-
parallelToolCalls
final Response.Builder parallelToolCalls(Boolean parallelToolCalls)
Whether to allow the model to run tool calls in parallel.
-
parallelToolCalls
final Response.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.
-
temperature
final Response.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_pbut not both.
-
temperature
final Response.Builder temperature(Double temperature)
Alias for Builder.temperature.
This unboxed primitive overload exists for backwards compatibility.
-
temperature
final Response.Builder temperature(Optional<Double> temperature)
Alias for calling Builder.temperature with
temperature.orElse(null).
-
temperature
final Response.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 Response.Builder toolChoice(Response.ToolChoice toolChoice)
How the model should select which tool (or tools) to use when generating a response. See the
toolsparameter to see how to specify which tools the model can call.
-
toolChoice
final Response.Builder toolChoice(JsonField<Response.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 Response.Builder toolChoice(ToolChoiceOptions options)
Alias for calling toolChoice with
ToolChoice.ofOptions(options).
-
toolChoice
final Response.Builder toolChoice(ToolChoiceAllowed allowed)
Alias for calling toolChoice with
ToolChoice.ofAllowed(allowed).
-
toolChoice
final Response.Builder toolChoice(ToolChoiceTypes types)
Alias for calling toolChoice with
ToolChoice.ofTypes(types).
-
toolChoice
final Response.Builder toolChoice(ToolChoiceFunction function)
Alias for calling toolChoice with
ToolChoice.ofFunction(function).
-
toolChoice
final Response.Builder toolChoice(ToolChoiceMcp mcp)
Alias for calling toolChoice with
ToolChoice.ofMcp(mcp).
-
toolChoice
final Response.Builder toolChoice(ToolChoiceCustom custom)
Alias for calling toolChoice with
ToolChoice.ofCustom(custom).
-
tools
final Response.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_choiceparameter.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 with strongly typed arguments and outputs. Learn more about function calling. You can also use custom tools to call your own code.
-
tools
final Response.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 Response.Builder addTool(Tool tool)
-
addTool
final Response.Builder addTool(FunctionTool function)
Alias for calling addTool with
Tool.ofFunction(function).
-
addTool
final Response.Builder addTool(FileSearchTool fileSearch)
Alias for calling addTool with
Tool.ofFileSearch(fileSearch).
-
addTool
final Response.Builder addTool(WebSearchTool webSearch)
Alias for calling addTool with
Tool.ofWebSearch(webSearch).
-
addTool
final Response.Builder addTool(ComputerTool computerUsePreview)
Alias for calling addTool with
Tool.ofComputerUsePreview(computerUsePreview).
-
addTool
final Response.Builder addTool(Tool.Mcp mcp)
Alias for calling addTool with
Tool.ofMcp(mcp).
-
addTool
final Response.Builder addTool(Tool.CodeInterpreter codeInterpreter)
Alias for calling addTool with
Tool.ofCodeInterpreter(codeInterpreter).
-
addTool
final Response.Builder addTool(Tool.ImageGeneration imageGeneration)
Alias for calling addTool with
Tool.ofImageGeneration(imageGeneration).
-
addTool
final Response.Builder addTool(CustomTool custom)
Alias for calling addTool with
Tool.ofCustom(custom).
-
addFileSearchTool
final Response.Builder addFileSearchTool(List<String> vectorStoreIds)
Alias for calling addTool with the following:
FileSearchTool.builder() .vectorStoreIds(vectorStoreIds) .build()
-
addCodeInterpreterTool
final Response.Builder addCodeInterpreterTool(Tool.CodeInterpreter.Container container)
Alias for calling addTool with the following:
Tool.CodeInterpreter.builder() .container(container) .build()
-
addCodeInterpreterTool
final Response.Builder addCodeInterpreterTool(String string)
Alias for calling addCodeInterpreterTool with
Tool.CodeInterpreter.Container.ofString(string).
-
addCodeInterpreterTool
final Response.Builder addCodeInterpreterTool(Tool.CodeInterpreter.Container.CodeInterpreterToolAuto codeInterpreterToolAuto)
Alias for calling addCodeInterpreterTool with
Tool.CodeInterpreter.Container.ofCodeInterpreterToolAuto(codeInterpreterToolAuto).
-
addToolLocalShell
final Response.Builder addToolLocalShell()
Alias for calling addTool with
Tool.ofLocalShell().
-
addCustomTool
final Response.Builder addCustomTool(String name)
Alias for calling addTool with the following:
CustomTool.builder() .name(name) .build()
-
topP
final Response.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
temperaturebut not both.
-
topP
final Response.Builder topP(Double topP)
Alias for Builder.topP.
This unboxed primitive overload exists for backwards compatibility.
-
topP
final Response.Builder topP(Optional<Double> topP)
Alias for calling Builder.topP with
topP.orElse(null).
-
topP
final Response.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.
-
background
final Response.Builder background(Boolean background)
Whether to run the model response in the background. Learn more.
-
background
final Response.Builder background(Boolean background)
Alias for Builder.background.
This unboxed primitive overload exists for backwards compatibility.
-
background
final Response.Builder background(Optional<Boolean> background)
Alias for calling Builder.background with
background.orElse(null).
-
background
final Response.Builder background(JsonField<Boolean> background)
Sets Builder.background to an arbitrary JSON value.
You should usually call Builder.background with a well-typed Boolean value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
maxOutputTokens
final Response.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 Response.Builder maxOutputTokens(Long maxOutputTokens)
Alias for Builder.maxOutputTokens.
This unboxed primitive overload exists for backwards compatibility.
-
maxOutputTokens
final Response.Builder maxOutputTokens(Optional<Long> maxOutputTokens)
Alias for calling Builder.maxOutputTokens with
maxOutputTokens.orElse(null).
-
maxOutputTokens
final Response.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.
-
maxToolCalls
final Response.Builder maxToolCalls(Long maxToolCalls)
The maximum number of total calls to built-in tools that can be processed in a response. This maximum number applies across all built-in tool calls, not per individual tool. Any further attempts to call a tool by the model will be ignored.
-
maxToolCalls
final Response.Builder maxToolCalls(Long maxToolCalls)
Alias for Builder.maxToolCalls.
This unboxed primitive overload exists for backwards compatibility.
-
maxToolCalls
final Response.Builder maxToolCalls(Optional<Long> maxToolCalls)
Alias for calling Builder.maxToolCalls with
maxToolCalls.orElse(null).
-
maxToolCalls
final Response.Builder maxToolCalls(JsonField<Long> maxToolCalls)
Sets Builder.maxToolCalls to an arbitrary JSON value.
You should usually call Builder.maxToolCalls with a well-typed Long value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
previousResponseId
final Response.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 Response.Builder previousResponseId(Optional<String> previousResponseId)
Alias for calling Builder.previousResponseId with
previousResponseId.orElse(null).
-
previousResponseId
final Response.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.
-
prompt
final Response.Builder prompt(ResponsePrompt prompt)
Reference to a prompt template and its variables. Learn more.
-
prompt
final Response.Builder prompt(Optional<ResponsePrompt> prompt)
Alias for calling Builder.prompt with
prompt.orElse(null).
-
prompt
final Response.Builder prompt(JsonField<ResponsePrompt> prompt)
Sets Builder.prompt to an arbitrary JSON value.
You should usually call Builder.prompt with a well-typed ResponsePrompt value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
promptCacheKey
final Response.Builder promptCacheKey(String promptCacheKey)
Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the
userfield. Learn more.
-
promptCacheKey
final Response.Builder promptCacheKey(JsonField<String> promptCacheKey)
Sets Builder.promptCacheKey to an arbitrary JSON value.
You should usually call Builder.promptCacheKey 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 Response.Builder reasoning(Reasoning reasoning)
o-series models only
Configuration options for reasoning models.
-
reasoning
final Response.Builder reasoning(Optional<Reasoning> reasoning)
Alias for calling Builder.reasoning with
reasoning.orElse(null).
-
reasoning
final Response.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.
-
safetyIdentifier
final Response.Builder safetyIdentifier(String safetyIdentifier)
A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies. The IDs should be a string that uniquely identifies each user. We recommend hashing their username or email address, in order to avoid sending us any identifying information. Learn more.
-
safetyIdentifier
final Response.Builder safetyIdentifier(JsonField<String> safetyIdentifier)
Sets Builder.safetyIdentifier to an arbitrary JSON value.
You should usually call Builder.safetyIdentifier with a well-typed String value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
serviceTier
final Response.Builder serviceTier(Response.ServiceTier serviceTier)
Specifies the processing type used for serving the request.
If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'.
If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.
If set to 'flex' or 'priority', then the request will be processed with the corresponding service tier. Contact sales to learn more about Priority processing.
When not set, the default behavior is 'auto'.
When the
service_tierparameter is set, the response body will include theservice_tiervalue based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.
-
serviceTier
final Response.Builder serviceTier(Optional<Response.ServiceTier> serviceTier)
Alias for calling Builder.serviceTier with
serviceTier.orElse(null).
-
serviceTier
final Response.Builder serviceTier(JsonField<Response.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.
-
status
final Response.Builder status(ResponseStatus status)
The status of the response generation. One of
completed,failed,in_progress,cancelled,queued, orincomplete.
-
status
final Response.Builder status(JsonField<ResponseStatus> status)
Sets Builder.status to an arbitrary JSON value.
You should usually call Builder.status with a well-typed ResponseStatus value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
text
final Response.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 Response.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.
-
topLogprobs
final Response.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.
-
topLogprobs
final Response.Builder topLogprobs(Long topLogprobs)
Alias for Builder.topLogprobs.
This unboxed primitive overload exists for backwards compatibility.
-
topLogprobs
final Response.Builder topLogprobs(Optional<Long> topLogprobs)
Alias for calling Builder.topLogprobs with
topLogprobs.orElse(null).
-
topLogprobs
final Response.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.
-
truncation
final Response.Builder truncation(Response.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 Response.Builder truncation(Optional<Response.Truncation> truncation)
Alias for calling Builder.truncation with
truncation.orElse(null).
-
truncation
final Response.Builder truncation(JsonField<Response.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.
-
usage
final Response.Builder usage(ResponseUsage usage)
Represents token usage details including input tokens, output tokens, a breakdown of output tokens, and the total tokens used.
-
usage
final Response.Builder usage(JsonField<ResponseUsage> usage)
Sets Builder.usage to an arbitrary JSON value.
You should usually call Builder.usage with a well-typed ResponseUsage value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
user
@Deprecated(message = "deprecated") final Response.Builder user(String user)
This field is being replaced by
safety_identifierandprompt_cache_key. Useprompt_cache_keyinstead to maintain caching optimizations. 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
@Deprecated(message = "deprecated") final Response.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 Response.Builder additionalProperties(Map<String, JsonValue> additionalProperties)
-
putAdditionalProperty
final Response.Builder putAdditionalProperty(String key, JsonValue value)
-
putAllAdditionalProperties
final Response.Builder putAllAdditionalProperties(Map<String, JsonValue> additionalProperties)
-
removeAdditionalProperty
final Response.Builder removeAdditionalProperty(String key)
-
removeAllAdditionalProperties
final Response.Builder removeAllAdditionalProperties(Set<String> keys)
-
build
final Response build()
Returns an immutable instance of Response.
Further updates to this Builder will not mutate the returned instance.
The following fields are required:
.id() .createdAt() .error() .incompleteDetails() .instructions() .metadata() .model() .output() .parallelToolCalls() .temperature() .toolChoice() .tools() .topP()
-
-
-
-