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

# OpenAI - AI agent tools

Use tool definitions for OpenAI to let AI agents read and edit Tiptap documents.

The `@tiptap-pro/ai-toolkit-openai` package provides tool definitions you can add to your AI agent built with [OpenAI's JavaScript SDK](https://github.com/openai/openai-node).

The tool calls generated by the model can then be executed in the client-side 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-openai
```

Supply the tool definitions to your OpenAI model.

```ts
import OpenAI from 'openai'
import { toolDefinitions } from '@tiptap-pro/ai-toolkit-openai'

const openai = new OpenAI()

const response = await openai.responses.create({
  model: 'gpt-5.4-mini',
  input: [{ role: 'user', content: 'Help me edit this document' }],
  tools: toolDefinitions(),
})
```

Combine the tool definitions with your custom tools.

```ts
import OpenAI from 'openai'
import { toolDefinitions } from '@tiptap-pro/ai-toolkit-openai'

const openai = new OpenAI()

const customTools = [
  {
    type: 'function',
    name: 'get_weather',
    description: 'Get the weather in a location',
    parameters: {
      type: 'object',
      properties: {
        location: {
          type: 'string',
          description: 'The city and state, e.g. San Francisco, CA',
        },
      },
      required: ['location'],
    },
  },
]

const response = await openai.responses.create({
  model: 'gpt-5.4-mini',
  input: [{ role: 'user', content: 'What is the weather like and help me edit this document' }],
  tools: [...toolDefinitions(), ...customTools],
})
```

## API reference

### `toolDefinitions`

Creates tool definitions for the Tiptap AI Toolkit compatible with [OpenAI's responses API](https://platform.openai.com/docs/api-reference/responses).

#### 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 array containing the enabled tool definitions that can be used with [OpenAI's responses API](https://platform.openai.com/docs/api-reference/responses). To see the full list of tools, see the [Available tools](https://tiptap.dev/docs/content-ai/capabilities/ai-toolkit/agents/tools.md) page.

### `completionsApiToolDefinitions`

Creates tool definitions for the Tiptap AI Toolkit compatible with [OpenAI's completions API](https://platform.openai.com/docs/api-reference/completions).

#### 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 array containing the enabled tool definitions that can be used with [OpenAI's completions API](https://platform.openai.com/docs/api-reference/completions). To see the full list of tools, see the [Available tools](https://tiptap.dev/docs/content-ai/capabilities/ai-toolkit/agents/tools.md) page.
