Realtime: migrate to OpenAI GA shape (beta API was retired)
Upstream returned 'beta_api_shape_disabled' on every wake. Changes:
- Drop OpenAI-Beta: realtime=v1 header from the upgrade.
- session.update payload nests audio under session.audio.{input,output}
and adds session.type='realtime'; audio.{input,output}.format is now
an object {type:audio/pcm, rate:24000} instead of 'pcm16' string.
- Default model bumped to gpt-realtime (the GA name); the relay also
promotes any stored 'gpt-4o-realtime-preview*' to gpt-realtime so
pre-Plan-3 DeviceConfig rows keep working without a manual DB edit.
This commit is contained in:
@@ -6,6 +6,12 @@ namespace backend.Realtime;
|
||||
|
||||
public static class RealtimeEvents
|
||||
{
|
||||
// GA Realtime API shape (the Beta API shape was retired in 2026 with
|
||||
// upstream error "beta_api_shape_disabled"). Key differences:
|
||||
// - session.type = "realtime" is required.
|
||||
// - voice / audio formats / transcription / turn_detection now nested
|
||||
// under session.audio.{input,output}.
|
||||
// - No OpenAI-Beta header on the upgrade (see OpenAIRealtimeUpstream).
|
||||
public static JsonObject SessionUpdate(RealtimeSettings cfg, IEnumerable<ITool> enabledTools)
|
||||
{
|
||||
var tools = new JsonArray();
|
||||
@@ -25,18 +31,36 @@ public static class RealtimeEvents
|
||||
["type"] = "session.update",
|
||||
["session"] = new JsonObject
|
||||
{
|
||||
["voice"] = cfg.Voice,
|
||||
["type"] = "realtime",
|
||||
["model"] = cfg.Model,
|
||||
["instructions"] = cfg.SystemPrompt,
|
||||
["modalities"] = new JsonArray("text", "audio"),
|
||||
["input_audio_format"] = "pcm16",
|
||||
["output_audio_format"] = "pcm16",
|
||||
["input_audio_transcription"] = new JsonObject { ["model"] = "whisper-1" },
|
||||
["turn_detection"] = new JsonObject
|
||||
["audio"] = new JsonObject
|
||||
{
|
||||
["type"] = "server_vad",
|
||||
["threshold"] = 0.5,
|
||||
["prefix_padding_ms"] = 300,
|
||||
["silence_duration_ms"] = 500,
|
||||
["input"] = new JsonObject
|
||||
{
|
||||
["format"] = new JsonObject
|
||||
{
|
||||
["type"] = "audio/pcm",
|
||||
["rate"] = 24000,
|
||||
},
|
||||
["transcription"] = new JsonObject { ["model"] = "whisper-1" },
|
||||
["turn_detection"] = new JsonObject
|
||||
{
|
||||
["type"] = "server_vad",
|
||||
["threshold"] = 0.5,
|
||||
["prefix_padding_ms"] = 300,
|
||||
["silence_duration_ms"] = 500,
|
||||
},
|
||||
},
|
||||
["output"] = new JsonObject
|
||||
{
|
||||
["voice"] = cfg.Voice,
|
||||
["format"] = new JsonObject
|
||||
{
|
||||
["type"] = "audio/pcm",
|
||||
["rate"] = 24000,
|
||||
},
|
||||
},
|
||||
},
|
||||
["tools"] = tools,
|
||||
["tool_choice"] = "auto",
|
||||
|
||||
Reference in New Issue
Block a user