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.Programpublic final classResponseItem.ProgramOutputpublic 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
-
-
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.
-
program
final Optional<ResponseItem.Program> program()
-
programOutput
final Optional<ResponseItem.ProgramOutput> programOutput()
-
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()
-
isProgramOutput
final Boolean isProgramOutput()
-
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.
-
asProgram
final ResponseItem.Program asProgram()
-
asProgramOutput
final ResponseItem.ProgramOutput asProgramOutput()
-
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.
-
ofProgram
final static ResponseItem ofProgram(ResponseItem.Program program)
-
ofProgramOutput
final static ResponseItem ofProgramOutput(ResponseItem.ProgramOutput programOutput)
-
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.
-
-
-
-