Expose tools to a model
Pass several callable tools to streamText or generateText.
AI Tools · Type Alias
ToolSet is the AI SDK type for a named collection of tools available to model-generation functions. It enables typed tool calls and results across streamText and generateText.
ToolSet is the shared type for collections of tools supplied to AI SDK generation functions. Each named entry describes a callable tool, allowing the SDK and TypeScript to infer tool-call and tool-result types from the collection.
type ToolSet = Record<string, Tool>A ToolSet is a mapping of tool names to tool definitions; the documentation uses it as the type of the tools collection passed to generation functions.
import { tool, ToolSet } from 'ai';
import { z } from 'zod';
const tools = {
weather: tool({
description: 'Get the weather for a location.',
inputSchema: z.object({ location: z.string() }),
execute: async ({ location }) => ({ location, temperature: 21 }),
}),
} satisfies ToolSet;Defines a typed collection of AI SDK tools and checks that the object conforms to ToolSet.
Pass several callable tools to streamText or generateText.
Validate a tools object while retaining each tool's concrete type.
Derive tool-call and tool-result types for application logic.
streamTextgenerateTextToolTypedToolCallTypedToolResulttool