Skip to main content

Vercel AI SDK + Memanto

Vercel AI SDK Add persistent memory to any Vercel AI SDK agent with three ready-made tools, shipped as part of the @moorcheh-ai/memanto TypeScript SDK.

Prerequisites

  • Node.js 20+
  • uv (ships uvx) — the Memanto client spawns a local Memanto server via uvx on first use unless you pass baseUrl
  • Memanto / Moorcheh credentialsMoorcheh API key (cloud) or an on-prem backend (no Moorcheh API key). Set MOORCHEH_API_KEY or pass apiKey to new Memanto({ ... })
  • Agent model credentials — the quick start uses OpenAI gpt-4o for tool orchestration. Set OPENAI_API_KEY (or swap openai("gpt-4o") for any AI SDK provider you already use).
  • ai, zod, and @ai-sdk/openai installed in your app (ai and zod are optional peer dependencies of @moorcheh-ai/memanto)

Install

ai and zod are optional peer dependencies of @moorcheh-ai/memanto — install them yourself in the host app. Importing @moorcheh-ai/memanto/ai-sdk without them installed will fail at module load with a standard Node resolution error.

Quick Start

createMemantoTools returns an object with three AI SDK tools — pass it straight into tools on generateText / streamText.

Available Tools

answerMemory calls Memanto’s Generate AI Answer API (memanto.answer() → Moorcheh answer.generate). Memanto retrieves relevant memories and synthesizes a grounded response using Memanto’s configured LLM — not the model you pass to generateText / streamText. Your agent model only decides when to call the tool and how to use the result. recallMemory and rememberMemory do not invoke an LLM. 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

Memory Types

type fields are constrained to Memanto’s 13 supported types via a shared MEMORY_TYPES export:
See the Memory Types Reference 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 and the TypeScript SDK Reference.

Next Steps