{"record":{"id":"bc8fbdee7de8acc1","repo":"agentscope-ai/agentscope","slug":"dashscope-text-embedding-api-error-response","errorCode":null,"errorMessage":"DashScope text embedding API error: {response}","messagePattern":"DashScope text embedding API error: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/agentscope/embedding/_dashscope/_model.py","lineNumber":379,"sourceCode":"            )\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        response = dashscope.embeddings.TextEmbedding.call(\n            api_key=self.api_key,\n            **api_kwargs,\n        )\n        time = (datetime.now() - start_time).total_seconds()\n\n        if response.status_code != 200:\n            raise RuntimeError(\n                f\"DashScope text embedding API error: {response}\",\n            )\n\n        embeddings = [\n            entry[\"embedding\"] for entry in response.output[\"embeddings\"]\n        ]\n        if self.embedding_cache:\n            await self.embedding_cache.store(\n                identifier=api_kwargs,\n                embeddings=embeddings,\n            )\n        return EmbeddingResponse(\n            embeddings=embeddings,\n            usage=EmbeddingUsage(\n                tokens=response.usage[\"total_tokens\"],\n                time=time,\n            ),\n        )","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/embedding/_dashscope/_model.py#L361-L397","documentation":"Raised when the DashScope text embedding HTTP API returns a non-200 status code; the whole response object is embedded in the message for diagnosis (auth errors, quota, invalid model name, bad request).","triggerScenarios":"Calling the text embedding model and DashScope returns status != 200: wrong/missing API key, unknown model name, malformed request payload, rate limits, or service outages.","commonSituations":"DASHSCOPE_API_KEY not set or revoked; using a model id not enabled for the account; hitting QPS/quota limits at high batch sizes.","solutions":["Print the response body to identify the exact status code and message, then fix credentials/model/quota accordingly","Verify DASHSCOPE_API_KEY is set and valid for the model used","Retry with the built-in retry/backoff for transient 429/5xx and reduce batch size"],"exampleFix":"# before\nresp = await model(texts)  # raises RuntimeError on failure\n# after\ntry:\n    resp = await model(texts)\nexcept RuntimeError as e:\n    logging.error(\"dashscope failed: %s\", e)\n    raise","handlingStrategy":"retry","validationCode":"assert os.getenv(\\\"DASHSCOPE_API_KEY\\\"), \\\"set DASHSCOPE_API_KEY\\\"","typeGuard":null,"tryCatchPattern":"try:\\n    await model(texts)\\nexcept RuntimeError as e:\\n    log.error(\\\"dashscope: %s\\\", e)\\n    if is_transient(str(e)): await asyncio.sleep(backoff); await model(texts)\\n    else: raise","preventionTips":["Log the full response payload on failure","Keep batches small to avoid 429s","Configure max_retries for transient errors"],"tags":["embedding","dashscope","api-error","http"],"backgroundTag":"api-request-failed","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}