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<ComputerTool>computerUsePreview()A tool that controls a virtual computer. final Optional<WebSearchTool>webSearch()Search the Internet for sources related to the prompt. 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()final Optional<CustomTool>custom()final Optional<WebSearchPreviewTool>webSearchPreview()This tool searches the web for relevant results to use in a response. final BooleanisFunction()final BooleanisFileSearch()final BooleanisComputerUsePreview()final BooleanisWebSearch()final BooleanisMcp()final BooleanisCodeInterpreter()final BooleanisImageGeneration()final BooleanisLocalShell()final BooleanisCustom()final BooleanisWebSearchPreview()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 ComputerToolasComputerUsePreview()A tool that controls a virtual computer. final WebSearchToolasWebSearch()Search the Internet for sources related to the prompt. 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()final CustomToolasCustom()final WebSearchPreviewToolasWebSearchPreview()This tool searches the web for relevant results to use in a response. 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 ToolofComputerUsePreview(ComputerTool computerUsePreview)A tool that controls a virtual computer. final static ToolofWebSearch(WebSearchTool webSearch)Search the Internet for sources related to the prompt. 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()final static ToolofCustom(CustomTool custom)final static ToolofWebSearchPreview(WebSearchPreviewTool webSearchPreview)This tool searches the web for relevant results to use in a response. -
-
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.
-
computerUsePreview
final Optional<ComputerTool> computerUsePreview()
A tool that controls a virtual computer. Learn more about the computer tool.
-
webSearch
final Optional<WebSearchTool> webSearch()
Search the Internet for sources related to the prompt. Learn more about the web search 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()
-
custom
final Optional<CustomTool> custom()
-
webSearchPreview
final Optional<WebSearchPreviewTool> webSearchPreview()
This tool searches the web for relevant results to use in a response. Learn more about the web search tool.
-
isFunction
final Boolean isFunction()
-
isFileSearch
final Boolean isFileSearch()
-
isComputerUsePreview
final Boolean isComputerUsePreview()
-
isWebSearch
final Boolean isWebSearch()
-
isCodeInterpreter
final Boolean isCodeInterpreter()
-
isImageGeneration
final Boolean isImageGeneration()
-
isLocalShell
final Boolean isLocalShell()
-
isWebSearchPreview
final Boolean isWebSearchPreview()
-
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.
-
asComputerUsePreview
final ComputerTool asComputerUsePreview()
A tool that controls a virtual computer. Learn more about the computer tool.
-
asWebSearch
final WebSearchTool asWebSearch()
Search the Internet for sources related to the prompt. Learn more about the web search 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()
-
asCustom
final CustomTool asCustom()
-
asWebSearchPreview
final WebSearchPreviewTool asWebSearchPreview()
This tool searches the web for relevant results to use in a response. Learn more about the web search tool.
-
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.
-
ofComputerUsePreview
final static Tool ofComputerUsePreview(ComputerTool computerUsePreview)
A tool that controls a virtual computer. Learn more about the computer tool.
-
ofWebSearch
final static Tool ofWebSearch(WebSearchTool webSearch)
Search the Internet for sources related to the prompt. Learn more about the web search 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()
-
ofCustom
final static Tool ofCustom(CustomTool custom)
-
ofWebSearchPreview
final static Tool ofWebSearchPreview(WebSearchPreviewTool webSearchPreview)
This tool searches the web for relevant results to use in a response. Learn more about the web search tool.
-
-
-
-