agentscope-ai/agentscope · error · RuntimeError
DashScope multimodal embedding API error: {res}
Error message
DashScope multimodal embedding API error: {res} What it means
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).
Source
Thrown at src/agentscope/embedding/_dashscope/_model.py:461
if self.embedding_cache:
cached = await self.embedding_cache.retrieve(
identifier=cache_identifier,
)
if cached:
return EmbeddingResponse(
embeddings=cached,
usage=EmbeddingUsage(tokens=0, time=0),
source="cache",
)
import dashscope
start_time = datetime.now()
res = dashscope.MultiModalEmbedding.call(**api_kwargs)
time = (datetime.now() - start_time).total_seconds()
if res.status_code != 200:
raise RuntimeError(
f"DashScope multimodal embedding API error: {res}",
)
embeddings = [entry["embedding"] for entry in res.output["embeddings"]]
if self.embedding_cache:
await self.embedding_cache.store(
identifier=cache_identifier,
embeddings=embeddings,
)
return EmbeddingResponse(
embeddings=embeddings,
usage=EmbeddingUsage(
tokens=res.usage.get("image_tokens", 0)
+ res.usage.get("input_tokens", 0),
time=time,
),
source="api",
)View on GitHub (pinned to e90f1c7592)
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
Example fix
# before
res = await model(items)
# after
try:
res = await model(items)
except RuntimeError as e:
if "429" in str(e):
await asyncio.sleep(5); res = await model(items)
else:
raise Defensive patterns
Strategy: retry
Validate before calling
urls = [b.source.url for b in blocks if hasattr(b.source, 'url')] assert all(urllib.parse.urlparse(u).scheme in (\"http\", \"https\") for u in urls)
Try / catch
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
Prevention
- Use publicly reachable media URLs
- Re-generate pre-signed URLs before they expire
- Batch media items modestly
When it happens
Trigger: Calling multimodal embedding while DashScope rejects the request: bad API key, unreachable/expired media URLs, oversized payloads, rate limits, or an unavailable model.
Common situations: Embedding images referenced by internal URLs not reachable from DashScope; expired pre-signed URLs; large batches exceeding request limits; quota exhaustion.
Related errors
- DashScope text embedding API error: {response}
- Invalid input: {item!r}. Expected str or DataBlock.
- Multimodal embedding API only supports URL input for video d
- Unsupported media type {media_type!r} in DataBlock. Expected
- Text embedding model {self.model!r} only accepts str inputs,
AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28).
Data as JSON: /api/errors/6399df0dba70d4a5.
Report an issue: GitHub.