Class Tool
-
- All Implemented Interfaces:
public final class Tool
A tool that can be used to generate a response.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
Tool.Visitor
An interface that defines how to map each variant of Tool to a value of type T.
public final class
Tool.Mcp
Give the model access to additional tools via remote Model Context Protocol (MCP) servers. Learn more about MCP.
public final class
Tool.CodeInterpreter
A tool that runs Python code to help generate a response to a prompt.
public final class
Tool.ImageGeneration
A 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()
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 Optional<WebSearchPreviewTool>
webSearchPreview()
This tool searches the web for relevant results to use in a response. final Boolean
isFunction()
final Boolean
isFileSearch()
final Boolean
isComputerUsePreview()
final Boolean
isWebSearch()
final Boolean
isMcp()
final Boolean
isCodeInterpreter()
final Boolean
isImageGeneration()
final Boolean
isLocalShell()
final Boolean
isCustom()
final Boolean
isWebSearchPreview()
final FunctionTool
asFunction()
Defines a function in your own code the model can choose to call. final FileSearchTool
asFileSearch()
A tool that searches for relevant content from uploaded files. final ComputerTool
asComputerUsePreview()
A tool that controls a virtual computer. final WebSearchTool
asWebSearch()
Search the Internet for sources related to the prompt. final Tool.Mcp
asMcp()
Give the model access to additional tools via remote Model Context Protocol (MCP) servers. final Tool.CodeInterpreter
asCodeInterpreter()
A tool that runs Python code to help generate a response to a prompt. final Tool.ImageGeneration
asImageGeneration()
A tool that generates images using a model like gpt-image-1
.final JsonValue
asLocalShell()
A tool that allows the model to execute shell commands in a local environment. final CustomTool
asCustom()
A custom tool that processes input using a specified format. final WebSearchPreviewTool
asWebSearchPreview()
This tool searches the web for relevant results to use in a response. final Optional<JsonValue>
_json()
final <T extends Any> T
accept(Tool.Visitor<T> visitor)
final Tool
validate()
final Boolean
isValid()
Boolean
equals(Object other)
Integer
hashCode()
String
toString()
final static Tool
ofFunction(FunctionTool function)
Defines a function in your own code the model can choose to call. final static Tool
ofFileSearch(FileSearchTool fileSearch)
A tool that searches for relevant content from uploaded files. final static Tool
ofComputerUsePreview(ComputerTool computerUsePreview)
A tool that controls a virtual computer. final static Tool
ofWebSearch(WebSearchTool webSearch)
Search the Internet for sources related to the prompt. final static Tool
ofMcp(Tool.Mcp mcp)
Give the model access to additional tools via remote Model Context Protocol (MCP) servers. final static Tool
ofCodeInterpreter(Tool.CodeInterpreter codeInterpreter)
A tool that runs Python code to help generate a response to a prompt. final static Tool
ofImageGeneration(Tool.ImageGeneration imageGeneration)
A tool that generates images using a model like gpt-image-1
.final static Tool
ofLocalShell()
A tool that allows the model to execute shell commands in a local environment. final static Tool
ofCustom(CustomTool custom)
A custom tool that processes input using a specified format. final static Tool
ofWebSearchPreview(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()
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.
-
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()
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.
-
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()
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.
-
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.
-
-
-
-