---
title: "Install the AI Agent extension"
description: "Learn how to install and set up the AI Agent extension for Tiptap."
---

> [Tiptap Editor 3.0 is out. Start here](https://tiptap.dev/docs/resources/whats-new.md)

# Install the AI Agent extension

Learn how to install and set up the AI Agent extension for Tiptap.

Tags: Available in Team plan, Beta

## Requirements

**1. Activate trial or subscribe**

Start a [free trial](https://cloud.tiptap.dev/v2?trial=true) or [subscribe to the Team
plan](https://cloud.tiptap.dev/v2/billing) in your account.

**2. Integrate an AI provider**

Configure OpenAI in your [AI settings](https://cloud.tiptap.dev/v2/cloud/ai) or follow the
[Custom AI Agent guide](https://tiptap.dev/docs/v2/content-ai/capabilities/agent/custom-llms/overview.md) to integrate it with other
AI providers.

**3. Install from private registry**

To install the frontend extensions, authenticate to Tiptap&apos;s private npm registry by
following the [setup guide](https://tiptap.dev/docs/v2/guides/pro-extensions.md).

## Install the package

The AI Agent extension is published in Tiptap's private npm registry. Integrate the extension by following the [private registry guide](https://tiptap.dev/docs/v2/guides/pro-extensions.md).

Once you're ready you can install it like any other Tiptap Pro extension.

```bash
npm install @tiptap-pro/extension-ai-agent
```

## Set up the provider

The provider object manages the state of the AI Agent. The easiest way to get started with the AI Agent extension is to use the Tiptap Cloud provider:

```tsx
import { AiAgentProvider } from '@tiptap-pro/extension-ai-agent'

const provider = new AiAgentProvider({
  // Configure Tiptap Cloud (see next section)
  appId: 'APP_ID_HERE',
  token: 'TOKEN_HERE',
})
```

The AI Agent works out-of-the-box [with Tiptap Cloud](https://tiptap.dev/docs/v2/content-ai/capabilities/agent/use-with-content-ai-cloud.md) as a backend.

To add text-editing capabilities to your custom AI Agent that runs in your backend, read [the integration guide](https://tiptap.dev/docs/v2/content-ai/capabilities/agent/custom-llms/overview.md).

## Import the extension in your editor

Add `AiAgent` to the list of extensions and configure it with the provider.

```tsx
import { Editor } from '@tiptap/core'
import StarterKit from '@tiptap/starter-kit'
import AiAgent from '@tiptap-pro/extension-ai-agent'

const editor = new Editor({
  extensions: [
    StarterKit,
    AiAgent.configure({
      provider,
      // … other options
    }),
    // … more extensions
  ],
})
```

## Call the AI Agent

Call the methods of the provider to interact with the AI Agent.

```tsx
provider.addUserMessage(
  'Correct the spelling and grammar mistakes. Then, find the key phrases in the text and format them in bold.',
)
provider.run()
```

## Display the AI Agent chat conversation

You can access the AI Agent state (including the chat conversations) and display it in the UI:

```tsx
provider.state.messages
```

You can also subscribe to events and update the UI when they are triggered:

```tsx
// Subscribe to state changes
provider.on('stateChange', (newState, previousState, context) => {
  console.log('State changed:', newState)
  // Update your UI based on the new state
})

// Subscribe to loading errors
provider.on('loadingError', (error, context) => {
  console.error('Error occurred:', error)
  // Show error message to the user
})
```
