Class ResponseItem
-
- All Implemented Interfaces:
public final class ResponseItemContent item used to generate a response.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceResponseItem.VisitorAn interface that defines how to map each variant of ResponseItem to a value of type T.
public final classResponseItem.AdditionalToolspublic final classResponseItem.ImageGenerationCallAn image generation request made by the model.
public final classResponseItem.LocalShellCallA tool call to run a command on the local shell.
public final classResponseItem.LocalShellCallOutputThe output of a local shell tool call.
public final classResponseItem.McpListToolsA list of tools available on an MCP server.
public final classResponseItem.McpApprovalRequestA request for human approval of a tool invocation.
public final classResponseItem.McpApprovalResponseA response to an MCP approval request.
public final classResponseItem.McpCallAn invocation of a tool on an MCP server.
-
Method Summary
Modifier and Type Method Description final Optional<ResponseInputMessageItem>responseInputMessageItem()final Optional<ResponseOutputMessage>responseOutputMessage()An output message from the model. final Optional<ResponseFileSearchToolCall>fileSearchCall()The results of a file search tool call. final Optional<ResponseComputerToolCall>computerCall()A tool call to a computer use tool. final Optional<ResponseComputerToolCallOutputItem>computerCallOutput()final Optional<ResponseFunctionWebSearch>webSearchCall()The results of a web search tool call. final Optional<ResponseFunctionToolCallItem>functionCall()A tool call to run a function. final Optional<ResponseFunctionToolCallOutputItem>functionCallOutput()final Optional<ResponseToolSearchCall>toolSearchCall()final Optional<ResponseToolSearchOutputItem>toolSearchOutput()final Optional<ResponseItem.AdditionalTools>additionalTools()final Optional<ResponseReasoningItem>reasoning()A description of the chain of thought used by a reasoning model while generating a response. final Optional<ResponseCompactionItem>compaction()A compaction item generated by the v1/responses/compactAPI.final Optional<ResponseItem.ImageGenerationCall>imageGenerationCall()An image generation request made by the model. final Optional<ResponseCodeInterpreterToolCall>codeInterpreterCall()A tool call to run code. final Optional<ResponseItem.LocalShellCall>localShellCall()A tool call to run a command on the local shell. final Optional<ResponseItem.LocalShellCallOutput>localShellCallOutput()The output of a local shell tool call. final Optional<ResponseFunctionShellToolCall>shellCall()A tool call that executes one or more shell commands in a managed environment. final Optional<ResponseFunctionShellToolCallOutput>shellCallOutput()The output of a shell tool call that was emitted. final Optional<ResponseApplyPatchToolCall>applyPatchCall()A tool call that applies file diffs by creating, deleting, or updating files. final Optional<ResponseApplyPatchToolCallOutput>applyPatchCallOutput()The output emitted by an apply patch tool call. final Optional<ResponseItem.McpListTools>mcpListTools()A list of tools available on an MCP server. final Optional<ResponseItem.McpApprovalRequest>mcpApprovalRequest()A request for human approval of a tool invocation. final Optional<ResponseItem.McpApprovalResponse>mcpApprovalResponse()A response to an MCP approval request. final Optional<ResponseItem.McpCall>mcpCall()An invocation of a tool on an MCP server. final Optional<ResponseCustomToolCallItem>customToolCall()A call to a custom tool created by the model. final Optional<ResponseCustomToolCallOutputItem>customToolCallOutput()The output of a custom tool call from your code, being sent back to the model. final BooleanisResponseInputMessageItem()final BooleanisResponseOutputMessage()final BooleanisFileSearchCall()final BooleanisComputerCall()final BooleanisComputerCallOutput()final BooleanisWebSearchCall()final BooleanisFunctionCall()final BooleanisFunctionCallOutput()final BooleanisToolSearchCall()final BooleanisToolSearchOutput()final BooleanisAdditionalTools()final BooleanisReasoning()final BooleanisCompaction()final BooleanisImageGenerationCall()final BooleanisCodeInterpreterCall()final BooleanisLocalShellCall()final BooleanisLocalShellCallOutput()final BooleanisShellCall()final BooleanisShellCallOutput()final BooleanisApplyPatchCall()final BooleanisApplyPatchCallOutput()final BooleanisMcpListTools()final BooleanisMcpApprovalRequest()final BooleanisMcpApprovalResponse()final BooleanisMcpCall()final BooleanisCustomToolCall()final BooleanisCustomToolCallOutput()final ResponseInputMessageItemasResponseInputMessageItem()final ResponseOutputMessageasResponseOutputMessage()An output message from the model. final ResponseFileSearchToolCallasFileSearchCall()The results of a file search tool call. final ResponseComputerToolCallasComputerCall()A tool call to a computer use tool. final ResponseComputerToolCallOutputItemasComputerCallOutput()final ResponseFunctionWebSearchasWebSearchCall()The results of a web search tool call. final ResponseFunctionToolCallItemasFunctionCall()A tool call to run a function. final ResponseFunctionToolCallOutputItemasFunctionCallOutput()final ResponseToolSearchCallasToolSearchCall()final ResponseToolSearchOutputItemasToolSearchOutput()final ResponseItem.AdditionalToolsasAdditionalTools()final ResponseReasoningItemasReasoning()A description of the chain of thought used by a reasoning model while generating a response. final ResponseCompactionItemasCompaction()A compaction item generated by the v1/responses/compactAPI.final ResponseItem.ImageGenerationCallasImageGenerationCall()An image generation request made by the model. final ResponseCodeInterpreterToolCallasCodeInterpreterCall()A tool call to run code. final ResponseItem.LocalShellCallasLocalShellCall()A tool call to run a command on the local shell. final ResponseItem.LocalShellCallOutputasLocalShellCallOutput()The output of a local shell tool call. final ResponseFunctionShellToolCallasShellCall()A tool call that executes one or more shell commands in a managed environment. final ResponseFunctionShellToolCallOutputasShellCallOutput()The output of a shell tool call that was emitted. final ResponseApplyPatchToolCallasApplyPatchCall()A tool call that applies file diffs by creating, deleting, or updating files. final ResponseApplyPatchToolCallOutputasApplyPatchCallOutput()The output emitted by an apply patch tool call. final ResponseItem.McpListToolsasMcpListTools()A list of tools available on an MCP server. final ResponseItem.McpApprovalRequestasMcpApprovalRequest()A request for human approval of a tool invocation. final ResponseItem.McpApprovalResponseasMcpApprovalResponse()A response to an MCP approval request. final ResponseItem.McpCallasMcpCall()An invocation of a tool on an MCP server. final ResponseCustomToolCallItemasCustomToolCall()A call to a custom tool created by the model. final ResponseCustomToolCallOutputItemasCustomToolCallOutput()The output of a custom tool call from your code, being sent back to the model. final Optional<JsonValue>_json()final <T extends Any> Taccept(ResponseItem.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final ResponseItemvalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static ResponseItemofResponseInputMessageItem(ResponseInputMessageItem responseInputMessageItem)final static ResponseItemofResponseOutputMessage(ResponseOutputMessage responseOutputMessage)An output message from the model. final static ResponseItemofFileSearchCall(ResponseFileSearchToolCall fileSearchCall)The results of a file search tool call. final static ResponseItemofComputerCall(ResponseComputerToolCall computerCall)A tool call to a computer use tool. final static ResponseItemofComputerCallOutput(ResponseComputerToolCallOutputItem computerCallOutput)final static ResponseItemofWebSearchCall(ResponseFunctionWebSearch webSearchCall)The results of a web search tool call. final static ResponseItemofFunctionCall(ResponseFunctionToolCallItem functionCall)A tool call to run a function. final static ResponseItemofFunctionCallOutput(ResponseFunctionToolCallOutputItem functionCallOutput)final static ResponseItemofToolSearchCall(ResponseToolSearchCall toolSearchCall)final static ResponseItemofToolSearchOutput(ResponseToolSearchOutputItem toolSearchOutput)final static ResponseItemofAdditionalTools(ResponseItem.AdditionalTools additionalTools)final static ResponseItemofReasoning(ResponseReasoningItem reasoning)A description of the chain of thought used by a reasoning model while generating a response. final static ResponseItemofCompaction(ResponseCompactionItem compaction)A compaction item generated by the v1/responses/compactAPI.final static ResponseItemofImageGenerationCall(ResponseItem.ImageGenerationCall imageGenerationCall)An image generation request made by the model. final static ResponseItemofCodeInterpreterCall(ResponseCodeInterpreterToolCall codeInterpreterCall)A tool call to run code. final static ResponseItemofLocalShellCall(ResponseItem.LocalShellCall localShellCall)A tool call to run a command on the local shell. final static ResponseItemofLocalShellCallOutput(ResponseItem.LocalShellCallOutput localShellCallOutput)The output of a local shell tool call. final static ResponseItemofShellCall(ResponseFunctionShellToolCall shellCall)A tool call that executes one or more shell commands in a managed environment. final static ResponseItemofShellCallOutput(ResponseFunctionShellToolCallOutput shellCallOutput)The output of a shell tool call that was emitted. final static ResponseItemofApplyPatchCall(ResponseApplyPatchToolCall applyPatchCall)A tool call that applies file diffs by creating, deleting, or updating files. final static ResponseItemofApplyPatchCallOutput(ResponseApplyPatchToolCallOutput applyPatchCallOutput)The output emitted by an apply patch tool call. final static ResponseItemofMcpListTools(ResponseItem.McpListTools mcpListTools)A list of tools available on an MCP server. final static ResponseItemofMcpApprovalRequest(ResponseItem.McpApprovalRequest mcpApprovalRequest)A request for human approval of a tool invocation. final static ResponseItemofMcpApprovalResponse(ResponseItem.McpApprovalResponse mcpApprovalResponse)A response to an MCP approval request. final static ResponseItemofMcpCall(ResponseItem.McpCall mcpCall)An invocation of a tool on an MCP server. final static ResponseItemofCustomToolCall(ResponseCustomToolCallItem customToolCall)A call to a custom tool created by the model. final static ResponseItemofCustomToolCallOutput(ResponseCustomToolCallOutputItem customToolCallOutput)The output of a custom tool call from your code, being sent back to the model. -
-
Method Detail
-
responseInputMessageItem
final Optional<ResponseInputMessageItem> responseInputMessageItem()
-
responseOutputMessage
final Optional<ResponseOutputMessage> responseOutputMessage()
An output message from the model.
-
fileSearchCall
final Optional<ResponseFileSearchToolCall> fileSearchCall()
The results of a file search tool call. See the file search guide for more information.
-
computerCall
final Optional<ResponseComputerToolCall> computerCall()
A tool call to a computer use tool. See the computer use guide for more information.
-
computerCallOutput
final Optional<ResponseComputerToolCallOutputItem> computerCallOutput()
-
webSearchCall
final Optional<ResponseFunctionWebSearch> webSearchCall()
The results of a web search tool call. See the web search guide for more information.
-
functionCall
final Optional<ResponseFunctionToolCallItem> functionCall()
A tool call to run a function. See the function calling guide for more information.
-
functionCallOutput
final Optional<ResponseFunctionToolCallOutputItem> functionCallOutput()
-
toolSearchCall
final Optional<ResponseToolSearchCall> toolSearchCall()
-
toolSearchOutput
final Optional<ResponseToolSearchOutputItem> toolSearchOutput()
-
additionalTools
final Optional<ResponseItem.AdditionalTools> additionalTools()
-
reasoning
final Optional<ResponseReasoningItem> reasoning()
A description of the chain of thought used by a reasoning model while generating a response. Be sure to include these items in your
inputto the Responses API for subsequent turns of a conversation if you are manually managing context.
-
compaction
final Optional<ResponseCompactionItem> compaction()
A compaction item generated by the
v1/responses/compactAPI.
-
imageGenerationCall
final Optional<ResponseItem.ImageGenerationCall> imageGenerationCall()
An image generation request made by the model.
-
codeInterpreterCall
final Optional<ResponseCodeInterpreterToolCall> codeInterpreterCall()
A tool call to run code.
-
localShellCall
final Optional<ResponseItem.LocalShellCall> localShellCall()
A tool call to run a command on the local shell.
-
localShellCallOutput
final Optional<ResponseItem.LocalShellCallOutput> localShellCallOutput()
The output of a local shell tool call.
-
shellCall
final Optional<ResponseFunctionShellToolCall> shellCall()
A tool call that executes one or more shell commands in a managed environment.
-
shellCallOutput
final Optional<ResponseFunctionShellToolCallOutput> shellCallOutput()
The output of a shell tool call that was emitted.
-
applyPatchCall
final Optional<ResponseApplyPatchToolCall> applyPatchCall()
A tool call that applies file diffs by creating, deleting, or updating files.
-
applyPatchCallOutput
final Optional<ResponseApplyPatchToolCallOutput> applyPatchCallOutput()
The output emitted by an apply patch tool call.
-
mcpListTools
final Optional<ResponseItem.McpListTools> mcpListTools()
A list of tools available on an MCP server.
-
mcpApprovalRequest
final Optional<ResponseItem.McpApprovalRequest> mcpApprovalRequest()
A request for human approval of a tool invocation.
-
mcpApprovalResponse
final Optional<ResponseItem.McpApprovalResponse> mcpApprovalResponse()
A response to an MCP approval request.
-
mcpCall
final Optional<ResponseItem.McpCall> mcpCall()
An invocation of a tool on an MCP server.
-
customToolCall
final Optional<ResponseCustomToolCallItem> customToolCall()
A call to a custom tool created by the model.
-
customToolCallOutput
final Optional<ResponseCustomToolCallOutputItem> customToolCallOutput()
The output of a custom tool call from your code, being sent back to the model.
-
isResponseInputMessageItem
final Boolean isResponseInputMessageItem()
-
isResponseOutputMessage
final Boolean isResponseOutputMessage()
-
isFileSearchCall
final Boolean isFileSearchCall()
-
isComputerCall
final Boolean isComputerCall()
-
isComputerCallOutput
final Boolean isComputerCallOutput()
-
isWebSearchCall
final Boolean isWebSearchCall()
-
isFunctionCall
final Boolean isFunctionCall()
-
isFunctionCallOutput
final Boolean isFunctionCallOutput()
-
isToolSearchCall
final Boolean isToolSearchCall()
-
isToolSearchOutput
final Boolean isToolSearchOutput()
-
isAdditionalTools
final Boolean isAdditionalTools()
-
isReasoning
final Boolean isReasoning()
-
isCompaction
final Boolean isCompaction()
-
isImageGenerationCall
final Boolean isImageGenerationCall()
-
isCodeInterpreterCall
final Boolean isCodeInterpreterCall()
-
isLocalShellCall
final Boolean isLocalShellCall()
-
isLocalShellCallOutput
final Boolean isLocalShellCallOutput()
-
isShellCall
final Boolean isShellCall()
-
isShellCallOutput
final Boolean isShellCallOutput()
-
isApplyPatchCall
final Boolean isApplyPatchCall()
-
isApplyPatchCallOutput
final Boolean isApplyPatchCallOutput()
-
isMcpListTools
final Boolean isMcpListTools()
-
isMcpApprovalRequest
final Boolean isMcpApprovalRequest()
-
isMcpApprovalResponse
final Boolean isMcpApprovalResponse()
-
isCustomToolCall
final Boolean isCustomToolCall()
-
isCustomToolCallOutput
final Boolean isCustomToolCallOutput()
-
asResponseInputMessageItem
final ResponseInputMessageItem asResponseInputMessageItem()
-
asResponseOutputMessage
final ResponseOutputMessage asResponseOutputMessage()
An output message from the model.
-
asFileSearchCall
final ResponseFileSearchToolCall asFileSearchCall()
The results of a file search tool call. See the file search guide for more information.
-
asComputerCall
final ResponseComputerToolCall asComputerCall()
A tool call to a computer use tool. See the computer use guide for more information.
-
asComputerCallOutput
final ResponseComputerToolCallOutputItem asComputerCallOutput()
-
asWebSearchCall
final ResponseFunctionWebSearch asWebSearchCall()
The results of a web search tool call. See the web search guide for more information.
-
asFunctionCall
final ResponseFunctionToolCallItem asFunctionCall()
A tool call to run a function. See the function calling guide for more information.
-
asFunctionCallOutput
final ResponseFunctionToolCallOutputItem asFunctionCallOutput()
-
asToolSearchCall
final ResponseToolSearchCall asToolSearchCall()
-
asToolSearchOutput
final ResponseToolSearchOutputItem asToolSearchOutput()
-
asAdditionalTools
final ResponseItem.AdditionalTools asAdditionalTools()
-
asReasoning
final ResponseReasoningItem asReasoning()
A description of the chain of thought used by a reasoning model while generating a response. Be sure to include these items in your
inputto the Responses API for subsequent turns of a conversation if you are manually managing context.
-
asCompaction
final ResponseCompactionItem asCompaction()
A compaction item generated by the
v1/responses/compactAPI.
-
asImageGenerationCall
final ResponseItem.ImageGenerationCall asImageGenerationCall()
An image generation request made by the model.
-
asCodeInterpreterCall
final ResponseCodeInterpreterToolCall asCodeInterpreterCall()
A tool call to run code.
-
asLocalShellCall
final ResponseItem.LocalShellCall asLocalShellCall()
A tool call to run a command on the local shell.
-
asLocalShellCallOutput
final ResponseItem.LocalShellCallOutput asLocalShellCallOutput()
The output of a local shell tool call.
-
asShellCall
final ResponseFunctionShellToolCall asShellCall()
A tool call that executes one or more shell commands in a managed environment.
-
asShellCallOutput
final ResponseFunctionShellToolCallOutput asShellCallOutput()
The output of a shell tool call that was emitted.
-
asApplyPatchCall
final ResponseApplyPatchToolCall asApplyPatchCall()
A tool call that applies file diffs by creating, deleting, or updating files.
-
asApplyPatchCallOutput
final ResponseApplyPatchToolCallOutput asApplyPatchCallOutput()
The output emitted by an apply patch tool call.
-
asMcpListTools
final ResponseItem.McpListTools asMcpListTools()
A list of tools available on an MCP server.
-
asMcpApprovalRequest
final ResponseItem.McpApprovalRequest asMcpApprovalRequest()
A request for human approval of a tool invocation.
-
asMcpApprovalResponse
final ResponseItem.McpApprovalResponse asMcpApprovalResponse()
A response to an MCP approval request.
-
asMcpCall
final ResponseItem.McpCall asMcpCall()
An invocation of a tool on an MCP server.
-
asCustomToolCall
final ResponseCustomToolCallItem asCustomToolCall()
A call to a custom tool created by the model.
-
asCustomToolCallOutput
final ResponseCustomToolCallOutputItem asCustomToolCallOutput()
The output of a custom tool call from your code, being sent back to the model.
-
accept
final <T extends Any> T accept(ResponseItem.Visitor<T> visitor)
Maps this instance's current variant to a value of type T using the given visitor.
Note that this method is not forwards compatible with new variants from the API, unless visitor overrides Visitor.unknown. To handle variants not known to this version of the SDK gracefully, consider overriding Visitor.unknown:
import com.openai.core.JsonValue; import java.util.Optional; Optional<String> result = responseItem.accept(new ResponseItem.Visitor<Optional<String>>() { @Override public Optional<String> visitResponseInputMessageItem(ResponseInputMessageItem responseInputMessageItem) { return Optional.of(responseInputMessageItem.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final ResponseItem validate()
Validates that the types of all values in this object match their expected types recursively.
This method is not forwards compatible with new types from the API for existing fields.
-
ofResponseInputMessageItem
final static ResponseItem ofResponseInputMessageItem(ResponseInputMessageItem responseInputMessageItem)
-
ofResponseOutputMessage
final static ResponseItem ofResponseOutputMessage(ResponseOutputMessage responseOutputMessage)
An output message from the model.
-
ofFileSearchCall
final static ResponseItem ofFileSearchCall(ResponseFileSearchToolCall fileSearchCall)
The results of a file search tool call. See the file search guide for more information.
-
ofComputerCall
final static ResponseItem ofComputerCall(ResponseComputerToolCall computerCall)
A tool call to a computer use tool. See the computer use guide for more information.
-
ofComputerCallOutput
final static ResponseItem ofComputerCallOutput(ResponseComputerToolCallOutputItem computerCallOutput)
-
ofWebSearchCall
final static ResponseItem ofWebSearchCall(ResponseFunctionWebSearch webSearchCall)
The results of a web search tool call. See the web search guide for more information.
-
ofFunctionCall
final static ResponseItem ofFunctionCall(ResponseFunctionToolCallItem functionCall)
A tool call to run a function. See the function calling guide for more information.
-
ofFunctionCallOutput
final static ResponseItem ofFunctionCallOutput(ResponseFunctionToolCallOutputItem functionCallOutput)
-
ofToolSearchCall
final static ResponseItem ofToolSearchCall(ResponseToolSearchCall toolSearchCall)
-
ofToolSearchOutput
final static ResponseItem ofToolSearchOutput(ResponseToolSearchOutputItem toolSearchOutput)
-
ofAdditionalTools
final static ResponseItem ofAdditionalTools(ResponseItem.AdditionalTools additionalTools)
-
ofReasoning
final static ResponseItem ofReasoning(ResponseReasoningItem reasoning)
A description of the chain of thought used by a reasoning model while generating a response. Be sure to include these items in your
inputto the Responses API for subsequent turns of a conversation if you are manually managing context.
-
ofCompaction
final static ResponseItem ofCompaction(ResponseCompactionItem compaction)
A compaction item generated by the
v1/responses/compactAPI.
-
ofImageGenerationCall
final static ResponseItem ofImageGenerationCall(ResponseItem.ImageGenerationCall imageGenerationCall)
An image generation request made by the model.
-
ofCodeInterpreterCall
final static ResponseItem ofCodeInterpreterCall(ResponseCodeInterpreterToolCall codeInterpreterCall)
A tool call to run code.
-
ofLocalShellCall
final static ResponseItem ofLocalShellCall(ResponseItem.LocalShellCall localShellCall)
A tool call to run a command on the local shell.
-
ofLocalShellCallOutput
final static ResponseItem ofLocalShellCallOutput(ResponseItem.LocalShellCallOutput localShellCallOutput)
The output of a local shell tool call.
-
ofShellCall
final static ResponseItem ofShellCall(ResponseFunctionShellToolCall shellCall)
A tool call that executes one or more shell commands in a managed environment.
-
ofShellCallOutput
final static ResponseItem ofShellCallOutput(ResponseFunctionShellToolCallOutput shellCallOutput)
The output of a shell tool call that was emitted.
-
ofApplyPatchCall
final static ResponseItem ofApplyPatchCall(ResponseApplyPatchToolCall applyPatchCall)
A tool call that applies file diffs by creating, deleting, or updating files.
-
ofApplyPatchCallOutput
final static ResponseItem ofApplyPatchCallOutput(ResponseApplyPatchToolCallOutput applyPatchCallOutput)
The output emitted by an apply patch tool call.
-
ofMcpListTools
final static ResponseItem ofMcpListTools(ResponseItem.McpListTools mcpListTools)
A list of tools available on an MCP server.
-
ofMcpApprovalRequest
final static ResponseItem ofMcpApprovalRequest(ResponseItem.McpApprovalRequest mcpApprovalRequest)
A request for human approval of a tool invocation.
-
ofMcpApprovalResponse
final static ResponseItem ofMcpApprovalResponse(ResponseItem.McpApprovalResponse mcpApprovalResponse)
A response to an MCP approval request.
-
ofMcpCall
final static ResponseItem ofMcpCall(ResponseItem.McpCall mcpCall)
An invocation of a tool on an MCP server.
-
ofCustomToolCall
final static ResponseItem ofCustomToolCall(ResponseCustomToolCallItem customToolCall)
A call to a custom tool created by the model.
-
ofCustomToolCallOutput
final static ResponseItem ofCustomToolCallOutput(ResponseCustomToolCallOutputItem customToolCallOutput)
The output of a custom tool call from your code, being sent back to the model.
-
-
-
-