LLM Configuration
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, particularly when using smaller models.
Graphiti defaults to using OpenAI for LLM inference and embeddings, but supports multiple LLM providers including Azure OpenAI, Google Gemini, Anthropic, Groq, and local models via Ollama. This guide covers configuring Graphiti with alternative LLM providers.
Azure OpenAI
Azure OpenAI deployments often require different endpoints for LLM and embedding services, and separate deployments for default and small models.
Installation
Configuration
Make sure to replace the placeholder values with your actual Azure OpenAI credentials and deployment names.
Environment Variables
Azure OpenAI can also be configured using environment variables:
AZURE_OPENAI_ENDPOINT
- Azure OpenAI LLM endpoint URLAZURE_OPENAI_DEPLOYMENT_NAME
- Azure OpenAI LLM deployment nameAZURE_OPENAI_API_VERSION
- Azure OpenAI API versionAZURE_OPENAI_EMBEDDING_API_KEY
- Azure OpenAI Embedding deployment key (if different fromOPENAI_API_KEY
)AZURE_OPENAI_EMBEDDING_ENDPOINT
- Azure OpenAI Embedding endpoint URLAZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME
- Azure OpenAI embedding deployment nameAZURE_OPENAI_EMBEDDING_API_VERSION
- Azure OpenAI embedding API versionAZURE_OPENAI_USE_MANAGED_IDENTITY
- Use Azure Managed Identities for authentication
Google Gemini
Google’s Gemini models provide excellent structured output support and can be used for LLM inference, embeddings, and cross-encoding/reranking.
Installation
Configuration
The Gemini reranker uses the gemini-2.0-flash-exp
model by default, which is optimized for cost-effective and low-latency classification tasks.
Environment Variables
Google Gemini can be configured using:
GOOGLE_API_KEY
- Your Google API key
Anthropic
Anthropic’s Claude models can be used for LLM inference with OpenAI embeddings and reranking.
When using Anthropic for LLM inference, you still need an OpenAI API key for embeddings and reranking functionality. Make sure to set both ANTHROPIC_API_KEY
and OPENAI_API_KEY
environment variables.
Installation
Configuration
Environment Variables
Anthropic can be configured using:
ANTHROPIC_API_KEY
- Your Anthropic API keyOPENAI_API_KEY
- Required for embeddings and reranking
Groq
Groq provides fast inference with various open-source models, using OpenAI for embeddings and reranking.
When using Groq, avoid smaller models as they may not accurately extract data or output the correct JSON structures required by Graphiti. Use larger, more capable models like Llama 3.1 70B for best results.
Installation
Configuration
Environment Variables
Groq can be configured using:
GROQ_API_KEY
- Your Groq API keyOPENAI_API_KEY
- Required for embeddings
Ollama (Local LLMs)
Ollama enables running local LLMs and embedding models via its OpenAI-compatible API, ideal for privacy-focused applications or avoiding API costs.
When using Ollama, avoid smaller local models as they may not accurately extract data or output the correct JSON structures required by Graphiti. Use larger, more capable models and ensure they support structured output for reliable knowledge graph construction.
Installation
First, install and configure Ollama:
Configuration
Ensure Ollama is running (ollama serve
) and that you have pulled the models you want to use.
OpenAI Compatible Services
Many LLM providers offer OpenAI-compatible APIs. Use the OpenAIGenericClient
for these services, which ensures proper schema injection for JSON output since most providers don’t support OpenAI’s structured output format.
When using OpenAI-compatible services, avoid smaller models as they may not accurately extract data or output the correct JSON structures required by Graphiti. Choose larger, more capable models that can handle complex reasoning and structured output.
Installation
Configuration
Replace the placeholder values with your actual service credentials and model names.