Interface: ToolInput
@providerprotocol/ai / @providerprotocol/ai / ToolInput
Interface: ToolInput<TParams, TResult>
Section titled “Interface: ToolInput<TParams, TResult>”Defined in: src/types/tool.ts:187
Tool input type that accepts Zod schemas for parameters.
This is the user-facing type for defining tools. Zod schemas are automatically converted to JSON Schema before being sent to providers.
Example
Section titled “Example”import { z } from 'zod';
const tool: ToolInput<{ location: string }> = { name: 'get_weather', description: 'Get weather for a location', parameters: z.object({ location: z.string().describe('City name'), }), run: async (params) => fetchWeather(params.location),};Type Parameters
Section titled “Type Parameters”TParams
Section titled “TParams”TParams = unknown
The type of parameters the tool accepts
TResult
Section titled “TResult”TResult = unknown
The type of result the tool returns
Properties
Section titled “Properties”description
Section titled “description”description:
string
Defined in: src/types/tool.ts:192
Human-readable description for the model to understand when to use this tool
metadata?
Section titled “metadata?”
optionalmetadata:ToolMetadata
Defined in: src/types/tool.ts:198
Provider-specific metadata, namespaced by provider name
name:
string
Defined in: src/types/tool.ts:189
Tool name (must be unique within an llm() instance)
parameters
Section titled “parameters”parameters:
Structure
Defined in: src/types/tool.ts:195
JSON Schema or Zod schema defining the tool’s parameters
Methods
Section titled “Methods”approval()?
Section titled “approval()?”
optionalapproval(params):boolean|Promise<boolean>
Defined in: src/types/tool.ts:204
Optional approval handler for sensitive operations
Parameters
Section titled “Parameters”params
Section titled “params”TParams
Returns
Section titled “Returns”boolean | Promise<boolean>
run(
params):TResult|Promise<TResult>
Defined in: src/types/tool.ts:201
Executes the tool with the provided parameters
Parameters
Section titled “Parameters”params
Section titled “params”TParams
Returns
Section titled “Returns”TResult | Promise<TResult>