microsoft/semantic-kernel · error · NotSupportedException
The provided audio options '{executionSettings.Audio?.GetTyp
Error message
The provided audio options '{executionSettings.Audio?.GetType()}' is not supported. What it means
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.
Source
Thrown at dotnet/src/Connectors/Connectors.OpenAI/Core/ClientCore.ChatCompletion.cs:1220
if (executionSettings.Audio is JsonElement audioOptionsElement)
{
var result = ModelReaderWriter.Read<ChatAudioOptions>(BinaryData.FromString(audioOptionsElement.GetRawText()));
if (result != null)
{
return result;
}
}
if (executionSettings.Audio is string audioOptionsString)
{
var result = ModelReaderWriter.Read<ChatAudioOptions>(BinaryData.FromString(audioOptionsString));
if (result != null)
{
return result;
}
}
throw new NotSupportedException($"The provided audio options '{executionSettings.Audio?.GetType()}' is not supported.");
}
/// <summary>
/// Captures usage details, including token information.
/// </summary>
/// <param name="usage">Instance of <see cref="ChatTokenUsage"/> with token usage details.</param>
private void LogUsage(ChatTokenUsage usage)
{
if (usage is null)
{
this.Logger!.LogDebug("Token usage information unavailable.");
return;
}
if (this.Logger!.IsEnabled(LogLevel.Information))
{
this.Logger.LogInformation(
"Prompt tokens: {InputTokenCount}. Completion tokens: {OutputTokenCount}. Total tokens: {TotalTokenCount}.",View on GitHub (pinned to c028a0c7dc)
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.
Example fix
// before
settings.Audio = new Dictionary<string,object> { ["voice"] = "alloy" };
// after
settings.Audio = "{\"voice\":\"alloy\",\"format\":\"wav\"}"; Defensive patterns
Strategy: type-guard
Validate before calling
static bool IsSupportedAudioOptions(object? o) => o is ChatAudioOptions or string or JsonElement;
Type guard
static bool IsSupportedAudioOptions(object? o) => o is ChatAudioOptions or string or JsonElement;
Try / catch
try { await client.GetChatCompletionAsync(...); }
catch (NotSupportedException ex) when (ex.Message.Contains("audio options")) { settings.Audio = null; } Prevention
- Prefer ChatAudioOptions instances.
- Serialize dictionaries to JSON strings before assigning.
When it happens
Trigger: 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.
Common situations: Building settings from dynamic JSON; interop with System.Text.Json.Nodes; passing a partial object from another library.
Related errors
- The provided reasoning effort '{effortLevelObject.GetType()}
- The provided web search options '{executionSettings.WebSearc
- The provided response modalities '{executionSettings.Modalit
- Failed to get a response from the chat completion service.
- The provided reasoning effort '{textEffortLevel}' is not sup
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/f82ac262de20e7cb.
Report an issue: GitHub.