{"record":{"id":"67d10cbb6e50c3a9","repo":"BerriAI/litellm","slug":"no-results-found-in-the-response-response-67d10c","errorCode":null,"errorMessage":"No results found in the response={response}","messagePattern":"No results found in the response=(.+?)","errorType":"http","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/hosted_vllm/rerank/transformation.py","lineNumber":185,"sourceCode":"            raise ValueError(f\"Error parsing response: {raw_response.text}, status_code={raw_response.status_code}\")\n\n        return self._transform_response(raw_response_json)\n\n    def get_error_class(self, error_message: str, status_code: int, headers: dict | httpx.Headers) -> BaseLLMException:\n        return HostedVLLMRerankError(message=error_message, status_code=status_code, headers=headers)\n\n    def _transform_response(self, response: dict) -> RerankResponse:\n        # Extract usage information\n        usage_data: Final = response.get(\"usage\", {})\n        _billed_units: Final = RerankBilledUnits(total_tokens=usage_data.get(\"total_tokens\", 0))\n        _tokens: Final = RerankTokens(input_tokens=usage_data.get(\"total_tokens\", 0))\n        rerank_meta: Final = RerankResponseMeta(billed_units=_billed_units, tokens=_tokens)\n\n        # Extract results\n        _results: Final[list[dict] | None] = response.get(\"results\")\n\n        if _results is None:\n            raise ValueError(f\"No results found in the response={response}\")\n\n        rerank_results: Final[list[RerankResponseResult]] = []\n\n        for result in _results:\n            # Validate required fields exist\n            if not all(key in result for key in [\"index\", \"relevance_score\"]):\n                raise ValueError(f\"Missing required fields in the result={result}\")\n\n            # Get document data if it exists\n            document_data = result.get(\"document\", {})\n            document = RerankResponseDocument(text=str(document_data.get(\"text\", \"\"))) if document_data else None\n\n            # Create typed result\n            rerank_result = RerankResponseResult(\n                index=int(result[\"index\"]),\n                relevance_score=float(result[\"relevance_score\"]),\n            )\n","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/hosted_vllm/rerank/transformation.py#L167-L203","documentation":"Raised in HostedVLLM RerankConfig._transform_response when the parsed rerank response JSON has no top-level 'results' key (response.get('results') is None). The body parsed fine as JSON, but it is not a successful vLLM rerank payload — usually an error object like {'error': ...} or {'detail': ...} with an HTTP 200, or a different schema version.","triggerScenarios":"vLLM returns a JSON error body without a results field (e.g. {'detail':'model not loaded'}, {'error':'invalid request'}) while the HTTP layer still delivers the body to this parser; or pointing api_base at a Cohere/Jina-compatible reranker whose response schema nests data differently, or a vLLM version whose rerank response shape differs.","commonSituations":"vLLM server built without rerank support or with the wrong model loaded; vLLM version mismatch (older server, newer LiteLLM client expectations); pointing at a hosted rerank API with a different response schema; request succeeded HTTP-wise but server-side validation failed softly.","solutions":["Inspect the response embedded in the message — it tells you the real server error (e.g. 'model not found', 'not a reranking model').","Confirm the target server actually serves vLLM's /v1/rerank endpoint with a reranker model loaded (check vLLM startup logs / curl the endpoint directly).","Align client and server versions: upgrade vLLM to a version whose rerank response includes top-level 'results'.","If the error body indicates a request problem (bad model id, malformed query), fix that request field."],"exampleFix":"# debug: see the actual response body\n# ValueError: No results found in the response={'detail': 'Model xyz is not a reranking model'}\n\n# before: pointed at a chat-only server\nlitellm.rerank(model='hosted_vllm/llama-3-8b', query=q, documents=docs, api_base=base)\n\n# after: use an actual reranker model served by vLLM\nlitellm.rerank(model='hosted_vllm/bge-reranker-v2-m3', query=q, documents=docs, api_base=base)\n","handlingStrategy":"validation","validationCode":"null  # response-side; validate deployment instead\n\nimport httpx\n\ndef check_rerank_results_schema(api_base: str) -> None:\n    r = httpx.post(api_base.rstrip(\"/\") + \"/rerank\",\n                   json={\"model\": \"reranker\", \"query\": \"q\", \"documents\": [\"a\", \"b\"]}, timeout=10)\n    r.raise_for_status()\n    assert \"results\" in r.json(), \"endpoint does not return vLLM rerank schema\"","typeGuard":"def is_vllm_rerank_payload(body: dict) -> bool:\n    \"\"\"True when the parsed rerank body looks like vLLM's native schema.\"\"\"\n    results = body.get(\"results\")\n    return isinstance(results, list) and all(\n        isinstance(r, dict) and \"index\" in r and \"relevance_score\" in r for r in results\n    )","tryCatchPattern":"try:\n    result = litellm.rerank(...)\nexcept ValueError as e:\n    if \"No results found in the response\" in str(e):\n        # body is embedded in the message — surface the real server error to ops\n        raise RuntimeError(f\"vLLM rerank returned an error body: {e}\") from e\n    raise","preventionTips":["Run a startup smoke test of the /rerank endpoint against the deployed server to pin the schema early.","Load a real reranker model (not a chat model) on the vLLM instance used for rerank."],"tags":["hosted-vllm","rerank","response-schema","validation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}