Class Tool
- 
                    
                    
- All Implemented Interfaces:
 
public final class ToolA tool that can be used to generate a response.
 
- 
                
                    
                    
- 
                                
                            
                                
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceTool.VisitorAn interface that defines how to map each variant of Tool to a value of type T.
public final classTool.McpGive the model access to additional tools via remote Model Context Protocol (MCP) servers. Learn more about MCP.
public final classTool.CodeInterpreterA tool that runs Python code to help generate a response to a prompt.
public final classTool.ImageGenerationA tool that generates images using a model like
gpt-image-1. 
- 
                                
                            
                                
Method Summary
Modifier and Type Method Description final Optional<FunctionTool>function()Defines a function in your own code the model can choose to call. final Optional<FileSearchTool>fileSearch()A tool that searches for relevant content from uploaded files. final Optional<WebSearchTool>webSearch()This tool searches the web for relevant results to use in a response. final Optional<ComputerTool>computerUsePreview()A tool that controls a virtual computer. final Optional<Tool.Mcp>mcp()Give the model access to additional tools via remote Model Context Protocol (MCP) servers. final Optional<Tool.CodeInterpreter>codeInterpreter()A tool that runs Python code to help generate a response to a prompt. final Optional<Tool.ImageGeneration>imageGeneration()A tool that generates images using a model like gpt-image-1.final Optional<JsonValue>localShell()A tool that allows the model to execute shell commands in a local environment. final Optional<CustomTool>custom()A custom tool that processes input using a specified format. final BooleanisFunction()final BooleanisFileSearch()final BooleanisWebSearch()final BooleanisComputerUsePreview()final BooleanisMcp()final BooleanisCodeInterpreter()final BooleanisImageGeneration()final BooleanisLocalShell()final BooleanisCustom()final FunctionToolasFunction()Defines a function in your own code the model can choose to call. final FileSearchToolasFileSearch()A tool that searches for relevant content from uploaded files. final WebSearchToolasWebSearch()This tool searches the web for relevant results to use in a response. final ComputerToolasComputerUsePreview()A tool that controls a virtual computer. final Tool.McpasMcp()Give the model access to additional tools via remote Model Context Protocol (MCP) servers. final Tool.CodeInterpreterasCodeInterpreter()A tool that runs Python code to help generate a response to a prompt. final Tool.ImageGenerationasImageGeneration()A tool that generates images using a model like gpt-image-1.final JsonValueasLocalShell()A tool that allows the model to execute shell commands in a local environment. final CustomToolasCustom()A custom tool that processes input using a specified format. final Optional<JsonValue>_json()final <T extends Any> Taccept(Tool.Visitor<T> visitor)final Toolvalidate()final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static ToolofFunction(FunctionTool function)Defines a function in your own code the model can choose to call. final static ToolofFileSearch(FileSearchTool fileSearch)A tool that searches for relevant content from uploaded files. final static ToolofWebSearch(WebSearchTool webSearch)This tool searches the web for relevant results to use in a response. final static ToolofComputerUsePreview(ComputerTool computerUsePreview)A tool that controls a virtual computer. final static ToolofMcp(Tool.Mcp mcp)Give the model access to additional tools via remote Model Context Protocol (MCP) servers. final static ToolofCodeInterpreter(Tool.CodeInterpreter codeInterpreter)A tool that runs Python code to help generate a response to a prompt. final static ToolofImageGeneration(Tool.ImageGeneration imageGeneration)A tool that generates images using a model like gpt-image-1.final static ToolofLocalShell()A tool that allows the model to execute shell commands in a local environment. final static ToolofCustom(CustomTool custom)A custom tool that processes input using a specified format. - 
                    
                    
                    
- 
                                
                            
                                
Method Detail
- 
                                        
function
final Optional<FunctionTool> function()
Defines a function in your own code the model can choose to call. Learn more about function calling.
 
- 
                                        
fileSearch
final Optional<FileSearchTool> fileSearch()
A tool that searches for relevant content from uploaded files. Learn more about the file search tool.
 
- 
                                        
webSearch
final Optional<WebSearchTool> webSearch()
This tool searches the web for relevant results to use in a response. Learn more about the web search tool.
 
- 
                                        
computerUsePreview
final Optional<ComputerTool> computerUsePreview()
A tool that controls a virtual computer. Learn more about the computer tool.
 
- 
                                        
mcp
final Optional<Tool.Mcp> mcp()
Give the model access to additional tools via remote Model Context Protocol (MCP) servers. Learn more about MCP.
 
- 
                                        
codeInterpreter
final Optional<Tool.CodeInterpreter> codeInterpreter()
A tool that runs Python code to help generate a response to a prompt.
 
- 
                                        
imageGeneration
final Optional<Tool.ImageGeneration> imageGeneration()
A tool that generates images using a model like
gpt-image-1. 
- 
                                        
localShell
final Optional<JsonValue> localShell()
A tool that allows the model to execute shell commands in a local environment.
 
- 
                                        
custom
final Optional<CustomTool> custom()
A custom tool that processes input using a specified format. Learn more about custom tools.
 
- 
                                        
isFunction
final Boolean isFunction()
 
- 
                                        
isFileSearch
final Boolean isFileSearch()
 
- 
                                        
isWebSearch
final Boolean isWebSearch()
 
- 
                                        
isComputerUsePreview
final Boolean isComputerUsePreview()
 
- 
                                        
isCodeInterpreter
final Boolean isCodeInterpreter()
 
- 
                                        
isImageGeneration
final Boolean isImageGeneration()
 
- 
                                        
isLocalShell
final Boolean isLocalShell()
 
- 
                                        
asFunction
final FunctionTool asFunction()
Defines a function in your own code the model can choose to call. Learn more about function calling.
 
- 
                                        
asFileSearch
final FileSearchTool asFileSearch()
A tool that searches for relevant content from uploaded files. Learn more about the file search tool.
 
- 
                                        
asWebSearch
final WebSearchTool asWebSearch()
This tool searches the web for relevant results to use in a response. Learn more about the web search tool.
 
- 
                                        
asComputerUsePreview
final ComputerTool asComputerUsePreview()
A tool that controls a virtual computer. Learn more about the computer tool.
 
- 
                                        
asMcp
final Tool.Mcp asMcp()
Give the model access to additional tools via remote Model Context Protocol (MCP) servers. Learn more about MCP.
 
- 
                                        
asCodeInterpreter
final Tool.CodeInterpreter asCodeInterpreter()
A tool that runs Python code to help generate a response to a prompt.
 
- 
                                        
asImageGeneration
final Tool.ImageGeneration asImageGeneration()
A tool that generates images using a model like
gpt-image-1. 
- 
                                        
asLocalShell
final JsonValue asLocalShell()
A tool that allows the model to execute shell commands in a local environment.
 
- 
                                        
asCustom
final CustomTool asCustom()
A custom tool that processes input using a specified format. Learn more about custom tools.
 
- 
                                        
accept
final <T extends Any> T accept(Tool.Visitor<T> visitor)
 
- 
                                        
ofFunction
final static Tool ofFunction(FunctionTool function)
Defines a function in your own code the model can choose to call. Learn more about function calling.
 
- 
                                        
ofFileSearch
final static Tool ofFileSearch(FileSearchTool fileSearch)
A tool that searches for relevant content from uploaded files. Learn more about the file search tool.
 
- 
                                        
ofWebSearch
final static Tool ofWebSearch(WebSearchTool webSearch)
This tool searches the web for relevant results to use in a response. Learn more about the web search tool.
 
- 
                                        
ofComputerUsePreview
final static Tool ofComputerUsePreview(ComputerTool computerUsePreview)
A tool that controls a virtual computer. Learn more about the computer tool.
 
- 
                                        
ofMcp
final static Tool ofMcp(Tool.Mcp mcp)
Give the model access to additional tools via remote Model Context Protocol (MCP) servers. Learn more about MCP.
 
- 
                                        
ofCodeInterpreter
final static Tool ofCodeInterpreter(Tool.CodeInterpreter codeInterpreter)
A tool that runs Python code to help generate a response to a prompt.
 
- 
                                        
ofImageGeneration
final static Tool ofImageGeneration(Tool.ImageGeneration imageGeneration)
A tool that generates images using a model like
gpt-image-1. 
- 
                                        
ofLocalShell
final static Tool ofLocalShell()
A tool that allows the model to execute shell commands in a local environment.
 
- 
                                        
ofCustom
final static Tool ofCustom(CustomTool custom)
A custom tool that processes input using a specified format. Learn more about custom tools.
 
 - 
                                        
 
 - 
                                
                            
                                
 
 - 
                    
                    
                    
 
 -