Skip to main content

gproxy_protocol/wire/openai/
audio.rs

1//! Sources: local OpenAI create-operation docs; missing request/event schemas
2//! from openai/openai-python e12b81d3bbf644ec7045e152d69bc4b68d69cd48
3//! and openai/openai-openapi 38170fdddbb6a1813eae6c6587ee17cf2987185b,
4//! checked 2026-09-13. Binary bodies and multipart streams remain transport-owned.
5use crate::connection::{HttpBody, MultipartPart};
6use crate::{Rest, WireRequest, WireResponse};
7use serde::{Deserialize, Serialize};
8fn optional<'de, D, T>(d: D) -> Result<Option<T>, D::Error>
9where
10    D: serde::Deserializer<'de>,
11    T: Deserialize<'de>,
12{
13    T::deserialize(d).map(Some)
14}
15
16#[derive(
17    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
18)]
19#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
20#[derive(gproxy_protocol_macros::DeclaredFields)]
21pub struct CreateSpeechRequestBody {
22    pub model: String,
23    pub input: String,
24    pub voice: SpeechVoice,
25    #[serde(
26        default,
27        deserialize_with = "optional",
28        skip_serializing_if = "Option::is_none"
29    )]
30    pub instructions: Option<String>,
31    #[serde(
32        default,
33        deserialize_with = "optional",
34        skip_serializing_if = "Option::is_none"
35    )]
36    pub response_format: Option<AudioResponseFormat>,
37    #[serde(
38        default,
39        deserialize_with = "optional",
40        skip_serializing_if = "Option::is_none"
41    )]
42    pub speed: Option<serde_json::Number>,
43    #[serde(
44        default,
45        deserialize_with = "optional",
46        skip_serializing_if = "Option::is_none"
47    )]
48    pub stream_format: Option<SpeechStreamFormat>,
49    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
50    pub rest: Rest,
51}
52
53#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
54#[serde(untagged)]
55#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
56#[derive(gproxy_protocol_macros::DeclaredFields)]
57pub enum SpeechVoice {
58    Name(String),
59    Custom(CustomVoice),
60}
61
62#[derive(
63    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
64)]
65#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
66#[derive(gproxy_protocol_macros::DeclaredFields)]
67pub struct CustomVoice {
68    pub id: String,
69    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
70    pub rest: Rest,
71}
72
73#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
74#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
75#[derive(gproxy_protocol_macros::DeclaredFields)]
76pub enum AudioResponseFormat {
77    #[serde(rename = "mp3")]
78    Mp3,
79    #[serde(rename = "opus")]
80    Opus,
81    #[serde(rename = "aac")]
82    Aac,
83    #[serde(rename = "flac")]
84    Flac,
85    #[serde(rename = "wav")]
86    Wav,
87    #[serde(rename = "pcm")]
88    Pcm,
89}
90
91#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
92#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
93#[derive(gproxy_protocol_macros::DeclaredFields)]
94pub enum SpeechStreamFormat {
95    #[serde(rename = "sse")]
96    Sse,
97    #[serde(rename = "audio")]
98    Audio,
99}
100
101#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
102#[serde(tag = "type")]
103#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
104#[derive(gproxy_protocol_macros::DeclaredFields)]
105pub enum SpeechAudioEvent {
106    #[serde(rename = "speech.audio.delta")]
107    Delta(SpeechAudioDelta),
108    #[serde(rename = "speech.audio.done")]
109    Done(SpeechAudioDone),
110}
111
112#[derive(
113    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
114)]
115#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
116#[derive(gproxy_protocol_macros::DeclaredFields)]
117pub struct SpeechAudioDelta {
118    pub audio: String,
119    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
120    pub rest: Rest,
121}
122
123#[derive(
124    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
125)]
126#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
127#[derive(gproxy_protocol_macros::DeclaredFields)]
128pub struct SpeechAudioDone {
129    pub usage: SpeechUsage,
130    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
131    pub rest: Rest,
132}
133
134#[derive(
135    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
136)]
137#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
138#[derive(gproxy_protocol_macros::DeclaredFields)]
139pub struct SpeechUsage {
140    pub input_tokens: i64,
141    pub output_tokens: i64,
142    pub total_tokens: i64,
143    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
144    pub rest: Rest,
145}
146
147#[derive(Debug, gproxy_protocol_macros::WireBuilder)]
148#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
149#[derive(gproxy_protocol_macros::DeclaredFields)]
150pub struct CreateTranscriptionMultipartForm {
151    pub file: MultipartPart,
152    pub model: String,
153    pub language: Option<String>,
154    pub languages: Option<Vec<String>>,
155    pub keywords: Option<Vec<String>>,
156    pub prompt: Option<String>,
157    pub response_format: Option<TranscriptionResponseFormat>,
158    pub temperature: Option<serde_json::Number>,
159    pub timestamp_granularities: Option<Vec<TranscriptionTimestampGranularity>>,
160    pub include: Option<Vec<TranscriptionInclude>>,
161    pub chunking_strategy: Option<Option<ChunkingStrategy>>,
162    pub known_speaker_names: Option<Vec<String>>,
163    pub known_speaker_references: Option<Vec<String>>,
164    pub stream: Option<Option<bool>>,
165}
166
167#[derive(Debug, gproxy_protocol_macros::WireBuilder)]
168#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
169#[derive(gproxy_protocol_macros::DeclaredFields)]
170pub struct CreateTranslationMultipartForm {
171    pub file: MultipartPart,
172    pub model: String,
173    pub prompt: Option<String>,
174    pub response_format: Option<TranslationResponseFormat>,
175    pub temperature: Option<serde_json::Number>,
176}
177
178#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
179#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
180#[derive(gproxy_protocol_macros::DeclaredFields)]
181pub enum TranscriptionResponseFormat {
182    #[serde(rename = "json")]
183    Json,
184    #[serde(rename = "text")]
185    Text,
186    #[serde(rename = "srt")]
187    Srt,
188    #[serde(rename = "verbose_json")]
189    VerboseJson,
190    #[serde(rename = "vtt")]
191    Vtt,
192    #[serde(rename = "diarized_json")]
193    DiarizedJson,
194}
195
196#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
197#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
198#[derive(gproxy_protocol_macros::DeclaredFields)]
199pub enum TranslationResponseFormat {
200    #[serde(rename = "json")]
201    Json,
202    #[serde(rename = "text")]
203    Text,
204    #[serde(rename = "srt")]
205    Srt,
206    #[serde(rename = "verbose_json")]
207    VerboseJson,
208    #[serde(rename = "vtt")]
209    Vtt,
210}
211
212#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
213#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
214#[derive(gproxy_protocol_macros::DeclaredFields)]
215pub enum TranscriptionTimestampGranularity {
216    #[serde(rename = "word")]
217    Word,
218    #[serde(rename = "segment")]
219    Segment,
220}
221
222#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
223#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
224#[derive(gproxy_protocol_macros::DeclaredFields)]
225pub enum TranscriptionInclude {
226    #[serde(rename = "logprobs")]
227    Logprobs,
228}
229
230#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
231#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
232#[derive(gproxy_protocol_macros::DeclaredFields)]
233pub enum AutomaticChunking {
234    #[serde(rename = "auto")]
235    Auto,
236}
237
238#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
239#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
240#[derive(gproxy_protocol_macros::DeclaredFields)]
241pub enum VadType {
242    #[serde(rename = "server_vad")]
243    ServerVad,
244}
245
246#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
247#[serde(untagged)]
248#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
249#[derive(gproxy_protocol_macros::DeclaredFields)]
250pub enum ChunkingStrategy {
251    Auto(AutomaticChunking),
252    Vad(VadConfig),
253}
254
255#[derive(
256    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
257)]
258#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
259#[derive(gproxy_protocol_macros::DeclaredFields)]
260pub struct VadConfig {
261    #[serde(rename = "type")]
262    pub type_: VadType,
263    #[serde(
264        default,
265        deserialize_with = "optional",
266        skip_serializing_if = "Option::is_none"
267    )]
268    pub prefix_padding_ms: Option<i64>,
269    #[serde(
270        default,
271        deserialize_with = "optional",
272        skip_serializing_if = "Option::is_none"
273    )]
274    pub silence_duration_ms: Option<i64>,
275    #[serde(
276        default,
277        deserialize_with = "optional",
278        skip_serializing_if = "Option::is_none"
279    )]
280    pub threshold: Option<serde_json::Number>,
281    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
282    pub rest: Rest,
283}
284
285#[derive(
286    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
287)]
288#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
289#[derive(gproxy_protocol_macros::DeclaredFields)]
290pub struct TranscriptionJson {
291    pub text: String,
292    #[serde(
293        default,
294        deserialize_with = "optional",
295        skip_serializing_if = "Option::is_none"
296    )]
297    pub languages: Option<Vec<TranscriptionLanguage>>,
298    #[serde(
299        default,
300        deserialize_with = "optional",
301        skip_serializing_if = "Option::is_none"
302    )]
303    pub logprobs: Option<Vec<TranscriptionLogprob>>,
304    #[serde(
305        default,
306        deserialize_with = "optional",
307        skip_serializing_if = "Option::is_none"
308    )]
309    pub usage: Option<TranscriptionUsage>,
310    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
311    pub rest: Rest,
312}
313
314#[derive(
315    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
316)]
317#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
318#[derive(gproxy_protocol_macros::DeclaredFields)]
319pub struct TranscriptionLanguage {
320    pub code: String,
321    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
322    pub rest: Rest,
323}
324
325#[derive(
326    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
327)]
328#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
329#[derive(gproxy_protocol_macros::DeclaredFields)]
330pub struct TranscriptionLogprob {
331    #[serde(
332        default,
333        deserialize_with = "optional",
334        skip_serializing_if = "Option::is_none"
335    )]
336    pub token: Option<String>,
337    #[serde(
338        default,
339        deserialize_with = "optional",
340        skip_serializing_if = "Option::is_none"
341    )]
342    pub bytes: Option<Vec<i64>>,
343    #[serde(
344        default,
345        deserialize_with = "optional",
346        skip_serializing_if = "Option::is_none"
347    )]
348    pub logprob: Option<serde_json::Number>,
349    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
350    pub rest: Rest,
351}
352
353#[derive(
354    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
355)]
356#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
357#[derive(gproxy_protocol_macros::DeclaredFields)]
358pub struct TranscriptionVerbose {
359    // Verbose examples in Create transcription.md include task, although the
360    // field table and SDK omit it. Preserve the observed field as optional.
361    #[serde(
362        default,
363        deserialize_with = "optional",
364        skip_serializing_if = "Option::is_none"
365    )]
366    pub task: Option<TranscriptionTask>,
367    pub duration: serde_json::Number,
368    pub language: String,
369    pub text: String,
370    #[serde(
371        default,
372        deserialize_with = "optional",
373        skip_serializing_if = "Option::is_none"
374    )]
375    pub segments: Option<Vec<TranscriptionSegment>>,
376    #[serde(
377        default,
378        deserialize_with = "optional",
379        skip_serializing_if = "Option::is_none"
380    )]
381    pub usage: Option<TranscriptionDurationUsage>,
382    #[serde(
383        default,
384        deserialize_with = "optional",
385        skip_serializing_if = "Option::is_none"
386    )]
387    pub words: Option<Vec<TranscriptionWord>>,
388    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
389    pub rest: Rest,
390}
391
392#[derive(
393    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
394)]
395#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
396#[derive(gproxy_protocol_macros::DeclaredFields)]
397pub struct TranscriptionDiarized {
398    pub duration: serde_json::Number,
399    pub segments: Vec<TranscriptionDiarizedSegment>,
400    pub task: TranscriptionTask,
401    pub text: String,
402    #[serde(
403        default,
404        deserialize_with = "optional",
405        skip_serializing_if = "Option::is_none"
406    )]
407    pub usage: Option<TranscriptionUsage>,
408    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
409    pub rest: Rest,
410}
411
412#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
413#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
414#[derive(gproxy_protocol_macros::DeclaredFields)]
415pub enum TranscriptionTask {
416    #[serde(rename = "transcribe")]
417    Transcribe,
418}
419
420#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
421#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
422#[derive(gproxy_protocol_macros::DeclaredFields)]
423pub enum TranscriptionDiarizedSegmentType {
424    #[serde(rename = "transcript.text.segment")]
425    Segment,
426}
427
428#[derive(
429    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
430)]
431#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
432#[derive(gproxy_protocol_macros::DeclaredFields)]
433pub struct TranscriptionDiarizedSegment {
434    pub id: String,
435    pub end: serde_json::Number,
436    pub speaker: String,
437    pub start: serde_json::Number,
438    pub text: String,
439    #[serde(rename = "type")]
440    pub type_: TranscriptionDiarizedSegmentType,
441    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
442    pub rest: Rest,
443}
444
445#[derive(
446    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
447)]
448#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
449#[derive(gproxy_protocol_macros::DeclaredFields)]
450pub struct TranscriptionSegment {
451    pub id: i64,
452    pub avg_logprob: serde_json::Number,
453    pub compression_ratio: serde_json::Number,
454    pub end: serde_json::Number,
455    pub no_speech_prob: serde_json::Number,
456    pub seek: i64,
457    pub start: serde_json::Number,
458    pub temperature: serde_json::Number,
459    pub text: String,
460    pub tokens: Vec<i64>,
461    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
462    pub rest: Rest,
463}
464
465#[derive(
466    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
467)]
468#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
469#[derive(gproxy_protocol_macros::DeclaredFields)]
470pub struct TranscriptionWord {
471    pub end: serde_json::Number,
472    pub start: serde_json::Number,
473    pub word: String,
474    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
475    pub rest: Rest,
476}
477
478#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
479#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
480#[derive(gproxy_protocol_macros::DeclaredFields)]
481pub enum TokenUsageType {
482    #[serde(rename = "tokens")]
483    Tokens,
484}
485
486#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
487#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
488#[derive(gproxy_protocol_macros::DeclaredFields)]
489pub enum DurationUsageType {
490    #[serde(rename = "duration")]
491    Duration,
492}
493
494#[derive(
495    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
496)]
497#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
498#[derive(gproxy_protocol_macros::DeclaredFields)]
499pub struct TranscriptionTokenUsage {
500    pub input_tokens: i64,
501    pub output_tokens: i64,
502    pub total_tokens: i64,
503    #[serde(rename = "type")]
504    pub type_: TokenUsageType,
505    #[serde(
506        default,
507        deserialize_with = "optional",
508        skip_serializing_if = "Option::is_none"
509    )]
510    pub input_token_details: Option<TranscriptionInputTokenDetails>,
511    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
512    pub rest: Rest,
513}
514
515#[derive(
516    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
517)]
518#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
519#[derive(gproxy_protocol_macros::DeclaredFields)]
520pub struct TranscriptionInputTokenDetails {
521    #[serde(
522        default,
523        deserialize_with = "optional",
524        skip_serializing_if = "Option::is_none"
525    )]
526    pub audio_tokens: Option<i64>,
527    #[serde(
528        default,
529        deserialize_with = "optional",
530        skip_serializing_if = "Option::is_none"
531    )]
532    pub text_tokens: Option<i64>,
533    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
534    pub rest: Rest,
535}
536
537#[derive(
538    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
539)]
540#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
541#[derive(gproxy_protocol_macros::DeclaredFields)]
542pub struct TranscriptionDurationUsage {
543    pub seconds: serde_json::Number,
544    #[serde(rename = "type")]
545    pub type_: DurationUsageType,
546    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
547    pub rest: Rest,
548}
549
550#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
551#[serde(untagged)]
552#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
553#[derive(gproxy_protocol_macros::DeclaredFields)]
554pub enum TranscriptionUsage {
555    Tokens(TranscriptionTokenUsage),
556    Duration(TranscriptionDurationUsage),
557}
558
559#[derive(
560    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
561)]
562#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
563#[derive(gproxy_protocol_macros::DeclaredFields)]
564pub struct TranslationJson {
565    pub text: String,
566    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
567    pub rest: Rest,
568}
569
570#[derive(
571    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
572)]
573#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
574#[derive(gproxy_protocol_macros::DeclaredFields)]
575pub struct TranslationVerbose {
576    pub duration: serde_json::Number,
577    pub language: String,
578    pub text: String,
579    #[serde(
580        default,
581        deserialize_with = "optional",
582        skip_serializing_if = "Option::is_none"
583    )]
584    pub segments: Option<Vec<TranscriptionSegment>>,
585    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
586    pub rest: Rest,
587}
588
589#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
590#[serde(tag = "type")]
591#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
592#[derive(gproxy_protocol_macros::DeclaredFields)]
593pub enum TranscriptionTextStreamEvent {
594    #[serde(rename = "transcript.text.delta")]
595    Delta(TranscriptionTextDelta),
596    #[serde(rename = "transcript.text.done")]
597    Done(TranscriptionTextDone),
598}
599
600#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
601#[serde(untagged)]
602#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
603#[derive(gproxy_protocol_macros::DeclaredFields)]
604pub enum TranscriptionStreamEvent {
605    Text(TranscriptionTextStreamEvent),
606    Segment(TranscriptionDiarizedSegment),
607}
608
609#[derive(
610    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
611)]
612#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
613#[derive(gproxy_protocol_macros::DeclaredFields)]
614pub struct TranscriptionTextDelta {
615    pub delta: String,
616    #[serde(
617        default,
618        deserialize_with = "optional",
619        skip_serializing_if = "Option::is_none"
620    )]
621    pub logprobs: Option<Vec<TranscriptionLogprob>>,
622    #[serde(
623        default,
624        deserialize_with = "optional",
625        skip_serializing_if = "Option::is_none"
626    )]
627    pub segment_id: Option<String>,
628    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
629    pub rest: Rest,
630}
631
632#[derive(
633    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
634)]
635#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
636#[derive(gproxy_protocol_macros::DeclaredFields)]
637pub struct TranscriptionTextDone {
638    pub text: String,
639    #[serde(
640        default,
641        deserialize_with = "optional",
642        skip_serializing_if = "Option::is_none"
643    )]
644    pub languages: Option<Vec<TranscriptionLanguage>>,
645    #[serde(
646        default,
647        deserialize_with = "optional",
648        skip_serializing_if = "Option::is_none"
649    )]
650    pub logprobs: Option<Vec<TranscriptionLogprob>>,
651    #[serde(
652        default,
653        deserialize_with = "optional",
654        skip_serializing_if = "Option::is_none"
655    )]
656    pub usage: Option<TranscriptionTokenUsage>,
657    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
658    pub rest: Rest,
659}
660
661pub type CreateSpeechRequest = WireRequest<CreateSpeechRequestBody>;
662pub type CreateSpeechResponse = WireResponse<HttpBody>;
663pub type SpeechStreamResponse = WireResponse<crate::connection::ByteStream>;
664pub type CreateTranscriptionRequest = WireRequest<CreateTranscriptionMultipartForm>;
665pub type RawTranscriptionRequest = WireRequest<crate::connection::Multipart>;
666pub type CreateTranslationRequest = WireRequest<CreateTranslationMultipartForm>;
667pub type RawTranslationRequest = WireRequest<crate::connection::Multipart>;
668pub type CreateTranscriptionResponse = WireResponse<HttpBody>;
669pub type CreateTranslationResponse = WireResponse<HttpBody>;
670pub type TranscriptionJsonResponse = WireResponse<TranscriptionJson>;
671pub type TranscriptionVerboseResponse = WireResponse<TranscriptionVerbose>;
672pub type TranscriptionDiarizedResponse = WireResponse<TranscriptionDiarized>;
673pub type TranslationJsonResponse = WireResponse<TranslationJson>;
674pub type TranslationVerboseResponse = WireResponse<TranslationVerbose>;
675pub type TranscriptionStreamResponse = WireResponse<crate::connection::ByteStream>;