Skip to content

Interface: ToolInput

@providerprotocol/ai


@providerprotocol/ai / @providerprotocol/ai / ToolInput

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.

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),
};

TParams = unknown

The type of parameters the tool accepts

TResult = unknown

The type of result the tool returns

description: string

Defined in: src/types/tool.ts:192

Human-readable description for the model to understand when to use this tool


optional metadata: 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: Structure

Defined in: src/types/tool.ts:195

JSON Schema or Zod schema defining the tool’s parameters

optional approval(params): boolean | Promise<boolean>

Defined in: src/types/tool.ts:204

Optional approval handler for sensitive operations

TParams

boolean | Promise<boolean>


run(params): TResult | Promise<TResult>

Defined in: src/types/tool.ts:201

Executes the tool with the provided parameters

TParams

TResult | Promise<TResult>