BerriAI/litellm · error · DashScopeError

{error.message}

Error message

{error.message}

What it means

The DashScope embeddings response parsed as JSON but the body contained an 'error' object — DashScope's error envelope. LiteLLM re-raises it as DashScopeError using the upstream message text (falling back to str(error) when there is no 'message' key) and the HTTP status of the response. The message you see is DashScope's own error description, so it names the real problem (invalid key, unknown model, quota, malformed input).

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 77b7c6c40c)

Solutions

  1. Read the message verbatim — it is DashScope's error text (e.g. InvalidApiKey, QuotaExceeded.AllocationQPS, Model.NotFound) and directly names the fault
  2. Smoke-test the key with curl against the compatible-mode embeddings endpoint to confirm the failure is upstream, not LiteLLM config
  3. Fix the specific cause: correct model name, valid key for the right region, or smaller/cleaner input
  4. For quota/throttling errors add client-side rate limiting and retries with backoff, or raise limits in the DashScope console
Defensive patterns

Strategy: try-catch

Try / catch

try:
    resp = litellm.embedding(model=model, input=texts)
except Exception as e:
    msg = str(e)
    if 'InvalidApiKey' in msg:
        rotate_key_and_alert()
    elif 'quota' in msg.lower() or 'throttl' in msg.lower():
        backoff_and_retry()
    else:
        raise

Prevention

When it happens

Trigger: Invalid/expired DASHSCOPE_API_KEY; a model name that does not exist on DashScope (typo in 'dashscope/text-embedding-vX'); exceeded account quota or QPS; malformed input such as an empty input array or non-string elements — each makes DashScope answer with an error body instead of embeddings.

Common situations: cn-region key used against the intl endpoint (or vice versa); free tier quota exhausted; model identifier from outdated docs; input exceeding per-request token limits.

Related errors


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