Introduction
RetainDB is hosted memory infrastructure for AI apps and agentic systems.
Build user memory
Store preferences, retrieve context, and personalize an OpenAI-compatible chat flow.
Start quickstart ->
Connect agents
Record task events, retrieve shared memory, and hand work from planner to builder.
Use Agent Memory Bus ->
Wrap chat calls
Inject memory into OpenAI-compatible requests with Memory Router v1 and fallback.
Add router ->
Wire MCP
Expose RetainDB memory tools to Claude Code, Codex, Cursor, OpenCode, and Cline.
Setup MCP ->
Install
Agent-readable docs
Give coding agents the docs index at /llms.txt so they can find the right page before editing code.
RetainDB gives AI products a memory layer they can trust in production.
Use it when your app or agents need to remember users, sessions, decisions, tool results, project context, and handoffs without building a storage, search, auth, and routing stack yourself.
Choose your path
| If you are building | Start here | Then read |
|---|---|---|
| Chatbots, copilots, assistants | 5 minute quickstart | User and session memory |
| Multi-agent workflows | Agent Memory Bus | Multi-agent handoff tutorial |
| Existing OpenAI-compatible chat stack | Memory Router v1 | OpenAI-compatible integration |
| MCP or coding agents | MCP setup | Agent host setup |
| Non-TypeScript runtime | Raw HTTP quickstart | API reference |
What RetainDB is for
| Need | RetainDB surface |
|---|---|
| Remember user preferences and facts | User and session memory |
| Retrieve context before calling a model | SDK context helpers or Memory Router |
| Share memory across multiple agents | Agent Memory Bus |
| Hand work from one agent to another | Agent handoffs |
| Connect coding or MCP agents | RetainDB MCP tools |
| Use raw HTTP from any runtime | REST API at https://api.retaindb.com |
First path: user memory chat
Most teams should start with a user memory loop:
- Store a user fact or preference.
- Retrieve relevant context for the next message.
- Add that context to your OpenAI-compatible chat call.
- Store useful new information after the turn.
That path is simple, production-shaped, and maps to nearly every AI app.
import { RetainDB } from "@retaindb/sdk";
const db = new RetainDB({ apiKey: process.env.RETAINDB_API_KEY });
const user = db.user("user_123");
await user.remember("User prefers concise technical answers.");
const { context } = await user.getContext("How should I answer this user?");Continue with 5 minute quickstart.
Agent path: shared memory across agents
When your product has planners, builders, reviewers, support agents, or coding agents, use Agent Memory Bus.
const task = db.agent("planner").task("checkout-redesign");
await task.event({
type: "decision",
summary: "Use Stripe Checkout for the first release."
});
const handoff = await task.handoff({
toAgentId: "builder",
summary: "Builder should implement the Stripe Checkout path."
});Continue with Agent Memory Bus.
Product surfaces
- SDK v5: the recommended TypeScript interface for app and agent builders.
- REST API: stable HTTP endpoints for non-TypeScript stacks.
- Memory Router v1: OpenAI-compatible chat memory injection with fallback.
- MCP tools: agent-native memory and handoff tools.
- Dashboard: keys, usage, projects, and team operations.
What good integration feels like
After RetainDB is wired correctly:
- users stop repeating stable preferences and facts
- agents can resume work without rediscovering previous decisions
- prompts include a small memory context instead of a pasted transcript
- each memory result is scoped to the right user, session, project, or task
- failures include a
trace_idyour team can debug
Next steps
- Build the first app flow: 5 minute quickstart
- Follow a complete app tutorial: User memory chatbot
- Learn scopes: Memory model
- Learn quality controls: Memory quality
- Add multi-agent continuity: Agent Memory Bus
- Connect MCP agents: MCP setup
Was this page helpful?
Your feedback helps us prioritize docs improvements weekly.