invoke-ai/InvokeAI · error · ExternalProviderRequestError
Failed to download image from DashScope (status {response.st
Error message
Failed to download image from DashScope (status {response.status_code}) What it means
The HTTP request for the generated image completed but returned a non-2xx status. _download_image checks response.ok inside the stream context and raises ExternalProviderRequestError embedding the status code, because the image could not be fetched.
Source
Thrown at invokeai/app/services/external_generation/providers/alibabacloud.py:299
raise ExternalProviderRequestError(f"DashScope async response contained no images: {output}")
return ExternalGenerationResult(
images=images,
seed_used=request.seed,
provider_request_id=request_id,
provider_metadata={"model": request.model.provider_model_id},
)
def _download_image(self, url: str) -> PILImageType:
"""Download an image from a URL and return it as a PIL Image, with a size cap."""
try:
response = requests.get(url, timeout=_DOWNLOAD_TIMEOUT, stream=True)
except requests.RequestException as exc:
raise ExternalProviderRequestError(f"Failed to download image from DashScope: {exc}") from exc
with response:
if not response.ok:
raise ExternalProviderRequestError(
f"Failed to download image from DashScope (status {response.status_code})"
)
content_length = response.headers.get("Content-Length")
if content_length is not None:
try:
if int(content_length) > _DOWNLOAD_MAX_BYTES:
raise ExternalProviderRequestError(
f"DashScope image exceeds {_DOWNLOAD_MAX_BYTES} byte cap (Content-Length={content_length})"
)
except ValueError:
pass
buffer = bytearray()
for chunk in response.iter_content(chunk_size=64 * 1024):
if not chunk:
continue
buffer.extend(chunk)View on GitHub (pinned to 0b6a024f2f)
Solutions
- Note the status: 403/404/410 usually means the signed URL expired — regenerate the image rather than re-fetching the old URL
- Retry the full generation request to obtain fresh URLs
- Ensure you consume results promptly after generation
- Check that no proxy/ACL blocks access to the DashScope result-URL hosts
- If 5xx, retry after a short delay
Example fix
// before pil_image = provider._download_image(stale_url) # 403 // after result = provider.generate(request) # fresh URLs each run pil_image = provider._download_image(result.images[0].url)
Defensive patterns
Strategy: retry
Validate before calling
def validate_provider_config(cfg) -> None:
if not cfg.external_alibabacloud_api_key:
raise ValueError("DashScope API key missing")
if "dashscope" not in (cfg.external_alibabacloud_base_url or "dashscope-intl.aliyuncs.com"):
raise ValueError("base_url does not look like a DashScope endpoint") Try / catch
try:
result = provider.generate(request)
except ExternalProviderRequestError as e:
if "status 403" in str(e) or "status 404" in str(e) or "status 410" in str(e):
log.warning("Image URL rejected (%s); regenerating for a fresh URL", e)
result = provider.generate(request)
else:
raise Prevention
- Use image URLs promptly — DashScope signed URLs expire
- Keep base_url region consistent with the API key's region
- Ensure proxies/ACLs don't block the result-CDN hosts
- Treat 5xx statuses as retryable with delay
When it happens
Trigger: 403/404 from an expired or region-mismatched signed URL; 403 from CDN hotlink/ACL restrictions; 410 Gone after URL TTL; 5xx from the image CDN.
Common situations: Downloading images long after generation once signed URLs expire; base_url region (intl vs cn) differing from the URL host region; corporate proxy blocking the CDN; transient CDN errors.
Related errors
- Failed to download image from DashScope: {exc}
- Not authorized to modify this image
- Not authorized to access this image
- Not authorized to access this board
- {reason}
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/065fab38f5185ba2.
Report an issue: GitHub.