AI SDK - AI agent tools
The @tiptap-pro/ai-toolkit-ai-sdk
package provides tool definitions you can add to your AI agent built with the AI SDK by Vercel.
The tool calls generated by the model can then be executed using the executeTool
method.
Example usage
Install the package.
npm install @tiptap-pro/ai-toolkit-ai-sdk
Supply the tool definitions to the tools
parameter of the generateText
or streamText
functions.
import { openai } from '@ai-sdk/openai'
import { streamText } from 'ai'
import { toolDefinitions } from '@tiptap-pro/ai-toolkit-ai-sdk'
const result = streamText({
model: openai('gpt-5-mini'),
tools: toolDefinitions(),
})
Combine the tool definitions with your custom tools.
import { openai } from '@ai-sdk/openai'
import { streamText, tool } from 'ai'
import { toolDefinitions } from '@tiptap-pro/ai-toolkit-ai-sdk'
import { z } from 'zod'
const result = streamText({
model: openai('gpt-5-mini'),
tools: {
// Tool definitions from the AI Toolkit
...toolDefinitions(),
// Custom weather tool
weather: tool({
description: 'Get the weather in a location',
inputSchema: z.object({
location: z.string(),
}),
execute: async () => ({
temperature: 72,
}),
}),
},
})
API reference
toolDefinitions
Creates tool definitions for the Tiptap AI Toolkit compatible with Vercel AI SDK.
Parameters (ToolDefinitionsOptions
)
tools?
:EnabledTools
- Enable/disable specific tools. All tools are enabled by default.insertContent?
:boolean
- Enable/disable theinsertContent
tool (default:true
)applyDiff?
:boolean
- Enable/disable theapplyDiff
tool (default:true
)readFirstChunk?
:boolean
- Enable/disable thereadFirstChunk
tool (default:true
)readNextChunk?
:boolean
- Enable/disable thereadNextChunk
tool (default:true
)readPreviousChunk?
:boolean
- Enable/disable thereadPreviousChunk
tool (default:true
)readSelection?
:boolean
- Enable/disable thereadSelection
tool (default:true
)
Returns
An object containing the enabled tool definitions that can be used with the Vercel AI SDK's tool calling system. The returned object includes:
insertContent
- Tool for inserting HTML content at a specific positionapplyDiff
- Tool for applying targeted edits via diffsreadFirstChunk
- Tool for reading the first chunk of the documentreadNextChunk
- Tool for reading the next chunk of the documentreadPreviousChunk
- Tool for reading the previous chunk of the documentreadSelection
- Tool for reading the currently selected content in the editor