MemLibMemLib

Introduction

MemLib — The open-source memory layer for AI agents and applications

What is MemLib?

MemLib is an open-source memory API that gives your AI agents persistent, semantic memory. Store natural language, and MemLib automatically extracts facts, deduplicates, resolves conflicts, and retrieves memories by meaning — all via a simple SDK or REST API.

Bring Your Own Database. Your memory data stays in your PostgreSQL instance. MemLib connects to your database and AI provider at request time — no vendor lock-in, full data ownership.

Key Capabilities

CapabilityWhat It DoesLLM Calls
Smart StoreExtract facts from natural language, deduplicate, and resolve conflicts1–2
Semantic RecallFind memories by meaning with hybrid scoring0
Context SynthesisSynthesize a tailored briefing paragraph for your system prompt2
Memory DiffTrack what changed — new facts, updates, and contraditions0
ConsolidationSummarize old memories into concise entries1
MCP ServerLet Claude, Cursor, and other clients use memories directly

How It Works

Supported Providers

LLM: Google Gemini · OpenAI · Anthropic · Mistral · Groq · xAI · Cohere · OpenRouter

Embedding: Google Gemini · OpenAI · Cohere · Mistral · Voyage

Architecture

ComponentDescription
SDK (memlib on npm)TypeScript client with typed methods
REST APIHTTP endpoints with API key auth
MCP ServerModel Context Protocol for Claude Desktop, Cursor, etc.
Memory EngineEmbedding, fact extraction, dedup, conflict resolution
DashboardWeb UI for project management, API keys, and memory browsing

Quick Example

import { MemLib } from "memlib";

const mem = new MemLib({
  apiKey: "sk_...",
  namespace: "my-app",
  entity: "user-123",
});

// Store — extracts facts, deduplicates, resolves conflicts
await mem.store({
  content: "I prefer TypeScript and dark mode. My team uses React.",
});

// Recall — semantic search by meaning
const memories = await mem.recall({
  query: "What tech stack?",
});

// Prepare — synthesize context for a system prompt
const { context } = await mem.prepare({
  messages: [{ role: "user", content: "Help me set up a project" }],
});

// Diff — what changed since last session
const diff = await mem.diff({ since: "2024-01-01T00:00:00Z" });

Next Steps

On this page