Skip to main content

gproxy_protocol/wire/openai/realtime/
session_response_audio.rs

1//! Native Realtime wire DTOs. Source definitions are cited on each object.
2//! Verified with Realtime.md and openai-python snapshot
3//! e12b81d3bbf644ec7045e152d69bc4b68d69cd48 (2026-09-13).
4//! https://github.com/openai/openai-python/tree/e12b81d3bbf644ec7045e152d69bc4b68d69cd48/src/openai/types/realtime
5use super::wire::present_nullable;
6use super::{AudioTranscription, NoiseReductionType, RealtimeAudioFormats};
7use crate::Rest;
8use serde::{Deserialize, Serialize};
9
10/// Source: `openai/types/realtime/realtime_session_create_response.py`, `Audio`.
11#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
12#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
13#[derive(gproxy_protocol_macros::DeclaredFields)]
14pub struct RealtimeSessionCreateResponseAudio {
15    #[serde(
16        default,
17        deserialize_with = "present_nullable",
18        skip_serializing_if = "Option::is_none"
19    )]
20    pub input: Option<Option<RealtimeSessionCreateResponseAudioInput>>,
21    #[serde(
22        default,
23        deserialize_with = "present_nullable",
24        skip_serializing_if = "Option::is_none"
25    )]
26    pub output: Option<Option<RealtimeSessionCreateResponseAudioOutput>>,
27    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
28    pub rest: Rest,
29}
30
31/// Source: `openai/types/realtime/realtime_session_create_response.py`, `AudioInput`.
32#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
33#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
34#[derive(gproxy_protocol_macros::DeclaredFields)]
35pub struct RealtimeSessionCreateResponseAudioInput {
36    #[serde(
37        default,
38        deserialize_with = "present_nullable",
39        skip_serializing_if = "Option::is_none"
40    )]
41    pub format: Option<Option<RealtimeAudioFormats>>,
42    #[serde(
43        default,
44        deserialize_with = "present_nullable",
45        skip_serializing_if = "Option::is_none"
46    )]
47    pub noise_reduction: Option<Option<RealtimeSessionCreateResponseAudioInputNoiseReduction>>,
48    #[serde(
49        default,
50        deserialize_with = "present_nullable",
51        skip_serializing_if = "Option::is_none"
52    )]
53    pub transcription: Option<Option<AudioTranscription>>,
54    #[serde(
55        default,
56        deserialize_with = "present_nullable",
57        skip_serializing_if = "Option::is_none"
58    )]
59    pub turn_detection: Option<Option<RealtimeSessionCreateResponseAudioInputTurnDetection>>,
60    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
61    pub rest: Rest,
62}
63
64/// Source: `openai/types/realtime/realtime_session_create_response.py`, `AudioOutput`.
65#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
66#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
67#[derive(gproxy_protocol_macros::DeclaredFields)]
68pub struct RealtimeSessionCreateResponseAudioOutput {
69    #[serde(
70        default,
71        deserialize_with = "present_nullable",
72        skip_serializing_if = "Option::is_none"
73    )]
74    pub format: Option<Option<RealtimeAudioFormats>>,
75    #[serde(
76        default,
77        deserialize_with = "present_nullable",
78        skip_serializing_if = "Option::is_none"
79    )]
80    pub speed: Option<Option<serde_json::Number>>,
81    #[serde(
82        default,
83        deserialize_with = "present_nullable",
84        skip_serializing_if = "Option::is_none"
85    )]
86    pub voice: Option<Option<String>>,
87    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
88    pub rest: Rest,
89}
90
91/// Source: `openai/types/realtime/realtime_session_create_response.py`, `AudioInputNoiseReduction`.
92#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
93#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
94#[derive(gproxy_protocol_macros::DeclaredFields)]
95pub struct RealtimeSessionCreateResponseAudioInputNoiseReduction {
96    #[serde(rename = "type")]
97    #[serde(
98        default,
99        deserialize_with = "present_nullable",
100        skip_serializing_if = "Option::is_none"
101    )]
102    pub type_: Option<Option<NoiseReductionType>>,
103    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
104    pub rest: Rest,
105}
106
107/// Source: `openai/types/realtime/realtime_session_create_response.py`, `AudioInputTurnDetection`.
108#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
109#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
110#[serde(untagged)]
111#[derive(gproxy_protocol_macros::DeclaredFields)]
112pub enum RealtimeSessionCreateResponseAudioInputTurnDetection {
113    RealtimeSessionCreateResponseAudioInputTurnDetectionServerVad(
114        RealtimeSessionCreateResponseAudioInputTurnDetectionServerVad,
115    ),
116    RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVad(
117        RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVad,
118    ),
119    Variant3(()),
120}
121
122/// Source: `openai/types/realtime/realtime_session_create_response.py`, `AudioInputTurnDetectionServerVad`.
123#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
124#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
125#[derive(gproxy_protocol_macros::DeclaredFields)]
126pub struct RealtimeSessionCreateResponseAudioInputTurnDetectionServerVad {
127    #[serde(rename = "type")]
128    pub type_: RealtimeSessionCreateResponseAudioInputTurnDetectionServerVadType,
129    #[serde(
130        default,
131        deserialize_with = "present_nullable",
132        skip_serializing_if = "Option::is_none"
133    )]
134    pub create_response: Option<Option<bool>>,
135    #[serde(
136        default,
137        deserialize_with = "present_nullable",
138        skip_serializing_if = "Option::is_none"
139    )]
140    pub idle_timeout_ms: Option<Option<i64>>,
141    #[serde(
142        default,
143        deserialize_with = "present_nullable",
144        skip_serializing_if = "Option::is_none"
145    )]
146    pub interrupt_response: Option<Option<bool>>,
147    #[serde(
148        default,
149        deserialize_with = "present_nullable",
150        skip_serializing_if = "Option::is_none"
151    )]
152    pub prefix_padding_ms: Option<Option<i64>>,
153    #[serde(
154        default,
155        deserialize_with = "present_nullable",
156        skip_serializing_if = "Option::is_none"
157    )]
158    pub silence_duration_ms: Option<Option<i64>>,
159    #[serde(
160        default,
161        deserialize_with = "present_nullable",
162        skip_serializing_if = "Option::is_none"
163    )]
164    pub threshold: Option<Option<serde_json::Number>>,
165    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
166    pub rest: Rest,
167}
168
169/// Source: `openai/types/realtime/realtime_session_create_response.py`, `AudioInputTurnDetectionSemanticVad`.
170#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
171#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
172#[derive(gproxy_protocol_macros::DeclaredFields)]
173pub struct RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVad {
174    #[serde(rename = "type")]
175    pub type_: RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadType,
176    #[serde(
177        default,
178        deserialize_with = "present_nullable",
179        skip_serializing_if = "Option::is_none"
180    )]
181    pub create_response: Option<Option<bool>>,
182    #[serde(
183        default,
184        deserialize_with = "present_nullable",
185        skip_serializing_if = "Option::is_none"
186    )]
187    pub eagerness:
188        Option<Option<RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadEagerness>>,
189    #[serde(
190        default,
191        deserialize_with = "present_nullable",
192        skip_serializing_if = "Option::is_none"
193    )]
194    pub interrupt_response: Option<Option<bool>>,
195    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
196    pub rest: Rest,
197}
198
199#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
200#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
201#[derive(gproxy_protocol_macros::DeclaredFields)]
202pub enum RealtimeSessionCreateResponseAudioInputTurnDetectionServerVadType {
203    #[serde(rename = "server_vad")]
204    ServerVad,
205}
206
207#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
208#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
209#[derive(gproxy_protocol_macros::DeclaredFields)]
210pub enum RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadType {
211    #[serde(rename = "semantic_vad")]
212    SemanticVad,
213}
214
215#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
216#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
217#[derive(gproxy_protocol_macros::DeclaredFields)]
218pub enum RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadEagerness {
219    #[serde(rename = "low")]
220    Low,
221    #[serde(rename = "medium")]
222    Medium,
223    #[serde(rename = "high")]
224    High,
225    #[serde(rename = "auto")]
226    Auto,
227}