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