Vercel AI SDK
Memory for the Vercel AI SDK
Wrap any model once. Before each call it recalls what this user said before; one wrapped model serves every user of your app.
npm install recallic-ai-sdk ai
TypeScript
import { generateText, wrapLanguageModel } from "ai";
import { openai } from "@ai-sdk/openai";
import { recallicMemory } from "recallic-ai-sdk";
const model = wrapLanguageModel({
model: openai("gpt-4.1-mini"),
middleware: recallicMemory({ apiKey: process.env.RECALLIC_SERVICE_KEY!, baseUrl: "http://localhost:8000" }),
});
const { text } = await generateText({
model,
prompt: "Which city did I move to?",
providerOptions: { recallic: { userId: "alice" } }, // whose memory, per call
});- Memories go in as a system message after your own system prompt; when nothing answers, the model is told there is no record.
- Works with generateText, streamText, tools and multi-step calls: a tool loop recalls once and stores once.
- If Recallic is unreachable, the call goes on without memory instead of failing.
- AI SDK 7 by default, AI SDK 6 with specificationVersion: "v3".
Settings
| Option | Default | What it does |
|---|---|---|
userId | per call | whose memory, fixed here or with providerOptions.recallic.userId |
mode | server's | cautious, balanced or helpful |
limit | 5 | memories given to the model |
tellModelOnDecline | true | when nothing answers, tell the model not to guess |
Needs a running Recallic server: set one up with Docker, or deploy it to your own Render account in one click. Nothing goes through us; your data stays on your server.