BerriAI/litellm · error · ValueError
Cohere 'documents' param is required for HuggingFace rerank
Error message
Cohere 'documents' param is required for HuggingFace rerank
What it means
Error "Cohere 'documents' param is required for HuggingFace rerank" thrown in BerriAI/litellm.
Solutions
- Pass documents (the Cohere-style documents param) to litellm.rerank() for HuggingFace rerank.
When it happens
Trigger: Thrown at litellm/llms/huggingface/rerank/transformation.py:154 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/2d2050cea31c8645.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/huggingface/rerank/transformation.py:154
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,
model_response: RerankResponse,
logging_obj: LoggingClass,View on GitHub (pinned to 77b7c6c40c)