pub struct ToolParam {
pub input_schema: Value,
pub name: String,
pub cache_control: Option<CacheControlEphemeral>,
pub description: Option<String>,
pub strict: Option<bool>,
}anthropic-client only.Expand description
Common parameters for a custom tool.
Fields§
§input_schema: ValueJSON schema for this tool’s input.
This defines the shape of the input that your tool accepts and that the model
will produce.
name: StringName of the tool.
This is how the tool will be called by the model and in tool_use blocks.
cache_control: Option<CacheControlEphemeral>Create a cache control breakpoint at this content block.
description: Option<String>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.
strict: Option<bool>Enable strict mode for tool parameter validation.
When enabled, Claude will guarantee that tool parameters exactly match the
input_schema. This ensures type-safe function calls with correctly-typed
arguments.
This feature requires the beta header structured-outputs-2025-11-13.
See structured outputs for details.
Implementations§
Source§impl ToolParam
impl ToolParam
Sourcepub fn new(name: String, input_schema: Value) -> ToolParam
pub fn new(name: String, input_schema: Value) -> ToolParam
Create a new ToolParam with the required fields.
Sourcepub fn with_description(self, description: String) -> ToolParam
pub fn with_description(self, description: String) -> ToolParam
Add a description to the tool.
Sourcepub fn with_cache_control(
self,
cache_control: CacheControlEphemeral,
) -> ToolParam
pub fn with_cache_control( self, cache_control: CacheControlEphemeral, ) -> ToolParam
Add cache control to the tool.
Sourcepub fn with_strict(self, strict: bool) -> ToolParam
pub fn with_strict(self, strict: bool) -> ToolParam
Enable strict mode for tool parameter validation.
When enabled, Claude will guarantee that tool parameters exactly match the
input_schema. This ensures type-safe function calls with correctly-typed
arguments.
This feature requires the beta header structured-outputs-2025-11-13.
§Example
use serde_json::json;
use adk_anthropic::ToolParam;
let tool = ToolParam::new(
"get_weather".to_string(),
json!({
"type": "object",
"properties": {
"location": { "type": "string" },
"unit": { "type": "string", "enum": ["celsius", "fahrenheit"] }
},
"required": ["location"],
"additionalProperties": false
})
)
.with_strict(true);