Class Tool
-
- All Implemented Interfaces:
public final class Tool
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classTool.BuilderA builder for Tool.
public final classTool.InputSchemaJSON schema for this tool's input.
This defines the shape of the
inputthat your tool accepts and that the model will produce.public final classTool.AllowedCallerSpecifies who can invoke a tool.
Values: direct: The model can call this tool directly. code_execution_20250825: The tool can be called from the code execution environment (v1). code_execution_20260120: The tool can be called from the code execution environment (v2 with persistence).
public final classTool.InputExamplepublic final classTool.Type
-
Method Summary
Modifier and Type Method Description final Tool.InputSchemainputSchema()JSON schema for this tool's input. final Stringname()Name of the tool. final Optional<List<Tool.AllowedCaller>>allowedCallers()final Optional<CacheControlEphemeral>cacheControl()Create a cache control breakpoint at this content block. final Optional<Boolean>deferLoading()If true, tool will not be included in initial system prompt. final Optional<String>description()Description of what this tool does. final Optional<Boolean>eagerInputStreaming()Enable eager input streaming for this tool. final Optional<List<Tool.InputExample>>inputExamples()final Optional<Boolean>strict()When true, guarantees schema validation on tool names and inputs final Optional<Tool.Type>type()final JsonField<Tool.InputSchema>_inputSchema()Returns the raw JSON value of inputSchema. final JsonField<String>_name()Returns the raw JSON value of name. final JsonField<List<Tool.AllowedCaller>>_allowedCallers()Returns the raw JSON value of allowedCallers. final JsonField<CacheControlEphemeral>_cacheControl()Returns the raw JSON value of cacheControl. final JsonField<Boolean>_deferLoading()Returns the raw JSON value of deferLoading. final JsonField<String>_description()Returns the raw JSON value of description. final JsonField<Boolean>_eagerInputStreaming()Returns the raw JSON value of eagerInputStreaming. final JsonField<List<Tool.InputExample>>_inputExamples()Returns the raw JSON value of inputExamples. final JsonField<Boolean>_strict()Returns the raw JSON value of strict. final JsonField<Tool.Type>_type()Returns the raw JSON value of type. final Map<String, JsonValue>_additionalProperties()final Tool.BuildertoBuilder()final Toolvalidate()final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static Tool.Builderbuilder()Returns a mutable builder for constructing an instance of Tool. -
-
Method Detail
-
inputSchema
final Tool.InputSchema inputSchema()
JSON schema for this tool's input.
This defines the shape of the
inputthat your tool accepts and that the model will produce.
-
name
final String name()
Name of the tool.
This is how the tool will be called by the model and in
tool_useblocks.
-
allowedCallers
final Optional<List<Tool.AllowedCaller>> allowedCallers()
-
cacheControl
final Optional<CacheControlEphemeral> cacheControl()
Create a cache control breakpoint at this content block.
-
deferLoading
final Optional<Boolean> deferLoading()
If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
-
description
final Optional<String> description()
Description of what this tool does.
Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.
-
eagerInputStreaming
final Optional<Boolean> eagerInputStreaming()
Enable eager input streaming for this tool. When true, tool input parameters will be streamed incrementally as they are generated, and types will be inferred on-the-fly rather than buffering the full JSON output. When false, streaming is disabled for this tool even if the fine-grained-tool-streaming beta is active. When null (default), uses the default behavior based on beta headers.
-
inputExamples
final Optional<List<Tool.InputExample>> inputExamples()
-
strict
final Optional<Boolean> strict()
When true, guarantees schema validation on tool names and inputs
-
_inputSchema
final JsonField<Tool.InputSchema> _inputSchema()
Returns the raw JSON value of inputSchema.
Unlike inputSchema, this method doesn't throw if the JSON field has an unexpected type.
-
_name
final JsonField<String> _name()
Returns the raw JSON value of name.
Unlike name, this method doesn't throw if the JSON field has an unexpected type.
-
_allowedCallers
final JsonField<List<Tool.AllowedCaller>> _allowedCallers()
Returns the raw JSON value of allowedCallers.
Unlike allowedCallers, this method doesn't throw if the JSON field has an unexpected type.
-
_cacheControl
final JsonField<CacheControlEphemeral> _cacheControl()
Returns the raw JSON value of cacheControl.
Unlike cacheControl, this method doesn't throw if the JSON field has an unexpected type.
-
_deferLoading
final JsonField<Boolean> _deferLoading()
Returns the raw JSON value of deferLoading.
Unlike deferLoading, this method doesn't throw if the JSON field has an unexpected type.
-
_description
final JsonField<String> _description()
Returns the raw JSON value of description.
Unlike description, this method doesn't throw if the JSON field has an unexpected type.
-
_eagerInputStreaming
final JsonField<Boolean> _eagerInputStreaming()
Returns the raw JSON value of eagerInputStreaming.
Unlike eagerInputStreaming, this method doesn't throw if the JSON field has an unexpected type.
-
_inputExamples
final JsonField<List<Tool.InputExample>> _inputExamples()
Returns the raw JSON value of inputExamples.
Unlike inputExamples, this method doesn't throw if the JSON field has an unexpected type.
-
_strict
final JsonField<Boolean> _strict()
Returns the raw JSON value of strict.
Unlike strict, this method doesn't throw if the JSON field has an unexpected type.
-
_type
final JsonField<Tool.Type> _type()
Returns the raw JSON value of type.
Unlike type, this method doesn't throw if the JSON field has an unexpected type.
-
_additionalProperties
final Map<String, JsonValue> _additionalProperties()
-
toBuilder
final Tool.Builder toBuilder()
-
builder
final static Tool.Builder builder()
Returns a mutable builder for constructing an instance of Tool.
The following fields are required:
.inputSchema() .name()
-
-
-
-