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