Class ToolUnion
-
- All Implemented Interfaces:
public final class ToolUnion
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceToolUnion.VisitorAn interface that defines how to map each variant of ToolUnion to a value of type T.
-
Method Summary
-
-
Method Detail
-
bash20250124
final Optional<ToolBash20250124> bash20250124()
-
codeExecutionTool20250522
final Optional<CodeExecutionTool20250522> codeExecutionTool20250522()
-
codeExecutionTool20250825
final Optional<CodeExecutionTool20250825> codeExecutionTool20250825()
-
codeExecutionTool20260120
final Optional<CodeExecutionTool20260120> codeExecutionTool20260120()
A
toolsentry for the code execution tool, versioncode_execution_20260120. It adds REPL state persistence to versioncode_execution_20250825.REPL state persistence applies with programmatic tool calling. With it, the Python interpreter state, such as variable bindings, persists across requests that reuse the container.
See the code execution tool guide to learn what each tool version adds.
-
codeExecutionTool20260521
final Optional<CodeExecutionTool20260521> codeExecutionTool20260521()
Code execution tool with REPL state persistence.
-
browserToolset20260801
final Optional<BrowserToolset20260801> browserToolset20260801()
The browser toolset: a single
`tools[]`entry (carrying no`name`) that declares the browser tool family. The model is served the family's tool with any members disabled via`configs`removed from its schema.
-
memoryTool20250818
final Optional<MemoryTool20250818> memoryTool20250818()
-
computerToolset20260801
final Optional<ComputerToolset20260801> computerToolset20260801()
The computer toolset: a single
`tools[]`entry (carrying no`name`) that declares the computer tool family. The model is served the family's tool with any members disabled via`configs`removed from its schema. Every member is enabled by default, zoom included. The single-tool options`display_number`and`enable_zoom`are not fields of a toolset entry — it carries only`type`,`configs`, and`cache_control`; zoom is controlled via`configs.zoom.enabled`.
-
textEditor20250124
final Optional<ToolTextEditor20250124> textEditor20250124()
-
textEditor20250429
final Optional<ToolTextEditor20250429> textEditor20250429()
-
textEditor20250728
final Optional<ToolTextEditor20250728> textEditor20250728()
-
webSearchTool20250305
final Optional<WebSearchTool20250305> webSearchTool20250305()
-
webFetchTool20250910
final Optional<WebFetchTool20250910> webFetchTool20250910()
-
webSearchTool20260209
final Optional<WebSearchTool20260209> webSearchTool20260209()
-
webFetchTool20260209
final Optional<WebFetchTool20260209> webFetchTool20260209()
-
webFetchTool20260309
final Optional<WebFetchTool20260309> webFetchTool20260309()
Web fetch tool with use_cache parameter for bypassing cached content.
-
webSearchTool20260318
final Optional<WebSearchTool20260318> webSearchTool20260318()
-
webFetchTool20260318
final Optional<WebFetchTool20260318> webFetchTool20260318()
-
searchToolBm25_20251119
final Optional<ToolSearchToolBm25_20251119> searchToolBm25_20251119()
-
searchToolRegex20251119
final Optional<ToolSearchToolRegex20251119> searchToolRegex20251119()
-
cacheControl
final Optional<CacheControlEphemeral> cacheControl()
-
deferLoading
final Optional<Boolean> deferLoading()
-
allowedDomains
final Optional<List<String>> allowedDomains()
-
blockedDomains
final Optional<List<String>> blockedDomains()
-
userLocation
final Optional<UserLocation> userLocation()
-
citations
final Optional<CitationsConfigParam> citations()
-
maxContentTokens
final Optional<Long> maxContentTokens()
-
urlSources
final Optional<WebFetchUrlSources> urlSources()
-
isBash20250124
final Boolean isBash20250124()
-
isCodeExecutionTool20250522
final Boolean isCodeExecutionTool20250522()
-
isCodeExecutionTool20250825
final Boolean isCodeExecutionTool20250825()
-
isCodeExecutionTool20260120
final Boolean isCodeExecutionTool20260120()
-
isCodeExecutionTool20260521
final Boolean isCodeExecutionTool20260521()
-
isBrowserToolset20260801
final Boolean isBrowserToolset20260801()
-
isMemoryTool20250818
final Boolean isMemoryTool20250818()
-
isComputerToolset20260801
final Boolean isComputerToolset20260801()
-
isTextEditor20250124
final Boolean isTextEditor20250124()
-
isTextEditor20250429
final Boolean isTextEditor20250429()
-
isTextEditor20250728
final Boolean isTextEditor20250728()
-
isWebSearchTool20250305
final Boolean isWebSearchTool20250305()
-
isWebFetchTool20250910
final Boolean isWebFetchTool20250910()
-
isWebSearchTool20260209
final Boolean isWebSearchTool20260209()
-
isWebFetchTool20260209
final Boolean isWebFetchTool20260209()
-
isWebFetchTool20260309
final Boolean isWebFetchTool20260309()
-
isWebSearchTool20260318
final Boolean isWebSearchTool20260318()
-
isWebFetchTool20260318
final Boolean isWebFetchTool20260318()
-
isSearchToolBm25_20251119
final Boolean isSearchToolBm25_20251119()
-
isSearchToolRegex20251119
final Boolean isSearchToolRegex20251119()
-
asBash20250124
final ToolBash20250124 asBash20250124()
-
asCodeExecutionTool20250522
final CodeExecutionTool20250522 asCodeExecutionTool20250522()
-
asCodeExecutionTool20250825
final CodeExecutionTool20250825 asCodeExecutionTool20250825()
-
asCodeExecutionTool20260120
final CodeExecutionTool20260120 asCodeExecutionTool20260120()
A
toolsentry for the code execution tool, versioncode_execution_20260120. It adds REPL state persistence to versioncode_execution_20250825.REPL state persistence applies with programmatic tool calling. With it, the Python interpreter state, such as variable bindings, persists across requests that reuse the container.
See the code execution tool guide to learn what each tool version adds.
-
asCodeExecutionTool20260521
final CodeExecutionTool20260521 asCodeExecutionTool20260521()
Code execution tool with REPL state persistence.
-
asBrowserToolset20260801
final BrowserToolset20260801 asBrowserToolset20260801()
The browser toolset: a single
`tools[]`entry (carrying no`name`) that declares the browser tool family. The model is served the family's tool with any members disabled via`configs`removed from its schema.
-
asMemoryTool20250818
final MemoryTool20250818 asMemoryTool20250818()
-
asComputerToolset20260801
final ComputerToolset20260801 asComputerToolset20260801()
The computer toolset: a single
`tools[]`entry (carrying no`name`) that declares the computer tool family. The model is served the family's tool with any members disabled via`configs`removed from its schema. Every member is enabled by default, zoom included. The single-tool options`display_number`and`enable_zoom`are not fields of a toolset entry — it carries only`type`,`configs`, and`cache_control`; zoom is controlled via`configs.zoom.enabled`.
-
asTextEditor20250124
final ToolTextEditor20250124 asTextEditor20250124()
-
asTextEditor20250429
final ToolTextEditor20250429 asTextEditor20250429()
-
asTextEditor20250728
final ToolTextEditor20250728 asTextEditor20250728()
-
asWebSearchTool20250305
final WebSearchTool20250305 asWebSearchTool20250305()
-
asWebFetchTool20250910
final WebFetchTool20250910 asWebFetchTool20250910()
-
asWebSearchTool20260209
final WebSearchTool20260209 asWebSearchTool20260209()
-
asWebFetchTool20260209
final WebFetchTool20260209 asWebFetchTool20260209()
-
asWebFetchTool20260309
final WebFetchTool20260309 asWebFetchTool20260309()
Web fetch tool with use_cache parameter for bypassing cached content.
-
asWebSearchTool20260318
final WebSearchTool20260318 asWebSearchTool20260318()
-
asWebFetchTool20260318
final WebFetchTool20260318 asWebFetchTool20260318()
-
asSearchToolBm25_20251119
final ToolSearchToolBm25_20251119 asSearchToolBm25_20251119()
-
asSearchToolRegex20251119
final ToolSearchToolRegex20251119 asSearchToolRegex20251119()
-
accept
final <T extends Any> T accept(ToolUnion.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.anthropic.core.JsonValue; import java.util.Optional; Optional<String> result = toolUnion.accept(new ToolUnion.Visitor<Optional<String>>() { @Override public Optional<String> visitTool(Tool tool) { return Optional.of(tool.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final ToolUnion 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.
-
ofBash20250124
final static ToolUnion ofBash20250124(ToolBash20250124 bash20250124)
-
ofCodeExecutionTool20250522
final static ToolUnion ofCodeExecutionTool20250522(CodeExecutionTool20250522 codeExecutionTool20250522)
-
ofCodeExecutionTool20250825
final static ToolUnion ofCodeExecutionTool20250825(CodeExecutionTool20250825 codeExecutionTool20250825)
-
ofCodeExecutionTool20260120
final static ToolUnion ofCodeExecutionTool20260120(CodeExecutionTool20260120 codeExecutionTool20260120)
A
toolsentry for the code execution tool, versioncode_execution_20260120. It adds REPL state persistence to versioncode_execution_20250825.REPL state persistence applies with programmatic tool calling. With it, the Python interpreter state, such as variable bindings, persists across requests that reuse the container.
See the code execution tool guide to learn what each tool version adds.
-
ofCodeExecutionTool20260521
final static ToolUnion ofCodeExecutionTool20260521(CodeExecutionTool20260521 codeExecutionTool20260521)
Code execution tool with REPL state persistence.
-
ofBrowserToolset20260801
final static ToolUnion ofBrowserToolset20260801(BrowserToolset20260801 browserToolset20260801)
The browser toolset: a single
`tools[]`entry (carrying no`name`) that declares the browser tool family. The model is served the family's tool with any members disabled via`configs`removed from its schema.
-
ofMemoryTool20250818
final static ToolUnion ofMemoryTool20250818(MemoryTool20250818 memoryTool20250818)
-
ofComputerToolset20260801
final static ToolUnion ofComputerToolset20260801(ComputerToolset20260801 computerToolset20260801)
The computer toolset: a single
`tools[]`entry (carrying no`name`) that declares the computer tool family. The model is served the family's tool with any members disabled via`configs`removed from its schema. Every member is enabled by default, zoom included. The single-tool options`display_number`and`enable_zoom`are not fields of a toolset entry — it carries only`type`,`configs`, and`cache_control`; zoom is controlled via`configs.zoom.enabled`.
-
ofTextEditor20250124
final static ToolUnion ofTextEditor20250124(ToolTextEditor20250124 textEditor20250124)
-
ofTextEditor20250429
final static ToolUnion ofTextEditor20250429(ToolTextEditor20250429 textEditor20250429)
-
ofTextEditor20250728
final static ToolUnion ofTextEditor20250728(ToolTextEditor20250728 textEditor20250728)
-
ofWebSearchTool20250305
final static ToolUnion ofWebSearchTool20250305(WebSearchTool20250305 webSearchTool20250305)
-
ofWebFetchTool20250910
final static ToolUnion ofWebFetchTool20250910(WebFetchTool20250910 webFetchTool20250910)
-
ofWebSearchTool20260209
final static ToolUnion ofWebSearchTool20260209(WebSearchTool20260209 webSearchTool20260209)
-
ofWebFetchTool20260209
final static ToolUnion ofWebFetchTool20260209(WebFetchTool20260209 webFetchTool20260209)
-
ofWebFetchTool20260309
final static ToolUnion ofWebFetchTool20260309(WebFetchTool20260309 webFetchTool20260309)
Web fetch tool with use_cache parameter for bypassing cached content.
-
ofWebSearchTool20260318
final static ToolUnion ofWebSearchTool20260318(WebSearchTool20260318 webSearchTool20260318)
-
ofWebFetchTool20260318
final static ToolUnion ofWebFetchTool20260318(WebFetchTool20260318 webFetchTool20260318)
-
ofSearchToolBm25_20251119
final static ToolUnion ofSearchToolBm25_20251119(ToolSearchToolBm25_20251119 searchToolBm25_20251119)
-
ofSearchToolBm25_20251119
final static ToolUnion ofSearchToolBm25_20251119(ToolSearchToolBm25_20251119.Type type)
Returns an immutable instance of ToolUnion whose ofSearchToolBm25_20251119 variant is built from the given required type.
-
ofSearchToolRegex20251119
final static ToolUnion ofSearchToolRegex20251119(ToolSearchToolRegex20251119 searchToolRegex20251119)
-
ofSearchToolRegex20251119
final static ToolUnion ofSearchToolRegex20251119(ToolSearchToolRegex20251119.Type type)
Returns an immutable instance of ToolUnion whose ofSearchToolRegex20251119 variant is built from the given required type.
-
-
-
-