ai-tool-set has 790 recorded weekly downloads on npm, a decrease of 23.4% over the past 30 days, ranking #2143 of 3,247 tracked listings.
About ai-tool-set
This library provides a type-safe API to manage activeTools, toolApproval, and toolChoice for generateText() and streamText() in the AI SDK.
Why?
The AI SDK gives you activeTools, toolApproval and toolChoice to control which tools the model can use, which tool calls need approval, and which tool the model must call. But you must compute these values yourself for each call and for each step. This becomes complex when the values depend on the conversation, on the previous steps or on your own context, for example a tool that is available only to admins, or only after the user asks for it.
ai-tool-set lets you declare these rules once, on the standard AI SDK tool() definitions. Then .inferTools() resolves activeTools, toolApproval, toolChoice and toolOrder for any AI SDK function.
Features
- Static activation: Turn tools on or off with
.activate()and.deactivate(). - Conditional activation: Turn tools on or off from the messages, the steps or your own context with
.activateWhen()and.deactivateWhen(). - Activation reasons: Give each activation a reason, and tell the model why a tool is not available.
- Tool approval: Approve, deny or ask the user for each tool with
.approve(),.deny()and.approval(). - Tool choice: Force a specific tool, any tool or no tool with
.choice(). - Stable tool order: Keep the static tools in a fixed prefix, so that the provider prompt cache stays valid when a conditional tool changes.
- Per step: Resolve all values again for each step in
prepareStep. - Type-safe: Tool names are checked at compile time and at runtime, and the
Infer*types show which tools are active, inactive or conditional.
Installation
[!NOTE] Version compatibility:
- Use
ai-tool-set@1.xfor AI SDK v6- Use
ai-tool-set@2.xfor AI SDK v7
npm install ai-tool-set@1 # AI SDK v6
npm install ai-tool-set@2 # AI SDK v7
Usage
Creating a Tool Set
Pass a plain record of AI SDK tool() definitions to createToolSet(). All tools are active by default.
import { tool } from 'ai';
import { z } from 'zod';
import { createToolSet } from 'ai-tool-set';
const tools = {
search: tool({
description: 'Search for products',
inputSchema: z.object({ query: z.string() }),
execute: async ({ query }) => searchProducts(query),
}),
list_orders: tool({
description: 'List orders for a customer',
inputSchema: z.object({ customerId: z.string() }),
execute: async ({ customerId }) => listOrders(customerId),
}),
cancel_order: tool({
description: 'Cancel an order',
inputSchema: z.object({ orderId: z.string() }),
execute: async ({ orderId }) => cancelOrder(orderId),
}),
};
const toolSet = createToolSet({ tools });
Activate and Deactivate Tools
Use .activate() and .deactivate() to statically control which tools are available. Call .inferTools() to resolve activeTools and pass into generateText() or streamText():
import { generateText } from 'ai';
// Activate and deactivate tools
const toolSet = createToolSet({ tools }).deactivate(['cancel_order']).activate(['list_orders']);
// Infer active tools
const { tools, activeTools } = toolSet.inferTools();
const result = await generateText({
model,
// Pass tools and activeTools:
tools,
activeTools,
// Or spread directly:
// ...toolSet.deactivate(['cancel_order']).activate(['list_orders']).inferTools(),
prompt: 'Show me my orders',
});
Conditional Activation
Use .activateWhen() and .deactivateWhen() to conditionally control tools based on messages, step history, and context. The predicate receives an input with messages, steps, and toolSetContext (all can be undefined if not provided to inferTools) and should return a boolean (or undefined) to determine whether the tool should be activated/deactivated.…
Description from the npm listing.
- ai
- ai-sdk
- tools
- toolset
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (142)Similar npm AI SDKs plugins
All 20 ai-tool-set alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/ai-tool-set. First seen Nov 11, 2026; last successful collection Dec 6, 2026. See the methodology.