Persistent memory infrastructure for AI agents.
RetainDB lets AI agents remember users across sessions, devices, and deployments — with semantic retrieval, not just chat history. SOTA on LongMemEval (88% preference recall).
import { withRetainDB } from "@retaindb/sdk/ai-sdk";
import { openai } from "@ai-sdk/openai";
import { streamText } from "ai";
const model = withRetainDB(openai("gpt-4o-mini"), { userId });
const result = streamText({ model, messages });
// ↑ memories retrieved before, stored after — automatically| Template | Stack |
|---|---|
| retaindb-nextjs-starter | Next.js · Vercel AI SDK · OpenAI |
| retaindb-express-starter | Express.js · Vercel AI SDK · OpenAI |
| retaindb-python-starter | FastAPI · OpenAI |
| retaindb-langchain-starter | LangChain · LangGraph · OpenAI |
User message
│
├─► POST /v1/context/query → relevant memories injected into system prompt
│
├─► Your LLM → generates reply
│
└─► POST /v1/learn → stores the turn for future sessions
Two API calls. Works with any LLM, any framework.
Free tier — 10K memory ops/month · retaindb.com