Cognee is an open-source AI memory platform that gives agents persistent long-term memory across sessions using a self-hosted knowledge graph. Its defining idea is the ECL pipeline — Extract, Cognify, Load — which ingests documents, conversations, and data from many sources, structures them into a graph of entities and relationships (the “cognify” step), and loads them into graph + vector stores for retrieval. This makes memory an active, queryable layer rather than a flat vector dump.
Installation
| Method | Command |
|---|
| pip | pip install cognee |
| uv | uv add cognee |
| With extras | pip install "cognee[postgres,neo4j]" |
| Set an LLM key | export LLM_API_KEY="sk-..." |
| Verify | python -c "import cognee; print('ok')" |
The ECL Pipeline
| Stage | What it does |
|---|
| Extract | Ingest raw data from 30+ source types |
| Cognify | Build a knowledge graph (entities, relationships) |
| Load | Store into graph + vector databases for retrieval |
| Search | Query memory (graph, vector, or hybrid) |
Basic Usage
import cognee
import asyncio
async def main():
# 1) Add data to memory
await cognee.add("Nick prefers concise, direct answers.")
await cognee.add(open("notes.md").read())
# 2) Build the knowledge graph
await cognee.cognify()
# 3) Query memory
results = await cognee.search("What are Nick's preferences?")
print(results)
asyncio.run(main())
| Call | Description |
|---|
cognee.add(data) | Ingest text, files, or structured data |
cognee.cognify() | Process ingested data into the graph |
cognee.search(query, ...) | Retrieve from memory |
cognee.prune() | Reset/clear memory stores |
Search Types
| Type | Returns |
|---|
SearchType.GRAPH_COMPLETION | Answer grounded in the knowledge graph |
SearchType.RAG_COMPLETION | Classic vector RAG answer |
SearchType.INSIGHTS | Entity relationships/insights |
SearchType.CHUNKS | Raw matching chunks |
SearchType.SUMMARIES | Summarized results |
from cognee import SearchType
res = await cognee.search("connections between X and Y",
query_type=SearchType.INSIGHTS)
Data Sources
| Category | Examples |
|---|
| Documents | PDF, DOCX, Markdown, text |
| Structured | CSV, JSON, databases |
| Conversations | Chat/message history |
| Code | Source files/repos |
Storage Backends
| Layer | Options |
|---|
| Graph store | NetworkX (default), Neo4j, Kuzu |
| Vector store | LanceDB (default), Qdrant, pgvector, Weaviate |
| Relational | SQLite (default), PostgreSQL |
| Config | Set via environment variables / config |
Datasets & Multi-Tenancy
| Feature | Use |
|---|
| Datasets | Namespace memory per user/project |
cognee.add(data, dataset_name="user-123") | Scope ingestion |
| Permissions | Control access to memory partitions |
Common Workflows
# Give an agent durable memory of a user across sessions
await cognee.add(conversation_history, dataset_name="user-42")
await cognee.cognify()
context = await cognee.search("summarize what we know about user-42")
# inject `context` into the agent's prompt
# Build a graph over a document corpus for connect-the-dots questions
for f in docs: await cognee.add(open(f).read())
await cognee.cognify()
await cognee.search("how do these documents relate?",
query_type=SearchType.INSIGHTS)
Cognee vs Other Memory Frameworks
| Aspect | Cognee | Mem0 | Graphiti |
|---|
| Model | Graph-native (ECL) | Multi-tier vector/graph/KV | Temporal knowledge graph |
| Strength | Local-first graph reasoning | Conversational personalization | Facts that change over time |
| Self-host | Yes | Yes | Yes |
| Best for | Privacy-critical graph memory | Personalization | Temporal reasoning |
Resources