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

# LangChain.js - AI agent tools

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

The `@tiptap-pro/ai-toolkit-langchain` package provides tool definitions you can add to your AI agent built with [LangChain.js](https://js.langchain.com/).

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-langchain
```

Supply the tool definitions to your LangChain.js model.

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

const llm = new ChatOpenAI({ model: 'gpt-5.4-mini' })
const llmWithTools = llm.bindTools(toolDefinitions())
```

Combine the tool definitions with your custom tools.

```ts
import { ChatOpenAI } from '@langchain/openai'
import { toolDefinitions } from '@tiptap-pro/ai-toolkit-langchain'
import { DynamicStructuredTool } from '@langchain/core/tools'
import { z } from 'zod'

const llm = new ChatOpenAI({ model: 'gpt-5.4-mini' })

const customTools = [
  new DynamicStructuredTool({
    name: 'weather',
    description: 'Get the weather in a location',
    schema: z.object({
      location: z.string(),
    }),
    func: async ({ location }) => {
      return `The weather in ${location} is sunny with 72°F`
    },
  }),
]

const llmWithTools = llm.bindTools([...toolDefinitions(), ...customTools])
```

## API reference

### `toolDefinitions`

Creates tool definitions for the Tiptap AI Toolkit compatible with [LangChain.js](https://js.langchain.com/).

#### 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 [LangChain.js](https://js.langchain.com/)'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.
