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
Graphiti supports Azure OpenAI through the Azure OpenAI v1 API compatibility layer. Use your Azure deployment names as the model names.
Installation
Configuration
The maintained Azure OpenAI example reads AZURE_OPENAI_ENDPOINT,
AZURE_OPENAI_API_KEY, AZURE_OPENAI_DEPLOYMENT, and
AZURE_OPENAI_EMBEDDING_DEPLOYMENT. Load these variables in your application,
and pass their values to the clients as shown above.
This example uses one Azure OpenAI resource. If the chat and embedding
deployments use different resources, create a separate AsyncOpenAI client for
each resource. Pass the chat client to AzureOpenAILLMClient and
OpenAIRerankerClient. Pass the embedding client to
AzureOpenAIEmbedderClient.
Google Gemini
Google’s Gemini models support structured output and can be used for LLM inference, embeddings, and cross-encoding/reranking.
Installation
Configuration
This example uses gemini-3.7-flash for generation and reranking.
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.
Ollama provides an OpenAI-compatible API, but does not support the /v1/responses endpoint that OpenAIClient uses. Use OpenAIGenericClient instead, which uses the /v1/chat/completions endpoint with response_format for structured outputs—both of which Ollama supports.
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.