📄 Read the research paper: [Optimizing the Interface Between Knowledge Graphs and LLMs for Complex Reasoning](https://arxiv.org/abs/2505.24478) — Markovic et al., 2025
## When to use Cognee
- **Build a Company Brain.** Bring documentation, conversations, tickets, code, and agent work into shared memory. Help your team and agents connect a decision to the discussion and implementation behind it. [Explore Company Brain](https://www.cognee.ai/company-brain).
- **Give agents memory across runs.** Retain project context, past decisions, fixes, and learned rules. Distill useful session lessons into durable knowledge that another session can retrieve. [Connect your agent](#connect-your-agent).
- **Ground agents in your domain.** Structure memory around the entities and relationships your application needs, with custom data models and ontologies. [Explore ontologies](https://docs.cognee.ai/guides/ontology-support).
## Choose your starting point
| I want to… | Start here |
| --- | --- |
| See a memory graph without an API key | [Bundled demo](#try-it-without-an-api-key) |
| Build with text, code, and session memory | [Python quickstart](#quickstart) |
| Give an existing agent memory | [Plugins and MCP](#connect-your-agent) |
| Run Cognee on my infrastructure | [Deployment options](#deploy-cognee) |
| Use a managed service | [Cognee Cloud](https://docs.cognee.ai/cognee-cloud/overview) |
## Quickstart
Requires **Python 3.10–3.14**.
You can install Cognee with **pip**, **uv**, or your preferred Python package manager.
```bash
uv pip install cognee
```
### Try it without an API key
```bash
cognee-cli demo
```
### Step 2: Configure the LLM
```python
import os
os.environ["LLM_API_KEY"] = "YOUR OPENAI_API_KEY"
```
Alternatively, create a `.env` file using our [template](https://github.com/topoteretes/cognee/blob/main/.env.template).
The default uses OpenAI for language models and embeddings. Processing and generated answers make provider calls. See [installation](https://docs.cognee.ai/getting-started/installation), [other providers](https://docs.cognee.ai/setup-configuration/llm-providers), or [local Ollama models](https://docs.cognee.ai/guides/local-ollama) for other setups.
```python
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)
# Query session memory first, fall through to 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())
```
## How Cognee works
Cognee builds connected memory from different sources. Text becomes entities, relationships, and searchable chunks; code becomes a graph of symbols and dependencies. Session distillation curates accepted lessons into permanent memory.