1use super::wire::present_nullable;
6use super::{ConversationItem, Metadata, RealtimeAudioFormats};
7use crate::Rest;
8use serde::{Deserialize, Serialize};
9
10#[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 RealtimeResponse {
16 #[serde(
17 default,
18 deserialize_with = "present_nullable",
19 skip_serializing_if = "Option::is_none"
20 )]
21 pub id: Option<Option<String>>,
22 #[serde(
23 default,
24 deserialize_with = "present_nullable",
25 skip_serializing_if = "Option::is_none"
26 )]
27 pub audio: Option<Option<RealtimeResponseAudio>>,
28 #[serde(
29 default,
30 deserialize_with = "present_nullable",
31 skip_serializing_if = "Option::is_none"
32 )]
33 pub conversation_id: Option<Option<String>>,
34 #[serde(
35 default,
36 deserialize_with = "present_nullable",
37 skip_serializing_if = "Option::is_none"
38 )]
39 pub max_output_tokens: Option<Option<RealtimeResponseMaxOutputTokens>>,
40 #[serde(
41 default,
42 deserialize_with = "present_nullable",
43 skip_serializing_if = "Option::is_none"
44 )]
45 pub metadata: Option<Option<Metadata>>,
46 #[serde(
47 default,
48 deserialize_with = "present_nullable",
49 skip_serializing_if = "Option::is_none"
50 )]
51 pub object: Option<Option<RealtimeResponseObject>>,
52 #[serde(
53 default,
54 deserialize_with = "present_nullable",
55 skip_serializing_if = "Option::is_none"
56 )]
57 pub output: Option<Option<Vec<ConversationItem>>>,
58 #[serde(
59 default,
60 deserialize_with = "present_nullable",
61 skip_serializing_if = "Option::is_none"
62 )]
63 pub output_modalities: Option<Option<Vec<RealtimeResponseOutputModalitiesItem>>>,
64 #[serde(
65 default,
66 deserialize_with = "present_nullable",
67 skip_serializing_if = "Option::is_none"
68 )]
69 pub status: Option<Option<RealtimeResponseStatusValue>>,
70 #[serde(
71 default,
72 deserialize_with = "present_nullable",
73 skip_serializing_if = "Option::is_none"
74 )]
75 pub status_details: Option<Option<RealtimeResponseStatus>>,
76 #[serde(
77 default,
78 deserialize_with = "present_nullable",
79 skip_serializing_if = "Option::is_none"
80 )]
81 pub usage: Option<Option<RealtimeResponseUsage>>,
82 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
83 pub rest: Rest,
84}
85
86#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
88#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
89#[derive(gproxy_protocol_macros::DeclaredFields)]
90#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
91pub struct RealtimeResponseAudio {
92 #[serde(
93 default,
94 deserialize_with = "present_nullable",
95 skip_serializing_if = "Option::is_none"
96 )]
97 pub output: Option<Option<RealtimeResponseAudioOutput>>,
98 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
99 pub rest: Rest,
100}
101
102#[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 RealtimeResponseStatus {
108 #[serde(
109 default,
110 deserialize_with = "present_nullable",
111 skip_serializing_if = "Option::is_none"
112 )]
113 pub error: Option<Option<RealtimeResponseStatusError>>,
114 #[serde(
115 default,
116 deserialize_with = "present_nullable",
117 skip_serializing_if = "Option::is_none"
118 )]
119 pub reason: Option<Option<RealtimeResponseStatusReason>>,
120 #[serde(rename = "type")]
121 #[serde(
122 default,
123 deserialize_with = "present_nullable",
124 skip_serializing_if = "Option::is_none"
125 )]
126 pub type_: Option<Option<RealtimeResponseStatusType>>,
127 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
128 pub rest: Rest,
129}
130
131#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
133#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
134#[derive(gproxy_protocol_macros::DeclaredFields)]
135#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
136pub struct RealtimeResponseUsage {
137 #[serde(
138 default,
139 deserialize_with = "present_nullable",
140 skip_serializing_if = "Option::is_none"
141 )]
142 pub input_token_details: Option<Option<RealtimeResponseUsageInputTokenDetails>>,
143 #[serde(
144 default,
145 deserialize_with = "present_nullable",
146 skip_serializing_if = "Option::is_none"
147 )]
148 pub input_tokens: Option<Option<i64>>,
149 #[serde(
150 default,
151 deserialize_with = "present_nullable",
152 skip_serializing_if = "Option::is_none"
153 )]
154 pub output_token_details: Option<Option<RealtimeResponseUsageOutputTokenDetails>>,
155 #[serde(
156 default,
157 deserialize_with = "present_nullable",
158 skip_serializing_if = "Option::is_none"
159 )]
160 pub output_tokens: Option<Option<i64>>,
161 #[serde(
162 default,
163 deserialize_with = "present_nullable",
164 skip_serializing_if = "Option::is_none"
165 )]
166 pub total_tokens: Option<Option<i64>>,
167 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
168 pub rest: Rest,
169}
170
171#[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 RealtimeResponseAudioOutput {
177 #[serde(
178 default,
179 deserialize_with = "present_nullable",
180 skip_serializing_if = "Option::is_none"
181 )]
182 pub format: Option<Option<RealtimeAudioFormats>>,
183 #[serde(
184 default,
185 deserialize_with = "present_nullable",
186 skip_serializing_if = "Option::is_none"
187 )]
188 pub voice: Option<Option<String>>,
189 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
190 pub rest: Rest,
191}
192
193#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
195#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
196#[derive(gproxy_protocol_macros::DeclaredFields)]
197#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
198pub struct RealtimeResponseStatusError {
199 #[serde(
200 default,
201 deserialize_with = "present_nullable",
202 skip_serializing_if = "Option::is_none"
203 )]
204 pub code: Option<Option<String>>,
205 #[serde(rename = "type")]
206 #[serde(
207 default,
208 deserialize_with = "present_nullable",
209 skip_serializing_if = "Option::is_none"
210 )]
211 pub type_: Option<Option<String>>,
212 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
213 pub rest: Rest,
214}
215
216#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
218#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
219#[derive(gproxy_protocol_macros::DeclaredFields)]
220#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
221pub struct RealtimeResponseUsageInputTokenDetails {
222 #[serde(
223 default,
224 deserialize_with = "present_nullable",
225 skip_serializing_if = "Option::is_none"
226 )]
227 pub audio_tokens: Option<Option<i64>>,
228 #[serde(
229 default,
230 deserialize_with = "present_nullable",
231 skip_serializing_if = "Option::is_none"
232 )]
233 pub cached_tokens: Option<Option<i64>>,
234 #[serde(
235 default,
236 deserialize_with = "present_nullable",
237 skip_serializing_if = "Option::is_none"
238 )]
239 pub cached_tokens_details:
240 Option<Option<RealtimeResponseUsageInputTokenDetailsCachedTokensDetails>>,
241 #[serde(
242 default,
243 deserialize_with = "present_nullable",
244 skip_serializing_if = "Option::is_none"
245 )]
246 pub image_tokens: Option<Option<i64>>,
247 #[serde(
248 default,
249 deserialize_with = "present_nullable",
250 skip_serializing_if = "Option::is_none"
251 )]
252 pub text_tokens: Option<Option<i64>>,
253 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
254 pub rest: Rest,
255}
256
257#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
259#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
260#[derive(gproxy_protocol_macros::DeclaredFields)]
261#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
262pub struct RealtimeResponseUsageOutputTokenDetails {
263 #[serde(
264 default,
265 deserialize_with = "present_nullable",
266 skip_serializing_if = "Option::is_none"
267 )]
268 pub audio_tokens: Option<Option<i64>>,
269 #[serde(
270 default,
271 deserialize_with = "present_nullable",
272 skip_serializing_if = "Option::is_none"
273 )]
274 pub text_tokens: Option<Option<i64>>,
275 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
276 pub rest: Rest,
277}
278
279#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
281#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
282#[derive(gproxy_protocol_macros::DeclaredFields)]
283#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
284pub struct RealtimeResponseUsageInputTokenDetailsCachedTokensDetails {
285 #[serde(
286 default,
287 deserialize_with = "present_nullable",
288 skip_serializing_if = "Option::is_none"
289 )]
290 pub audio_tokens: Option<Option<i64>>,
291 #[serde(
292 default,
293 deserialize_with = "present_nullable",
294 skip_serializing_if = "Option::is_none"
295 )]
296 pub image_tokens: Option<Option<i64>>,
297 #[serde(
298 default,
299 deserialize_with = "present_nullable",
300 skip_serializing_if = "Option::is_none"
301 )]
302 pub text_tokens: Option<Option<i64>>,
303 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
304 pub rest: Rest,
305}
306
307#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
308#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
309#[derive(gproxy_protocol_macros::DeclaredFields)]
310#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
311pub enum RealtimeResponseMaxOutputTokensVariant2 {
312 #[serde(rename = "inf")]
313 Inf,
314}
315
316#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
317#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
318#[serde(untagged)]
319#[derive(gproxy_protocol_macros::DeclaredFields)]
320#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
321pub enum RealtimeResponseMaxOutputTokens {
322 Number(i64),
323 Literal(RealtimeResponseMaxOutputTokensVariant2),
324}
325
326#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
327#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
328#[derive(gproxy_protocol_macros::DeclaredFields)]
329#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
330pub enum RealtimeResponseObject {
331 #[serde(rename = "realtime.response")]
332 RealtimeResponse,
333}
334
335#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
336#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
337#[derive(gproxy_protocol_macros::DeclaredFields)]
338#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
339pub enum RealtimeResponseOutputModalitiesItem {
340 #[serde(rename = "text")]
341 Text,
342 #[serde(rename = "audio")]
343 Audio,
344}
345
346#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
347#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
348#[derive(gproxy_protocol_macros::DeclaredFields)]
349#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
350pub enum RealtimeResponseStatusValue {
351 #[serde(rename = "completed")]
352 Completed,
353 #[serde(rename = "cancelled")]
354 Cancelled,
355 #[serde(rename = "failed")]
356 Failed,
357 #[serde(rename = "incomplete")]
358 Incomplete,
359 #[serde(rename = "in_progress")]
360 InProgress,
361}
362
363#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
364#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
365#[derive(gproxy_protocol_macros::DeclaredFields)]
366#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
367pub enum RealtimeResponseStatusReason {
368 #[serde(rename = "turn_detected")]
369 TurnDetected,
370 #[serde(rename = "client_cancelled")]
371 ClientCancelled,
372 #[serde(rename = "max_output_tokens")]
373 MaxOutputTokens,
374 #[serde(rename = "content_filter")]
375 ContentFilter,
376}
377
378#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
379#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
380#[derive(gproxy_protocol_macros::DeclaredFields)]
381#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
382pub enum RealtimeResponseStatusType {
383 #[serde(rename = "completed")]
384 Completed,
385 #[serde(rename = "cancelled")]
386 Cancelled,
387 #[serde(rename = "incomplete")]
388 Incomplete,
389 #[serde(rename = "failed")]
390 Failed,
391}