> ## Documentation Index
> Fetch the complete documentation index at: https://docs.memanto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Vercel AI SDK Integration

> Give Vercel AI SDK agents persistent, cross-session memory with Memanto tools.

# Vercel AI SDK + Memanto

<img src="https://mintcdn.com/memanto/7cqii5_wGejS32un/logo/integrations/vercel.svg?fit=max&auto=format&n=7cqii5_wGejS32un&q=85&s=7cb990b58d77c29fc1c4f189c6b9bded" alt="Vercel AI SDK" width="64" style={{marginBottom: "1.5rem"}} data-path="logo/integrations/vercel.svg" />

Add persistent memory to any [Vercel AI SDK](https://sdk.vercel.ai/) agent with three ready-made tools, shipped as part of the `@moorcheh-ai/memanto` TypeScript SDK.

## Prerequisites

* Node.js 20+
* [Moorcheh API key](https://console.moorcheh.ai/api-keys) (or an on-prem Memanto backend — see [On-Prem](/on-prem/overview))
* `ai` and `zod` installed in your app (optional peer dependencies of `@moorcheh-ai/memanto`)

## Install

```bash theme={null}
npm install @moorcheh-ai/memanto ai zod @ai-sdk/openai
```

`ai` and `zod` are optional peer dependencies of `@moorcheh-ai/memanto` — install them yourself in the host app; `createMemantoTools` fails fast with a clear error if they're missing.

## Quick Start

```ts theme={null}
import { generateText, stepCountIs } from "ai";
import { openai } from "@ai-sdk/openai";
import { Memanto } from "@moorcheh-ai/memanto";
import { createMemantoTools } from "@moorcheh-ai/memanto/ai-sdk";

const memanto = new Memanto({ agentId: "my-agent" });

const { text } = await generateText({
  model: openai("gpt-4o"),
  tools: createMemantoTools(memanto),
  stopWhen: stepCountIs(5),
  prompt: "What milk does Alex like? Also note he switched to soy today.",
});

console.log(text);
```

`createMemantoTools` returns an object with three [AI SDK tools](https://sdk.vercel.ai/docs/ai-sdk-core/tools-and-tool-calling) — pass it straight into `tools` on `generateText` / `streamText`.

## Available Tools

| Tool             | Backed by                                                  | Description                                                                                                                                           |
| ---------------- | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `recallMemory`   | [Recall](/api-reference/search/recall)                     | Semantic search over stored memories. `query` (required), `limit` (1-50), `type` (filter by memory type).                                             |
| `rememberMemory` | [Remember](/api-reference/data/remember)                   | Persist a durable fact/preference/decision/instruction. `content` (required), `type` (optional — server auto-classifies if omitted), `title`, `tags`. |
| `answerMemory`   | [Generate AI Answer](/api-reference/ai/generate-ai-answer) | RAG-synthesized answer over stored memories. `question` (required), `limit` (1-100).                                                                  |

Each tool's description is written for the model to decide *when* to call it (e.g. `recallMemory`: "Call this before answering whenever the user refers to information from earlier or from a previous session").

## Options

```ts theme={null}
createMemantoTools(memanto, {
  include: ["recallMemory", "answerMemory"], // expose a subset — omit for all three
  defaultLimit: 10,                           // default limit for recall/answer when the model doesn't specify one
});
```

## Memory Types

`type` fields are constrained to Memanto's 13 supported types via a shared `MEMORY_TYPES` export:

```ts theme={null}
import { MEMORY_TYPES } from "@moorcheh-ai/memanto/ai-sdk";
// ["fact", "preference", "goal", "decision", "artifact", "learning", "event",
//  "instruction", "relationship", "context", "observation", "commitment", "error"]
```

See the [Memory Types Reference](/reference/memory-types) for what each type means.

## On-Prem

The integration talks to Memanto through the `Memanto` client, so it works identically against an on-prem backend — no code changes, just configure the backend once with the CLI. See [On-Prem Overview](/on-prem/overview) and the [TypeScript SDK Reference](/sdk/typescript#on-prem-no-api-key).

## Next Steps

* [TypeScript SDK Reference](/sdk/typescript) for the full `Memanto` client API
* [Mastra Integration](/integrations/mastra) for the equivalent Mastra tools
* [OpenAI Integration](/integrations/openai) for the equivalent OpenAI `runTools()` tools
* [Memory Types Reference](/reference/memory-types)
