BerriAI/litellm · error · DashScopeError
message (upstream DashScope response error message)
Error message
message (upstream DashScope response error message)
What it means
Raised by LiteLLM's DashScope embeddings handler when the upstream DashScope (Alibaba Cloud) embeddings API returns a body containing an 'error' object. The message is taken verbatim from the upstream error payload, so the text you see is DashScope's own error description. LiteLLM wraps it in DashScopeError along with the HTTP status code from the raw response.
Source
Thrown at litellm/llms/dashscope/embed/transformation.py:148
try:
response_json: Final = raw_response.json()
except Exception as e:
raise DashScopeError(
status_code=raw_response.status_code,
message=f"Failed to parse DashScope response as JSON: {e}",
)
logging_obj.post_call(
input=request_data.get("input"),
api_key=api_key,
additional_args={"complete_input_dict": request_data},
original_response=response_json,
)
if "error" in response_json:
error: Final = response_json["error"]
message: Final = error.get("message", str(error)) if isinstance(error, dict) else str(error)
raise DashScopeError(
status_code=raw_response.status_code,
message=message,
)
model_response.object = "list"
model_response.data = response_json.get("data", [])
model_response.model = response_json.get("model", model)
usage: Final = response_json.get("usage") or {}
prompt_tokens: Final = usage.get("prompt_tokens", 0)
total_tokens: Final = usage.get("total_tokens", prompt_tokens)
setattr(
model_response,
"usage",
Usage(
prompt_tokens=prompt_tokens,
completion_tokens=0,
total_tokens=total_tokens,View on GitHub (pinned to 6c2dcb801b)
Solutions
- Read the upstream message and status code — they identify the exact DashScope failure (auth, model, limits)
- Verify the model name is a valid DashScope embedding model for your account/region
- Check that DASHSCOPE_API_KEY is valid and has quota (test with a minimal 1-input embedding call)
- Reduce batch size / input length to comply with DashScope embedding limits
- If auth-related, rotate the API key in the Alibaba Cloud DashScope console
Example fix
# before resp = litellm.embedding(model="dashscope/BadModelName", input=["hi"]) # after resp = litellm.embedding(model="dashscope/text-embedding-v3", input=["hi"], api_key=os.environ["DASHSCOPE_API_KEY"])
Defensive patterns
Strategy: try-catch
Validate before calling
model = "dashscope/text-embedding-v3" inputs = ["short text"] assert inputs and all(isinstance(i, str) and 0 < len(i) < 8000 for i in inputs), "invalid embedding input"
Try / catch
from litellm.exceptions import APIError
try:
resp = litellm.embedding(model=model, input=inputs)
except APIError as e:
logger.error("DashScope embed failed (%s): %s", getattr(e, 'status_code', '?'), e)
raise Prevention
- Pin known-good DashScope embedding model names in config rather than free-form strings
- Batch embedding inputs below DashScope's per-request item and token limits
- Run a one-input smoke embedding at startup to fail fast on auth/model errors
When it happens
Trigger: Calling litellm.embedding() with a DashScope model (e.g. text-embedding-v3/qwen embeddings) and the upstream API responding with a JSON body containing an 'error' key: invalid/expired API key, nonexistent model name, malformed 'input' array, token-per-input limits exceeded, or quota exhaustion.
Common situations: Using a model string not available in your DashScope region/account; sending more inputs or longer texts than the endpoint allows; a DASHSCOPE_API_KEY from a different environment; rate/quota limits on a fresh Alibaba Cloud account.
Related errors
- response_json.get("message", str(response_json)) (upstream D
- {embeddings[error]}
- DashScope API key is required. Set 'DASHSCOPE_API_KEY' env v
- Failed to parse DashScope response as JSON: {e}
- raw_response.text (upstream DashScope error body)
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/915bead3e173a229.
Report an issue: GitHub.