{"record":{"id":"199b4ba1cab0c4ed","repo":"microsoft/semantic-kernel","slug":"unsupported-audio-format-mimetype-supported-f","errorCode":null,"errorMessage":"Unsupported audio format '{mimeType}'. Supported formats are 'audio/wav' and 'audio/mp3'.","messagePattern":"Unsupported audio format '(.+?)'\\. Supported formats are 'audio/wav' and 'audio/mp3'\\.","errorType":"validation","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Connectors/Connectors.OpenAI/Core/ClientCore.ChatCompletion.cs","lineNumber":936,"sourceCode":"        {\n            return ChatMessageContentPart.CreateFilePart(BinaryData.FromBytes(data), binaryContent.MimeType, Guid.NewGuid().ToString());\n        }\n\n        throw new ArgumentException($\"{nameof(BinaryContent)} must have Data bytes.\");\n    }\n\n    private static ChatInputAudioFormat GetChatInputAudioFormat(string? mimeType)\n    {\n        if (string.IsNullOrWhiteSpace(mimeType))\n        {\n            return ChatInputAudioFormat.Mp3;\n        }\n\n        return mimeType.ToUpperInvariant() switch\n        {\n            \"AUDIO/WAV\" => ChatInputAudioFormat.Wav,\n            \"AUDIO/MP3\" => ChatInputAudioFormat.Mp3,\n            _ => throw new NotSupportedException($\"Unsupported audio format '{mimeType}'. Supported formats are 'audio/wav' and 'audio/mp3'.\")\n        };\n    }\n\n    private static ChatImageDetailLevel? GetChatImageDetailLevel(ImageContent imageContent)\n    {\n        const string DetailLevelProperty = \"ChatImageDetailLevel\";\n\n        if (imageContent.Metadata is not null &&\n            imageContent.Metadata.TryGetValue(DetailLevelProperty, out object? detailLevel) &&\n            detailLevel is not null)\n        {\n            if (detailLevel is string detailLevelString && !string.IsNullOrWhiteSpace(detailLevelString))\n            {\n                return detailLevelString.ToUpperInvariant() switch\n                {\n                    \"AUTO\" => ChatImageDetailLevel.Auto,\n                    \"LOW\" => ChatImageDetailLevel.Low,\n                    \"HIGH\" => ChatImageDetailLevel.High,","sourceCodeStart":918,"sourceCodeEnd":954,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.OpenAI/Core/ClientCore.ChatCompletion.cs#L918-L954","documentation":"Thrown by GetChatInputAudioFormat. For input audio the connector maps the mime-type to OpenAI's ChatInputAudioFormat, accepting only 'audio/wav' and 'audio/mp3'. Any other mime-type (ogg, flac, m4a, etc.) is not representable as an input-audio format and is rejected with an explicit list of allowed values.","triggerScenarios":"Building an AudioContent for chat input with a MimeType other than audio/wav or audio/mp3 (e.g. 'audio/ogg', 'audio/m4a', or a null/whitespace handled separately that still resolves elsewhere).","commonSituations":"Recording in a container format the model's realtime/audio input does not accept; mismatched file extension vs actual codec; passing a generic 'application/octet-stream'.","solutions":["Transcode the source to WAV or MP3 and set MimeType to 'audio/wav' or 'audio/mp3'.","If MimeType is missing, the connector defaults to Mp3 — supply bytes that are actually MP3 in that case.","Validate the mime-type against the allowed set before constructing AudioContent."],"exampleFix":"// before\nvar audio = new AudioContent(bytes, \"audio/ogg\");\n// after\nvar audio = new AudioContent(wavBytes, \"audio/wav\");","handlingStrategy":"validation","validationCode":"static readonly HashSet<string> ValidInputAudioMime = new(StringComparer.OrdinalIgnoreCase) { \"audio/wav\", \"audio/mp3\" };\nstatic string NormalizeInputAudioMime(string? m) => string.IsNullOrWhiteSpace(m) ? \"audio/mp3\" : ValidInputAudioMime.Contains(m) ? m.ToLowerInvariant() : throw new ArgumentException($\"Transcode to WAV/MP3; got {m}\");","typeGuard":"static bool IsValidInputAudioMime(string? m) => string.IsNullOrWhiteSpace(m) || ValidInputAudioMime.Contains(m);","tryCatchPattern":"try { await client.GetChatCompletionAsync(history); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"audio format\")) { /* transcode to wav/mp3 and retry */ }","preventionTips":["Transcode sources to WAV or MP3 at capture time.","Set MimeType explicitly to audio/wav or audio/mp3."],"tags":["openai","audio-input","audio-format","mime-type"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}