BerriAI/litellm · error · CohereError
{response_text}
Error message
{response_text} What it means
Response-parsing failure in Cohere rerank: raw_response.json() raised (non-JSON body), so the raw response text is re-raised as the CohereError message — typically an HTML/XML error page or truncated body from the rerank endpoint.
Source
Thrown at litellm/llms/cohere/rerank/transformation.py:147
self,
model: str,
raw_response: httpx.Response,
model_response: RerankResponse,
logging_obj: LiteLLMLoggingObj,
api_key: str | None = None,
request_data: dict = {},
optional_params: dict = {},
litellm_params: dict = {},
) -> RerankResponse:
"""
Transform Cohere rerank response
No transformation required, litellm follows cohere API response format
"""
try:
raw_response_json: Final = raw_response.json()
except Exception:
raise CohereError(message=raw_response.text, status_code=raw_response.status_code)
return RerankResponse(**raw_response_json)
def get_error_class(self, error_message: str, status_code: int, headers: dict | httpx.Headers) -> BaseLLMException:
return CohereError(message=error_message, status_code=status_code)
View on GitHub (pinned to 77b7c6c40c)
Solutions
- Read the response text in the error; the Cohere rerank API rejected the request (commonly auth, model name, or payload shape).
- Verify COHERE_API_KEY is valid and the model (e.g. rerank-v3.5) is available on your plan.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at litellm/llms/cohere/rerank/transformation.py:147 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/4c4231ba0407b27c.
Report an issue: GitHub.