Official SDK

Vercel AI SDK memory

Long-term memory for generateText and streamText with one wrapLanguageModel call, on AI SDK v6 and v7.

Overview

Install memorysync-ai-sdk and wrap any model once: recalled context is injected before generation and the user’s message is sent to fact extraction after it — once per user turn, never on tool-loop steps — streaming included. Only the durable facts in the message are stored; assistant replies are not. Standalone helpers cover hand-wired setups, five structured tools give agents explicit memory, and one build supports AI SDK v6 and v7 — the current major no other memory vendor supports.

Setup status and requirements

Supported version
memorysync-ai-sdk 1.1.0 (npm)
Last setup review
2026-10-01
Permissions
A MemorySync API key with read and write scopes.
Limits
Requires the ai package v6 or newer (Node 18+; ai v7 itself requires Node 22+). JavaScript/TypeScript only — Python agents use the LangChain, LangGraph or CrewAI integrations.
Open setup documentation →

Capabilities

Quick Start

import { generateText, wrapLanguageModel } from "ai";
import { openai } from "@ai-sdk/openai";
import { createMemorySyncMiddleware } from "memorysync-ai-sdk";
const model = wrapLanguageModel({
model: openai("your-model"),
middleware: createMemorySyncMiddleware({ userId: "customer-7" }),
});
const { text } = await generateText({ model, prompt: "Book my usual trip." });

Use Cases

Next.js chatbots that remember users

AI SDK agents with explicit memory tools

Adding memory to an existing app without changing call sites

Guides and related pages

Explore More

Add long-term memory to Vercel AI SDK

Start free with 10,000 add requests a month and no credit card. Memory is stored per end user and comes back in every later session.