{"record":{"id":"6933190b6e1ad6d6","repo":"microsoft/semantic-kernel","slug":"audio-content-uri-needs-to-be-set-because-onnx-ca","errorCode":null,"errorMessage":"Audio Content URI needs to be set, because onnx can only work with file paths","messagePattern":"Audio Content URI needs to be set, because onnx can only work with file paths","errorType":"exception","errorClass":"ServiceInvalidExecutionSettingsError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/onnx/services/onnx_gen_ai_chat_completion.py","lineNumber":210,"sourceCode":"                    if image.uri:\n                        images.append(image)\n                    else:\n                        raise ServiceInvalidExecutionSettingsError(\n                            \"Image Content URI needs to be set, because onnx can only work with file paths\"\n                        )\n        return images if len(images) else None\n\n    def _get_audios_from_history(self, chat_history: \"ChatHistory\") -> list[AudioContent] | None:\n        audios = []\n        for message in chat_history.messages:\n            for audio in message.items:\n                if isinstance(audio, AudioContent):\n                    if not self.enable_multi_modality:\n                        raise ServiceInvalidExecutionSettingsError(\"The model does not support multi-modality\")\n                    if audio.uri:\n                        audios.append(audio)\n                    else:\n                        raise ServiceInvalidExecutionSettingsError(\n                            \"Audio Content URI needs to be set, because onnx can only work with file paths\"\n                        )\n        return audios if len(audios) else None\n\n    @override\n    def get_prompt_execution_settings_class(self) -> type[\"PromptExecutionSettings\"]:\n        \"\"\"Create a request settings object.\"\"\"\n        return OnnxGenAIPromptExecutionSettings\n","sourceCodeStart":192,"sourceCodeEnd":219,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/onnx/services/onnx_gen_ai_chat_completion.py#L192-L219","documentation":"Raised inside _get_audios_from_history when the model IS multi-modal but an AudioContent item has a falsy .uri attribute. Like images, the ONNX runtime can only load audio from file paths (OnnxRuntimeGenAi.Audios.open), not from in-memory data. Raised as ServiceInvalidExecutionSettingsError.","triggerScenarios":"Adding AudioContent with data but no uri to chat history for a multi-modal ONNX model. The check fires on audio.uri being falsy.","commonSituations":"Creating AudioContent from a byte buffer or base64 without writing to disk; reusing audio objects from another connector that uses data instead of uri; ONNX file-path-only limitation not accounted for.","solutions":["Set audio.uri to a local file path for ONNX models","Write in-memory audio to a temp file and reference its path via uri","Use AudioContent(uri='file:///tmp/audio.wav')"],"exampleFix":"// before\nAudioContent(data=audio_bytes)\n// after\nAudioContent(uri='file:///tmp/audio.wav')","handlingStrategy":"validation","validationCode":"from semantic_kernel.contents import AudioContent\n\ndef validate_audio_uris(chat_history):\n    for msg in chat_history.messages:\n        for item in msg.items:\n            if isinstance(item, AudioContent) and not item.uri:\n                raise ValueError('AudioContent must have a uri for ONNX models')","typeGuard":"from semantic_kernel.contents import AudioContent\n\ndef all_audios_have_uri(chat_history) -> bool:\n    return all(\n        item.uri for msg in chat_history.messages\n        for item in msg.items if isinstance(item, AudioContent)\n    )","tryCatchPattern":"from semantic_kernel.exceptions.service_exceptions import ServiceInvalidExecutionSettingsError\n\ntry:\n    result = await chat.get_chat_message_contents(chat_history=history, settings=settings)\nexcept ServiceInvalidExecutionSettingsError as e:\n    if 'Audio Content URI needs to be set' in str(e):\n        for msg in history.messages:\n            for item in msg.items:\n                if isinstance(item, AudioContent) and not item.uri:\n                    item.uri = 'file:///tmp/resolved_audio.wav'\n        result = await chat.get_chat_message_contents(chat_history=history, settings=settings)","preventionTips":["Always set AudioContent.uri to a local file path for ONNX models","Write in-memory audio to a temp file if only byte data is available","Pre-validate all audio URIs point to existing files before inference"],"tags":["onnx","multimodal","audio-content","uri","execution-settings"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}