Skip to main content
GraphRAG SDK uses two provider types: LLM (for text generation and extraction) and Embedder (for vector embeddings). Both are abstract base classes with built-in implementations for LiteLLM and OpenRouter.

Provider Overview

LiteLLM provides a unified interface to 100+ LLM providers. It is the recommended default.

LLM

Parameters:

Embedder

Parameters:

OpenRouter

OpenRouter aggregates models from multiple providers behind a single API.

LLM

Embedder

LLMInterface ABC

To integrate a provider not covered by LiteLLM or OpenRouter, subclass LLMInterface.

Required Method

Optional Overrides

ainvoke_messages() is called by completion() when conversation history is provided. Override it to pass messages natively to your LLM’s chat API for proper multi-turn handling:

Constructor Parameters

Embedder ABC

Required Methods

The model_name property is used by the graph config node to validate that the same embedding model is used for ingestion and retrieval.

Optional Overrides

Batch Embedding

The embed_documents() and aembed_documents() methods are critical for performance. The ingestion pipeline calls them with hundreds or thousands of texts. If your provider supports batch embedding, always override these methods:

Environment Variables

For convenience, you can configure providers via environment variables instead of passing parameters directly. LiteLLM respects standard environment variables: See the LiteLLM documentation for the full list of supported providers and their environment variables.

Choosing a Provider