{"record":{"id":"2d2050cea31c8645","repo":"BerriAI/litellm","slug":"cohere-documents-param-is-required-for-huggingfa","errorCode":null,"errorMessage":"Cohere 'documents' param is required for HuggingFace rerank","messagePattern":"Cohere 'documents' param is required for HuggingFace rerank","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/huggingface/rerank/transformation.py","lineNumber":154,"sourceCode":"        if api_key:\n            default_headers[\"Authorization\"] = f\"Bearer {api_key}\"\n\n        if \"Authorization\" in headers:\n            default_headers[\"Authorization\"] = headers[\"Authorization\"]\n\n        return {**default_headers, **headers}\n\n    def transform_rerank_request(\n        self,\n        model: str,\n        optional_rerank_params: OptionalRerankParams | dict,\n        headers: dict,\n        litellm_params: dict | None = None,\n    ) -> dict:\n        if \"query\" not in optional_rerank_params:\n            raise ValueError(\"query is required for HuggingFace rerank\")\n        if \"texts\" not in optional_rerank_params:\n            raise ValueError(\"Cohere 'documents' param is required for HuggingFace rerank\")\n        # Ensure return_text is a boolean value\n        # HuggingFace API expects return_text parameter, corresponding to our return_documents parameter\n        request_body: Final = {\n            \"raw_scores\": False,\n            \"truncate\": False,\n            \"truncation_direction\": \"Right\",\n        }\n\n        request_body.update(optional_rerank_params)\n\n        return request_body\n\n    def transform_rerank_response(\n        self,\n        model: str,\n        raw_response: httpx.Response,\n        model_response: RerankResponse,\n        logging_obj: LoggingClass,","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/huggingface/rerank/transformation.py#L136-L172","documentation":"Error \"Cohere 'documents' param is required for HuggingFace rerank\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/huggingface/rerank/transformation.py:154 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass documents (the Cohere-style documents param) to litellm.rerank() for HuggingFace rerank."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}