Skip to main content

gproxy_protocol/wire/openai/realtime/
transcription.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::RealtimeAudioFormats;
6use super::wire::present_nullable;
7use crate::Rest;
8use serde::{Deserialize, Serialize};
9
10/// Source: `openai/types/audio/transcription_language.py`, `TranscriptionLanguage`.
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)]
14#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
15pub struct TranscriptionLanguage {
16    pub code: String,
17    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
18    pub rest: Rest,
19}
20
21/// Source: `openai/types/realtime/log_prob_properties.py`, `LogProbProperties`.
22#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
23#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
24#[derive(gproxy_protocol_macros::DeclaredFields)]
25#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
26pub struct LogProbProperties {
27    pub token: String,
28    pub bytes: Vec<i64>,
29    pub logprob: serde_json::Number,
30    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
31    pub rest: Rest,
32}
33
34/// Source: `openai/types/realtime/realtime_transcription_session_create_request.py`, `RealtimeTranscriptionSessionCreateRequest`.
35#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
36#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
37#[derive(gproxy_protocol_macros::DeclaredFields)]
38#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
39pub struct RealtimeTranscriptionSessionCreateRequest {
40    #[serde(rename = "type")]
41    pub type_: RealtimeTranscriptionSessionCreateRequestType,
42    #[serde(
43        default,
44        deserialize_with = "present_nullable",
45        skip_serializing_if = "Option::is_none"
46    )]
47    pub audio: Option<Option<RealtimeTranscriptionSessionAudio>>,
48    #[serde(
49        default,
50        deserialize_with = "present_nullable",
51        skip_serializing_if = "Option::is_none"
52    )]
53    pub include: Option<Option<Vec<RealtimeTranscriptionSessionCreateRequestIncludeItem>>>,
54    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
55    pub rest: Rest,
56}
57
58/// Source: `openai/types/realtime/audio_transcription.py`, `AudioTranscription`.
59#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
60#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
61#[derive(gproxy_protocol_macros::DeclaredFields)]
62#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
63pub struct AudioTranscription {
64    #[serde(
65        default,
66        deserialize_with = "present_nullable",
67        skip_serializing_if = "Option::is_none"
68    )]
69    pub delay: Option<Option<AudioTranscriptionDelay>>,
70    #[serde(
71        default,
72        deserialize_with = "present_nullable",
73        skip_serializing_if = "Option::is_none"
74    )]
75    pub keywords: Option<Option<Vec<String>>>,
76    #[serde(
77        default,
78        deserialize_with = "present_nullable",
79        skip_serializing_if = "Option::is_none"
80    )]
81    pub language: Option<Option<String>>,
82    #[serde(
83        default,
84        deserialize_with = "present_nullable",
85        skip_serializing_if = "Option::is_none"
86    )]
87    pub languages: Option<Option<Vec<String>>>,
88    #[serde(
89        default,
90        deserialize_with = "present_nullable",
91        skip_serializing_if = "Option::is_none"
92    )]
93    pub model: Option<Option<String>>,
94    #[serde(
95        default,
96        deserialize_with = "present_nullable",
97        skip_serializing_if = "Option::is_none"
98    )]
99    pub prompt: Option<Option<String>>,
100    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
101    pub rest: Rest,
102}
103
104/// Source: `openai/types/realtime/realtime_transcription_session_audio.py`, `RealtimeTranscriptionSessionAudio`.
105#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
106#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
107#[derive(gproxy_protocol_macros::DeclaredFields)]
108#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
109pub struct RealtimeTranscriptionSessionAudio {
110    #[serde(
111        default,
112        deserialize_with = "present_nullable",
113        skip_serializing_if = "Option::is_none"
114    )]
115    pub input: Option<Option<RealtimeTranscriptionSessionAudioInput>>,
116    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
117    pub rest: Rest,
118}
119
120/// Source: `openai/types/realtime/noise_reduction_type.py`, `NoiseReductionType`.
121#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
122#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
123#[derive(gproxy_protocol_macros::DeclaredFields)]
124#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
125pub enum NoiseReductionType {
126    #[serde(rename = "near_field")]
127    NearField,
128    #[serde(rename = "far_field")]
129    FarField,
130}
131
132/// Source: `openai/types/realtime/realtime_transcription_session_audio_input.py`, `RealtimeTranscriptionSessionAudioInput`.
133#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
134#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
135#[derive(gproxy_protocol_macros::DeclaredFields)]
136#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
137pub struct RealtimeTranscriptionSessionAudioInput {
138    #[serde(
139        default,
140        deserialize_with = "present_nullable",
141        skip_serializing_if = "Option::is_none"
142    )]
143    pub format: Option<Option<RealtimeAudioFormats>>,
144    #[serde(
145        default,
146        deserialize_with = "present_nullable",
147        skip_serializing_if = "Option::is_none"
148    )]
149    pub noise_reduction: Option<Option<RealtimeTranscriptionSessionAudioInputNoiseReduction>>,
150    #[serde(
151        default,
152        deserialize_with = "present_nullable",
153        skip_serializing_if = "Option::is_none"
154    )]
155    pub transcription: Option<Option<AudioTranscription>>,
156    #[serde(
157        default,
158        deserialize_with = "present_nullable",
159        skip_serializing_if = "Option::is_none"
160    )]
161    pub turn_detection: Option<Option<RealtimeTranscriptionSessionAudioInputTurnDetection>>,
162    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
163    pub rest: Rest,
164}
165
166/// Source: `openai/types/realtime/realtime_transcription_session_audio_input.py`, `NoiseReduction`.
167#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
168#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
169#[derive(gproxy_protocol_macros::DeclaredFields)]
170#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
171pub struct RealtimeTranscriptionSessionAudioInputNoiseReduction {
172    #[serde(rename = "type")]
173    #[serde(
174        default,
175        deserialize_with = "present_nullable",
176        skip_serializing_if = "Option::is_none"
177    )]
178    pub type_: Option<Option<NoiseReductionType>>,
179    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
180    pub rest: Rest,
181}
182
183/// Source: `openai/types/realtime/realtime_transcription_session_audio_input_turn_detection.py`, `RealtimeTranscriptionSessionAudioInputTurnDetection`.
184#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
185#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
186#[serde(untagged)]
187#[derive(gproxy_protocol_macros::DeclaredFields)]
188#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
189pub enum RealtimeTranscriptionSessionAudioInputTurnDetection {
190    RealtimeTranscriptionSessionAudioInputTurnDetectionServerVad(
191        RealtimeTranscriptionSessionAudioInputTurnDetectionServerVad,
192    ),
193    RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVad(
194        RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVad,
195    ),
196    Variant3(()),
197}
198
199/// Source: `openai/types/realtime/realtime_transcription_session_audio_input_turn_detection.py`, `ServerVad`.
200#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
201#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
202#[derive(gproxy_protocol_macros::DeclaredFields)]
203#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
204pub struct RealtimeTranscriptionSessionAudioInputTurnDetectionServerVad {
205    #[serde(rename = "type")]
206    pub type_: RealtimeTranscriptionSessionAudioInputTurnDetectionServerVadType,
207    #[serde(
208        default,
209        deserialize_with = "present_nullable",
210        skip_serializing_if = "Option::is_none"
211    )]
212    pub create_response: Option<Option<bool>>,
213    #[serde(
214        default,
215        deserialize_with = "present_nullable",
216        skip_serializing_if = "Option::is_none"
217    )]
218    pub idle_timeout_ms: Option<Option<i64>>,
219    #[serde(
220        default,
221        deserialize_with = "present_nullable",
222        skip_serializing_if = "Option::is_none"
223    )]
224    pub interrupt_response: Option<Option<bool>>,
225    #[serde(
226        default,
227        deserialize_with = "present_nullable",
228        skip_serializing_if = "Option::is_none"
229    )]
230    pub prefix_padding_ms: Option<Option<i64>>,
231    #[serde(
232        default,
233        deserialize_with = "present_nullable",
234        skip_serializing_if = "Option::is_none"
235    )]
236    pub silence_duration_ms: Option<Option<i64>>,
237    #[serde(
238        default,
239        deserialize_with = "present_nullable",
240        skip_serializing_if = "Option::is_none"
241    )]
242    pub threshold: Option<Option<serde_json::Number>>,
243    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
244    pub rest: Rest,
245}
246
247/// Source: `openai/types/realtime/realtime_transcription_session_audio_input_turn_detection.py`, `SemanticVad`.
248#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
249#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
250#[derive(gproxy_protocol_macros::DeclaredFields)]
251#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
252pub struct RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVad {
253    #[serde(rename = "type")]
254    pub type_: RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadType,
255    #[serde(
256        default,
257        deserialize_with = "present_nullable",
258        skip_serializing_if = "Option::is_none"
259    )]
260    pub create_response: Option<Option<bool>>,
261    #[serde(
262        default,
263        deserialize_with = "present_nullable",
264        skip_serializing_if = "Option::is_none"
265    )]
266    pub eagerness:
267        Option<Option<RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadEagerness>>,
268    #[serde(
269        default,
270        deserialize_with = "present_nullable",
271        skip_serializing_if = "Option::is_none"
272    )]
273    pub interrupt_response: Option<Option<bool>>,
274    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
275    pub rest: Rest,
276}
277
278#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
279#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
280#[derive(gproxy_protocol_macros::DeclaredFields)]
281#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
282pub enum RealtimeTranscriptionSessionCreateRequestType {
283    #[serde(rename = "transcription")]
284    Transcription,
285}
286
287#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
288#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
289#[derive(gproxy_protocol_macros::DeclaredFields)]
290#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
291pub enum RealtimeTranscriptionSessionCreateRequestIncludeItem {
292    #[serde(rename = "item.input_audio_transcription.logprobs")]
293    ItemInputAudioTranscriptionLogprobs,
294}
295
296#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
297#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
298#[derive(gproxy_protocol_macros::DeclaredFields)]
299#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
300pub enum AudioTranscriptionDelay {
301    #[serde(rename = "minimal")]
302    Minimal,
303    #[serde(rename = "low")]
304    Low,
305    #[serde(rename = "medium")]
306    Medium,
307    #[serde(rename = "high")]
308    High,
309    #[serde(rename = "xhigh")]
310    Xhigh,
311}
312
313#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
314#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
315#[derive(gproxy_protocol_macros::DeclaredFields)]
316#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
317pub enum RealtimeTranscriptionSessionAudioInputTurnDetectionServerVadType {
318    #[serde(rename = "server_vad")]
319    ServerVad,
320}
321
322#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
323#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
324#[derive(gproxy_protocol_macros::DeclaredFields)]
325#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
326pub enum RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadType {
327    #[serde(rename = "semantic_vad")]
328    SemanticVad,
329}
330
331#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
332#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
333#[derive(gproxy_protocol_macros::DeclaredFields)]
334#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
335pub enum RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadEagerness {
336    #[serde(rename = "low")]
337    Low,
338    #[serde(rename = "medium")]
339    Medium,
340    #[serde(rename = "high")]
341    High,
342    #[serde(rename = "auto")]
343    Auto,
344}