Class BetaTool
-
- All Implemented Interfaces:
public final class BetaToolA tool that can be used to generate a response.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceBetaTool.VisitorAn interface that defines how to map each variant of BetaTool to a value of type T.
public final classBetaTool.McpGive the model access to additional tools via remote Model Context Protocol (MCP) servers. Learn more about MCP.
public final classBetaTool.CodeInterpreterA tool that runs Python code to help generate a response to a prompt.
public final classBetaTool.ImageGenerationA tool that generates images using the GPT image models.
-
Method Summary
Modifier and Type Method Description final Optional<BetaFunctionTool>function()Defines a function in your own code the model can choose to call. final Optional<BetaFileSearchTool>fileSearch()A tool that searches for relevant content from uploaded files. final Optional<BetaComputerTool>computer()A tool that controls a virtual computer. final Optional<BetaComputerUsePreviewTool>computerUsePreview()A tool that controls a virtual computer. final Optional<BetaWebSearchTool>webSearch()Search the Internet for sources related to the prompt. final Optional<BetaTool.Mcp>mcp()Give the model access to additional tools via remote Model Context Protocol (MCP) servers. final Optional<BetaTool.CodeInterpreter>codeInterpreter()A tool that runs Python code to help generate a response to a prompt. final Optional<JsonValue>programmaticToolCalling()final Optional<BetaTool.ImageGeneration>imageGeneration()A tool that generates images using the GPT image models. final Optional<JsonValue>localShell()A tool that allows the model to execute shell commands in a local environment. final Optional<BetaFunctionShellTool>shell()A tool that allows the model to execute shell commands. final Optional<BetaCustomTool>custom()A custom tool that processes input using a specified format. final Optional<BetaNamespaceTool>namespace()Groups function/custom tools under a shared namespace. final Optional<BetaToolSearchTool>toolSearch()Hosted or BYOT tool search configuration for deferred tools. final Optional<BetaWebSearchPreviewTool>webSearchPreview()This tool searches the web for relevant results to use in a response. final Optional<BetaApplyPatchTool>applyPatch()Allows the assistant to create, delete, or update files using unified diffs. final BooleanisFunction()final BooleanisFileSearch()final BooleanisComputer()final BooleanisComputerUsePreview()final BooleanisWebSearch()final BooleanisMcp()final BooleanisCodeInterpreter()final BooleanisProgrammaticToolCalling()final BooleanisImageGeneration()final BooleanisLocalShell()final BooleanisShell()final BooleanisCustom()final BooleanisNamespace()final BooleanisToolSearch()final BooleanisWebSearchPreview()final BooleanisApplyPatch()final BetaFunctionToolasFunction()Defines a function in your own code the model can choose to call. final BetaFileSearchToolasFileSearch()A tool that searches for relevant content from uploaded files. final BetaComputerToolasComputer()A tool that controls a virtual computer. final BetaComputerUsePreviewToolasComputerUsePreview()A tool that controls a virtual computer. final BetaWebSearchToolasWebSearch()Search the Internet for sources related to the prompt. final BetaTool.McpasMcp()Give the model access to additional tools via remote Model Context Protocol (MCP) servers. final BetaTool.CodeInterpreterasCodeInterpreter()A tool that runs Python code to help generate a response to a prompt. final JsonValueasProgrammaticToolCalling()final BetaTool.ImageGenerationasImageGeneration()A tool that generates images using the GPT image models. final JsonValueasLocalShell()A tool that allows the model to execute shell commands in a local environment. final BetaFunctionShellToolasShell()A tool that allows the model to execute shell commands. final BetaCustomToolasCustom()A custom tool that processes input using a specified format. final BetaNamespaceToolasNamespace()Groups function/custom tools under a shared namespace. final BetaToolSearchToolasToolSearch()Hosted or BYOT tool search configuration for deferred tools. final BetaWebSearchPreviewToolasWebSearchPreview()This tool searches the web for relevant results to use in a response. final BetaApplyPatchToolasApplyPatch()Allows the assistant to create, delete, or update files using unified diffs. final Optional<JsonValue>_json()final <T extends Any> Taccept(BetaTool.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final BetaToolvalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static BetaToolofFunction(BetaFunctionTool function)Defines a function in your own code the model can choose to call. final static BetaToolofFileSearch(BetaFileSearchTool fileSearch)A tool that searches for relevant content from uploaded files. final static BetaToolofComputer(BetaComputerTool computer)A tool that controls a virtual computer. final static BetaToolofComputerUsePreview(BetaComputerUsePreviewTool computerUsePreview)A tool that controls a virtual computer. final static BetaToolofWebSearch(BetaWebSearchTool webSearch)Search the Internet for sources related to the prompt. final static BetaToolofMcp(BetaTool.Mcp mcp)Give the model access to additional tools via remote Model Context Protocol (MCP) servers. final static BetaToolofCodeInterpreter(BetaTool.CodeInterpreter codeInterpreter)A tool that runs Python code to help generate a response to a prompt. final static BetaToolofProgrammaticToolCalling()final static BetaToolofImageGeneration(BetaTool.ImageGeneration imageGeneration)A tool that generates images using the GPT image models. final static BetaToolofLocalShell()A tool that allows the model to execute shell commands in a local environment. final static BetaToolofShell(BetaFunctionShellTool shell)A tool that allows the model to execute shell commands. final static BetaToolofCustom(BetaCustomTool custom)A custom tool that processes input using a specified format. final static BetaToolofNamespace(BetaNamespaceTool namespace)Groups function/custom tools under a shared namespace. final static BetaToolofToolSearch(BetaToolSearchTool toolSearch)Hosted or BYOT tool search configuration for deferred tools. final static BetaToolofWebSearchPreview(BetaWebSearchPreviewTool webSearchPreview)This tool searches the web for relevant results to use in a response. final static BetaToolofApplyPatch(BetaApplyPatchTool applyPatch)Allows the assistant to create, delete, or update files using unified diffs. -
-
Method Detail
-
function
final Optional<BetaFunctionTool> function()
Defines a function in your own code the model can choose to call. Learn more about function calling.
-
fileSearch
final Optional<BetaFileSearchTool> fileSearch()
A tool that searches for relevant content from uploaded files. Learn more about the file search tool.
-
computer
final Optional<BetaComputerTool> computer()
A tool that controls a virtual computer. Learn more about the computer tool.
-
computerUsePreview
final Optional<BetaComputerUsePreviewTool> computerUsePreview()
A tool that controls a virtual computer. Learn more about the computer tool.
-
webSearch
final Optional<BetaWebSearchTool> webSearch()
Search the Internet for sources related to the prompt. Learn more about the web search tool.
-
mcp
final Optional<BetaTool.Mcp> mcp()
Give the model access to additional tools via remote Model Context Protocol (MCP) servers. Learn more about MCP.
-
codeInterpreter
final Optional<BetaTool.CodeInterpreter> codeInterpreter()
A tool that runs Python code to help generate a response to a prompt.
-
programmaticToolCalling
final Optional<JsonValue> programmaticToolCalling()
-
imageGeneration
final Optional<BetaTool.ImageGeneration> imageGeneration()
A tool that generates images using the GPT image models.
-
localShell
final Optional<JsonValue> localShell()
A tool that allows the model to execute shell commands in a local environment.
-
shell
final Optional<BetaFunctionShellTool> shell()
A tool that allows the model to execute shell commands.
-
custom
final Optional<BetaCustomTool> custom()
A custom tool that processes input using a specified format. Learn more about custom tools
-
namespace
final Optional<BetaNamespaceTool> namespace()
Groups function/custom tools under a shared namespace.
-
toolSearch
final Optional<BetaToolSearchTool> toolSearch()
Hosted or BYOT tool search configuration for deferred tools.
-
webSearchPreview
final Optional<BetaWebSearchPreviewTool> webSearchPreview()
This tool searches the web for relevant results to use in a response. Learn more about the web search tool.
-
applyPatch
final Optional<BetaApplyPatchTool> applyPatch()
Allows the assistant to create, delete, or update files using unified diffs.
-
isFunction
final Boolean isFunction()
-
isFileSearch
final Boolean isFileSearch()
-
isComputer
final Boolean isComputer()
-
isComputerUsePreview
final Boolean isComputerUsePreview()
-
isWebSearch
final Boolean isWebSearch()
-
isCodeInterpreter
final Boolean isCodeInterpreter()
-
isProgrammaticToolCalling
final Boolean isProgrammaticToolCalling()
-
isImageGeneration
final Boolean isImageGeneration()
-
isLocalShell
final Boolean isLocalShell()
-
isNamespace
final Boolean isNamespace()
-
isToolSearch
final Boolean isToolSearch()
-
isWebSearchPreview
final Boolean isWebSearchPreview()
-
isApplyPatch
final Boolean isApplyPatch()
-
asFunction
final BetaFunctionTool asFunction()
Defines a function in your own code the model can choose to call. Learn more about function calling.
-
asFileSearch
final BetaFileSearchTool asFileSearch()
A tool that searches for relevant content from uploaded files. Learn more about the file search tool.
-
asComputer
final BetaComputerTool asComputer()
A tool that controls a virtual computer. Learn more about the computer tool.
-
asComputerUsePreview
final BetaComputerUsePreviewTool asComputerUsePreview()
A tool that controls a virtual computer. Learn more about the computer tool.
-
asWebSearch
final BetaWebSearchTool asWebSearch()
Search the Internet for sources related to the prompt. Learn more about the web search tool.
-
asMcp
final BetaTool.Mcp asMcp()
Give the model access to additional tools via remote Model Context Protocol (MCP) servers. Learn more about MCP.
-
asCodeInterpreter
final BetaTool.CodeInterpreter asCodeInterpreter()
A tool that runs Python code to help generate a response to a prompt.
-
asProgrammaticToolCalling
final JsonValue asProgrammaticToolCalling()
-
asImageGeneration
final BetaTool.ImageGeneration asImageGeneration()
A tool that generates images using the GPT image models.
-
asLocalShell
final JsonValue asLocalShell()
A tool that allows the model to execute shell commands in a local environment.
-
asShell
final BetaFunctionShellTool asShell()
A tool that allows the model to execute shell commands.
-
asCustom
final BetaCustomTool asCustom()
A custom tool that processes input using a specified format. Learn more about custom tools
-
asNamespace
final BetaNamespaceTool asNamespace()
Groups function/custom tools under a shared namespace.
-
asToolSearch
final BetaToolSearchTool asToolSearch()
Hosted or BYOT tool search configuration for deferred tools.
-
asWebSearchPreview
final BetaWebSearchPreviewTool asWebSearchPreview()
This tool searches the web for relevant results to use in a response. Learn more about the web search tool.
-
asApplyPatch
final BetaApplyPatchTool asApplyPatch()
Allows the assistant to create, delete, or update files using unified diffs.
-
accept
final <T extends Any> T accept(BetaTool.Visitor<T> visitor)
Maps this instance's current variant to a value of type T using the given visitor.
Note that this method is not forwards compatible with new variants from the API, unless visitor overrides Visitor.unknown. To handle variants not known to this version of the SDK gracefully, consider overriding Visitor.unknown:
import com.openai.core.JsonValue; import java.util.Optional; Optional<String> result = betaTool.accept(new BetaTool.Visitor<Optional<String>>() { @Override public Optional<String> visitFunction(BetaFunctionTool function) { return Optional.of(function.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final BetaTool validate()
Validates that the types of all values in this object match their expected types recursively.
This method is not forwards compatible with new types from the API for existing fields.
-
ofFunction
final static BetaTool ofFunction(BetaFunctionTool function)
Defines a function in your own code the model can choose to call. Learn more about function calling.
-
ofFileSearch
final static BetaTool ofFileSearch(BetaFileSearchTool fileSearch)
A tool that searches for relevant content from uploaded files. Learn more about the file search tool.
-
ofComputer
final static BetaTool ofComputer(BetaComputerTool computer)
A tool that controls a virtual computer. Learn more about the computer tool.
-
ofComputerUsePreview
final static BetaTool ofComputerUsePreview(BetaComputerUsePreviewTool computerUsePreview)
A tool that controls a virtual computer. Learn more about the computer tool.
-
ofWebSearch
final static BetaTool ofWebSearch(BetaWebSearchTool webSearch)
Search the Internet for sources related to the prompt. Learn more about the web search tool.
-
ofMcp
final static BetaTool ofMcp(BetaTool.Mcp mcp)
Give the model access to additional tools via remote Model Context Protocol (MCP) servers. Learn more about MCP.
-
ofCodeInterpreter
final static BetaTool ofCodeInterpreter(BetaTool.CodeInterpreter codeInterpreter)
A tool that runs Python code to help generate a response to a prompt.
-
ofProgrammaticToolCalling
final static BetaTool ofProgrammaticToolCalling()
-
ofImageGeneration
final static BetaTool ofImageGeneration(BetaTool.ImageGeneration imageGeneration)
A tool that generates images using the GPT image models.
-
ofLocalShell
final static BetaTool ofLocalShell()
A tool that allows the model to execute shell commands in a local environment.
-
ofShell
final static BetaTool ofShell(BetaFunctionShellTool shell)
A tool that allows the model to execute shell commands.
-
ofCustom
final static BetaTool ofCustom(BetaCustomTool custom)
A custom tool that processes input using a specified format. Learn more about custom tools
-
ofNamespace
final static BetaTool ofNamespace(BetaNamespaceTool namespace)
Groups function/custom tools under a shared namespace.
-
ofToolSearch
final static BetaTool ofToolSearch(BetaToolSearchTool toolSearch)
Hosted or BYOT tool search configuration for deferred tools.
-
ofWebSearchPreview
final static BetaTool ofWebSearchPreview(BetaWebSearchPreviewTool webSearchPreview)
This tool searches the web for relevant results to use in a response. Learn more about the web search tool.
-
ofApplyPatch
final static BetaTool ofApplyPatch(BetaApplyPatchTool applyPatch)
Allows the assistant to create, delete, or update files using unified diffs.
-
-
-
-