BerriAI/litellm · error · ValueError
query is required for Nvidia NIM rerank
Error message
query is required for Nvidia NIM rerank
What it means
Error "query is required for Nvidia NIM rerank" thrown in BerriAI/litellm.
Solutions
- Provide the query argument to the Nvidia NIM rerank call.
When it happens
Trigger: Thrown at litellm/llms/nvidia_nim/rerank/transformation.py:198 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/1ac212e47ca5868b.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/nvidia_nim/rerank/transformation.py:198
model: str,
optional_rerank_params: dict,
headers: dict,
litellm_params: dict | None = None,
) -> dict:
"""
Transform request to Nvidia NIM format.
Nvidia NIM expects:
- query as {text: "..."}
- documents as passages: [{text: "..."}, ...]
- Optional: truncate (NONE or END), top_k
Note: optional_rerank_params may contain provider-specific params like 'top_k' and 'truncate'
that aren't in the OptionalRerankParams TypedDict but are passed through at runtime.
The mapping from Cohere's 'top_n' to Nvidia's 'top_k' already happened in map_cohere_rerank_params.
"""
if "query" not in optional_rerank_params:
raise ValueError("query is required for Nvidia NIM rerank")
if "documents" not in optional_rerank_params:
raise ValueError("documents is required for Nvidia NIM rerank")
query: Final = optional_rerank_params["query"]
documents: Final = optional_rerank_params["documents"]
# Transform query to object format
query_obj: Final[NvidiaNimQueryObject] = {"text": query}
# Transform documents to passages format
passages: Final[list[NvidiaNimPassageObject]] = []
for doc in documents:
if isinstance(doc, str):
passages.append({"text": doc})
elif isinstance(doc, dict):
# Preserve only the structured passage fields supported by the
# selected rerank route.
supported_fields: NvidiaNimPassageObject = {} # mutable-ok: assembling a request TypedDictView on GitHub (pinned to 77b7c6c40c)