BerriAI/litellm · error · DashScopeError
response_json.get("message", str(response_json)) (upstream D
Error message
response_json.get("message", str(response_json)) (upstream DashScope error message) What it means
Raised when the DashScope rerank response carries the DashScope error envelope ({"code": ..., "message": ..., "request_id": ...}) without a 'results' field. The exception message is the upstream 'message' value (or the whole body if absent) and the status code comes from the HTTP response.
Source
Thrown at litellm/llms/dashscope/rerank/transformation.py:187
litellm_params = litellm_params or {}
try:
response_json: Final = raw_response.json()
except Exception:
raise DashScopeError(
status_code=raw_response.status_code,
message=raw_response.text,
)
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:View on GitHub (pinned to 6c2dcb801b)
Solutions
- Match the upstream 'code' field in the response body to DashScope's error-code docs to pinpoint the cause
- For throttling errors, add retry with exponential backoff and respect QPS limits
- For auth errors, refresh DASHSCOPE_API_KEY
- For parameter errors, validate model name and documents/query sizes before calling
- Include the request_id from the body when opening a support case with Alibaba Cloud
Defensive patterns
Strategy: retry
Try / catch
try:
resp = litellm.rerank(model=m, query=q, documents=docs)
except Exception as e:
msg = str(e)
if "Throttling" in msg or "RateLimit" in msg:
resp = backoff_retry(lambda: litellm.rerank(model=m, query=q, documents=docs))
elif "ApiKey" in msg or "Unauthorized" in msg:
raise ConfigError("DASHSCOPE_API_KEY invalid") from e
else:
raise Prevention
- Map DashScope 'code' values (Throttling/InvalidApiKey/InvalidParameter) to distinct handling branches
- Respect QPS limits with a client-side rate limiter for rerank traffic
- Keep the response request_id in logs to correlate with Alibaba Cloud support
When it happens
Trigger: DashScope rerank API call rejected server-side: invalid model (code InvalidParameter.ModelNotFound), expired API key (InvalidApiKey), throttling (Throttling), or input exceeding limits — any case where the response contains 'code' but no 'results'.
Common situations: Model name typo for qwen3-rerank/gte-rerank variants; API key rotated but old one cached in env; QPS/quota throttling under bursty RAG traffic; documents payload too large.
Related errors
- message (upstream DashScope response error message)
- raw_response.text (upstream DashScope error body)
- No results in DashScope rerank response: {response_json}
- DashScope API key is required. Set 'DASHSCOPE_API_KEY' env v
- query is required for DashScope rerank
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/551c535bcb48f2a3.
Report an issue: GitHub.