microsoft/semantic-kernel · error · NotSupportedException

Unsupported audio output format '{audioOptions.OutputAudioFo

Error message

Unsupported audio output format '{audioOptions.OutputAudioFormat}'. Supported formats are 'wav', 'mp3', 'opus', 'aac', 'flac' and 'pcm16'.

What it means

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.

Source

Thrown at dotnet/src/Connectors/Connectors.OpenAI/Core/ClientCore.ChatCompletion.cs:1024

            return "audio/opus";
        }

        if (audioOptions.OutputAudioFormat == ChatOutputAudioFormat.Aac)
        {
            return "audio/aac";
        }

        if (audioOptions.OutputAudioFormat == ChatOutputAudioFormat.Flac)
        {
            return "audio/flac";
        }

        if (audioOptions.OutputAudioFormat == ChatOutputAudioFormat.Pcm16)
        {
            return "audio/pcm16";
        }

        throw new NotSupportedException($"Unsupported audio output format '{audioOptions.OutputAudioFormat}'. Supported formats are 'wav', 'mp3', 'opus', 'aac', 'flac' and 'pcm16'.");
    }

    private OpenAIChatMessageContent CreateChatMessageContent(ChatMessageRole chatRole, string content, ChatToolCall[] toolCalls, FunctionCallContent[]? functionCalls, IReadOnlyDictionary<string, object?>? metadata, string? authorName)
    {
        var message = new OpenAIChatMessageContent(chatRole, content, this.ModelId, toolCalls, metadata)
        {
            AuthorName = authorName,
        };

        if (functionCalls is not null)
        {
            message.Items.AddRange(functionCalls);
        }

        return message;
    }

    private List<FunctionCallContent> GetFunctionCallContents(IEnumerable<ChatToolCall> toolCalls, bool retainArgumentTypes)

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Use one of the documented formats: wav, mp3, opus, aac, flac, or pcm16.
  2. If a new format appeared, upgrade Connectors.OpenAI to a version whose switch covers it.
  3. Do not cast arbitrary integers to ChatOutputAudioFormat.

Example fix

// before
settings.Audio = new ChatAudioOptions { OutputAudioFormat = (ChatOutputAudioFormat)99 };
// after
settings.Audio = new ChatAudioOptions { OutputAudioFormat = ChatOutputAudioFormat.Wav };
Defensive patterns

Strategy: validation

Validate before calling

static readonly HashSet<ChatOutputAudioFormat> ValidOut = new() { ChatOutputAudioFormat.Wav, ChatOutputAudioFormat.Mp3, ChatOutputAudioFormat.Opus, ChatOutputAudioFormat.Aac, ChatOutputAudioFormat.Flac, ChatOutputAudioFormat.Pcm16 };
static void EnsureOutputFormat(ChatOutputAudioFormat f) { if (!ValidOut.Contains(f)) throw new ArgumentException($"Unsupported output audio format {f}"); }

Type guard

static bool IsValidOutputAudioFormat(ChatOutputAudioFormat f) => ValidOut.Contains(f);

Try / catch

try { await client.GetChatCompletionAsync(...); }
catch (NotSupportedException ex) when (ex.Message.Contains("output audio format")) { /* fall back to Wav and retry */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/df38252225fdb417. Report an issue: GitHub.