---
title: "AI SDK - AI agent tools"
description: "Use tool definitions for the AI SDK by Vercel to let AI agents read and edit Tiptap documents."
canonical_url: "https://tiptap.dev/docs/content-ai/capabilities/ai-toolkit/agents/tools/ai-sdk"
---

# AI SDK - AI agent tools

Use tool definitions for the AI SDK by Vercel to let AI agents read and edit Tiptap documents.

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](https://ai-sdk.dev/).

The tool calls generated by the model can then be executed using the [`executeTool` method](https://tiptap.dev/docs/content-ai/capabilities/ai-toolkit/api-reference/execute-tool.md).

## Example usage

Install the package.

```bash
npm install @tiptap-pro/ai-toolkit-ai-sdk
```

Supply the tool definitions to the `tools` parameter of the `ToolLoopAgent` class.

```ts
import { openai } from '@ai-sdk/openai'
import { createAgentUIStreamResponse, ToolLoopAgent, UIMessage } from 'ai'
import { toolDefinitions } from '@tiptap-pro/ai-toolkit-ai-sdk'

export async function POST(req: Request) {
  const { messages }: { messages: UIMessage[] } = await req.json()

  const agent = new ToolLoopAgent({
    model: openai('gpt-5.4-mini'),
    tools: toolDefinitions(),
  })

  return createAgentUIStreamResponse({
    agent,
    uiMessages: messages,
  })
}
```

Combine the tool definitions with your custom tools.

```ts
import { openai } from '@ai-sdk/openai'
import { createAgentUIStreamResponse, ToolLoopAgent, tool, UIMessage } from 'ai'
import { toolDefinitions } from '@tiptap-pro/ai-toolkit-ai-sdk'
import { z } from 'zod'

export async function POST(req: Request) {
  const { messages }: { messages: UIMessage[] } = await req.json()

  const agent = new ToolLoopAgent({
    model: openai('gpt-5.4-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,
        }),
      }),
    },
  })

  return createAgentUIStreamResponse({
    agent,
    uiMessages: messages,
  })
}
```

> **Type error with Zod 3:**
>
> If your app uses version 3 of the [Zod validation library](https://zod.dev/), you might get a type
> error when you pass the tool definitions to the `tools` parameter of the `ToolLoopAgent` class. You can fix it by upgrading to Zod 4 or by type casting the tool
> definitions to the `ToolSet` type of the AI SDK.

## API reference

### `toolDefinitions`

Creates tool definitions for the Tiptap AI Toolkit compatible with [Vercel AI SDK](https://ai-sdk.dev/).

#### Parameters (`ToolDefinitionsOptions`)

- `tools?`: `EnabledTools` - Enable/disable specific tools by setting the value to `true` (enabled) or `false` (disabled).
  - `tiptapRead?`: `boolean` - Enable/disable the `tiptapRead` tool (default: `true`)
  - `tiptapEdit?`: `boolean` - Enable/disable the `tiptapEdit` tool (default: `true`)
  - `tiptapReadSelection?`: `boolean` - Enable/disable the `tiptapReadSelection` tool (default: `true`)
  - `getThreads?`: `boolean` - Enable/disable the `getThreads` tool (default: `false`)
  - `editThreads?`: `boolean` - Enable/disable the `editThreads` tool (default: `false`)

#### Returns

An object containing the enabled tool definitions that can be used with the [Vercel AI SDK](https://ai-sdk.dev/)'s tool calling system. To see the full list of tools, see the [Available tools](https://tiptap.dev/docs/content-ai/capabilities/ai-toolkit/agents/tools.md) page.
