{"record":{"id":"1534e16e6f0c1981","repo":"invoke-ai/InvokeAI","slug":"dashscope-async-request-failed-with-status-respon","errorCode":null,"errorMessage":"DashScope async request failed with status {response.status_code} for model '{model_id}': {response.text}","messagePattern":"DashScope async request failed with status (.+?) for model '(.+?)': (.+?)","errorType":"exception","errorClass":"ExternalProviderRequestError","httpStatus":null,"severity":"error","filePath":"invokeai/app/services/external_generation/providers/alibabacloud.py","lineNumber":156,"sourceCode":"            \"prompt_extend\": False,\n            \"watermark\": False,\n        }\n        if request.seed is not None:\n            parameters[\"seed\"] = request.seed\n\n        input_data: dict[str, object] = {\"prompt\": request.prompt}\n\n        payload: dict[str, object] = {\n            \"model\": model_id,\n            \"input\": input_data,\n            \"parameters\": parameters,\n        }\n\n        response = self._post_with_retry(\n            endpoint, headers=async_headers, json=payload, timeout=60, label=\"DashScope async submit\"\n        )\n        if not response.ok:\n            raise ExternalProviderRequestError(\n                f\"DashScope async request failed with status {response.status_code} for model '{model_id}': {response.text}\"\n            )\n\n        data = response.json()\n        request_id = data.get(\"request_id\")\n        output = data.get(\"output\", {})\n        task_id = output.get(\"task_id\")\n\n        if not task_id:\n            raise ExternalProviderRequestError(f\"DashScope async response missing task_id: {data}\")\n\n        return self._poll_task(base_url, headers, task_id, request, request_id)\n\n    def _poll_task(\n        self,\n        base_url: str,\n        headers: dict[str, str],\n        task_id: str,","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/external_generation/providers/alibabacloud.py#L138-L174","documentation":"In the asynchronous DashScope path, task submission POST must return 2xx; otherwise _generate_async raises ExternalProviderRequestError with the status code and response body before any task_id exists. Same family as error 624 but for the async submit endpoint.","triggerScenarios":"_generate_async posts the task-creation payload (with async headers) to the DashScope async endpoint and receives a non-2xx response: bad key (401), invalid model or parameters (400), throttling (429), or server error (5xx).","commonSituations":"Using an async-only model with an invalid key; request payload violating the async API schema; exceeding QPS limits on DashScope; transient DashScope incidents.","solutions":["Inspect status code and body in the message for DashScope's error code (e.g. AccessDenied, Throttling)","Fix authentication: set a valid external_alibabacloud_api_key","Correct request parameters/size/model id per the async API docs","Retry with backoff on 429/5xx; submission already uses _post_with_retry"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if not api_key:\n    raise ConfigError(\"DashScope key missing\")  # avoid guaranteed 401 on async submit\nif request.model.provider_model_id not in _ASYNC_MODELS:\n    raise ValueError(\"model is not an async DashScope model\")","typeGuard":"def is_async_submit_error(e: Exception) -> bool:\n    return isinstance(e, ExternalProviderRequestError) and 'DashScope async request failed' in str(e)","tryCatchPattern":"try:\n    result = provider.generate(request)\nexcept ExternalProviderRequestError as e:\n    if 'async request failed with status 429' in str(e):\n        wait_and_resubmit(request)\n    else:\n        log.error(\"DashScope async submit failed: %s\", e)\n        raise","preventionTips":["Pre-check key and model registration before submission","Throttle submissions to stay under DashScope QPS limits","Capture the request_id from logs when reporting issues to Alibaba"],"tags":["network","http-error","dashscope","alibabacloud","async"],"backgroundTag":"http-4xx-error","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}