Browse docs

Getting Started

Tap to expand

Contribute

StartUpdated 2026-03-18

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:

typescript
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

WhatIn practice
Persistent memoryUsers don't repeat themselves. Preferences, facts, and history carry forward.
Automatic learningEvery conversation is extracted and stored. The longer you run, the smarter it gets.
Context retrievalThe right memories surface at the right time for each user.
Project knowledgeGround answers in docs, repos, and websites you index.

Where to start


The mental model

RetainDB has two main surfaces:

  1. Memory — per-user facts, preferences, events, and instructions that persist indefinitely.
  2. Index — project-scoped knowledge from documents, repos, and websites you ingest.

A typical turn:

  1. User sends a message.
  2. runTurn retrieves relevant memories for that user.
  3. Memories are injected into the LLM system prompt automatically.
  4. 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.