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: Any other keyword argument is forwarded to LiteLLM and sent with every request, for example reasoning_effort="low". Reasoning models need no extra setting; how temperature and max_tokens are handled for them is below. Reasoning models (OpenAI o-series, gpt-5, gpt-6 and others) need no setting. Many of them reject a temperature other than 1 and take max_completion_tokens instead of max_tokens. When a model rejects one of the two, the SDK sends the request again at once, without the temperature or with max_completion_tokens, and keeps doing so for that LLM’s later requests. LiteLLM rejects these itself, before anything is sent, for every model it knows; an Azure deployment name or a model newer than your LiteLLM costs at most one rejected request per parameter. With reasoning_effort="none", set on the LLM or passed with a call, the temperature is sent, since a gpt-5.x model without reasoning takes one; a temperature rejected at one reasoning_effort is dropped at that effort only. A re-sent request gets its own timeout (a rejection usually comes back at once), so one call can take up to three timeouts. OpenRouterLLM behaves the same way (it takes reasoning_effort per call). A max_tokens passed with a call replaces the LLM’s; max_tokens=None there means no limit.

Embedder

Parameters: Other keyword arguments (such as dimensions) are forwarded to LiteLLM. The vectors must match GraphRAG(embedding_dimension=...), which defaults to 256; a mismatch raises ConfigError before any extraction work.

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

timeout is set by the SDK from the Context latency budget; honour it if your client supports one. completion() generates every answer through ainvoke_messages(), with or without conversation history. 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.

One LLM, Several Jobs

GraphRAG(llm=...) is used for extraction, keyword extraction at query time, text-to-Cypher (when enabled), answer generation, and by default the dedup judge in finalize(). Give the judge a stronger model if your main one is small: finalize(judge=LLMJudge(LiteLLM(model="openai/gpt-4.1"))). On the benchmark corpus a gpt-4.1-class judge made 9 wrong merges where gpt-4o-mini made 51. See Configuration.

Choosing a Provider