Bug Report
Describe the bug
When using GraphRAG with non-OpenAI LLM providers routed through LiteLLM (e.g. Gemini via OpenRouter), the extract_graph workflow fails with a pydantic validation error:
Error: 1 validation error for LLMCompletionResponse
service_tier
Input should be 'auto', 'default', 'flex', 'scale' or 'priority'
For further information visit https://errors.pydantic.dev/2.13/v/literal_error
Root cause
LLMCompletionResponse in graphrag_llm/types/types.py extends openai.types.chat.ChatCompletion, which defines:
service_tier: Optional[Literal["auto", "default", "flex", "scale", "priority"]] = None
In graphrag_llm/completion/lite_llm_completion.py, the LiteLLM ModelResponse is converted via:
return LLMCompletionResponse(**response.model_dump())
When the upstream provider returns a service_tier value outside the OpenAI literal (e.g. Gemini via OpenRouter returns a non-standard string), pydantic rejects it during model construction.
Steps to reproduce
- Configure GraphRAG to use a non-OpenAI model via LiteLLM (e.g.
gemini/gemini-2.5-flash-preview through OpenRouter)
- Run indexing on any document
- The
create_base_text_units workflow succeeds, but extract_graph fails with the validation error above
Expected behavior
service_tier is an OpenAI-specific field that GraphRAG does not use. Non-standard values should not cause indexing to fail.
Suggested fix
Either:
- Widen the type — override
service_tier in LLMCompletionResponse to accept str | None instead of the strict literal
- Strip the field — pop
service_tier from response.model_dump() before constructing LLMCompletionResponse in lite_llm_completion.py
- Use
model_validate with strict=False or configure the model to ignore extra/non-conforming fields
Option 2 is the most minimal:
# In _base_completion and _base_completion_async:
if isinstance(response, ModelResponse):
dump = response.model_dump()
dump.pop("service_tier", None)
return LLMCompletionResponse(**dump)
Environment
- graphrag >= 2.0
- graphrag-llm (latest as of May 2026)
- LiteLLM routing to Gemini via OpenRouter
- Python 3.12
- pydantic 2.13
Workaround
Monkey-patch LLMCompletionResponse at application startup:
from graphrag_llm.types import LLMCompletionResponse
LLMCompletionResponse.model_fields["service_tier"].annotation = str | None
LLMCompletionResponse.model_rebuild()
Bug Report
Describe the bug
When using GraphRAG with non-OpenAI LLM providers routed through LiteLLM (e.g. Gemini via OpenRouter), the
extract_graphworkflow fails with a pydantic validation error:Root cause
LLMCompletionResponseingraphrag_llm/types/types.pyextendsopenai.types.chat.ChatCompletion, which defines:In
graphrag_llm/completion/lite_llm_completion.py, the LiteLLMModelResponseis converted via:When the upstream provider returns a
service_tiervalue outside the OpenAI literal (e.g. Gemini via OpenRouter returns a non-standard string), pydantic rejects it during model construction.Steps to reproduce
gemini/gemini-2.5-flash-previewthrough OpenRouter)create_base_text_unitsworkflow succeeds, butextract_graphfails with the validation error aboveExpected behavior
service_tieris an OpenAI-specific field that GraphRAG does not use. Non-standard values should not cause indexing to fail.Suggested fix
Either:
service_tierinLLMCompletionResponseto acceptstr | Noneinstead of the strict literalservice_tierfromresponse.model_dump()before constructingLLMCompletionResponseinlite_llm_completion.pymodel_validatewith strict=False or configure the model to ignore extra/non-conforming fieldsOption 2 is the most minimal:
Environment
Workaround
Monkey-patch
LLMCompletionResponseat application startup: