Skip to main content

gproxy_protocol/wire/openai/realtime/
legacy_items.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_optional;
6use crate::Rest;
7use serde::{Deserialize, Serialize};
8// The local Markdown describes item_reference in prose despite omitting it from its literal list.
9
10/// Source: `upstream_docs/openai/docs/Realtime.md`, Conversation Item With Reference, `ConversationItemWithReference`.
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 ConversationItemWithReferencePayload {
16    #[serde(
17        default,
18        deserialize_with = "present_optional",
19        skip_serializing_if = "Option::is_none"
20    )]
21    pub id: Option<String>,
22    #[serde(
23        default,
24        deserialize_with = "present_optional",
25        skip_serializing_if = "Option::is_none"
26    )]
27    pub arguments: Option<String>,
28    #[serde(
29        default,
30        deserialize_with = "present_optional",
31        skip_serializing_if = "Option::is_none"
32    )]
33    pub call_id: Option<String>,
34    #[serde(
35        default,
36        deserialize_with = "present_optional",
37        skip_serializing_if = "Option::is_none"
38    )]
39    pub content: Option<Vec<ConversationItemWithReferenceContent>>,
40    #[serde(
41        default,
42        deserialize_with = "present_optional",
43        skip_serializing_if = "Option::is_none"
44    )]
45    pub name: Option<String>,
46    #[serde(
47        default,
48        deserialize_with = "present_optional",
49        skip_serializing_if = "Option::is_none"
50    )]
51    pub object: Option<ConversationItemWithReferenceObject>,
52    #[serde(
53        default,
54        deserialize_with = "present_optional",
55        skip_serializing_if = "Option::is_none"
56    )]
57    pub output: Option<String>,
58    #[serde(
59        default,
60        deserialize_with = "present_optional",
61        skip_serializing_if = "Option::is_none"
62    )]
63    pub role: Option<ConversationItemWithReferenceRole>,
64    #[serde(
65        default,
66        deserialize_with = "present_optional",
67        skip_serializing_if = "Option::is_none"
68    )]
69    pub status: Option<ConversationItemWithReferenceStatus>,
70    #[serde(rename = "type")]
71    #[serde(
72        default,
73        deserialize_with = "present_optional",
74        skip_serializing_if = "Option::is_none"
75    )]
76    pub type_: Option<ConversationItemWithReferenceType>,
77    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
78    pub rest: Rest,
79}
80
81/// Source: `upstream_docs/openai/docs/Realtime.md`, Conversation Item With Reference, `ConversationItemWithReferenceContent`.
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)]
85#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
86pub struct ConversationItemWithReferenceContent {
87    #[serde(
88        default,
89        deserialize_with = "present_optional",
90        skip_serializing_if = "Option::is_none"
91    )]
92    pub id: Option<String>,
93    #[serde(
94        default,
95        deserialize_with = "present_optional",
96        skip_serializing_if = "Option::is_none"
97    )]
98    pub audio: Option<String>,
99    #[serde(
100        default,
101        deserialize_with = "present_optional",
102        skip_serializing_if = "Option::is_none"
103    )]
104    pub text: Option<String>,
105    #[serde(
106        default,
107        deserialize_with = "present_optional",
108        skip_serializing_if = "Option::is_none"
109    )]
110    pub transcript: Option<String>,
111    #[serde(rename = "type")]
112    #[serde(
113        default,
114        deserialize_with = "present_optional",
115        skip_serializing_if = "Option::is_none"
116    )]
117    pub type_: Option<ConversationItemWithReferenceContentType>,
118    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
119    pub rest: Rest,
120}
121
122#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
123#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
124#[derive(gproxy_protocol_macros::DeclaredFields)]
125#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
126pub enum ConversationItemWithReferenceObject {
127    #[serde(rename = "realtime.item")]
128    RealtimeItem,
129}
130
131#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
132#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
133#[derive(gproxy_protocol_macros::DeclaredFields)]
134#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
135pub enum ConversationItemWithReferenceRole {
136    #[serde(rename = "user")]
137    User,
138    #[serde(rename = "assistant")]
139    Assistant,
140    #[serde(rename = "system")]
141    System,
142}
143
144#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
145#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
146#[derive(gproxy_protocol_macros::DeclaredFields)]
147#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
148pub enum ConversationItemWithReferenceStatus {
149    #[serde(rename = "completed")]
150    Completed,
151    #[serde(rename = "incomplete")]
152    Incomplete,
153    #[serde(rename = "in_progress")]
154    InProgress,
155}
156
157#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
158#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
159#[derive(gproxy_protocol_macros::DeclaredFields)]
160#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
161pub enum ConversationItemWithReferenceType {
162    #[serde(rename = "message")]
163    Message,
164    #[serde(rename = "function_call")]
165    FunctionCall,
166    #[serde(rename = "function_call_output")]
167    FunctionCallOutput,
168}
169
170#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
171#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
172#[derive(gproxy_protocol_macros::DeclaredFields)]
173#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
174pub enum ConversationItemWithReferenceContentType {
175    #[serde(rename = "input_audio")]
176    InputAudio,
177    #[serde(rename = "input_text")]
178    InputText,
179    #[serde(rename = "item_reference")]
180    ItemReference,
181    #[serde(rename = "text")]
182    Text,
183}
184
185/// References require an id; other legacy item fields follow the standalone Markdown shape.
186#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
187#[serde(untagged)]
188#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
189#[derive(gproxy_protocol_macros::DeclaredFields)]
190#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
191pub enum ConversationItemWithReference {
192    Item(ConversationItemWithReferencePayload),
193    Reference(ConversationItemReference),
194}
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 ConversationItemReference {
200    pub id: String,
201    #[serde(rename = "type")]
202    pub type_: ConversationItemReferenceType,
203    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
204    pub rest: Rest,
205}
206#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
207#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
208#[derive(gproxy_protocol_macros::DeclaredFields)]
209#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
210pub enum ConversationItemReferenceType {
211    #[serde(rename = "item_reference")]
212    ItemReference,
213}