TL;DR

Cognee is the open-source AI memory platform that gives agents persistent long-term memory across sessions. Instead of stuffing everything back into the context window every turn, you ingest data once and Cognee builds a self-hosted knowledge graph — combining vector embeddings with graph reasoning so your agent can recall facts and the relationships between them. It’s crossed 28,000 GitHub stars, ships under Apache 2.0, and has become the reference “GraphRAG memory” project for teams that want production-grade memory without vendor lock-in.

  • Four-verb API: remember, recall, forget, improve — the whole mental model fits on a napkin
  • Graph + vector: not just semantic search — it extracts entities and edges into a knowledge graph
  • Self-hosted: runs locally, Postgres/PGVector or Neo4j backends, nothing gated behind a paid tier
  • Multi-surface: Python SDK, TypeScript/Rust clients, a CLI, a web UI, and an MCP server
  • Ships with an OpenAI-compatible API so it drops into existing stacks
  • Docker images published on every push to main for the API and MCP servers

If you’ve been rebuilding “agent memory” out of a pile of embeddings and a WHERE similarity > 0.8 query, Cognee is the layer you’ve been reinventing.

Quick Reference

FieldValue
Repotopoteretes/cognee
Websitecognee.ai
LicenseApache 2.0
Stars~28,000 (190+ contributors, 127+ releases)
LanguagePython 3.10–3.14
Installuv pip install cognee
BackendsPGVector, Neo4j, LanceDB, Kuzu (pluggable)
PaperarXiv:2505.24478

What Problem Does It Actually Solve?

Every developer building an agent hits the same wall: the context window is not memory. You can jam the last 20 messages back in on every turn, but that’s a rolling buffer, not recall. Real memory needs three things a naive RAG pipeline doesn’t give you:

  1. Persistence — knowledge learned in session 1 is available in session 100 without re-ingestion.
  2. Structure — “Acme’s CTO is Dana, and Dana approved the migration” is two entities and a relationship, not a fuzzy blob of tokens.
  3. Evolution — as new facts arrive, the memory should update, not just append duplicates.

Plain vector search gives you #1 and a weak version of the others. Cognee’s pitch is that memory should be a knowledge graph layered on top of vectors: documents are searchable by meaning and connected by relationships that evolve. That’s the “GraphRAG” idea, but packaged as a memory API rather than a research technique you assemble yourself.

Getting Started

The quickstart is genuinely a few lines. Install it:

uv pip install cognee

Point it at an LLM (Cognee uses the model for entity/relationship extraction, not just the final answer):

import os
os.environ["LLM_API_KEY"] = "YOUR_OPENAI_API_KEY"

You can swap in other providers (Anthropic, local Ollama, etc.) via the .env template — nothing forces you onto OpenAI. Then the core loop:

import cognee
import asyncio


async def main():
    # Store permanently in the knowledge graph (runs add + cognify + improve)
    await cognee.remember("Cognee turns documents into AI memory.")

    # Store in session memory (fast cache, syncs to graph in background)
    await cognee.remember("User prefers detailed explanations.", session_id="chat_1")

    # Query with auto-routing (picks best search strategy automatically)
    results = await cognee.recall("What does Cognee do?")
    for result in results:
        print(result)

    # Session memory first, fall through to the graph if needed
    results = await cognee.recall("What does the user prefer?", session_id="chat_1")
    for result in results:
        print(result)

    # Delete when done
    await cognee.forget(dataset="main_dataset")


if __name__ == "__main__":
    asyncio.run(main())

The design decision worth calling out: remember does three things under the hood — add (ingest the raw data), cognify (extract entities and build graph edges), and improve (refine the memory over time). You don’t orchestrate a pipeline; you call one verb. The trade-off is that remember on the permanent store is not cheap — each call can fire LLM extraction — which is why there’s a separate fast session_id cache that syncs to the graph in the background.

The CLI

For quick experiments or shell scripting, there’s a CLI that mirrors the API:

cognee-cli remember "Cognee turns documents into AI memory."
cognee-cli recall "What does Cognee do?"
cognee-cli forget --all

# Launch the local web UI (runs the MCP server in Docker)
cognee-cli -ui

Running with Docker

If you’d rather not touch Python at all, Cognee publishes prebuilt images on every push to main. The Compose setup uses profiles so you only stand up what you need:

cp .env.template .env   # then set LLM_API_KEY

docker compose up                     # API server on :8000
docker compose --profile ui up        # + frontend on :3000
docker compose --profile mcp up       # + MCP server on :8001
docker compose --profile postgres up  # + Postgres/PGVector
docker compose --profile neo4j up     # + Neo4j

Or skip the clone entirely and pull the image:

echo 'LLM_API_KEY="YOUR_OPENAI_API_KEY"' > .env
docker run --env-file ./.env -p 8000:8000 --rm -it cognee/cognee:main

The MCP server is the piece that matters most in 2026: it means Claude Code, Cursor, or any MCP-aware client can call remember/recall as tools, so your coding agent gets persistent project memory without you writing glue code. There’s also a first-class Claude Code plugin and an OpenClaw plugin in the ecosystem.

How It Compares

The AI-memory space got crowded fast. The honest framing from the community is that these tools sit on a spectrum from “dead simple” to “explicit knowledge structures”:

ToolApproachLicenseBest for
CogneeGraph + vector, ontology-groundedApache 2.0Self-hosted, structured recall, air-gapped
Mem0Two LLM calls, simplest loopApache 2.0Fast setup, chat-style memory
Graphiti (Zep)Temporal knowledge graphApache 2.0Time-aware facts, support docs
LettaAgent manages its own memoryApache 2.0Self-editing / self-improving agents
HindsightExplicit graph, benchmark-toppingMITHighest benchmark scores

A widely-shared r/LocalLLaMA teardown of eight memory systems put it well: Mem0’s core loop is “two LLM calls — the simplest architecture of the eight,” Letta hands the agent tools to manage its own memory, while Cognee, Graphiti, Hindsight, and EverMemOS build explicit knowledge structures. If your data has real relationships — org charts, codebases, product docs, regulations — the explicit-structure camp tends to win. If you just want “remember what the user said last time,” Mem0 is less to reason about.

On the self-hosting axis specifically, the recurring recommendation is that Cognee (Apache 2.0) and Hindsight (MIT) are the closest open matches to what Mem0 does — automatic extraction, vector plus graph retrieval, and nothing behind a paywall. For air-gapped or on-prem enterprise deployments, Cognee shows up on almost every “Mem0 alternative” shortlist.

Community Reception

Cognee has an unusually engaged following for an infra project — it spun up its own subreddit (r/AIMemory) and a Discord, and it consistently trends on Trendshift. The sentiment in the GraphRAG-comparison threads is telling. From an r/AIMemory user who tried all three:

“I prefer Cognee (no affiliation) after trying Mem0 and Graphiti. Mem0 was easy-ish to get set up, but didn’t offer the cutting-edge configurations I was looking for. It also appeared to me to be poorly maintained (my impression only).”

That’s the pattern across threads: people who want control over the memory pipeline gravitate to Cognee; people who want the fastest possible “hello world” reach for Mem0 first. The counter-signal is real too — some users note that Cognee’s flexibility comes with more moving parts, and that its published benchmark numbers lag competitors like Hindsight (91.4%) and Mem0 on temporal-reasoning tests, which makes apples-to-apples procurement comparisons harder.

The other thing the community values: it’s backed by an actual research paper (Markovic et al., 2025) on optimizing the interface between knowledge graphs and LLMs, plus a $7.5M seed round and 70+ reported production deployments. For an open-source memory layer you’re going to bet an agent on, “there’s a paper and a company behind it” is not nothing.

Honest Limitations

No tool review is useful without the sharp edges. After digging through the docs and community threads, here’s where Cognee will bite you:

  • remember is LLM-expensive. Because permanent storage runs entity extraction, ingesting a large corpus can rack up token costs and take time. Budget for it; use the session cache for hot paths.
  • It’s a graph, so it can over-structure. For genuinely unstructured, low-relationship data (random notes, transcripts), the graph-building overhead may buy you little over plain vector search.
  • Backend sprawl. PGVector, Neo4j, Kuzu, LanceDB — flexibility is great until you’re debugging why your Neo4j profile won’t connect. Start with the default embedded setup before reaching for Postgres/Neo4j.
  • Docker dependency for the UI/MCP. The local UI launches the MCP server inside a container, so you need Docker Desktop, Colima, or an OCI runtime — a papercut for pure-pip users.
  • Benchmark gap. Cognee hasn’t published head-to-head temporal-reasoning scores against Mem0/Hindsight, so “is it more accurate?” is genuinely hard to answer objectively right now.
  • You still bring the LLM. Cognee is memory infrastructure, not a model. Extraction quality is only as good as the model you point it at.

Should You Use It?

Reach for Cognee if you’re building an agent that needs to accumulate structured knowledge over time — a company brain, a documentation assistant, a coding agent with persistent project memory — and you want to self-host with no paid tier. The four-verb API keeps the mental model simple, the MCP server makes it plug into modern agent stacks cleanly, and the Apache 2.0 license means no surprises.

Skip it (for now) if your need is “remember the last few chat turns” — Mem0 is less machinery — or if you need published benchmark superiority to justify the choice, in which case Hindsight is worth a look. But as the default open-source, graph-native, self-hosted memory layer in mid-2026, Cognee has earned its spot at the top of the shortlist.

FAQ

What is Cognee? Cognee is an open-source (Apache 2.0) AI memory platform that gives agents persistent long-term memory. You ingest data in any format and it builds a self-hosted knowledge graph combining vector embeddings and graph reasoning, exposed through a simple remember/recall/forget/improve API.

How is Cognee different from a vector database? A vector DB gives you semantic similarity search. Cognee adds a knowledge-graph layer on top — it extracts entities and the relationships between them, so recall can follow connections (“who approved X, and what did they approve before?”), not just find similar text.

Is Cognee free and self-hostable? Yes. It’s Apache 2.0, runs locally, and nothing is gated behind a paid tier. You can run it via pip, the CLI, or Docker images published on every push to main, with backends like PGVector or Neo4j.

Cognee vs Mem0 — which should I choose? Mem0 has the simplest architecture (roughly two LLM calls) and the fastest setup, ideal for chat-style memory. Cognee builds explicit knowledge structures and gives you far more control over the pipeline — better for structured, relationship-rich data and air-gapped deployments. Many users start on Mem0 and move to Cognee when they need more control.

Does Cognee work with Claude Code and other AI coding agents? Yes. Cognee ships an MCP server plus a dedicated Claude Code plugin and an OpenClaw plugin, so MCP-aware clients can call remember/recall as tools and give your coding agent persistent project memory.

What LLMs does Cognee support? Cognee uses an LLM for entity and relationship extraction. It defaults to OpenAI via LLM_API_KEY but supports other providers (including local models) through its .env configuration and LLM-provider docs.

Sources