{"record":{"id":"f82ac262de20e7cb","repo":"microsoft/semantic-kernel","slug":"the-provided-audio-options-executionsettings-aud-f82ac2","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.OpenAI/Core/ClientCore.ChatCompletion.cs","lineNumber":1220,"sourceCode":"        if (executionSettings.Audio is JsonElement audioOptionsElement)\n        {\n            var result = ModelReaderWriter.Read<ChatAudioOptions>(BinaryData.FromString(audioOptionsElement.GetRawText()));\n            if (result != null)\n            {\n                return result;\n            }\n        }\n\n        if (executionSettings.Audio is string audioOptionsString)\n        {\n            var result = ModelReaderWriter.Read<ChatAudioOptions>(BinaryData.FromString(audioOptionsString));\n            if (result != null)\n            {\n                return result;\n            }\n        }\n\n        throw new NotSupportedException($\"The provided audio options '{executionSettings.Audio?.GetType()}' is not supported.\");\n    }\n\n    /// <summary>\n    /// Captures usage details, including token information.\n    /// </summary>\n    /// <param name=\"usage\">Instance of <see cref=\"ChatTokenUsage\"/> with token usage details.</param>\n    private void LogUsage(ChatTokenUsage usage)\n    {\n        if (usage is null)\n        {\n            this.Logger!.LogDebug(\"Token usage information unavailable.\");\n            return;\n        }\n\n        if (this.Logger!.IsEnabled(LogLevel.Information))\n        {\n            this.Logger.LogInformation(\n                \"Prompt tokens: {InputTokenCount}. Completion tokens: {OutputTokenCount}. Total tokens: {TotalTokenCount}.\",","sourceCodeStart":1202,"sourceCodeEnd":1238,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.OpenAI/Core/ClientCore.ChatCompletion.cs#L1202-L1238","documentation":"Terminal throw in the audio-options mapper. After attempting ChatAudioOptions instances and a JSON string (via ModelReaderWriter.Read), any other runtime type for executionSettings.Audio cannot be converted and its GetType() is reported.","triggerScenarios":"Setting Audio to a Dictionary<string,object>, an anonymous object, a JsonElement of object kind, or a custom DTO instead of a ChatAudioOptions or a JSON string.","commonSituations":"Building settings from dynamic JSON; interop with System.Text.Json.Nodes; passing a partial object from another library.","solutions":["Pass a ChatAudioOptions instance or a JSON string that deserializes into one.","Serialize dictionaries/anonymous objects to a JSON string first.","Avoid JsonElement unless you first stringify it."],"exampleFix":"// before\nsettings.Audio = new Dictionary<string,object> { [\"voice\"] = \"alloy\" };\n// after\nsettings.Audio = \"{\\\"voice\\\":\\\"alloy\\\",\\\"format\\\":\\\"wav\\\"}\";","handlingStrategy":"type-guard","validationCode":"static bool IsSupportedAudioOptions(object? o) => o is ChatAudioOptions or string or JsonElement;","typeGuard":"static bool IsSupportedAudioOptions(object? o) => o is ChatAudioOptions or string or JsonElement;","tryCatchPattern":"try { await client.GetChatCompletionAsync(...); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"audio options\")) { settings.Audio = null; }","preventionTips":["Prefer ChatAudioOptions instances.","Serialize dictionaries to JSON strings before assigning."],"tags":["openai","chat-completion","audio-options","type-coercion"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}