{"record":{"id":"1b396426639a67bb","repo":"microsoft/semantic-kernel","slug":"the-provided-audio-options-executionsettings-aud","errorCode":null,"errorMessage":"The provided audio options '{executionSettings.Audio?.GetType()}' is not supported.","messagePattern":"The provided audio options '(.+?)' is not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Connectors/Connectors.AzureOpenAI/Core/AzureClientCore.ChatCompletion.cs","lineNumber":264,"sourceCode":"        }\n\n        if (executionSettings.Audio is string audioOptionsString)\n        {\n            try\n            {\n                var result = ModelReaderWriter.Read<ChatAudioOptions>(BinaryData.FromString(audioOptionsString));\n                if (result != null)\n                {\n                    return result;\n                }\n            }\n            catch (Exception ex)\n            {\n                throw new NotSupportedException(\"Failed to parse the provided audio options from string. Ensure the string is valid JSON that matches ChatAudioOptions format.\", ex);\n            }\n        }\n\n        throw new NotSupportedException($\"The provided audio options '{executionSettings.Audio?.GetType()}' is not supported.\");\n    }\n}\n","sourceCodeStart":246,"sourceCodeEnd":267,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.AzureOpenAI/Core/AzureClientCore.ChatCompletion.cs#L246-L267","documentation":"Thrown by AzureClientCore.GetAudioOptions when the executionSettings.Audio property is set to a type that is neither ChatAudioOptions, a System.Text.Json.JsonElement, nor a string. The method first tries a direct cast, then JSON-element parsing, then string-to-JSON parsing; if none succeed, this NotSupportedException fires. It indicates the caller supplied an audio configuration object in an unrecognized shape.","triggerScenarios":"Setting OpenAIPromptExecutionSettings.Audio to any type other than ChatAudioOptions, JsonElement, or string — e.g. an anonymous object, a dictionary, a custom POCO, or a JObject. The throw occurs at the bottom of the method after all three type branches are exhausted.","commonSituations":"Deserializing execution settings from a configuration source that materializes the Audio property as a non-supported type (e.g. a Dictionary<string,object> or an anonymous type from a JSON parser that is not System.Text.Json). Passing a custom audio options class that looks like ChatAudioOptions but is a different type. Loading settings from a YAML/JSON file whose audio node deserializes to an unexpected CLR type.","solutions":["Set executionSettings.Audio to an instance of ChatAudioOptions directly: executionSettings.Audio = new ChatAudioOptions { Voice = ChatAudioVoice.Alloy, Format = ChatAudioFormat.Wav };","If serializing/deserializing settings through System.Text.Json, ensure the Audio property round-trips as a JsonElement so the JsonElement branch handles it.","If passing a raw JSON string, ensure executionSettings.Audio is assigned a string containing valid JSON matching the ChatAudioOptions schema.","Avoid anonymous types or custom classes for the Audio property; the connector only recognizes ChatAudioOptions, JsonElement, and string."],"exampleFix":"// before — anonymous object is not recognized\nexecutionSettings.Audio = new { voice = \"alloy\", format = \"wav\" };\n\n// after — use the SDK type directly\nexecutionSettings.Audio = new ChatAudioOptions\n{\n    Voice = ChatAudioVoice.Alloy,\n    Format = ChatAudioFormat.Wav\n};","handlingStrategy":"validation","validationCode":"// Validate Audio type before the call\nif (executionSettings.Audio is not null\n    && executionSettings.Audio is not ChatAudioOptions\n    && executionSettings.Audio is not JsonElement\n    && executionSettings.Audio is not string)\n{\n    throw new ArgumentException(\n        $\"Audio must be ChatAudioOptions, JsonElement, or string, got {executionSettings.Audio.GetType().Name}\");\n}","typeGuard":"static bool IsSupportedAudio(object? audio) =>\n    audio is null or ChatAudioOptions or JsonElement or string;","tryCatchPattern":"try\n{\n    var result = await kernel.InvokeAsync(chatFunction, arguments);\n}\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"audio options\"))\n{\n    logger.LogError(\"Audio options type not supported: {Type}\", executionSettings.Audio?.GetType());\n    executionSettings.Audio = null; // fallback: disable audio\n}","preventionTips":["Always construct audio options as ChatAudioOptions directly rather than passing intermediate types.","If loading settings from JSON, deserialize into OpenAIPromptExecutionSettings which will produce a JsonElement for Audio.","Avoid anonymous types and custom classes for the Audio property."],"tags":["azure-openai","audio","configuration","type-mismatch","notsupported"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}