Class ConversationItem
-
- All Implemented Interfaces:
public final class ConversationItemA single item within a conversation. The set of possible types are the same as the
outputtype of a Response object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceConversationItem.VisitorAn interface that defines how to map each variant of ConversationItem to a value of type T.
public final classConversationItem.ImageGenerationCallAn image generation request made by the model.
public final classConversationItem.LocalShellCallA tool call to run a command on the local shell.
public final classConversationItem.LocalShellCallOutputThe output of a local shell tool call.
public final classConversationItem.McpListToolsA list of tools available on an MCP server.
public final classConversationItem.McpApprovalRequestA request for human approval of a tool invocation.
public final classConversationItem.McpApprovalResponseA response to an MCP approval request.
public final classConversationItem.McpCallAn invocation of a tool on an MCP server.
-
Method Summary
Modifier and Type Method Description final Optional<Message>message()A message to or from the model. final Optional<ResponseFunctionToolCallItem>functionCall()A tool call to run a function. final Optional<ResponseFunctionToolCallOutputItem>functionCallOutput()final Optional<ResponseFileSearchToolCall>fileSearchCall()The results of a file search tool call. final Optional<ResponseFunctionWebSearch>webSearchCall()The results of a web search tool call. final Optional<ConversationItem.ImageGenerationCall>imageGenerationCall()An image generation request made by the model. final Optional<ResponseComputerToolCall>computerCall()A tool call to a computer use tool. final Optional<ResponseComputerToolCallOutputItem>computerCallOutput()final Optional<ResponseReasoningItem>reasoning()A description of the chain of thought used by a reasoning model while generating a response. final Optional<ResponseCodeInterpreterToolCall>codeInterpreterCall()A tool call to run code. final Optional<ConversationItem.LocalShellCall>localShellCall()A tool call to run a command on the local shell. final Optional<ConversationItem.LocalShellCallOutput>localShellCallOutput()The output of a local shell tool call. final Optional<ConversationItem.McpListTools>mcpListTools()A list of tools available on an MCP server. final Optional<ConversationItem.McpApprovalRequest>mcpApprovalRequest()A request for human approval of a tool invocation. final Optional<ConversationItem.McpApprovalResponse>mcpApprovalResponse()A response to an MCP approval request. final Optional<ConversationItem.McpCall>mcpCall()An invocation of a tool on an MCP server. final Optional<ResponseCustomToolCall>customToolCall()A call to a custom tool created by the model. final Optional<ResponseCustomToolCallOutput>customToolCallOutput()The output of a custom tool call from your code, being sent back to the model. final BooleanisMessage()final BooleanisFunctionCall()final BooleanisFunctionCallOutput()final BooleanisFileSearchCall()final BooleanisWebSearchCall()final BooleanisImageGenerationCall()final BooleanisComputerCall()final BooleanisComputerCallOutput()final BooleanisReasoning()final BooleanisCodeInterpreterCall()final BooleanisLocalShellCall()final BooleanisLocalShellCallOutput()final BooleanisMcpListTools()final BooleanisMcpApprovalRequest()final BooleanisMcpApprovalResponse()final BooleanisMcpCall()final BooleanisCustomToolCall()final BooleanisCustomToolCallOutput()final MessageasMessage()A message to or from the model. final ResponseFunctionToolCallItemasFunctionCall()A tool call to run a function. final ResponseFunctionToolCallOutputItemasFunctionCallOutput()final ResponseFileSearchToolCallasFileSearchCall()The results of a file search tool call. final ResponseFunctionWebSearchasWebSearchCall()The results of a web search tool call. final ConversationItem.ImageGenerationCallasImageGenerationCall()An image generation request made by the model. final ResponseComputerToolCallasComputerCall()A tool call to a computer use tool. final ResponseComputerToolCallOutputItemasComputerCallOutput()final ResponseReasoningItemasReasoning()A description of the chain of thought used by a reasoning model while generating a response. final ResponseCodeInterpreterToolCallasCodeInterpreterCall()A tool call to run code. final ConversationItem.LocalShellCallasLocalShellCall()A tool call to run a command on the local shell. final ConversationItem.LocalShellCallOutputasLocalShellCallOutput()The output of a local shell tool call. final ConversationItem.McpListToolsasMcpListTools()A list of tools available on an MCP server. final ConversationItem.McpApprovalRequestasMcpApprovalRequest()A request for human approval of a tool invocation. final ConversationItem.McpApprovalResponseasMcpApprovalResponse()A response to an MCP approval request. final ConversationItem.McpCallasMcpCall()An invocation of a tool on an MCP server. final ResponseCustomToolCallasCustomToolCall()A call to a custom tool created by the model. final ResponseCustomToolCallOutputasCustomToolCallOutput()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(ConversationItem.Visitor<T> visitor)final ConversationItemvalidate()final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static ConversationItemofMessage(Message message)A message to or from the model. final static ConversationItemofFunctionCall(ResponseFunctionToolCallItem functionCall)A tool call to run a function. final static ConversationItemofFunctionCallOutput(ResponseFunctionToolCallOutputItem functionCallOutput)final static ConversationItemofFileSearchCall(ResponseFileSearchToolCall fileSearchCall)The results of a file search tool call. final static ConversationItemofWebSearchCall(ResponseFunctionWebSearch webSearchCall)The results of a web search tool call. final static ConversationItemofImageGenerationCall(ConversationItem.ImageGenerationCall imageGenerationCall)An image generation request made by the model. final static ConversationItemofComputerCall(ResponseComputerToolCall computerCall)A tool call to a computer use tool. final static ConversationItemofComputerCallOutput(ResponseComputerToolCallOutputItem computerCallOutput)final static ConversationItemofReasoning(ResponseReasoningItem reasoning)A description of the chain of thought used by a reasoning model while generating a response. final static ConversationItemofCodeInterpreterCall(ResponseCodeInterpreterToolCall codeInterpreterCall)A tool call to run code. final static ConversationItemofLocalShellCall(ConversationItem.LocalShellCall localShellCall)A tool call to run a command on the local shell. final static ConversationItemofLocalShellCallOutput(ConversationItem.LocalShellCallOutput localShellCallOutput)The output of a local shell tool call. final static ConversationItemofMcpListTools(ConversationItem.McpListTools mcpListTools)A list of tools available on an MCP server. final static ConversationItemofMcpApprovalRequest(ConversationItem.McpApprovalRequest mcpApprovalRequest)A request for human approval of a tool invocation. final static ConversationItemofMcpApprovalResponse(ConversationItem.McpApprovalResponse mcpApprovalResponse)A response to an MCP approval request. final static ConversationItemofMcpCall(ConversationItem.McpCall mcpCall)An invocation of a tool on an MCP server. final static ConversationItemofCustomToolCall(ResponseCustomToolCall customToolCall)A call to a custom tool created by the model. final static ConversationItemofCustomToolCallOutput(ResponseCustomToolCallOutput customToolCallOutput)The output of a custom tool call from your code, being sent back to the model. -
-
Method Detail
-
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()
-
fileSearchCall
final Optional<ResponseFileSearchToolCall> fileSearchCall()
The results of a file search tool call. See the file search guide for more information.
-
webSearchCall
final Optional<ResponseFunctionWebSearch> webSearchCall()
The results of a web search tool call. See the web search guide for more information.
-
imageGenerationCall
final Optional<ConversationItem.ImageGenerationCall> imageGenerationCall()
An image generation request made by the model.
-
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()
-
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.
-
codeInterpreterCall
final Optional<ResponseCodeInterpreterToolCall> codeInterpreterCall()
A tool call to run code.
-
localShellCall
final Optional<ConversationItem.LocalShellCall> localShellCall()
A tool call to run a command on the local shell.
-
localShellCallOutput
final Optional<ConversationItem.LocalShellCallOutput> localShellCallOutput()
The output of a local shell tool call.
-
mcpListTools
final Optional<ConversationItem.McpListTools> mcpListTools()
A list of tools available on an MCP server.
-
mcpApprovalRequest
final Optional<ConversationItem.McpApprovalRequest> mcpApprovalRequest()
A request for human approval of a tool invocation.
-
mcpApprovalResponse
final Optional<ConversationItem.McpApprovalResponse> mcpApprovalResponse()
A response to an MCP approval request.
-
mcpCall
final Optional<ConversationItem.McpCall> mcpCall()
An invocation of a tool on an MCP server.
-
customToolCall
final Optional<ResponseCustomToolCall> customToolCall()
A call to a custom tool created by the model.
-
customToolCallOutput
final Optional<ResponseCustomToolCallOutput> customToolCallOutput()
The output of a custom tool call from your code, being sent back to the model.
-
isFunctionCall
final Boolean isFunctionCall()
-
isFunctionCallOutput
final Boolean isFunctionCallOutput()
-
isFileSearchCall
final Boolean isFileSearchCall()
-
isWebSearchCall
final Boolean isWebSearchCall()
-
isImageGenerationCall
final Boolean isImageGenerationCall()
-
isComputerCall
final Boolean isComputerCall()
-
isComputerCallOutput
final Boolean isComputerCallOutput()
-
isReasoning
final Boolean isReasoning()
-
isCodeInterpreterCall
final Boolean isCodeInterpreterCall()
-
isLocalShellCall
final Boolean isLocalShellCall()
-
isLocalShellCallOutput
final Boolean isLocalShellCallOutput()
-
isMcpListTools
final Boolean isMcpListTools()
-
isMcpApprovalRequest
final Boolean isMcpApprovalRequest()
-
isMcpApprovalResponse
final Boolean isMcpApprovalResponse()
-
isCustomToolCall
final Boolean isCustomToolCall()
-
isCustomToolCallOutput
final Boolean isCustomToolCallOutput()
-
asFunctionCall
final ResponseFunctionToolCallItem asFunctionCall()
A tool call to run a function. See the function calling guide for more information.
-
asFunctionCallOutput
final ResponseFunctionToolCallOutputItem asFunctionCallOutput()
-
asFileSearchCall
final ResponseFileSearchToolCall asFileSearchCall()
The results of a file search tool call. See the file search guide for more information.
-
asWebSearchCall
final ResponseFunctionWebSearch asWebSearchCall()
The results of a web search tool call. See the web search guide for more information.
-
asImageGenerationCall
final ConversationItem.ImageGenerationCall asImageGenerationCall()
An image generation request made by the model.
-
asComputerCall
final ResponseComputerToolCall asComputerCall()
A tool call to a computer use tool. See the computer use guide for more information.
-
asComputerCallOutput
final ResponseComputerToolCallOutputItem asComputerCallOutput()
-
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.
-
asCodeInterpreterCall
final ResponseCodeInterpreterToolCall asCodeInterpreterCall()
A tool call to run code.
-
asLocalShellCall
final ConversationItem.LocalShellCall asLocalShellCall()
A tool call to run a command on the local shell.
-
asLocalShellCallOutput
final ConversationItem.LocalShellCallOutput asLocalShellCallOutput()
The output of a local shell tool call.
-
asMcpListTools
final ConversationItem.McpListTools asMcpListTools()
A list of tools available on an MCP server.
-
asMcpApprovalRequest
final ConversationItem.McpApprovalRequest asMcpApprovalRequest()
A request for human approval of a tool invocation.
-
asMcpApprovalResponse
final ConversationItem.McpApprovalResponse asMcpApprovalResponse()
A response to an MCP approval request.
-
asMcpCall
final ConversationItem.McpCall asMcpCall()
An invocation of a tool on an MCP server.
-
asCustomToolCall
final ResponseCustomToolCall asCustomToolCall()
A call to a custom tool created by the model.
-
asCustomToolCallOutput
final ResponseCustomToolCallOutput asCustomToolCallOutput()
The output of a custom tool call from your code, being sent back to the model.
-
accept
final <T extends Any> T accept(ConversationItem.Visitor<T> visitor)
-
validate
final ConversationItem validate()
-
ofMessage
final static ConversationItem ofMessage(Message message)
A message to or from the model.
-
ofFunctionCall
final static ConversationItem ofFunctionCall(ResponseFunctionToolCallItem functionCall)
A tool call to run a function. See the function calling guide for more information.
-
ofFunctionCallOutput
final static ConversationItem ofFunctionCallOutput(ResponseFunctionToolCallOutputItem functionCallOutput)
-
ofFileSearchCall
final static ConversationItem ofFileSearchCall(ResponseFileSearchToolCall fileSearchCall)
The results of a file search tool call. See the file search guide for more information.
-
ofWebSearchCall
final static ConversationItem ofWebSearchCall(ResponseFunctionWebSearch webSearchCall)
The results of a web search tool call. See the web search guide for more information.
-
ofImageGenerationCall
final static ConversationItem ofImageGenerationCall(ConversationItem.ImageGenerationCall imageGenerationCall)
An image generation request made by the model.
-
ofComputerCall
final static ConversationItem ofComputerCall(ResponseComputerToolCall computerCall)
A tool call to a computer use tool. See the computer use guide for more information.
-
ofComputerCallOutput
final static ConversationItem ofComputerCallOutput(ResponseComputerToolCallOutputItem computerCallOutput)
-
ofReasoning
final static ConversationItem 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.
-
ofCodeInterpreterCall
final static ConversationItem ofCodeInterpreterCall(ResponseCodeInterpreterToolCall codeInterpreterCall)
A tool call to run code.
-
ofLocalShellCall
final static ConversationItem ofLocalShellCall(ConversationItem.LocalShellCall localShellCall)
A tool call to run a command on the local shell.
-
ofLocalShellCallOutput
final static ConversationItem ofLocalShellCallOutput(ConversationItem.LocalShellCallOutput localShellCallOutput)
The output of a local shell tool call.
-
ofMcpListTools
final static ConversationItem ofMcpListTools(ConversationItem.McpListTools mcpListTools)
A list of tools available on an MCP server.
-
ofMcpApprovalRequest
final static ConversationItem ofMcpApprovalRequest(ConversationItem.McpApprovalRequest mcpApprovalRequest)
A request for human approval of a tool invocation.
-
ofMcpApprovalResponse
final static ConversationItem ofMcpApprovalResponse(ConversationItem.McpApprovalResponse mcpApprovalResponse)
A response to an MCP approval request.
-
ofMcpCall
final static ConversationItem ofMcpCall(ConversationItem.McpCall mcpCall)
An invocation of a tool on an MCP server.
-
ofCustomToolCall
final static ConversationItem ofCustomToolCall(ResponseCustomToolCall customToolCall)
A call to a custom tool created by the model.
-
ofCustomToolCallOutput
final static ConversationItem ofCustomToolCallOutput(ResponseCustomToolCallOutput customToolCallOutput)
The output of a custom tool call from your code, being sent back to the model.
-
-
-
-