Skip to main content

gproxy_protocol/wire/openai/realtime/
conversation_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::ConversationItem;
6use super::wire::present_nullable;
7use crate::Rest;
8use serde::{Deserialize, Serialize};
9
10/// Source: `openai/types/realtime/conversation_created_event.py`, `ConversationCreatedEvent`.
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)]
14pub struct ConversationCreatedEvent {
15    pub conversation: ConversationCreatedEventConversation,
16    pub event_id: String,
17    #[serde(rename = "type")]
18    pub type_: ConversationCreatedEventType,
19    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
20    pub rest: Rest,
21}
22
23/// Source: `openai/types/realtime/conversation_item_created_event.py`, `ConversationItemCreatedEvent`.
24#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
25#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
26#[derive(gproxy_protocol_macros::DeclaredFields)]
27pub struct ConversationItemCreatedEvent {
28    pub event_id: String,
29    pub item: ConversationItem,
30    #[serde(rename = "type")]
31    pub type_: ConversationItemCreatedEventType,
32    #[serde(
33        default,
34        deserialize_with = "present_nullable",
35        skip_serializing_if = "Option::is_none"
36    )]
37    pub previous_item_id: Option<Option<String>>,
38    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
39    pub rest: Rest,
40}
41
42/// Source: `openai/types/realtime/conversation_item_deleted_event.py`, `ConversationItemDeletedEvent`.
43#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
44#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
45#[derive(gproxy_protocol_macros::DeclaredFields)]
46pub struct ConversationItemDeletedEvent {
47    pub event_id: String,
48    pub item_id: String,
49    #[serde(rename = "type")]
50    pub type_: ConversationItemDeletedEventType,
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_truncated_event.py`, `ConversationItemTruncatedEvent`.
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 ConversationItemTruncatedEvent {
60    pub audio_end_ms: i64,
61    pub content_index: i64,
62    pub event_id: String,
63    pub item_id: String,
64    #[serde(rename = "type")]
65    pub type_: ConversationItemTruncatedEventType,
66    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
67    pub rest: Rest,
68}
69
70/// Source: `openai/types/realtime/conversation_item_added.py`, `ConversationItemAdded`.
71#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
72#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
73#[derive(gproxy_protocol_macros::DeclaredFields)]
74pub struct ConversationItemAdded {
75    pub event_id: String,
76    pub item: ConversationItem,
77    #[serde(rename = "type")]
78    pub type_: ConversationItemAddedType,
79    #[serde(
80        default,
81        deserialize_with = "present_nullable",
82        skip_serializing_if = "Option::is_none"
83    )]
84    pub previous_item_id: Option<Option<String>>,
85    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
86    pub rest: Rest,
87}
88
89/// Source: `openai/types/realtime/conversation_item_done.py`, `ConversationItemDone`.
90#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
91#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
92#[derive(gproxy_protocol_macros::DeclaredFields)]
93pub struct ConversationItemDone {
94    pub event_id: String,
95    pub item: ConversationItem,
96    #[serde(rename = "type")]
97    pub type_: ConversationItemDoneType,
98    #[serde(
99        default,
100        deserialize_with = "present_nullable",
101        skip_serializing_if = "Option::is_none"
102    )]
103    pub previous_item_id: Option<Option<String>>,
104    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
105    pub rest: Rest,
106}
107
108/// Source: `openai/types/realtime/conversation_created_event.py`, `Conversation`.
109#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
110#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
111#[derive(gproxy_protocol_macros::DeclaredFields)]
112pub struct ConversationCreatedEventConversation {
113    #[serde(
114        default,
115        deserialize_with = "present_nullable",
116        skip_serializing_if = "Option::is_none"
117    )]
118    pub id: Option<Option<String>>,
119    #[serde(
120        default,
121        deserialize_with = "present_nullable",
122        skip_serializing_if = "Option::is_none"
123    )]
124    pub object: Option<Option<ConversationCreatedEventConversationObject>>,
125    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
126    pub rest: Rest,
127}
128
129#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
130#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
131#[derive(gproxy_protocol_macros::DeclaredFields)]
132pub enum ConversationCreatedEventType {
133    #[serde(rename = "conversation.created")]
134    ConversationCreated,
135}
136
137#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
138#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
139#[derive(gproxy_protocol_macros::DeclaredFields)]
140pub enum ConversationItemCreatedEventType {
141    #[serde(rename = "conversation.item.created")]
142    ConversationItemCreated,
143}
144
145#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
146#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
147#[derive(gproxy_protocol_macros::DeclaredFields)]
148pub enum ConversationItemDeletedEventType {
149    #[serde(rename = "conversation.item.deleted")]
150    ConversationItemDeleted,
151}
152
153#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
154#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
155#[derive(gproxy_protocol_macros::DeclaredFields)]
156pub enum ConversationItemTruncatedEventType {
157    #[serde(rename = "conversation.item.truncated")]
158    ConversationItemTruncated,
159}
160
161#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
162#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
163#[derive(gproxy_protocol_macros::DeclaredFields)]
164pub enum ConversationItemAddedType {
165    #[serde(rename = "conversation.item.added")]
166    ConversationItemAdded,
167}
168
169#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
170#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
171#[derive(gproxy_protocol_macros::DeclaredFields)]
172pub enum ConversationItemDoneType {
173    #[serde(rename = "conversation.item.done")]
174    ConversationItemDone,
175}
176
177#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
178#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
179#[derive(gproxy_protocol_macros::DeclaredFields)]
180pub enum ConversationCreatedEventConversationObject {
181    #[serde(rename = "realtime.conversation")]
182    RealtimeConversation,
183}