BerriAI/litellm · error · ValueError

No results found in the response={raw_response_json}

Error message

No results found in the response={raw_response_json}

What it means

While transforming a Fireworks rerank response, litellm looks for ranked items under the 'data' key (Fireworks' native shape) and falls back to 'results'. If neither key exists (or both are null), it raises ValueError with the full raw response JSON so the caller can see what Fireworks actually returned.

Source

Thrown at litellm/llms/fireworks_ai/rerank/transformation.py:217

        #     "prompt_tokens": 50,
        #     "completion_tokens": 50
        #   }
        # }

        # Extract usage information
        usage: Final = raw_response_json.get("usage", {})
        _billed_units: Final = RerankBilledUnits(search_units=usage.get("total_tokens", 0))
        _tokens: Final = RerankTokens(
            input_tokens=usage.get("prompt_tokens", 0),
            output_tokens=usage.get("completion_tokens", 0),
        )
        rerank_meta: Final = RerankResponseMeta(billed_units=_billed_units, tokens=_tokens)

        # Extract results - Fireworks AI uses "data" instead of "results"
        _results: Final[list[dict] | None] = raw_response_json.get("data") or raw_response_json.get("results")

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

        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 - Fireworks AI returns document as a string directly
            document_text = result.get("document")
            document = None
            if document_text:
                # Handle both string and object formats
                if isinstance(document_text, str):
                    document = RerankResponseDocument(text=document_text)
                elif isinstance(document_text, dict):
                    # Handle object format if it exists
                    text = document_text.get("text", "")

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Inspect the raw JSON embedded in the message to see what Fireworks returned (often an auth/quota error surfaced with HTTP 200).
  2. Retry once — a truncated or incident-degraded response is frequently transient.
  3. If the schema genuinely changed, pin/upgrade the litellm version that tracks the current Fireworks rerank response format and update test fixtures to include a 'data' array.

Example fix

# before (test fixture lacking results)
mock_response = {"id": "resp_1", "model": "qwen3-reranker-8b"}

# after
mock_response = {
    "id": "resp_1",
    "model": "qwen3-reranker-8b",
    "data": [{"index": 0, "relevance_score": 0.93}],
    "usage": {"total_tokens": 10},
}
Defensive patterns

Strategy: try-catch

Type guard

def has_rerank_payload(raw: dict) -> bool:
    results = raw.get("data") or raw.get("results")
    return isinstance(results, list)

Try / catch

try:
    result = litellm.rerank(model="fireworks_ai/...", query=q, documents=docs)
except ValueError as e:
    if "No results found in the response" in str(e):
        logging.error("Fireworks rerank returned unparseable body: %s", e)
        return fallback_no_rerank(docs)  # e.g. original ordering
    raise

Prevention

When it happens

Trigger: Fireworks returns an error-shaped JSON (e.g. an error field with 200 status), an empty body, or changes/removes the data/results field; also triggered by mocked tests that return a response without 'data'/'results'.

Common situations: A provider-side API change or incident where the rerank endpoint's response schema drifts; a proxy in front of Fireworks that rewrites the body; unit tests with hand-crafted fixture JSON that omits the results array.

Related errors


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