BerriAI/litellm · error · ValueError

No results found in the response={response}

Error message

No results found in the response={response}

What it means

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.

Source

Thrown at litellm/llms/hosted_vllm/rerank/transformation.py:185

            raise ValueError(f"Error parsing response: {raw_response.text}, status_code={raw_response.status_code}")

        return self._transform_response(raw_response_json)

    def get_error_class(self, error_message: str, status_code: int, headers: dict | httpx.Headers) -> BaseLLMException:
        return HostedVLLMRerankError(message=error_message, status_code=status_code, headers=headers)

    def _transform_response(self, response: dict) -> RerankResponse:
        # Extract usage information
        usage_data: Final = response.get("usage", {})
        _billed_units: Final = RerankBilledUnits(total_tokens=usage_data.get("total_tokens", 0))
        _tokens: Final = RerankTokens(input_tokens=usage_data.get("total_tokens", 0))
        rerank_meta: Final = RerankResponseMeta(billed_units=_billed_units, tokens=_tokens)

        # Extract results
        _results: Final[list[dict] | None] = response.get("results")

        if _results is None:
            raise ValueError(f"No results found in the response={response}")

        rerank_results: Final[list[RerankResponseResult]] = []

        for result in _results:
            # Validate required fields exist
            if not all(key in result for key in ["index", "relevance_score"]):
                raise ValueError(f"Missing required fields in the result={result}")

            # Get document data if it exists
            document_data = result.get("document", {})
            document = RerankResponseDocument(text=str(document_data.get("text", ""))) if document_data else None

            # Create typed result
            rerank_result = RerankResponseResult(
                index=int(result["index"]),
                relevance_score=float(result["relevance_score"]),
            )

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Inspect the response embedded in the message — it tells you the real server error (e.g. 'model not found', 'not a reranking model').
  2. Confirm the target server actually serves vLLM's /v1/rerank endpoint with a reranker model loaded (check vLLM startup logs / curl the endpoint directly).
  3. Align client and server versions: upgrade vLLM to a version whose rerank response includes top-level 'results'.
  4. If the error body indicates a request problem (bad model id, malformed query), fix that request field.

Example fix

# debug: see the actual response body
# ValueError: No results found in the response={'detail': 'Model xyz is not a reranking model'}

# before: pointed at a chat-only server
litellm.rerank(model='hosted_vllm/llama-3-8b', query=q, documents=docs, api_base=base)

# after: use an actual reranker model served by vLLM
litellm.rerank(model='hosted_vllm/bge-reranker-v2-m3', query=q, documents=docs, api_base=base)
Defensive patterns

Strategy: validation

Validate before calling

null  # response-side; validate deployment instead

import httpx

def check_rerank_results_schema(api_base: str) -> None:
    r = httpx.post(api_base.rstrip("/") + "/rerank",
                   json={"model": "reranker", "query": "q", "documents": ["a", "b"]}, timeout=10)
    r.raise_for_status()
    assert "results" in r.json(), "endpoint does not return vLLM rerank schema"

Type guard

def is_vllm_rerank_payload(body: dict) -> bool:
    """True when the parsed rerank body looks like vLLM's native schema."""
    results = body.get("results")
    return isinstance(results, list) and all(
        isinstance(r, dict) and "index" in r and "relevance_score" in r for r in results
    )

Try / catch

try:
    result = litellm.rerank(...)
except ValueError as e:
    if "No results found in the response" in str(e):
        # body is embedded in the message — surface the real server error to ops
        raise RuntimeError(f"vLLM rerank returned an error body: {e}") from e
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/67d10cbb6e50c3a9. Report an issue: GitHub.