Skip to main content

gproxy_protocol/wire/openai/realtime/
audio_events.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 crate::Rest;
7use serde::{Deserialize, Serialize};
8
9/// Source: `openai/types/realtime/input_audio_buffer_cleared_event.py`, `InputAudioBufferClearedEvent`.
10#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
11#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
12#[derive(gproxy_protocol_macros::DeclaredFields)]
13pub struct InputAudioBufferClearedEvent {
14    pub event_id: String,
15    #[serde(rename = "type")]
16    pub type_: InputAudioBufferClearedEventType,
17    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
18    pub rest: Rest,
19}
20
21/// Source: `openai/types/realtime/input_audio_buffer_committed_event.py`, `InputAudioBufferCommittedEvent`.
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)]
25pub struct InputAudioBufferCommittedEvent {
26    pub event_id: String,
27    pub item_id: String,
28    #[serde(rename = "type")]
29    pub type_: InputAudioBufferCommittedEventType,
30    #[serde(
31        default,
32        deserialize_with = "present_nullable",
33        skip_serializing_if = "Option::is_none"
34    )]
35    pub previous_item_id: Option<Option<String>>,
36    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
37    pub rest: Rest,
38}
39
40/// Source: `openai/types/realtime/input_audio_buffer_dtmf_event_received_event.py`, `InputAudioBufferDtmfEventReceivedEvent`.
41#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
42#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
43#[derive(gproxy_protocol_macros::DeclaredFields)]
44pub struct InputAudioBufferDtmfEventReceivedEvent {
45    pub event: String,
46    pub received_at: i64,
47    #[serde(rename = "type")]
48    pub type_: InputAudioBufferDtmfEventReceivedEventType,
49    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
50    pub rest: Rest,
51}
52
53/// Source: `openai/types/realtime/input_audio_buffer_speech_started_event.py`, `InputAudioBufferSpeechStartedEvent`.
54#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
55#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
56#[derive(gproxy_protocol_macros::DeclaredFields)]
57pub struct InputAudioBufferSpeechStartedEvent {
58    pub audio_start_ms: i64,
59    pub event_id: String,
60    pub item_id: String,
61    #[serde(rename = "type")]
62    pub type_: InputAudioBufferSpeechStartedEventType,
63    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
64    pub rest: Rest,
65}
66
67/// Source: `openai/types/realtime/input_audio_buffer_speech_stopped_event.py`, `InputAudioBufferSpeechStoppedEvent`.
68#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
69#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
70#[derive(gproxy_protocol_macros::DeclaredFields)]
71pub struct InputAudioBufferSpeechStoppedEvent {
72    pub audio_end_ms: i64,
73    pub event_id: String,
74    pub item_id: String,
75    #[serde(rename = "type")]
76    pub type_: InputAudioBufferSpeechStoppedEventType,
77    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
78    pub rest: Rest,
79}
80
81/// Source: `openai/types/realtime/response_audio_delta_event.py`, `ResponseAudioDeltaEvent`.
82#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
83#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
84#[derive(gproxy_protocol_macros::DeclaredFields)]
85pub struct ResponseAudioDeltaEvent {
86    pub content_index: i64,
87    pub delta: String,
88    pub event_id: String,
89    pub item_id: String,
90    pub output_index: i64,
91    pub response_id: String,
92    #[serde(rename = "type")]
93    pub type_: ResponseAudioDeltaEventType,
94    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
95    pub rest: Rest,
96}
97
98/// Source: `openai/types/realtime/response_audio_done_event.py`, `ResponseAudioDoneEvent`.
99#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
100#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
101#[derive(gproxy_protocol_macros::DeclaredFields)]
102pub struct ResponseAudioDoneEvent {
103    pub content_index: i64,
104    pub event_id: String,
105    pub item_id: String,
106    pub output_index: i64,
107    pub response_id: String,
108    #[serde(rename = "type")]
109    pub type_: ResponseAudioDoneEventType,
110    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
111    pub rest: Rest,
112}
113
114/// Source: `openai/types/realtime/response_audio_transcript_delta_event.py`, `ResponseAudioTranscriptDeltaEvent`.
115#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
116#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
117#[derive(gproxy_protocol_macros::DeclaredFields)]
118pub struct ResponseAudioTranscriptDeltaEvent {
119    pub content_index: i64,
120    pub delta: String,
121    pub event_id: String,
122    pub item_id: String,
123    pub output_index: i64,
124    pub response_id: String,
125    #[serde(rename = "type")]
126    pub type_: ResponseAudioTranscriptDeltaEventType,
127    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
128    pub rest: Rest,
129}
130
131/// Source: `openai/types/realtime/response_audio_transcript_done_event.py`, `ResponseAudioTranscriptDoneEvent`.
132#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
133#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
134#[derive(gproxy_protocol_macros::DeclaredFields)]
135pub struct ResponseAudioTranscriptDoneEvent {
136    pub content_index: i64,
137    pub event_id: String,
138    pub item_id: String,
139    pub output_index: i64,
140    pub response_id: String,
141    pub transcript: String,
142    #[serde(rename = "type")]
143    pub type_: ResponseAudioTranscriptDoneEventType,
144    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
145    pub rest: Rest,
146}
147
148/// Source: `openai/types/realtime/input_audio_buffer_timeout_triggered.py`, `InputAudioBufferTimeoutTriggered`.
149#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
150#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
151#[derive(gproxy_protocol_macros::DeclaredFields)]
152pub struct InputAudioBufferTimeoutTriggered {
153    pub audio_end_ms: i64,
154    pub audio_start_ms: i64,
155    pub event_id: String,
156    pub item_id: String,
157    #[serde(rename = "type")]
158    pub type_: InputAudioBufferTimeoutTriggeredType,
159    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
160    pub rest: Rest,
161}
162
163#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
164#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
165#[derive(gproxy_protocol_macros::DeclaredFields)]
166pub enum InputAudioBufferClearedEventType {
167    #[serde(rename = "input_audio_buffer.cleared")]
168    InputAudioBufferCleared,
169}
170
171#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
172#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
173#[derive(gproxy_protocol_macros::DeclaredFields)]
174pub enum InputAudioBufferCommittedEventType {
175    #[serde(rename = "input_audio_buffer.committed")]
176    InputAudioBufferCommitted,
177}
178
179#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
180#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
181#[derive(gproxy_protocol_macros::DeclaredFields)]
182pub enum InputAudioBufferDtmfEventReceivedEventType {
183    #[serde(rename = "input_audio_buffer.dtmf_event_received")]
184    InputAudioBufferDtmfEventReceived,
185}
186
187#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
188#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
189#[derive(gproxy_protocol_macros::DeclaredFields)]
190pub enum InputAudioBufferSpeechStartedEventType {
191    #[serde(rename = "input_audio_buffer.speech_started")]
192    InputAudioBufferSpeechStarted,
193}
194
195#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
196#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
197#[derive(gproxy_protocol_macros::DeclaredFields)]
198pub enum InputAudioBufferSpeechStoppedEventType {
199    #[serde(rename = "input_audio_buffer.speech_stopped")]
200    InputAudioBufferSpeechStopped,
201}
202
203#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
204#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
205#[derive(gproxy_protocol_macros::DeclaredFields)]
206pub enum ResponseAudioDeltaEventType {
207    #[serde(rename = "response.output_audio.delta")]
208    ResponseOutputAudioDelta,
209}
210
211#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
212#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
213#[derive(gproxy_protocol_macros::DeclaredFields)]
214pub enum ResponseAudioDoneEventType {
215    #[serde(rename = "response.output_audio.done")]
216    ResponseOutputAudioDone,
217}
218
219#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
220#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
221#[derive(gproxy_protocol_macros::DeclaredFields)]
222pub enum ResponseAudioTranscriptDeltaEventType {
223    #[serde(rename = "response.output_audio_transcript.delta")]
224    ResponseOutputAudioTranscriptDelta,
225}
226
227#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
228#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
229#[derive(gproxy_protocol_macros::DeclaredFields)]
230pub enum ResponseAudioTranscriptDoneEventType {
231    #[serde(rename = "response.output_audio_transcript.done")]
232    ResponseOutputAudioTranscriptDone,
233}
234
235#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
236#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
237#[derive(gproxy_protocol_macros::DeclaredFields)]
238pub enum InputAudioBufferTimeoutTriggeredType {
239    #[serde(rename = "input_audio_buffer.timeout_triggered")]
240    InputAudioBufferTimeoutTriggered,
241}