HKUDS/DeepTutor · error · RuntimeError

DashScope MultiModalEmbedding call failed: status={status_co

Error message

DashScope MultiModalEmbedding call failed: status={status_code}, code={code}, message={message}, model={model_name}, request_id={request_id}

What it means

_raise_on_error inspects the DashScope SDK response and, when status_code is present and != 200, raises RuntimeError embedding status, error code, message, model, and request_id. It is the adapter's uniform translation of DashScope API failures (auth, quota, bad model, invalid params) into a Python exception with full diagnostic context.

Source

Thrown at deeptutor/services/embedding/adapters/dashscope_native.py:175

        resp = await asyncio.to_thread(
            TextEmbedding.call,
            api_key=self.api_key,
            model=model_name,
            input=inputs,
            **parameters,
        )

        self._raise_on_error(resp, model_name)
        return self._parse_response(resp, model_name, request)

    def _raise_on_error(self, resp: Any, model_name: str) -> None:
        status_code = getattr(resp, "status_code", None)
        if status_code is None or status_code == HTTPStatus.OK:
            return
        code = getattr(resp, "code", "") or ""
        message = getattr(resp, "message", "") or ""
        request_id = getattr(resp, "request_id", "") or ""
        raise RuntimeError(
            f"DashScope MultiModalEmbedding call failed: "
            f"status={status_code}, code={code}, message={message}, "
            f"model={model_name}, request_id={request_id}"
        )

    def _parse_response(
        self, resp: Any, model_name: str, request: EmbeddingRequest
    ) -> EmbeddingResponse:
        output = getattr(resp, "output", None)
        if output is None:
            raise ValueError(
                f"DashScope response missing `output` (request_id={getattr(resp, 'request_id', '')})"
            )

        # `output` is dict-like in the SDK.
        if isinstance(output, dict):
            raw = output.get("embeddings") or []
        else:

View on GitHub (pinned to 3e82f13042)

Solutions

  1. Map the embedded code: 401/InvalidApiKey -> fix DASHSCOPE_API_KEY; invalid model -> correct the model name; 429 -> back off and retry
  2. Retry idempotent embedding calls with exponential backoff; keep request_id for support tickets
  3. Verify the account has access to the requested model (e.g. multimodal-embedding-one)

Example fix

# before
resp = await adapter.embed(req)  # RuntimeError: status=401, code=InvalidApiKey
# after
import os, asyncio
assert os.environ.get("DASHSCOPE_API_KEY"), "set DASHSCOPE_API_KEY"
for attempt in range(3):
    try:
        resp = await adapter.embed(req)
        break
    except RuntimeError as e:
        if "status=429" in str(e) and attempt < 2:
            await asyncio.sleep(2 ** attempt)
        else:
            raise
Defensive patterns

Strategy: retry

Try / catch

for attempt in range(4):
    try:
        return await adapter.embed(req)
    except RuntimeError as e:
        msg = str(e)
        if "status=429" in msg and attempt < 3:
            await asyncio.sleep(2 ** attempt)
            continue
        if "status=401" in msg or "InvalidApiKey" in msg:
            raise ConfigError("bad DASHSCOPE_API_KEY") from e
        raise

Prevention

When it happens

Trigger: Any _embed_multimodal/_embed_text call where the DashScope endpoint returns non-200: invalid API key, nonexistent model, rate limiting, malformed inputs.

Common situations: DASHSCOPE_API_KEY missing/revoked; model not enabled for the account (e.g. multimodal model on a text-only tier); throttling under batch indexing load.

Related errors


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/bd07ad63b310d224. Report an issue: GitHub.