Installation

How to install Graphiti

Requirements:

  • Python 3.10 or higher
  • Neo4j 5.21 or higher
  • OpenAI API key (Graphiti defaults to OpenAI for LLM inference and embedding)

Optional:

  • Gemini, Anthropic, or Groq API key (for alternative LLM providers)

The simplest way to install Neo4j is via Neo4j Desktop. It provides a user-friendly interface to manage Neo4j instances and databases.

pip install graphiti-core

or

poetry add graphiti-core

Alternative LLM Providers

Graphiti supports multiple LLM providers beyond OpenAI. However, Graphiti works best with LLM services that support Structured Output (such as OpenAI and Gemini). Using other services may result in incorrect output schemas and ingestion failures. This is particularly problematic when using smaller models.

To install Graphiti with support for alternative providers, use the following package extras with Poetry:

Note that even when using Anthropic for LLM inference, OpenAI is still required for embedding functionality. Make sure to set both OPENAI_API_KEY and ANTHROPIC_API_KEY environment variables when using Anthropic.

# For Anthropic support
poetry add "graphiti-core[anthropic]"
# For Google Generative AI support
poetry add "graphiti-core[google-genai]"
# For Groq support
poetry add "graphiti-core[groq]"
# For multiple providers
poetry add "graphiti-core[anthropic,groq,google-genai]"

These extras automatically install the required dependencies for each provider.

OpenAI Compatible LLM Providers

Please use the OpenAIGenericClient to connect to OpenAI compatible LLM providers. Graphiti makes use of OpenAI Structured Output, which is not supported by other providers.

The OpenAIGenericClient ensures that required schema is injected into the prompt, so that the LLM can generate valid JSON output.

Graphiti works best with LLM services that support Structured Output (such as OpenAI and Gemini). Using other services may result in incorrect output schemas and ingestion failures. This is particularly problematic when using smaller models.

Using Graphiti with Azure OpenAI

Graphiti supports Azure OpenAI for both LLM inference and embeddings. To use Azure OpenAI, you’ll need to configure both the LLM client and embedder with your Azure OpenAI credentials:

1from openai import AsyncAzureOpenAI
2from graphiti_core import Graphiti
3from graphiti_core.llm_client import OpenAIClient
4from graphiti_core.embedder.openai import OpenAIEmbedder, OpenAIEmbedderConfig
5from graphiti_core.cross_encoder.openai_reranker_client import OpenAIRerankerClient
6
7# Azure OpenAI configuration
8api_key = "<your-api-key>"
9api_version = "<your-api-version>"
10azure_endpoint = "<your-azure-endpoint>"
11
12# Create Azure OpenAI client for LLM
13azure_openai_client = AsyncAzureOpenAI(
14 api_key=api_key,
15 api_version=api_version,
16 azure_endpoint=azure_endpoint
17)
18
19# Initialize Graphiti with Azure OpenAI clients
20graphiti = Graphiti(
21 "bolt://localhost:7687",
22 "neo4j",
23 "password",
24 llm_client=OpenAIClient(
25 client=azure_openai_client
26 ),
27 embedder=OpenAIEmbedder(
28 config=OpenAIEmbedderConfig(
29 embedding_model="text-embedding-3-small" # Use your Azure deployed embedding model name
30 ),
31 client=azure_openai_client
32 ),
33 # Optional: Configure the OpenAI cross encoder with Azure OpenAI
34 cross_encoder=OpenAIRerankerClient(
35 client=azure_openai_client
36 )
37)
38
39# Now you can use Graphiti with Azure OpenAI

Make sure to replace the placeholder values with your actual Azure OpenAI credentials and specify the correct embedding model name that’s deployed in your Azure OpenAI service.

Using Graphiti with Google Gemini

To use Graphiti with Google Gemini, install the required package:

poetry add "graphiti-core[google-genai]"

When using Google Gemini, you’ll need to set the GOOGLE_API_KEY environment variable with your Google API key.

Here’s how to configure Graphiti with Google Gemini:

1import os
2from graphiti_core import Graphiti
3from graphiti_core.llm_client.gemini_client import GeminiClient, LLMConfig
4from graphiti_core.embedder.gemini import GeminiEmbedder, GeminiEmbedderConfig
5
6# Google API key configuration
7api_key = os.environ.get("GOOGLE_API_KEY")
8if not api_key:
9 raise ValueError("GOOGLE_API_KEY environment variable must be set")
10
11# Initialize Graphiti with Gemini clients
12graphiti = Graphiti(
13 "bolt://localhost:7687",
14 "neo4j",
15 "password",
16 llm_client=GeminiClient(
17 config=LLMConfig(
18 api_key=api_key,
19 model="gemini-2.0-flash"
20 )
21 ),
22 embedder=GeminiEmbedder(
23 config=GeminiEmbedderConfig(
24 api_key=api_key,
25 embedding_model="embedding-001"
26 )
27 )
28)

Optional Environment Variables

In addition to the provider-specific API keys, Graphiti supports several optional environment variables:

  • USE_PARALLEL_RUNTIME: A boolean variable that can be set to true to enable Neo4j’s parallel runtime feature for several search queries. Note that this feature is not supported for Neo4j Community Edition or for smaller AuraDB instances, so it’s off by default.