Skip to main content

gproxy_protocol/wire/openai/realtime/
client_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 super::{
7    ConversationItem, RealtimeResponseCreateParams, RealtimeSessionCreateRequest,
8    RealtimeTranscriptionSessionCreateRequest,
9};
10use crate::Rest;
11use serde::{Deserialize, Serialize};
12
13/// Source: `openai/types/realtime/conversation_item_create_event.py`, `ConversationItemCreateEvent`.
14#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
15#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
16#[derive(gproxy_protocol_macros::DeclaredFields)]
17pub struct ConversationItemCreateEvent {
18    pub item: ConversationItem,
19    #[serde(rename = "type")]
20    pub type_: ConversationItemCreateEventType,
21    #[serde(
22        default,
23        deserialize_with = "present_nullable",
24        skip_serializing_if = "Option::is_none"
25    )]
26    pub event_id: Option<Option<String>>,
27    #[serde(
28        default,
29        deserialize_with = "present_nullable",
30        skip_serializing_if = "Option::is_none"
31    )]
32    pub previous_item_id: Option<Option<String>>,
33    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
34    pub rest: Rest,
35}
36
37/// Source: `openai/types/realtime/conversation_item_delete_event.py`, `ConversationItemDeleteEvent`.
38#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
39#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
40#[derive(gproxy_protocol_macros::DeclaredFields)]
41pub struct ConversationItemDeleteEvent {
42    pub item_id: String,
43    #[serde(rename = "type")]
44    pub type_: ConversationItemDeleteEventType,
45    #[serde(
46        default,
47        deserialize_with = "present_nullable",
48        skip_serializing_if = "Option::is_none"
49    )]
50    pub event_id: Option<Option<String>>,
51    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
52    pub rest: Rest,
53}
54
55/// Source: `openai/types/realtime/conversation_item_retrieve_event.py`, `ConversationItemRetrieveEvent`.
56#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
57#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
58#[derive(gproxy_protocol_macros::DeclaredFields)]
59pub struct ConversationItemRetrieveEvent {
60    pub item_id: String,
61    #[serde(rename = "type")]
62    pub type_: ConversationItemRetrieveEventType,
63    #[serde(
64        default,
65        deserialize_with = "present_nullable",
66        skip_serializing_if = "Option::is_none"
67    )]
68    pub event_id: Option<Option<String>>,
69    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
70    pub rest: Rest,
71}
72
73/// Source: `openai/types/realtime/conversation_item_truncate_event.py`, `ConversationItemTruncateEvent`.
74#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
75#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
76#[derive(gproxy_protocol_macros::DeclaredFields)]
77pub struct ConversationItemTruncateEvent {
78    pub audio_end_ms: i64,
79    pub content_index: i64,
80    pub item_id: String,
81    #[serde(rename = "type")]
82    pub type_: ConversationItemTruncateEventType,
83    #[serde(
84        default,
85        deserialize_with = "present_nullable",
86        skip_serializing_if = "Option::is_none"
87    )]
88    pub event_id: Option<Option<String>>,
89    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
90    pub rest: Rest,
91}
92
93/// Source: `openai/types/realtime/input_audio_buffer_append_event.py`, `InputAudioBufferAppendEvent`.
94#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
95#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
96#[derive(gproxy_protocol_macros::DeclaredFields)]
97pub struct InputAudioBufferAppendEvent {
98    pub audio: String,
99    #[serde(rename = "type")]
100    pub type_: InputAudioBufferAppendEventType,
101    #[serde(
102        default,
103        deserialize_with = "present_nullable",
104        skip_serializing_if = "Option::is_none"
105    )]
106    pub event_id: Option<Option<String>>,
107    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
108    pub rest: Rest,
109}
110
111/// Source: `openai/types/realtime/input_audio_buffer_clear_event.py`, `InputAudioBufferClearEvent`.
112#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
113#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
114#[derive(gproxy_protocol_macros::DeclaredFields)]
115pub struct InputAudioBufferClearEvent {
116    #[serde(rename = "type")]
117    pub type_: InputAudioBufferClearEventType,
118    #[serde(
119        default,
120        deserialize_with = "present_nullable",
121        skip_serializing_if = "Option::is_none"
122    )]
123    pub event_id: Option<Option<String>>,
124    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
125    pub rest: Rest,
126}
127
128/// Source: `openai/types/realtime/output_audio_buffer_clear_event.py`, `OutputAudioBufferClearEvent`.
129#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
130#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
131#[derive(gproxy_protocol_macros::DeclaredFields)]
132pub struct OutputAudioBufferClearEvent {
133    #[serde(rename = "type")]
134    pub type_: OutputAudioBufferClearEventType,
135    #[serde(
136        default,
137        deserialize_with = "present_nullable",
138        skip_serializing_if = "Option::is_none"
139    )]
140    pub event_id: Option<Option<String>>,
141    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
142    pub rest: Rest,
143}
144
145/// Source: `openai/types/realtime/input_audio_buffer_commit_event.py`, `InputAudioBufferCommitEvent`.
146#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
147#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
148#[derive(gproxy_protocol_macros::DeclaredFields)]
149pub struct InputAudioBufferCommitEvent {
150    #[serde(rename = "type")]
151    pub type_: InputAudioBufferCommitEventType,
152    #[serde(
153        default,
154        deserialize_with = "present_nullable",
155        skip_serializing_if = "Option::is_none"
156    )]
157    pub event_id: Option<Option<String>>,
158    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
159    pub rest: Rest,
160}
161
162/// Source: `openai/types/realtime/response_cancel_event.py`, `ResponseCancelEvent`.
163#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
164#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
165#[derive(gproxy_protocol_macros::DeclaredFields)]
166pub struct ResponseCancelEvent {
167    #[serde(rename = "type")]
168    pub type_: ResponseCancelEventType,
169    #[serde(
170        default,
171        deserialize_with = "present_nullable",
172        skip_serializing_if = "Option::is_none"
173    )]
174    pub event_id: Option<Option<String>>,
175    #[serde(
176        default,
177        deserialize_with = "present_nullable",
178        skip_serializing_if = "Option::is_none"
179    )]
180    pub response_id: Option<Option<String>>,
181    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
182    pub rest: Rest,
183}
184
185/// Source: `openai/types/realtime/response_create_event.py`, `ResponseCreateEvent`.
186#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
187#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
188#[derive(gproxy_protocol_macros::DeclaredFields)]
189pub struct ResponseCreateEvent {
190    #[serde(rename = "type")]
191    pub type_: ResponseCreateEventType,
192    #[serde(
193        default,
194        deserialize_with = "present_nullable",
195        skip_serializing_if = "Option::is_none"
196    )]
197    pub event_id: Option<Option<String>>,
198    #[serde(
199        default,
200        deserialize_with = "present_nullable",
201        skip_serializing_if = "Option::is_none"
202    )]
203    pub response: Option<Option<RealtimeResponseCreateParams>>,
204    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
205    pub rest: Rest,
206}
207
208/// Source: `openai/types/realtime/session_update_event.py`, `SessionUpdateEvent`.
209#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
210#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
211#[derive(gproxy_protocol_macros::DeclaredFields)]
212pub struct SessionUpdateEvent {
213    pub session: SessionUpdateEventSession,
214    #[serde(rename = "type")]
215    pub type_: SessionUpdateEventType,
216    #[serde(
217        default,
218        deserialize_with = "present_nullable",
219        skip_serializing_if = "Option::is_none"
220    )]
221    pub event_id: Option<Option<String>>,
222    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
223    pub rest: Rest,
224}
225
226/// Source: `openai/types/realtime/session_update_event.py`, `Session`.
227#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
228#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
229#[serde(untagged)]
230#[allow(clippy::large_enum_variant)]
231#[derive(gproxy_protocol_macros::DeclaredFields)]
232pub enum SessionUpdateEventSession {
233    RealtimeSessionCreateRequest(RealtimeSessionCreateRequest),
234    RealtimeTranscriptionSessionCreateRequest(RealtimeTranscriptionSessionCreateRequest),
235}
236
237#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
238#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
239#[derive(gproxy_protocol_macros::DeclaredFields)]
240pub enum ConversationItemCreateEventType {
241    #[serde(rename = "conversation.item.create")]
242    ConversationItemCreate,
243}
244
245#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
246#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
247#[derive(gproxy_protocol_macros::DeclaredFields)]
248pub enum ConversationItemDeleteEventType {
249    #[serde(rename = "conversation.item.delete")]
250    ConversationItemDelete,
251}
252
253#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
254#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
255#[derive(gproxy_protocol_macros::DeclaredFields)]
256pub enum ConversationItemRetrieveEventType {
257    #[serde(rename = "conversation.item.retrieve")]
258    ConversationItemRetrieve,
259}
260
261#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
262#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
263#[derive(gproxy_protocol_macros::DeclaredFields)]
264pub enum ConversationItemTruncateEventType {
265    #[serde(rename = "conversation.item.truncate")]
266    ConversationItemTruncate,
267}
268
269#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
270#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
271#[derive(gproxy_protocol_macros::DeclaredFields)]
272pub enum InputAudioBufferAppendEventType {
273    #[serde(rename = "input_audio_buffer.append")]
274    InputAudioBufferAppend,
275}
276
277#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
278#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
279#[derive(gproxy_protocol_macros::DeclaredFields)]
280pub enum InputAudioBufferClearEventType {
281    #[serde(rename = "input_audio_buffer.clear")]
282    InputAudioBufferClear,
283}
284
285#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
286#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
287#[derive(gproxy_protocol_macros::DeclaredFields)]
288pub enum OutputAudioBufferClearEventType {
289    #[serde(rename = "output_audio_buffer.clear")]
290    OutputAudioBufferClear,
291}
292
293#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
294#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
295#[derive(gproxy_protocol_macros::DeclaredFields)]
296pub enum InputAudioBufferCommitEventType {
297    #[serde(rename = "input_audio_buffer.commit")]
298    InputAudioBufferCommit,
299}
300
301#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
302#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
303#[derive(gproxy_protocol_macros::DeclaredFields)]
304pub enum ResponseCancelEventType {
305    #[serde(rename = "response.cancel")]
306    ResponseCancel,
307}
308
309#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
310#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
311#[derive(gproxy_protocol_macros::DeclaredFields)]
312pub enum ResponseCreateEventType {
313    #[serde(rename = "response.create")]
314    ResponseCreate,
315}
316
317#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
318#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
319#[derive(gproxy_protocol_macros::DeclaredFields)]
320pub enum SessionUpdateEventType {
321    #[serde(rename = "session.update")]
322    SessionUpdate,
323}