Overview
Cognee is an open-source AI memory platform for agents. You feed it data in many formats, and it builds a self-hosted knowledge graph that gives your agents long-term memory that lasts across sessions. It combines vector embeddings for meaning-based search with a graph layer that captures how facts relate to each other.
It is aimed at developers who are building agents, assistants, or RAG systems that need to remember context over time instead of starting fresh on every request. The Python API centers on four operations — remember, recall, forget, and improve — so you can store information, query it, and clean it up without managing the graph by hand.
As a memory framework, Cognee sits between your raw documents or conversations and the agent that uses them. It runs locally, supports multiple LLM providers, and also offers a CLI and integrations (including a Claude Code plugin) for capturing and recalling memory.
What it does
- Builds a self-hosted knowledge graph from documents and conversations, combining vector embeddings with graph reasoning
- Simple Python API with four core operations: remember, recall, forget, and improve
- Session memory (fast cache) plus a permanent graph store, with auto-routing that picks the best search strategy
- Command-line interface (cognee-cli) and a local web UI for storing and querying memory
- Works with multiple LLM providers and runs locally; ontology grounding for connecting facts
- Integrations for AI coding agents, including a Claude Code plugin that captures tool calls and syncs them to the graph
Getting started
Cognee needs Python 3.10 to 3.14. Install the package, point it at an LLM API key, then store and query memory in a few lines.
Install Cognee
Install with pip, poetry, uv, or your preferred Python package manager.
uv pip install cogneeConfigure the LLM
Set your LLM API key as an environment variable, or create a .env file from the project's template.
import os
os.environ["LLM_API_KEY"] = "YOUR OPENAI_API_KEY"Store and recall memory
Use remember to store data in the knowledge graph and recall to query it. Both calls are async.
import cognee
import asyncio
async def main():
# Store permanently in the knowledge graph
await cognee.remember("Cognee turns documents into AI memory.")
# Query with auto-routing
results = await cognee.recall("What does Cognee do?")
for result in results:
print(result)
if __name__ == '__main__':
asyncio.run(main())Use the CLI (optional)
The cognee-cli command mirrors the API, and -ui opens a local web interface.
cognee-cli remember "Cognee turns documents into AI memory."
cognee-cli recall "What does Cognee do?"
cognee-cli -uiCommands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Give an agent or chatbot persistent memory so it recalls user preferences and past context across sessions
- Turn a collection of internal documents into a queryable knowledge graph for retrieval-augmented agents
- Add long-term memory to a coding assistant via the Claude Code plugin, which captures tool calls and syncs them to the graph
- Build a shared 'company brain' that unifies data from several sources and serves it to multiple agents
How Cognee compares
Cognee alongside other open-source agent memory tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| Mem0 | ★ 59.6k | A memory layer that you add to existing LLM agents to extract, store, and recall user facts and preferences across sessions using vector, graph, and key-value backends. |
| Graphiti | ★ 28.1k | A library that builds a temporal knowledge graph from an agent's conversations and data so facts can be tracked and queried as they change over time. |
| Supermemory | ★ 27.8k | A memory and context engine that ingests information across tools and sessions and can run fully locally, acting as a second brain for AI applications. |
| Cognee | ★ 24k | Open-source AI memory that turns your data into a queryable knowledge graph for agents |
| Letta | ★ 23.5k | A framework (formerly MemGPT) for building stateful agents with long-term memory that persists across sessions and conversations. |
| Memvid | ★ 15.7k | Memvid packs an AI agent's data, embeddings, and search index into one portable file, so it can retrieve memory fast without running a vector database. |
| Memori | ★ 15.5k | An SQL-native memory engine that gives any LLM persistent, structured memory stored in standard PostgreSQL or MySQL databases instead of a vector store. |
| MemU | ★ 13.9k | A memory layer for AI agents that organizes structured storage and intent capture to reduce the tokens needed to keep context across conversations. |