Episode Types
Graphiti supports three episode types:EpisodeType.text- Plain text content like meeting notes or articlesEpisodeType.json- Structured JSON dataEpisodeType.message- Conversation messages with speaker patterns
Adding a Single Episode
Adding JSON Episodes
For structured data, useEpisodeType.json and serialize your data:
Adding Message Episodes
For conversations, useEpisodeType.message:
Episode Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | str | Yes | Unique identifier for the episode |
episode_body | str | Yes | The content (plain text or JSON string) |
source | EpisodeType | Yes | Type of episode (text, json, or message) |
source_description | str | Yes | Description of where this data came from |
reference_time | datetime | Yes | When this information was valid |
group_id | str | No | Graph partition identifier |
uuid | str | No | Custom UUID (auto-generated if not provided) |
entity_types | dict | No | Custom entity type definitions |
edge_types | dict | No | Custom relationship type definitions |
update_communities | bool | No | Whether to update community summaries |
Advanced Options
Group IDs for Multi-Tenancy
Usegroup_id to partition your graph for different users or contexts:
Custom Entity Types
Define custom entity types to extract domain-specific information:Updating Communities
Communities are clusters of related entities. Enable automatic community updates:Episode Results
Theadd_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):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