HKUDS/DeepTutor · error · GenerationProviderError
Chat model returned no image. Check the model supports image
Error message
Chat model returned no image. Check the model supports image output (its output modalities must include `image`).
What it means
The chat-completions response parsed successfully but _extract_sources found no usable image in the assistant message, so the images list is empty. The message text tells you the likely root cause: the model does not declare `image` in its output modalities.
Source
Thrown at deeptutor/services/imagegen/adapters/chat_completions.py:66
}
payload: dict[str, Any] = {
"model": config.model,
"messages": [{"role": "user", "content": prompt}],
"modalities": ["image", "text"],
}
logger.debug("imagegen(chat) url=%s model=%s", url, config.model)
try:
async with httpx.AsyncClient(timeout=config.request_timeout) as client:
resp = await client.post(url, headers=headers, json=payload)
raise_for_provider(resp, "Image generation")
images = [
await self._materialize(client, src) for src in self._extract_sources(resp)
]
except httpx.HTTPError as exc:
raise GenerationProviderError(f"Image generation request error: {exc}") from exc
if not images:
raise GenerationProviderError(
"Chat model returned no image. Check the model supports image output "
"(its output modalities must include `image`)."
)
return images
@staticmethod
def _extract_sources(resp: httpx.Response) -> list[str]:
"""Pull image URLs / data URIs out of the assistant message."""
data = resp.json()
sources: list[str] = []
choices = data.get("choices") if isinstance(data, dict) else None
for choice in choices or []:
message = (choice or {}).get("message") or {}
for image in message.get("images") or []:
if not isinstance(image, dict):
continue
src = (image.get("image_url") or {}).get("url") or image.get("url")
if isinstance(src, str) and src:View on GitHub (pinned to 3e82f13042)
Solutions
- Switch to a model that supports image output modalities (check the provider's model listing for `image` in output modalities)
- Ensure the request payload requests image output (modality settings in extra body/config) as required by the provider
- If image output isn't available on your chat endpoint, use the /images/generations adapter instead
- Inspect the raw response (log resp.json()) to confirm what the model actually returned
Example fix
// before adapter = ChatCompletionsImagegenAdapter() # model: gpt-4o-mini (text-only) // after config.model = "gpt-4o" # or a model whose output modalities include `image`
Defensive patterns
Strategy: fallback
Try / catch
try:
images = await chat_adapter.generate(prompt, config)
except GenerationProviderError as exc:
if "no image" in str(exc):
images = await openai_compat_adapter.generate(prompt, config) # fallback endpoint Prevention
- Pin a model known to support image output modalities
- Keep a dedicated /images/generations provider as fallback
- Log the raw response when this fires to distinguish refusal vs capability
When it happens
Trigger: Calling a chat model (e.g. gpt-4o style) that only outputs text because the request didn't request image modality or the model/deployment doesn't support image output; the model returned images in a response shape the extractor doesn't recognize; the model refused or returned only text.
Common situations: Using a text-only model name with the chat-completions imagegen adapter; forgetting the modalities/image config in the payload; provider deployed without image output support; model returned a refusal instead of an image.
Related errors
- Image response had no image in the assistant message.
- Cohere model '{model_name}' does not support multimodal `con
- No endpoint URL configured for image generation.
- Image generation request error: {exc}
- Malformed image data URI.
AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27).
Data as JSON: /api/errors/413b01551165ea78.
Report an issue: GitHub.