Skip to main content
Episodes are the primary units of information in Graphiti. Each episode represents a discrete piece of content that Graphiti processes to extract entities and relationships.

Episode Types

Graphiti supports three episode types:
  • EpisodeType.text - Plain text content like meeting notes or articles
  • EpisodeType.json - Structured JSON data
  • EpisodeType.message - Conversation messages with speaker patterns

Adding a Single Episode

1

Import dependencies

2

Initialize Graphiti

3

Add a text episode

The reference_time parameter specifies when this information was valid, enabling temporal queries.

Adding JSON Episodes

For structured data, use EpisodeType.json and serialize your data:

Adding Message Episodes

For conversations, use EpisodeType.message:

Episode Parameters

Advanced Options

Group IDs for Multi-Tenancy

Use group_id to partition your graph for different users or contexts:

Custom Entity Types

Define custom entity types to extract domain-specific information:
See the Custom Entities guide for more details.

Updating Communities

Communities are clusters of related entities. Enable automatic community updates:

Episode Results

The add_episode method returns an AddEpisodeResults object:

Best Practices

Sequential Processing

Add episodes sequentially, not in parallel. Each episode builds on the context of previous ones.

Descriptive Names

Use clear, unique names for episodes to make them easy to identify later.

Accurate Timestamps

Set reference_time to when the information was valid, not when you’re processing it.

Source Descriptions

Provide meaningful source descriptions to track data provenance.

Dense Content Handling

Graphiti automatically detects and chunks dense content (like cost reports with many entities):
Chunking is controlled by environment variables:
  • CHUNK_MIN_TOKENS - Minimum tokens before considering chunking (default: 1000)
  • CHUNK_DENSITY_THRESHOLD - Entity density threshold (default: 0.15)
  • CHUNK_TOKEN_SIZE - Target size per chunk (default: 3000)

Error Handling

Next Steps

Bulk Operations

Learn how to add multiple episodes efficiently

Searching

Query your knowledge graph to retrieve information

Custom Entities

Define domain-specific entity types