{"record":{"id":"df38252225fdb417","repo":"microsoft/semantic-kernel","slug":"unsupported-audio-output-format-audiooptions-out","errorCode":null,"errorMessage":"Unsupported audio output format '{audioOptions.OutputAudioFormat}'. Supported formats are 'wav', 'mp3', 'opus', 'aac', 'flac' and 'pcm16'.","messagePattern":"Unsupported audio output format '(.+?)'\\. Supported formats are 'wav', 'mp3', 'opus', 'aac', 'flac' and 'pcm16'\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Connectors/Connectors.OpenAI/Core/ClientCore.ChatCompletion.cs","lineNumber":1024,"sourceCode":"            return \"audio/opus\";\n        }\n\n        if (audioOptions.OutputAudioFormat == ChatOutputAudioFormat.Aac)\n        {\n            return \"audio/aac\";\n        }\n\n        if (audioOptions.OutputAudioFormat == ChatOutputAudioFormat.Flac)\n        {\n            return \"audio/flac\";\n        }\n\n        if (audioOptions.OutputAudioFormat == ChatOutputAudioFormat.Pcm16)\n        {\n            return \"audio/pcm16\";\n        }\n\n        throw new NotSupportedException($\"Unsupported audio output format '{audioOptions.OutputAudioFormat}'. Supported formats are 'wav', 'mp3', 'opus', 'aac', 'flac' and 'pcm16'.\");\n    }\n\n    private OpenAIChatMessageContent CreateChatMessageContent(ChatMessageRole chatRole, string content, ChatToolCall[] toolCalls, FunctionCallContent[]? functionCalls, IReadOnlyDictionary<string, object?>? metadata, string? authorName)\n    {\n        var message = new OpenAIChatMessageContent(chatRole, content, this.ModelId, toolCalls, metadata)\n        {\n            AuthorName = authorName,\n        };\n\n        if (functionCalls is not null)\n        {\n            message.Items.AddRange(functionCalls);\n        }\n\n        return message;\n    }\n\n    private List<FunctionCallContent> GetFunctionCallContents(IEnumerable<ChatToolCall> toolCalls, bool retainArgumentTypes)","sourceCodeStart":1006,"sourceCodeEnd":1042,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.OpenAI/Core/ClientCore.ChatCompletion.cs#L1006-L1042","documentation":"Terminal throw in the output-audio-format mapper. The method converts ChatOutputAudioFormat enum values (Wav, Mp3, Opus, Aac, Flac, Pcm16) into their mime-type strings; the switch covers all current members, so reaching this throw means a new enum value exists that this build does not map. The message enumerates the supported formats.","triggerScenarios":"audioOptions.OutputAudioFormat holds an enum value not covered by the if-chain (e.g. a future ChatOutputAudioFormat member added in a newer OpenAI library referenced by the connector), or a value injected via reflection/deserialization.","commonSituations":"Version skew: the OpenAI .NET library was upgraded and introduced a new format the connector's switch has not been updated for; corrupted/forced enum value via casting an invalid integer.","solutions":["Use one of the documented formats: wav, mp3, opus, aac, flac, or pcm16.","If a new format appeared, upgrade Connectors.OpenAI to a version whose switch covers it.","Do not cast arbitrary integers to ChatOutputAudioFormat."],"exampleFix":"// before\nsettings.Audio = new ChatAudioOptions { OutputAudioFormat = (ChatOutputAudioFormat)99 };\n// after\nsettings.Audio = new ChatAudioOptions { OutputAudioFormat = ChatOutputAudioFormat.Wav };","handlingStrategy":"validation","validationCode":"static readonly HashSet<ChatOutputAudioFormat> ValidOut = new() { ChatOutputAudioFormat.Wav, ChatOutputAudioFormat.Mp3, ChatOutputAudioFormat.Opus, ChatOutputAudioFormat.Aac, ChatOutputAudioFormat.Flac, ChatOutputAudioFormat.Pcm16 };\nstatic void EnsureOutputFormat(ChatOutputAudioFormat f) { if (!ValidOut.Contains(f)) throw new ArgumentException($\"Unsupported output audio format {f}\"); }","typeGuard":"static bool IsValidOutputAudioFormat(ChatOutputAudioFormat f) => ValidOut.Contains(f);","tryCatchPattern":"try { await client.GetChatCompletionAsync(...); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"output audio format\")) { /* fall back to Wav and retry */ }","preventionTips":["Never cast arbitrary ints to the enum.","Upgrade connector if a new format member appears."],"tags":["openai","audio-output","audio-format","enum-mapping"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}