{"record":{"id":"6399df0dba70d4a5","repo":"agentscope-ai/agentscope","slug":"dashscope-multimodal-embedding-api-error-res","errorCode":null,"errorMessage":"DashScope multimodal embedding API error: {res}","messagePattern":"DashScope multimodal embedding API error: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/agentscope/embedding/_dashscope/_model.py","lineNumber":461,"sourceCode":"        if self.embedding_cache:\n            cached = await self.embedding_cache.retrieve(\n                identifier=cache_identifier,\n            )\n            if cached:\n                return EmbeddingResponse(\n                    embeddings=cached,\n                    usage=EmbeddingUsage(tokens=0, time=0),\n                    source=\"cache\",\n                )\n\n        import dashscope\n\n        start_time = datetime.now()\n        res = dashscope.MultiModalEmbedding.call(**api_kwargs)\n        time = (datetime.now() - start_time).total_seconds()\n\n        if res.status_code != 200:\n            raise RuntimeError(\n                f\"DashScope multimodal embedding API error: {res}\",\n            )\n\n        embeddings = [entry[\"embedding\"] for entry in res.output[\"embeddings\"]]\n        if self.embedding_cache:\n            await self.embedding_cache.store(\n                identifier=cache_identifier,\n                embeddings=embeddings,\n            )\n        return EmbeddingResponse(\n            embeddings=embeddings,\n            usage=EmbeddingUsage(\n                tokens=res.usage.get(\"image_tokens\", 0)\n                + res.usage.get(\"input_tokens\", 0),\n                time=time,\n            ),\n            source=\"api\",\n        )","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/embedding/_dashscope/_model.py#L443-L479","documentation":"Raised when dashscope.MultiModalEmbedding.call returns a non-200 status code; the full result object is included in the message for root-causing (auth, quota, invalid media URL, model issues).","triggerScenarios":"Calling multimodal embedding while DashScope rejects the request: bad API key, unreachable/expired media URLs, oversized payloads, rate limits, or an unavailable model.","commonSituations":"Embedding images referenced by internal URLs not reachable from DashScope; expired pre-signed URLs; large batches exceeding request limits; quota exhaustion.","solutions":["Inspect the embedded response for the status code and message, then address credentials, URL reachability, or size limits","Ensure media URLs are publicly reachable (or use base64 for images)","Retry transient 429/5xx with backoff and shrink the batch"],"exampleFix":"# before\nres = await model(items)\n# after\ntry:\n    res = await model(items)\nexcept RuntimeError as e:\n    if \"429\" in str(e):\n        await asyncio.sleep(5); res = await model(items)\n    else:\n        raise","handlingStrategy":"retry","validationCode":"urls = [b.source.url for b in blocks if hasattr(b.source, 'url')]\nassert all(urllib.parse.urlparse(u).scheme in (\\\"http\\\", \\\"https\\\") for u in urls)","typeGuard":null,"tryCatchPattern":"try:\\n    await model(items)\\nexcept RuntimeError as e:\\n    if \\\"429\\\" in str(e) or \\\"timeout\\\" in str(e).lower(): await asyncio.sleep(2 ** n); await model(items)\\n    else: raise","preventionTips":["Use publicly reachable media URLs","Re-generate pre-signed URLs before they expire","Batch media items modestly"],"tags":["embedding","dashscope","multimodal","api-error"],"backgroundTag":"api-request-failed","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}