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<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 Boolean
isFunction()
final Boolean
isFileSearch()
final Boolean
isWebSearch()
final Boolean
isComputerUsePreview()
final Boolean
isMcp()
final Boolean
isCodeInterpreter()
final Boolean
isImageGeneration()
final Boolean
isLocalShell()
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 WebSearchTool
asWebSearch()
This tool searches the web for relevant results to use in a response. final ComputerTool
asComputerUsePreview()
A tool that controls a virtual computer. 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 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
ofWebSearch(WebSearchTool webSearch)
This tool searches the web for relevant results to use in a response. final static Tool
ofComputerUsePreview(ComputerTool computerUsePreview)
A tool that controls a virtual computer. 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. -
-
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.
-
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.
-
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.
-
-
-
-