microsoft/semantic-kernel · error · ServiceInvalidExecutionSettingsError
The model does not support multi-modality
Error message
The model does not support multi-modality
What it means
Raised inside _get_images_from_history when chat_history contains an ImageContent item but the loaded model is not multi-modal (self.enable_multi_modality is False). The ONNX model was loaded without a 'vision' key in its config, so it cannot process images. Raised as ServiceInvalidExecutionSettingsError during the chat completion call.
Source
Thrown at python/semantic_kernel/connectors/ai/onnx/services/onnx_gen_ai_chat_completion.py:191
return self.tokenizer.apply_chat_template(
json.dumps(self._chat_messages_to_dicts(chat_history)),
add_generation_prompt=True,
)
def _chat_messages_to_dicts(self, chat_history: "ChatHistory") -> list[dict[str, Any]]:
return [
message.to_dict(role_key="role", content_key="content")
for message in chat_history.messages
if isinstance(message, ChatMessageContent)
]
def _get_images_from_history(self, chat_history: "ChatHistory") -> list[ImageContent] | None:
images = []
for message in chat_history.messages:
for image in message.items:
if isinstance(image, ImageContent):
if not self.enable_multi_modality:
raise ServiceInvalidExecutionSettingsError("The model does not support multi-modality")
if image.uri:
images.append(image)
else:
raise ServiceInvalidExecutionSettingsError(
"Image Content URI needs to be set, because onnx can only work with file paths"
)
return images if len(images) else None
def _get_audios_from_history(self, chat_history: "ChatHistory") -> list[AudioContent] | None:
audios = []
for message in chat_history.messages:
for audio in message.items:
if isinstance(audio, AudioContent):
if not self.enable_multi_modality:
raise ServiceInvalidExecutionSettingsError("The model does not support multi-modality")
if audio.uri:
audios.append(audio)
else:View on GitHub (pinned to c028a0c7dc)
Solutions
- Use a multi-modal (vision) ONNX model if you need image inputs
- Remove ImageContent items from the chat history before sending to a text-only model
- Switch to OnnxGenAIChatCompletion with a vision model and a template
Example fix
// before (text-only model + image in history) history.add_message(ChatMessageContent(role=AuthorRole.USER, items=[ImageContent(uri='...')])) await chat.get_chat_message_contents(chat_history=history, settings=s) // after (remove image or use vision model) history.add_message(ChatMessageContent(role=AuthorRole.USER, items=[TextContent(text='describe the scene')]))
Defensive patterns
Strategy: validation
Validate before calling
from semantic_kernel.contents import ImageContent
def check_images_supported(chat_service, chat_history):
if not chat_service.enable_multi_modality:
for msg in chat_history.messages:
if any(isinstance(item, ImageContent) for item in msg.items):
raise ValueError('Chat history contains images but model is not multi-modal')
check_images_supported(chat, history) Type guard
from semantic_kernel.contents import ImageContent
def history_has_images(chat_history) -> bool:
return any(
isinstance(item, ImageContent)
for msg in chat_history.messages
for item in msg.items
) Try / catch
from semantic_kernel.exceptions.service_exceptions import ServiceInvalidExecutionSettingsError
try:
result = await chat.get_chat_message_contents(chat_history=history, settings=settings)
except ServiceInvalidExecutionSettingsError as e:
if 'does not support multi-modality' in str(e):
logger.error('Remove image content or switch to a vision model')
raise Prevention
- Check chat.enable_multi_modality before adding images to chat history
- Gate multimodal inputs behind a feature flag tied to the model type
- Log the model type at construction so you know its capabilities
When it happens
Trigger: Calling get_chat_message_contents on a text-only ONNX model with chat_history that includes one or more ImageContent items. The check fires per-message during _get_images_from_history iteration.
Common situations: Switching from a vision model to a text-only model but keeping image inputs in the pipeline; adding image content to a chat that was designed for text-only; using the wrong model folder that happens to be text-only.
Related errors
- Image Content URI needs to be set, because onnx can only wor
- Audio Content URI needs to be set, because onnx can only wor
- ImageContent in function result must contain binary data.
- When using a multi-modal model, a template must be specified
- ImageContent cannot be converted to ResponseContentPart. Onl
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/088ca07bee3cb91d.
Report an issue: GitHub.