{"record":{"id":"025c96726c5c3b2d","repo":"microsoft/autogen","slug":"model-does-not-support-vision-and-image-was-provid-025c96","errorCode":null,"errorMessage":"Model does not support vision and image was provided","messagePattern":"Model does not support vision and image was provided","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py","lineNumber":341,"sourceCode":"\n    def add_usage(self, usage: RequestUsage) -> None:\n        self._total_usage = RequestUsage(\n            self._total_usage.prompt_tokens + usage.prompt_tokens,\n            self._total_usage.completion_tokens + usage.completion_tokens,\n        )\n\n    def _validate_model_info(\n        self,\n        messages: Sequence[LLMMessage],\n        tools: Sequence[Tool | ToolSchema],\n        json_output: Optional[bool | type[BaseModel]],\n        create_args: Dict[str, Any],\n    ) -> None:\n        if self.model_info[\"vision\"] is False:\n            for message in messages:\n                if isinstance(message, UserMessage):\n                    if isinstance(message.content, list) and any(isinstance(x, Image) for x in message.content):\n                        raise ValueError(\"Model does not support vision and image was provided\")\n\n        if json_output is not None:\n            if self.model_info[\"json_output\"] is False and json_output is True:\n                raise ValueError(\"Model does not support JSON output\")\n\n            if isinstance(json_output, type):\n                # TODO: we should support this in the future.\n                raise ValueError(\"Structured output is not currently supported for AzureAIChatCompletionClient\")\n\n            if json_output is True and \"response_format\" not in create_args:\n                create_args[\"response_format\"] = \"json_object\"\n\n        if self.model_info[\"json_output\"] is False and json_output is True:\n            raise ValueError(\"Model does not support JSON output\")\n        if self.model_info[\"function_calling\"] is False and len(tools) > 0:\n            raise ValueError(\"Model does not support function calling\")\n\n    async def create(","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py#L323-L359","documentation":"Raised by AzureAIChatCompletionClient._validate_model_info during create()/create_stream() when self.model_info['vision'] is False and any UserMessage in the conversation has a list content containing at least one autogen Image. The client refuses to forward images to a model declared non-vision rather than let the service fail opaquely.","triggerScenarios":"Sending Image parts in a UserMessage to a model whose model_info was built with vision=False (e.g. a text-only Llama or GPT model deployed on Azure AI Foundry); reusing a vision conversation history after swapping to a text-only deployment.","commonSituations":"model_info copied from a text model while the deployment actually serves a vision model (mis-declared capabilities); pipeline branches that attach screenshots unconditionally.","solutions":["If the deployed model does support vision, fix model_info to vision=True","If it truly does not, strip Image parts from UserMessage content before calling create (or replace with a text placeholder)","Gate image-attaching code paths on client.model_info['vision']"],"exampleFix":"# before\nmodel_info = ModelInfo(family=\"llama-3-1-8b-instruct\", vision=False, ...)\nawait client.create([UserMessage(content=[\"what is this?\", img], source=\"user\")])\n\n# after\ncontent = [\"what is this?\", img] if client.model_info[\"vision\"] else [\"what is this? (image omitted)\"]\nawait client.create([UserMessage(content=content, source=\"user\")])","handlingStrategy":"validation","validationCode":"from autogen_core.models import UserMessage, Image\n\ndef has_images(messages) -> bool:\n    return any(\n        isinstance(m, UserMessage) and isinstance(m.content, list)\n        and any(isinstance(p, Image) for p in m.content)\n        for m in messages\n    )\n\nif client.model_info[\"vision\"] is False:\n    assert not has_images(msgs), \"cannot send images to a non-vision model\"","typeGuard":"from autogen_core.models import UserMessage, Image\n\ndef message_contains_image(msg) -> bool:\n    return isinstance(msg, UserMessage) and isinstance(msg.content, list) \\\n        and any(isinstance(p, Image) for p in msg.content)","tryCatchPattern":null,"preventionTips":["Declare vision=True in model_info only when the deployment truly supports it","Gate image attachment code on client.model_info['vision']","Strip Image parts when routing histories to text-only models"],"tags":["azure","vision","model-info","multimodal"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}