Quick Start
For complete working examples, check out the Graphiti Quickstart Examples on GitHub.
Installation
Requirements:
- Python 3.10 or higher
- Neo4j 5.26 or higher or FalkorDB 1.1.2 or higher (see Graph Database Configuration for setup options)
- OpenAI API key (Graphiti defaults to OpenAI for LLM inference and embedding)
The simplest way to install Neo4j is via Neo4j Desktop. It provides a user-friendly interface to manage Neo4j instances and databases.
or
Alternative LLM Providers
While Graphiti defaults to OpenAI, it supports multiple LLM providers including Azure OpenAI, Google Gemini, Anthropic, Groq, and local models via Ollama. For detailed configuration instructions, see our LLM Configuration guide.
Environment Variables
Set your OpenAI API key:
Optional Variables
USE_PARALLEL_RUNTIME
: Enable Neo4j’s parallel runtime feature for search queries (not supported in Community Edition)GRAPHITI_TELEMETRY_ENABLED
: Set tofalse
to disable anonymous telemetry collection
Getting Started with Graphiti
For a comprehensive overview of Graphiti and its capabilities, check out the Overview page.
Required Imports
First, import the necessary libraries for working with Graphiti:
Configuration
Graphiti uses OpenAI by default for LLM inference and embedding. Ensure that an OPENAI_API_KEY
is set in your environment. Support for multiple LLM providers is available - see our LLM Configuration guide.
Graphiti also requires Neo4j connection parameters. Set the following environment variables:
NEO4J_URI
: The URI of your Neo4j database (default: bolt://localhost:7687)NEO4J_USER
: Your Neo4j username (default: neo4j)NEO4J_PASSWORD
: Your Neo4j password
For detailed database setup instructions, see our Graph Database Configuration guide.
Set up logging and environment variables for connecting to the Neo4j database:
Main Function
Create an async main function to run all Graphiti operations:
Initialization
Connect to Neo4j and set up Graphiti indices. This is required before using other Graphiti functionality:
Adding Episodes
Episodes are the primary units of information in Graphiti. They can be text or structured JSON and are automatically processed to extract entities and relationships. For more detailed information on episodes and bulk loading, see the Adding Episodes page:
Basic Search
The simplest way to retrieve relationships (edges) from Graphiti is using the search method, which performs a hybrid search combining semantic similarity and BM25 text retrieval. For more details on search capabilities, see the Searching the Graph page:
Center Node Search
For more contextually relevant results, you can use a center node to rerank search results based on their graph distance to a specific node. This is particularly useful for entity-specific queries as described in the Searching the Graph page:
Node Search Using Search Recipes
Graphiti provides predefined search recipes optimized for different search scenarios. Here we use NODE_HYBRID_SEARCH_RRF for retrieving nodes directly instead of edges. For a complete list of available search recipes and reranking approaches, see the Configurable Search Strategies section in the Searching documentation:
Complete Example
For a complete working example that puts all these concepts together, check out the Graphiti Quickstart Examples on GitHub.
Next Steps
Now that you’ve learned the basics of Graphiti, you can explore more advanced features:
- Custom Entity Types: Learn how to define and use custom entity types to better model your domain-specific knowledge
- Communities: Discover how to work with communities, which are groups of related nodes that share common attributes or relationships
- Advanced Search Techniques: Explore more sophisticated search strategies, including different reranking approaches and configurable search recipes
- Adding Fact Triples: Learn how to directly add fact triples to your graph for more precise knowledge representation
- Agent Integration: Discover how to integrate Graphiti with LLM agents for more powerful AI applications
Make sure to run await statements within an async function.