BerriAI/litellm · error · ValueError
query is required for HuggingFace rerank
Error message
query is required for HuggingFace rerank
What it means
Error "query is required for HuggingFace rerank" thrown in BerriAI/litellm.
Solutions
- Pass a non-empty query to litellm.rerank() for HuggingFace rerank.
When it happens
Trigger: Thrown at litellm/llms/huggingface/rerank/transformation.py:152 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/37e877cd6fe61e69.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/huggingface/rerank/transformation.py:152
}
if api_key:
default_headers["Authorization"] = f"Bearer {api_key}"
if "Authorization" in headers:
default_headers["Authorization"] = headers["Authorization"]
return {**default_headers, **headers}
def transform_rerank_request(
self,
model: str,
optional_rerank_params: OptionalRerankParams | dict,
headers: dict,
litellm_params: dict | None = None,
) -> dict:
if "query" not in optional_rerank_params:
raise ValueError("query is required for HuggingFace rerank")
if "texts" not in optional_rerank_params:
raise ValueError("Cohere 'documents' param is required for HuggingFace rerank")
# Ensure return_text is a boolean value
# HuggingFace API expects return_text parameter, corresponding to our return_documents parameter
request_body: Final = {
"raw_scores": False,
"truncate": False,
"truncation_direction": "Right",
}
request_body.update(optional_rerank_params)
return request_body
def transform_rerank_response(
self,
model: str,
raw_response: httpx.Response,View on GitHub (pinned to 77b7c6c40c)