{"record":{"id":"95873dcdd280b708","repo":"microsoft/autogen","slug":"model-does-not-support-vision-and-image-was-provid-95873d","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/openai/_openai_client.py","lineNumber":577,"sourceCode":"\n        if response_format_value is not None and \"response_format\" in create_args:\n            warnings.warn(\n                \"response_format is found in extra_create_args while json_output is set to a Pydantic model class. \"\n                \"Skipping the response_format in extra_create_args in favor of the json_output. \"\n                \"Structured output will be used.\",\n                UserWarning,\n                stacklevel=2,\n            )\n            # If using beta client, remove response_format from create_args to prevent passing it twice\n            del create_args[\"response_format\"]\n\n        # TODO: allow custom handling.\n        # For now we raise an error if images are present and vision is not supported\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 self.model_info[\"json_output\"] is False and json_output is True:\n            raise ValueError(\"Model does not support JSON output.\")\n\n        if not self.model_info.get(\"multiple_system_messages\", False):\n            # Some models accept only one system message(or, it will read only the last one)\n            # So, merge system messages into one (if multiple and continuous)\n            system_message_content = \"\"\n            _messages: List[LLMMessage] = []\n            _first_system_message_idx = -1\n            _last_system_message_idx = -1\n            # Index of the first system message for adding the merged system message at the correct position\n            for idx, message in enumerate(messages):\n                if isinstance(message, SystemMessage):\n                    if _first_system_message_idx == -1:\n                        _first_system_message_idx = idx\n                    elif _last_system_message_idx + 1 != idx:\n                        # That case, system message is not continuous","sourceCodeStart":559,"sourceCodeEnd":595,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py#L559-L595","documentation":"Thrown by OpenAIChatCompletionClient when a message contains an Image part but the client's model_info declares vision support as False. The client validates capability metadata before sending the request, so this fails client-side before any API call. It exists to prevent sending image content to text-only models, which would otherwise fail opaquely at the API.","triggerScenarios":"Calling create/create_stream with a UserMessage whose content is a list containing one or more Image objects, while model_info['vision'] is False (e.g. a text-only model like gpt-3.5-turbo or a custom model_info with vision=False). Only UserMessage instances are checked; SystemMessage/AssistantMessage content is not scanned.","commonSituations":"Using a custom/open-hosted model with a hand-written model_info dict that omits or sets vision=False; upgrading autogen where older model_info entries lacked the vision key; replaying a vision conversation against a text-only model in tests.","solutions":["Switch to a vision-capable model (e.g. gpt-4o) whose model_info has vision=True","If the model actually supports vision, pass a corrected model_info dict to the client constructor with 'vision': True","Remove Image parts from the UserMessage content before calling create","If using an older model entry, regenerate model_info via the model info lookup helpers instead of a stale hardcoded dict"],"exampleFix":"// before\nclient = OpenAIChatCompletionClient(model=\"gpt-3.5-turbo\")\nmsg = UserMessage(content=[\"describe\", Image.from_file(\"cat.png\")], source=\"user\")\nawait client.create([msg])\n\n// after\nclient = OpenAIChatCompletionClient(model=\"gpt-4o\")  # vision-capable\nmsg = UserMessage(content=[\"describe\", Image.from_file(\"cat.png\")], source=\"user\")\nawait client.create([msg])","handlingStrategy":"validation","validationCode":"from autogen_core import Image\nfrom autogen_agentchat.messages import UserMessage\n\ndef has_image(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 has_image(messages) and not client.info.get(\"vision\", False):\n    raise RuntimeError(\"switch to a vision-capable model or strip images\")","typeGuard":"def is_vision_message_list(messages: Sequence[LLMMessage], vision_supported: bool) -> bool:\n    \"\"\"True when it is safe to send these messages: no images, or vision supported.\"\"\"\n    return vision_supported or not has_image(messages)","tryCatchPattern":"try:\n    result = await client.create(messages)\nexcept ValueError as e:\n    if \"does not support vision\" in str(e):\n        messages = [strip_images(m) for m in messages]  # degrade to text\n        result = await client.create(messages)\n    else:\n        raise","preventionTips":["Keep model_info accurate for every model you deploy; assert client.info['vision'] before routing image tasks","Route image-bearing requests through a model-selection step that checks the vision capability","In tests, use ReplayChatCompletionClient to decouple capability checks from fixtures"],"tags":["openai","vision","multimodal","validation","model-info"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}