Introduction
RetainDB gives AI applications persistent memory. Users tell it things once — it remembers across every session.
RetainDB gives your AI application persistent memory. Users tell it things once — it remembers across every session, automatically.
The full integration is three lines:
import { RetainDB } from "@retaindb/sdk";
const db = new RetainDB({ apiKey: process.env.RETAINDB_KEY });
const { response } = await db.user(userId).runTurn({
messages,
generate: (ctx) => llm.chat(ctx),
});Every runTurn call retrieves the user's relevant memories, injects them into your LLM, generates a response, and stores the conversation for future use — without any extra code.
What RetainDB does
| What | In practice |
|---|---|
| Persistent memory | Users don't repeat themselves. Preferences, facts, and history carry forward. |
| Automatic learning | Every conversation is extracted and stored. The longer you run, the smarter it gets. |
| Context retrieval | The right memories surface at the right time for each user. |
| Project knowledge | Ground answers in docs, repos, and websites you index. |
Where to start
- Fastest — Setup Wizard: guided, working in minutes.
- Manual proof — 5 minute quickstart: make one API call by hand.
- Start building — SDK quickstart: the full integration pattern.
- MCP client — MCP setup: for Claude Desktop, Claude Code, or Cursor.
The mental model
RetainDB has two main surfaces:
- Memory — per-user facts, preferences, events, and instructions that persist indefinitely.
- Index — project-scoped knowledge from documents, repos, and websites you ingest.
A typical turn:
- User sends a message.
runTurnretrieves relevant memories for that user.- Memories are injected into the LLM system prompt automatically.
- The response is returned, and the conversation is stored for next time.
That loop — retrieve, inject, generate, store — is what makes your app smarter with every interaction.
Next step
Go to SDK quickstart to see the complete pattern, or 5 minute quickstart to verify the API shape first.
Was this page helpful?
Your feedback helps us prioritize docs improvements weekly.