Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

AI Tools · Type Alias

ToolSet

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.

How it works

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.

Syntax

type ToolSet = Record<string, Tool>

Returns

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.

Key points

  • Use ToolSet for the tools object passed to streamText or generateText.
  • TypedToolCall can derive a typed tool-call representation from a ToolSet.
  • TypedToolResult can derive typed results for tools in a ToolSet.
  • Build entries with the tool helper to preserve accurate input and output inference.

Example: Define a ToolSet

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.

When to use it

Expose tools to a model

Pass several callable tools to streamText or generateText.

Preserve TypeScript inference

Validate a tools object while retaining each tool's concrete type.

Type tool interactions

Derive tool-call and tool-result types for application logic.

  • streamText
  • generateText
  • Tool
  • TypedToolCall
  • TypedToolResult
  • tool

Source: Tool Calling - AI SDK. Checked 2026-10-15.