{"record":{"id":"b0156d4f5f7ade3d","repo":"BerriAI/litellm","slug":"raw-response-text-b0156d","errorCode":null,"errorMessage":"{raw_response.text}","messagePattern":"\\{raw_response\\.text\\}","errorType":"http","errorClass":"InfinityError","httpStatus":null,"severity":"error","filePath":"litellm/llms/infinity/rerank/transformation.py","lineNumber":85,"sourceCode":"        self,\n        model: str,\n        raw_response: httpx.Response,\n        model_response: RerankResponse,\n        logging_obj: LiteLLMLoggingObj,\n        api_key: str | None = None,\n        request_data: dict = {},\n        optional_params: dict = {},\n        litellm_params: dict = {},\n    ) -> RerankResponse:\n        \"\"\"\n        Transform Infinity rerank response\n\n        No transformation required, Infinity follows Cohere API response format\n        \"\"\"\n        try:\n            raw_response_json: Final = raw_response.json()\n        except Exception:\n            raise InfinityError(message=raw_response.text, status_code=raw_response.status_code)\n\n        _billed_units: Final = RerankBilledUnits(**raw_response_json.get(\"usage\", {}))\n        _tokens: Final = RerankTokens(\n            input_tokens=raw_response_json.get(\"usage\", {}).get(\"prompt_tokens\", 0),\n            output_tokens=(\n                raw_response_json.get(\"usage\", {}).get(\"total_tokens\", 0)\n                - raw_response_json.get(\"usage\", {}).get(\"prompt_tokens\", 0)\n            ),\n        )\n        rerank_meta: Final = RerankResponseMeta(billed_units=_billed_units, tokens=_tokens)\n\n        cohere_results: Final[list[RerankResponseResult]] = []\n        if raw_response_json.get(\"results\"):\n            for result in raw_response_json.get(\"results\"):\n                _rerank_response = RerankResponseResult(\n                    index=result.get(\"index\"),\n                    relevance_score=result.get(\"relevance_score\"),\n                )","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/infinity/rerank/transformation.py#L67-L103","documentation":"Raised when the Infinity rerank response body fails JSON parsing. The raw text and status are forwarded as InfinityError, indicating the request reached something that does not return JSON — wrong route, down service, or an intermediary error page.","triggerScenarios":"api_base for rerank points at a server/route that replies with HTML or empty body; Infinity version that does not implement /rerank returns a plain-text 404; service restarted mid-request.","commonSituations":"Older Infinity versions without a rerank endpoint; nginx default pages; wrong path prefix in a containerized deployment.","solutions":["Read the forwarded body text to identify what answered.","Confirm the Infinity version supports /rerank: curl -X POST http://<base>/rerank.","Fix or pin the deployment so the rerank route exists at api_base."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"def rerank_route_exists(base: str, api_key: str | None = None) -> bool:\n    import httpx\n    r = httpx.post(f'{base.rstrip(\"/\")}/rerank', json={'query': 'x', 'texts': ['y']},\n                   headers={'Authorization': f'Bearer {api_key}'} if api_key else {},\n                   timeout=5)\n    return r.status_code != 404 and 'json' in r.headers.get('content-type', '')","typeGuard":null,"tryCatchPattern":"try:\n    out = litellm.rerank(model='infinity/r', query=q, documents=docs, api_base=base)\nexcept Exception as e:\n    if type(e).__name__ == 'InfinityError' and '404' not in str(e):\n        raise\n    raise RuntimeError(f'Infinity at {base} lacks /rerank or returned non-JSON') from e","preventionTips":["Pin an Infinity version that implements /rerank","Add an integration test hitting /rerank in CI for self-hosted services"],"tags":["infinity","rerank","response-format","self-hosted","json"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}