# Graphiti

> Build temporal knowledge graphs that track how an AI agent's facts change over time

- Category: Agents & Automation / Agent Memory
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/getzep/graphiti
- Website: https://help.getzep.com/graphiti
- Canonical page: https://ai-tldr.dev/tools/graphiti/

## In short

Graphiti is an open-source Python framework for building and querying temporal context graphs for AI agents. Instead of treating an agent's history as flat document chunks or raw chat logs, it turns conversations and other data into a graph of entities, relationships, and facts. It sits in the Agent Memory category of the Agents & Automation tools and is open-source, written in Python and licensed Apache-2.0.

## Overview

Graphiti is an open-source Python framework for building and querying temporal context graphs for AI agents. Instead of treating an agent's history as flat document chunks or raw chat logs, it turns conversations and other data into a graph of entities, relationships, and facts. Each fact carries a validity window, so the graph records both what is true now and what was true before.

It is aimed at developers building context-aware agents that work with data that keeps changing. New episodes (the raw data you feed in) are integrated incrementally, without recomputing the whole graph, and every derived fact traces back to its source. You can define entity and edge types up front with Pydantic models, or let structure emerge from the data.

As a memory framework, Graphiti fills the role of long-term agent memory: it stores interactions and enterprise data in a queryable graph and retrieves context using a mix of semantic embeddings, BM25 keyword search, and graph traversal. It is the open-source engine behind Zep's managed context infrastructure, and can be used on its own with a supported graph database.

## What it does

- Temporal fact management: facts have validity windows, and when information changes old facts are invalidated rather than deleted, so you can query the current state or any past point in time
- Episodes and provenance: every entity and relationship traces back to the raw episodes that produced it, giving full lineage from a derived fact to its source data
- Prescribed and learned ontology: define entity and edge types with Pydantic models, or let structure emerge from the data as patterns appear
- Incremental graph construction: new data integrates immediately without batch recomputation, so the graph evolves as episodes are ingested
- Hybrid retrieval: combines semantic embeddings, keyword (BM25) search, and graph traversal for low-latency queries without relying on LLM summarization
- Pluggable backends: works with Neo4j, FalkorDB, and Amazon Neptune, and supports OpenAI, Anthropic, Google Gemini, and Groq as LLM providers

## Getting started

Graphiti is a Python package (graphiti-core) that connects to a graph database and an LLM provider. You need Python 3.10+, a supported graph database such as Neo4j 5.26+, and an OpenAI API key for the default LLM.

1. Install the package

   Install graphiti-core with pip or uv. Optional extras add support for FalkorDB or alternative LLM providers.

```bash
pip install graphiti-core
```

2. Set your LLM API key

   OpenAI is the default LLM provider, so export your key before running. Anthropic, Google Gemini, and Groq are available via extras.

```bash
export OPENAI_API_KEY=your-api-key
```

3. Connect, add an episode, and search

   Point Graphiti at your graph database (here a local Neo4j over bolt), ingest a piece of raw data as an episode, then query for related edges and nodes. These calls are async.

```python
from graphiti_core import Graphiti

graphiti = Graphiti(
    "bolt://localhost:7687",
    "neo4j",
    "password"
)

# Add episodes (raw data)
await graphiti.add_episode("user_message_text")

# Search for relationships
results = await graphiti.search_edges("query_text")

# Search for nodes
node_results = await graphiti.search_nodes("entity_name")
```

## When to use it

- Give a conversational agent long-term memory that tracks how a user's preferences and facts change across sessions
- Combine structured and unstructured enterprise data into one queryable graph for a context-aware assistant
- Answer historical questions by querying what was true at a specific point in time, not just the current state
- Provide MCP clients such as Claude or Cursor with temporal, graph-based memory via the included MCP server
