{"record":{"id":"413b01551165ea78","repo":"HKUDS/DeepTutor","slug":"chat-model-returned-no-image-check-the-model-supp","errorCode":null,"errorMessage":"Chat model returned no image. Check the model supports image output (its output modalities must include `image`).","messagePattern":"Chat model returned no image\\. Check the model supports image output \\(its output modalities must include `image`\\)\\.","errorType":"error_code","errorClass":"GenerationProviderError","httpStatus":null,"severity":"error","filePath":"deeptutor/services/imagegen/adapters/chat_completions.py","lineNumber":66,"sourceCode":"        }\n        payload: dict[str, Any] = {\n            \"model\": config.model,\n            \"messages\": [{\"role\": \"user\", \"content\": prompt}],\n            \"modalities\": [\"image\", \"text\"],\n        }\n\n        logger.debug(\"imagegen(chat) url=%s model=%s\", url, config.model)\n        try:\n            async with httpx.AsyncClient(timeout=config.request_timeout) as client:\n                resp = await client.post(url, headers=headers, json=payload)\n                raise_for_provider(resp, \"Image generation\")\n                images = [\n                    await self._materialize(client, src) for src in self._extract_sources(resp)\n                ]\n        except httpx.HTTPError as exc:\n            raise GenerationProviderError(f\"Image generation request error: {exc}\") from exc\n        if not images:\n            raise GenerationProviderError(\n                \"Chat model returned no image. Check the model supports image output \"\n                \"(its output modalities must include `image`).\"\n            )\n        return images\n\n    @staticmethod\n    def _extract_sources(resp: httpx.Response) -> list[str]:\n        \"\"\"Pull image URLs / data URIs out of the assistant message.\"\"\"\n        data = resp.json()\n        sources: list[str] = []\n        choices = data.get(\"choices\") if isinstance(data, dict) else None\n        for choice in choices or []:\n            message = (choice or {}).get(\"message\") or {}\n            for image in message.get(\"images\") or []:\n                if not isinstance(image, dict):\n                    continue\n                src = (image.get(\"image_url\") or {}).get(\"url\") or image.get(\"url\")\n                if isinstance(src, str) and src:","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/services/imagegen/adapters/chat_completions.py#L48-L84","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nadapter = ChatCompletionsImagegenAdapter()  # model: gpt-4o-mini (text-only)\n// after\nconfig.model = \"gpt-4o\"  # or a model whose output modalities include `image`","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    images = await chat_adapter.generate(prompt, config)\nexcept GenerationProviderError as exc:\n    if \"no image\" in str(exc):\n        images = await openai_compat_adapter.generate(prompt, config)  # fallback endpoint","preventionTips":["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"],"tags":["imagegen","model-capability","chat-completions"],"backgroundTag":"unsupported-model-modality","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}