invoke-ai/InvokeAI · error · ExternalProviderRequestError
DashScope response missing choices: {data}
Error message
DashScope response missing choices: {data} What it means
After locating the 'output' object, _parse_sync_response expects output.choices to be a list (OpenAI-style chat choices) from the multimodal-generation endpoint. If 'choices' is missing or not a list, the provider raises ExternalProviderRequestError with the raw data, since it cannot extract any generated image content.
Source
Thrown at invokeai/app/services/external_generation/providers/alibabacloud.py:225
raise ExternalProviderRequestError(f"DashScope task {task_id} failed: {message}")
self._logger.debug("DashScope task %s status: %s (%.0fs elapsed)", task_id, status, elapsed)
time.sleep(_TASK_POLL_INTERVAL)
def _parse_sync_response(
self,
data: dict[str, object],
request: ExternalGenerationRequest,
request_id: str | None,
) -> ExternalGenerationResult:
"""Parse the synchronous multimodal-generation response."""
output = data.get("output")
if not isinstance(output, dict):
raise ExternalProviderRequestError(f"DashScope response missing output: {data}")
choices = output.get("choices")
if not isinstance(choices, list):
raise ExternalProviderRequestError(f"DashScope response missing choices: {data}")
images: list[ExternalGeneratedImage] = []
for choice in choices:
if not isinstance(choice, dict):
continue
message = choice.get("message")
if not isinstance(message, dict):
continue
content = message.get("content")
if not isinstance(content, list):
continue
for part in content:
if not isinstance(part, dict):
continue
image_url = part.get("image")
if isinstance(image_url, str) and image_url:
pil_image = self._download_image(image_url)
images.append(ExternalGeneratedImage(image=pil_image, seed=request.seed))View on GitHub (pinned to 0b6a024f2f)
Solutions
- Check the embedded response data for a rejection/error message from DashScope (content moderation often returns an output without choices)
- Confirm the model_id belongs in _SYNC_MODELS; move it to _ASYNC_MODELS if it uses the flat-prompt image-generation endpoint
- Verify the endpoint path /api/v1/services/aigc/multimodal-generation/generation matches your base_url and DashScope API version
- Retry the request — transient moderation or backend issues can yield empty outputs
- Check InvokeAI/DashScope docs for API schema changes
Example fix
# before
if model_id in _SYNC_MODELS:
return self._generate_sync(...)
# after
if model_id in _SYNC_MODELS:
return self._generate_sync(...)
# if you see 'missing choices', the model likely uses the async API:
# move it from _SYNC_MODELS to _ASYNC_MODELS Defensive patterns
Strategy: validation
Validate before calling
if model.provider_model_id not in {"qwen-image-2.0-pro","qwen-image-2.0","qwen-image-max","wan2.6-t2i","qwen-image-edit-max"}:
raise ValueError(f"{model.provider_model_id} is not a known sync DashScope model") Type guard
def has_choices(output: dict) -> bool:
return isinstance(output.get("choices"), list) and len(output["choices"]) > 0 Try / catch
try:
result = provider.generate(request)
except ExternalProviderRequestError as e:
if "missing choices" in str(e):
log.error("DashScope output lacked choices (possible moderation or wrong endpoint): %s", e)
raise Prevention
- Only route models verified to use the multimodal-generation endpoint into _SYNC_MODELS
- Check embedded response text for content-policy messages and adjust prompts
- Pin the DashScope API version/base_url
- Validate model IDs before submitting generation jobs
When it happens
Trigger: DashScope returns 200 with output present but no 'choices' array — e.g. an output containing only task/error fields, a moderation/rejection payload, or a response shape from the wrong endpoint (async image-generation returns output.results instead of output.choices).
Common situations: Routing a model that only supports the async image-generation endpoint into _SYNC_MODELS; content-policy rejection returning output without choices; custom base_url serving a different API revision whose output omits choices.
Related errors
- DashScope response missing output: {data}
- DashScope request failed with status {response.status_code}
- DashScope async response missing results: {output}
- DashScope async response contained no images: {output}
- Alibaba Cloud DashScope API key is not configured
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/11e20d730fbcac43.
Report an issue: GitHub.