Skip to content

Repository files navigation

OpenMemory

Add long-term, semantic, and contextual memory to any AI system.
Open source. Self-hosted. Explainable. Framework-agnostic.

Report BugRequest FeatureDiscord server


1. Overview

OpenMemory is a self-hosted, modular AI memory engine designed to provide persistent, structured, and semantic memory for large language model (LLM) applications.
It enables AI agents, assistants, and copilots to remember user data, preferences, and prior interactions — securely and efficiently.

Unlike traditional vector databases or SaaS “memory layers”, OpenMemory implements a Hierarchical Memory Decomposition (HMD) architecture:

  • One canonical node per memory (no data duplication)
  • Multi-sector embeddings (episodic, semantic, procedural, emotional, reflective)
  • Single-waypoint linking (sparse, biologically-inspired graph)
  • Composite similarity retrieval (sector fusion + activation spreading)

This design offers better recall, lower latency, and explainable reasoning at a fraction of the cost.


2. Competitor Comparison

Feature / MetricOpenMemoryZep (Cloud)Supermemory (SaaS)Mem0OpenAI MemoryLangChain MemoryVector DBs (Chroma / Weaviate / Pinecone)
Open-source✅ MIT❌ Closed (SaaS only)❌ Closed✅ Apache❌ Closed✅ Apache✅ Varies
Self-hosted
ArchitectureHMD v2 (multi-sector + single-waypoint graph)Flat embeddings (Postgres + FAISS)Flat embeddingsFlat JSON memoryProprietary long-term cacheContext cacheVector index
Avg response time (100k nodes)110–130 ms280–350 ms350–400 ms250 ms300 ms200 ms160 ms
Retrieval depthMulti-sector fusion + 1-hop waypointSingle embeddingSingle embeddingSingle embeddingUnspecified1 session onlySingle embedding
Explainable recall paths
Cost per 1M tokens (with hosted embeddings)~$0.30–0.40~$2.0–2.5~$2.50+~$1.20~$3.00User-managedUser-managed
Local embeddings support✅ (Ollama / E5 / BGE)Partial
Ingestion✅ (pdf, docx, txt, audio, website)✅ (via API)
Scalability modelHorizontally sharded by sectorCloud-native (Postgres + FAISS shards)Vendor scale onlySingle nodeVendor scaleIn-memoryHorizontally scalable
DeploymentLocal / Docker / CloudCloud onlyWeb onlyNode appCloudPython SDKDocker / Cloud
Data ownership100% yoursVendorVendor100% yoursVendorYoursYours
Use-case fitLong-term agent memory, assistants, journaling, enterprise copilotsEnterprise AI agents, retrieval-based assistantsSaaS AI assistantsBasic agent memoryChatGPT-onlyLLM frameworkGeneric vector search

Summary

OpenMemory delivers 2–3× faster contextual recall, 6–10× lower cost, and full transparency compared to hosted “memory APIs” like Zep or Supermemory.
Its multi-sector cognitive model allows explainable recall paths, hybrid embeddings (OpenAI / Gemini / Ollama / local), and real-time decay, making it ideal for developers seeking open, private, and interpretable long-term memory for LLMs.

For more detailed comparison check "Performance and Cost Analysis" below.


3. Setup

Manual Setup (Recommended for development)

Prerequisites

  • Node.js 20+
  • SQLite 3.40+ (bundled)
  • Optional: Ollama / OpenAI / Gemini embeddings
git clone https://github.com/caviraoss/openmemory.git
cp .env.example .env
cd openmemory/backend
npm install
npm run dev

Example .env configuration:

OM_PORT=8080
OM_DB_PATH=./data/openmemory.sqlite
OM_EMBEDDINGS=openai
OPENAI_API_KEY=
GEMINI_API_KEY=
OLLAMA_URL=http://localhost:11434
OM_VEC_DIM=768
OM_MIN_SCORE=0.3
OM_DECAY_LAMBDA=0.02
OM_LG_NAMESPACE=default
OM_LG_MAX_CONTEXT=50
OM_LG_REFLECTIVE=true

Start server:

npx tsx src/server.ts

OpenMemory runs on http://localhost:8080.


Docker Setup (Production)

docker compose up --build -d

Default ports:

  • 8080 → OpenMemory API
  • Data persisted in /data/openmemory.sqlite

4. Architecture and Technology Stack

Core Components

LayerTechnologyDescription
BackendTypescriptREST API and orchestration
StorageSQLite (WAL)Memory metadata, vectors, waypoints
EmbeddingsE5 / BGE / OpenAI / Gemini / OllamaSector-specific embeddings
Graph LogicIn-processSingle-waypoint associative graph
Schedulernode-cronDecay, pruning, log repair

Retrieval Flow

  1. User request → Text sectorized into 2–3 likely memory types
  2. Query embeddings generated for those sectors
  3. Search over sector vectors + optional mean cache
  4. Top-K matches → one-hop waypoint expansion
  5. Ranked by composite score:
    0.6 × similarity + 0.2 × salience + 0.1 × recency + 0.1 × link weight

Architecture Diagram (simplified)

[User / Agent]
│
▼
[OpenMemory API]
│
┌───────────────┬───────────────┐
│ SQLite (meta) │ Vector Store │
│ memories.db │ sector blobs │
└───────────────┴───────────────┘
│
▼
[Waypoint Graph]

5. API Overview

MethodEndpointDescription
POST/memory/addAdd a memory item
POST/memory/queryRetrieve similar memories
GET/memory/allList all stored memories
DELETE/memory/:idDelete a memory
GET/healthHealth check

Example

curl -X POST http://localhost:8080/memory/add -H "Content-Type: application/json" -d '{"content": "User prefers dark mode"}'

LangGraph Integration Mode (LGM)

Set the following environment variables to enable LangGraph integration:

OM_MODE=langgraph
OM_LG_NAMESPACE=default
OM_LG_MAX_CONTEXT=50
OM_LG_REFLECTIVE=true

When activated, OpenMemory mounts additional REST endpoints tailored for LangGraph nodes:

MethodEndpointPurpose
POST/lgm/storePersist a LangGraph node output into HMD storage
POST/lgm/retrieveRetrieve memories scoped to a node/namespace/graph
POST/lgm/contextFetch a summarized multi-sector context for a graph session
POST/lgm/reflectionGenerate and store higher-level reflections
GET/lgm/configInspect active LangGraph mode configuration

Node outputs are mapped to sectors automatically:

NodeSector
observeepisodic
plansemantic
reflectreflective
actprocedural
emotionemotional

All LangGraph requests pass through the core HSG pipeline, benefiting from salience, decay, automatic waypointing, and optional auto-reflection.


Built-in MCP HTTP Server

OpenMemory ships with a zero-config Model Context Protocol endpoint so MCP-aware agents (Claude Desktop, VSCode extensions, custom SDKs) can connect immediately—no SDK install required. The server advertises protocolVersion: 2025-06-18 and serverInfo.version: 2.1.0 for broad compatibility.

MethodEndpointPurpose
POST/mcpStreamable HTTP MCP interactions

Available server features:

  • Tools:openmemory.query, openmemory.store, openmemory.reinforce, openmemory.list, openmemory.get
  • Resource:openmemory://config (runtime, sector, and embedding snapshot)

Example MCP tool call (JSON-RPC):

{
"jsonrpc": "2.0",
"id": "1",
"method": "tools/call",
"params": {
"name": "openmemory.query",
"arguments": {
"query": "preferred coding habits",
"k": 5
}
}
}

The MCP route is active as soon as the server starts and always responds with Content-Type: application/json, making it safe for curl, PowerShell, Claude, and other MCP runtimes.

Claude / stdio usage
For clients that require a command-based stdio transport (e.g., Claude Desktop), point them at the compiled CLI:

node backend/dist/mcp/index.js

The CLI binds to stdin/stdout using the same toolset shown above, so HTTP and stdio clients share one implementation.


6. Performance and Cost Analysis

MetricOpenMemory (self-hosted)Zep (Cloud)Supermemory (SaaS)Mem0Vector DB (avg)
Query latency (100k nodes)110–130 ms (local)280–350 ms350–400 ms250 ms160 ms
Memory addition throughput~40 ops/s (local batch)~15 ops/s~10 ops/s~25 ops/s~35 ops/s
CPU usageModerate (vector math only)Serverless (billed per req)Serverless (billed)ModerateHigh
Storage cost (per 1 M memories)15 GB ($3/mo VPS)~$75–100~$60 +~$20~$10–25
Hosted embedding cost~$0.30–0.40 / 1 M tokens~$2.0–2.5 / 1 M tokens~$2.50 +~$1.20User-managed
Local embedding cost$0 (Ollama / E5 / BGE)❌ Not supported❌ Not supportedPartial✅ Supported
Expected monthly cost (100k memories)~$5–8 (self-hosted)~$80–150 (Cloud)~$60–120~$25–40~$15–40
Reported accuracy (LongMemEval)94–97 % (avg)58–85 % (varies)82 % (claimed)74 %60–75 %
Median latency (LongMemEval)~2.1 s (GPT-4o)2.5–3.2 s (GPT-4o)3.1 s (GPT-4o)2.7 s2.4 s (avg)

Summary

  • OpenMemory is roughly 2.5× faster and 10–15× cheaper than Zep at the same memory scale when self-hosted.
  • Zep Cloud offers simplicity and hosted infra but with slower ingestion, higher latency, and no local-model support.
  • Mem0 balances cost and ease of use but lacks cognitive structure (no sectorized memory).
  • Vector DBs remain efficient for raw similarity search but miss cognitive behaviors such as decay, episodic recall, and reflection.

7. Security and Privacy

  • Bearer authentication required for write APIs
  • Optional AES-GCM content encryption
  • PII scrubbing and anonymization hooks
  • Tenant isolation for multi-user deployments
  • Full erasure via DELETE /memory/:id or /memory/delete_all?tenant=X
  • No vendor data exposure; 100% local control

8. Roadmap

PhaseFocusStatus
v1.0Core HMD backend (multi-sector memory)✅ Complete
v1.1Pluggable vector backends (pgvector, Weaviate)✅ Complete
v1.2Dashboard (React) + metrics⏳ In progress
v1.3Learned sector classifier (Tiny Transformer)🔜 Planned
v1.4Federated multi-node mode🔜 Planned

9. Contributing

Contributions are welcome.
See CONTRIBUTING.md, GOVERNANCE.md, and CODE_OF_CONDUCT.md for guidelines.

make build
make test

Our Contributers:

nullure
Morven
muhammad-fiaz
Muhammad Fiaz
pc-quiknode
Peter Chung
ammesonb
Brett Ammeson
josephgoksu
Joseph Goksu

10. License

MIT License.
Copyright (c) 2025 OpenMemory.


👥 Community

Join our Discord community to connect, share ideas, and take part in exciting discussions!


11. Check out our other projects

PageLM: PageLM is a community-driven version of NotebookLM & an education platform that transforms study materials into interactive resources like quizzes, flashcards, notes, and podcasts.

Link: https://github.com/CaviraOSS/PageLM

Positioning Statement

OpenMemory aims to become the standard open-source memory layer for AI agents and assistants — combining persistent semantic storage, graph-based recall, and explainability in a system that runs anywhere.

It bridges the gap between vector databases and cognitive memory systems, delivering high-recall reasoning at low cost — a foundation for the next generation of intelligent, memory-aware AI.

About

Add long-term memory to any AI in minutes. Self-hosted, open, and framework-free.

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages