async_openai/
translations.rs1use bytes::Bytes;
2
3use crate::{
4 config::Config,
5 error::OpenAIError,
6 types::audio::{
7 CreateTranslationRequest, CreateTranslationResponseJson,
8 CreateTranslationResponseVerboseJson,
9 },
10 Client,
11};
12
13pub struct Translations<'c, C: Config> {
14 client: &'c Client<C>,
15}
16
17impl<'c, C: Config> Translations<'c, C> {
18 pub fn new(client: &'c Client<C>) -> Self {
19 Self { client }
20 }
21
22 #[crate::byot(
24 T0 = Clone,
25 R = serde::de::DeserializeOwned,
26 where_clause = "reqwest::multipart::Form: crate::traits::AsyncTryFrom<T0, Error = OpenAIError>",
27 )]
28 pub async fn create(
29 &self,
30 request: CreateTranslationRequest,
31 ) -> Result<CreateTranslationResponseJson, OpenAIError> {
32 self.client.post_form("/audio/translations", request).await
33 }
34
35 #[crate::byot(
37 T0 = Clone,
38 R = serde::de::DeserializeOwned,
39 where_clause = "reqwest::multipart::Form: crate::traits::AsyncTryFrom<T0, Error = OpenAIError>",
40 )]
41 pub async fn create_verbose_json(
42 &self,
43 request: CreateTranslationRequest,
44 ) -> Result<CreateTranslationResponseVerboseJson, OpenAIError> {
45 self.client.post_form("/audio/translations", request).await
46 }
47
48 pub async fn create_raw(
50 &self,
51 request: CreateTranslationRequest,
52 ) -> Result<Bytes, OpenAIError> {
53 self.client
54 .post_form_raw("/audio/translations", request)
55 .await
56 }
57}