{"record":{"id":"fa10cfb0dd3f0aab","repo":"BerriAI/litellm","slug":"documents-is-required-for-cohere-rerank","errorCode":null,"errorMessage":"documents is required for Cohere rerank","messagePattern":"documents is required for Cohere rerank","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/cohere/rerank/transformation.py","lineNumber":116,"sourceCode":"\n        # If 'Authorization' is provided in headers, it overrides the default.\n        if \"Authorization\" in headers:\n            default_headers[\"Authorization\"] = headers[\"Authorization\"]\n\n        # Merge other headers, overriding any default ones except Authorization\n        return {**default_headers, **headers}\n\n    def transform_rerank_request(\n        self,\n        model: str,\n        optional_rerank_params: 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 Cohere rerank\")\n        if \"documents\" not in optional_rerank_params:\n            raise ValueError(\"documents is required for Cohere rerank\")\n        rerank_request: Final = RerankRequest(\n            model=model,\n            query=optional_rerank_params[\"query\"],\n            documents=optional_rerank_params[\"documents\"],\n            top_n=optional_rerank_params.get(\"top_n\", None),\n            rank_fields=optional_rerank_params.get(\"rank_fields\", None),\n            return_documents=optional_rerank_params.get(\"return_documents\", None),\n            max_chunks_per_doc=optional_rerank_params.get(\"max_chunks_per_doc\", None),\n        )\n        return rerank_request.model_dump(exclude_none=True)\n\n    def transform_rerank_response(\n        self,\n        model: str,\n        raw_response: httpx.Response,\n        model_response: RerankResponse,\n        logging_obj: LiteLLMLoggingObj,\n        api_key: str | None = None,","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/cohere/rerank/transformation.py#L98-L134","documentation":"Error \"documents is required for Cohere rerank\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/cohere/rerank/transformation.py:116 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass documents for the Cohere rerank request."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}