BerriAI/litellm · error · DashScopeError

No results in DashScope rerank response

Error message

No results in DashScope rerank response: {response_json}

What it means

The rerank response parsed as JSON and carried no error 'code', but the 'results' key was absent/None, so the transformer refuses to build a RerankResponse and raises DashScopeError embedding the entire response body in the message. It means DashScope returned HTTP 200 with an unexpected or empty schema rather than an explicit error.

Solutions

  1. Log the full response JSON (it is embedded in the message) and diff it against DashScope's documented rerank response shape
  2. Confirm the model genuinely supports the rerank API (gte-rerank, qwen3-rerank families)
  3. Ensure DASHSCOPE_API_BASE is not pointing at a compatibility endpoint with a different response schema
  4. Upgrade LiteLLM — response transformers get updated as schemas change; if the body is valid per DashScope docs, file an issue with the logged payload
Defensive patterns

Strategy: fallback

Validate before calling

RERANK_ALLOWED_MODELS = {'gte-rerank', 'gte-rerank-v2', 'qwen3-rerank-0.6b'}

def model_allows_rerank(model: str) -> bool:
    return model.split('/', 1)[-1].split(':')[0] in RERANK_ALLOWED_MODELS

Try / catch

try:
    results = litellm.rerank(model='dashscope/gte-rerank', query=q, documents=docs)
except Exception as e:
    if 'No results in DashScope rerank response' in str(e):
        log_schema_drift(e)
        results = fallback_rerank(q, docs)  # e.g. cohere/jina via same litellm.rerank
    else:
        raise

Prevention

When it happens

Trigger: A non-rerank model answering /reranks with a different body shape; DashScope changing/wrapping the results field (e.g. nesting under 'output'); zero documents surviving upstream filtering; api_base routing to a compatibility endpoint whose JSON differs from the native rerank schema.

Common situations: Model naming mismatch (chat/embedding model used on the rerank route); a gateway returning valid-but-different JSON; DashScope schema drift not yet handled by the installed LiteLLM version.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/142c3546e5be77bb. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/dashscope/rerank/transformation.py:194

            )

        logging_obj.post_call(
            input=request_data.get("query"),
            api_key=api_key,
            additional_args={"complete_input_dict": request_data},
            original_response=response_json,
        )

        # DashScope error envelope: {"code": "...", "message": "...", "request_id": "..."}
        if "code" in response_json and "results" not in response_json:
            raise DashScopeError(
                status_code=raw_response.status_code,
                message=response_json.get("message", str(response_json)),
            )

        results: Final = response_json.get("results")
        if results is None:
            raise DashScopeError(
                status_code=raw_response.status_code,
                message=f"No results in DashScope rerank response: {response_json}",
            )

        # qwen3-rerank returns:
        #   {"index": int, "relevance_score": float}
        # plus, when return_documents=true was sent:
        #   "document": {"text": "..."}
        # which already matches LiteLLM's RerankResponseDocument shape.
        transformed_results: Final[list[dict]] = []
        for r in results:
            item: dict[str, Any] = {
                "index": r["index"],
                "relevance_score": r["relevance_score"],
            }
            doc = r.get("document")
            if isinstance(doc, dict):
                item["document"] = doc

View on GitHub (pinned to 77b7c6c40c)