Skip to main content

gproxy_protocol/wire/openai/realtime/
response_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::{ConversationItem, RealtimeError, RealtimeResponse};
7use crate::Rest;
8use serde::{Deserialize, Serialize};
9
10/// Source: `openai/types/realtime/realtime_error_event.py`, `RealtimeErrorEvent`.
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 RealtimeErrorEvent {
16    pub error: RealtimeError,
17    pub event_id: String,
18    #[serde(rename = "type")]
19    pub type_: RealtimeErrorEventType,
20    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
21    pub rest: Rest,
22}
23
24/// Source: `openai/types/realtime/rate_limits_updated_event.py`, `RateLimitsUpdatedEvent`.
25#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
26#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
27#[derive(gproxy_protocol_macros::DeclaredFields)]
28#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
29pub struct RateLimitsUpdatedEvent {
30    pub event_id: String,
31    pub rate_limits: Vec<RateLimitsUpdatedEventRateLimit>,
32    #[serde(rename = "type")]
33    pub type_: RateLimitsUpdatedEventType,
34    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
35    pub rest: Rest,
36}
37
38/// Source: `openai/types/realtime/response_content_part_added_event.py`, `ResponseContentPartAddedEvent`.
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 ResponseContentPartAddedEvent {
44    pub content_index: i64,
45    pub event_id: String,
46    pub item_id: String,
47    pub output_index: i64,
48    pub part: ResponseContentPartAddedEventPart,
49    pub response_id: String,
50    #[serde(rename = "type")]
51    pub type_: ResponseContentPartAddedEventType,
52    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
53    pub rest: Rest,
54}
55
56/// Source: `openai/types/realtime/response_content_part_done_event.py`, `ResponseContentPartDoneEvent`.
57#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
58#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
59#[derive(gproxy_protocol_macros::DeclaredFields)]
60#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
61pub struct ResponseContentPartDoneEvent {
62    pub content_index: i64,
63    pub event_id: String,
64    pub item_id: String,
65    pub output_index: i64,
66    pub part: ResponseContentPartDoneEventPart,
67    pub response_id: String,
68    #[serde(rename = "type")]
69    pub type_: ResponseContentPartDoneEventType,
70    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
71    pub rest: Rest,
72}
73
74/// Source: `openai/types/realtime/response_created_event.py`, `ResponseCreatedEvent`.
75#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
76#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
77#[derive(gproxy_protocol_macros::DeclaredFields)]
78#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
79pub struct ResponseCreatedEvent {
80    pub event_id: String,
81    pub response: RealtimeResponse,
82    #[serde(rename = "type")]
83    pub type_: ResponseCreatedEventType,
84    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
85    pub rest: Rest,
86}
87
88/// Source: `openai/types/realtime/response_done_event.py`, `ResponseDoneEvent`.
89#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
90#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
91#[derive(gproxy_protocol_macros::DeclaredFields)]
92#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
93pub struct ResponseDoneEvent {
94    pub event_id: String,
95    pub response: RealtimeResponse,
96    #[serde(rename = "type")]
97    pub type_: ResponseDoneEventType,
98    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
99    pub rest: Rest,
100}
101
102/// Source: `openai/types/realtime/response_function_call_arguments_delta_event.py`, `ResponseFunctionCallArgumentsDeltaEvent`.
103#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
104#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
105#[derive(gproxy_protocol_macros::DeclaredFields)]
106#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
107pub struct ResponseFunctionCallArgumentsDeltaEvent {
108    pub call_id: String,
109    pub delta: String,
110    pub event_id: String,
111    pub item_id: String,
112    pub output_index: i64,
113    pub response_id: String,
114    #[serde(rename = "type")]
115    pub type_: ResponseFunctionCallArgumentsDeltaEventType,
116    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
117    pub rest: Rest,
118}
119
120/// Source: `openai/types/realtime/response_function_call_arguments_done_event.py`, `ResponseFunctionCallArgumentsDoneEvent`.
121#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
122#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
123#[derive(gproxy_protocol_macros::DeclaredFields)]
124#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
125pub struct ResponseFunctionCallArgumentsDoneEvent {
126    pub arguments: String,
127    pub call_id: String,
128    pub event_id: String,
129    pub item_id: String,
130    pub name: String,
131    pub output_index: i64,
132    pub response_id: String,
133    #[serde(rename = "type")]
134    pub type_: ResponseFunctionCallArgumentsDoneEventType,
135    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
136    pub rest: Rest,
137}
138
139/// Source: `openai/types/realtime/response_output_item_added_event.py`, `ResponseOutputItemAddedEvent`.
140#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
141#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
142#[derive(gproxy_protocol_macros::DeclaredFields)]
143#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
144pub struct ResponseOutputItemAddedEvent {
145    pub event_id: String,
146    pub item: ConversationItem,
147    pub output_index: i64,
148    pub response_id: String,
149    #[serde(rename = "type")]
150    pub type_: ResponseOutputItemAddedEventType,
151    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
152    pub rest: Rest,
153}
154
155/// Source: `openai/types/realtime/response_output_item_done_event.py`, `ResponseOutputItemDoneEvent`.
156#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
157#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
158#[derive(gproxy_protocol_macros::DeclaredFields)]
159#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
160pub struct ResponseOutputItemDoneEvent {
161    pub event_id: String,
162    pub item: ConversationItem,
163    pub output_index: i64,
164    pub response_id: String,
165    #[serde(rename = "type")]
166    pub type_: ResponseOutputItemDoneEventType,
167    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
168    pub rest: Rest,
169}
170
171/// Source: `openai/types/realtime/response_text_delta_event.py`, `ResponseTextDeltaEvent`.
172#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
173#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
174#[derive(gproxy_protocol_macros::DeclaredFields)]
175#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
176pub struct ResponseTextDeltaEvent {
177    pub content_index: i64,
178    pub delta: String,
179    pub event_id: String,
180    pub item_id: String,
181    pub output_index: i64,
182    pub response_id: String,
183    #[serde(rename = "type")]
184    pub type_: ResponseTextDeltaEventType,
185    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
186    pub rest: Rest,
187}
188
189/// Source: `openai/types/realtime/response_text_done_event.py`, `ResponseTextDoneEvent`.
190#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
191#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
192#[derive(gproxy_protocol_macros::DeclaredFields)]
193#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
194pub struct ResponseTextDoneEvent {
195    pub content_index: i64,
196    pub event_id: String,
197    pub item_id: String,
198    pub output_index: i64,
199    pub response_id: String,
200    pub text: String,
201    #[serde(rename = "type")]
202    pub type_: ResponseTextDoneEventType,
203    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
204    pub rest: Rest,
205}
206
207/// Source: `openai/types/realtime/rate_limits_updated_event.py`, `RateLimit`.
208#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
209#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
210#[derive(gproxy_protocol_macros::DeclaredFields)]
211#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
212pub struct RateLimitsUpdatedEventRateLimit {
213    #[serde(
214        default,
215        deserialize_with = "present_nullable",
216        skip_serializing_if = "Option::is_none"
217    )]
218    pub limit: Option<Option<i64>>,
219    #[serde(
220        default,
221        deserialize_with = "present_nullable",
222        skip_serializing_if = "Option::is_none"
223    )]
224    pub name: Option<Option<RateLimitsUpdatedEventRateLimitName>>,
225    #[serde(
226        default,
227        deserialize_with = "present_nullable",
228        skip_serializing_if = "Option::is_none"
229    )]
230    pub remaining: Option<Option<i64>>,
231    #[serde(
232        default,
233        deserialize_with = "present_nullable",
234        skip_serializing_if = "Option::is_none"
235    )]
236    pub reset_seconds: Option<Option<serde_json::Number>>,
237    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
238    pub rest: Rest,
239}
240
241/// Source: `openai/types/realtime/response_content_part_added_event.py`, `Part`.
242#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
243#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
244#[derive(gproxy_protocol_macros::DeclaredFields)]
245#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
246pub struct ResponseContentPartAddedEventPart {
247    #[serde(
248        default,
249        deserialize_with = "present_nullable",
250        skip_serializing_if = "Option::is_none"
251    )]
252    pub audio: Option<Option<String>>,
253    #[serde(
254        default,
255        deserialize_with = "present_nullable",
256        skip_serializing_if = "Option::is_none"
257    )]
258    pub text: Option<Option<String>>,
259    #[serde(
260        default,
261        deserialize_with = "present_nullable",
262        skip_serializing_if = "Option::is_none"
263    )]
264    pub transcript: Option<Option<String>>,
265    #[serde(rename = "type")]
266    #[serde(
267        default,
268        deserialize_with = "present_nullable",
269        skip_serializing_if = "Option::is_none"
270    )]
271    pub type_: Option<Option<ResponseContentPartAddedEventPartType>>,
272    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
273    pub rest: Rest,
274}
275
276/// Source: `openai/types/realtime/response_content_part_done_event.py`, `Part`.
277#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
278#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
279#[derive(gproxy_protocol_macros::DeclaredFields)]
280#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
281pub struct ResponseContentPartDoneEventPart {
282    #[serde(
283        default,
284        deserialize_with = "present_nullable",
285        skip_serializing_if = "Option::is_none"
286    )]
287    pub audio: Option<Option<String>>,
288    #[serde(
289        default,
290        deserialize_with = "present_nullable",
291        skip_serializing_if = "Option::is_none"
292    )]
293    pub text: Option<Option<String>>,
294    #[serde(
295        default,
296        deserialize_with = "present_nullable",
297        skip_serializing_if = "Option::is_none"
298    )]
299    pub transcript: Option<Option<String>>,
300    #[serde(rename = "type")]
301    #[serde(
302        default,
303        deserialize_with = "present_nullable",
304        skip_serializing_if = "Option::is_none"
305    )]
306    pub type_: Option<Option<ResponseContentPartDoneEventPartType>>,
307    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
308    pub rest: Rest,
309}
310
311#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
312#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
313#[derive(gproxy_protocol_macros::DeclaredFields)]
314#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
315pub enum RealtimeErrorEventType {
316    #[serde(rename = "error")]
317    Error,
318}
319
320#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
321#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
322#[derive(gproxy_protocol_macros::DeclaredFields)]
323#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
324pub enum RateLimitsUpdatedEventType {
325    #[serde(rename = "rate_limits.updated")]
326    RateLimitsUpdated,
327}
328
329#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
330#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
331#[derive(gproxy_protocol_macros::DeclaredFields)]
332#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
333pub enum ResponseContentPartAddedEventType {
334    #[serde(rename = "response.content_part.added")]
335    ResponseContentPartAdded,
336}
337
338#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
339#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
340#[derive(gproxy_protocol_macros::DeclaredFields)]
341#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
342pub enum ResponseContentPartDoneEventType {
343    #[serde(rename = "response.content_part.done")]
344    ResponseContentPartDone,
345}
346
347#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
348#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
349#[derive(gproxy_protocol_macros::DeclaredFields)]
350#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
351pub enum ResponseCreatedEventType {
352    #[serde(rename = "response.created")]
353    ResponseCreated,
354}
355
356#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
357#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
358#[derive(gproxy_protocol_macros::DeclaredFields)]
359#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
360pub enum ResponseDoneEventType {
361    #[serde(rename = "response.done")]
362    ResponseDone,
363}
364
365#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
366#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
367#[derive(gproxy_protocol_macros::DeclaredFields)]
368#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
369pub enum ResponseFunctionCallArgumentsDeltaEventType {
370    #[serde(rename = "response.function_call_arguments.delta")]
371    ResponseFunctionCallArgumentsDelta,
372}
373
374#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
375#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
376#[derive(gproxy_protocol_macros::DeclaredFields)]
377#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
378pub enum ResponseFunctionCallArgumentsDoneEventType {
379    #[serde(rename = "response.function_call_arguments.done")]
380    ResponseFunctionCallArgumentsDone,
381}
382
383#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
384#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
385#[derive(gproxy_protocol_macros::DeclaredFields)]
386#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
387pub enum ResponseOutputItemAddedEventType {
388    #[serde(rename = "response.output_item.added")]
389    ResponseOutputItemAdded,
390}
391
392#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
393#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
394#[derive(gproxy_protocol_macros::DeclaredFields)]
395#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
396pub enum ResponseOutputItemDoneEventType {
397    #[serde(rename = "response.output_item.done")]
398    ResponseOutputItemDone,
399}
400
401#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
402#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
403#[derive(gproxy_protocol_macros::DeclaredFields)]
404#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
405pub enum ResponseTextDeltaEventType {
406    #[serde(rename = "response.output_text.delta")]
407    ResponseOutputTextDelta,
408}
409
410#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
411#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
412#[derive(gproxy_protocol_macros::DeclaredFields)]
413#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
414pub enum ResponseTextDoneEventType {
415    #[serde(rename = "response.output_text.done")]
416    ResponseOutputTextDone,
417}
418
419#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
420#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
421#[derive(gproxy_protocol_macros::DeclaredFields)]
422#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
423pub enum RateLimitsUpdatedEventRateLimitName {
424    #[serde(rename = "requests")]
425    Requests,
426    #[serde(rename = "tokens")]
427    Tokens,
428}
429
430#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
431#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
432#[derive(gproxy_protocol_macros::DeclaredFields)]
433#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
434pub enum ResponseContentPartAddedEventPartType {
435    #[serde(rename = "text")]
436    Text,
437    #[serde(rename = "audio")]
438    Audio,
439}
440
441#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
442#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
443#[derive(gproxy_protocol_macros::DeclaredFields)]
444#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
445pub enum ResponseContentPartDoneEventPartType {
446    #[serde(rename = "text")]
447    Text,
448    #[serde(rename = "audio")]
449    Audio,
450}