1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#[derive(Debug)]
pub struct TextToVideoClient<'a> {
base_client: &'a mut crate::core::base_client::BaseClient,
}
impl<'a> TextToVideoClient<'a> {
pub(crate) fn _new(
base_client: &'a mut crate::core::base_client::BaseClient,
) -> Self {
Self { base_client }
}
/// Text-to-Video
///
/// **What this API does**
///
/// Create the same Text To Video you can make in the browser, but programmatically, so you can automate it, run it at scale, or connect it to your own app or workflow.
///
/// **Good for**
/// - Automation and batch processing
/// - Adding text to video into apps, pipelines, or tools
///
/// **How it works (3 steps)**
/// 1) Upload your inputs (video, image, or audio) with [Generate Upload URLs](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls) and copy the `file_path`.
/// 2) Send a request to create a text to video job with the basic fields.
/// 3) Check the job status until it's `complete`, then download the result from `downloads`.
///
/// **Key options**
/// - Inputs: usually a file, sometimes a YouTube link, depending on project type
/// - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
/// - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
///
/// **Cost**
/// Credits are charged when the job is queued (`credits_charged` in the response). Tools billed per frame charge an estimate and settle to the frames that actually render once the job finishes; tools billed per second charge the final amount upfront. Failed jobs are refunded.
///
/// For detailed examples, see the [product page](https://magichour.ai/products/text-to-video).
///
/// POST /v1/text-to-video
pub async fn create(
&mut self,
request: super::request_types::CreateRequest,
) -> crate::SdkResult<crate::models::V1TextToVideoCreateResponse> {
let url = self.base_client.build_url("/v1/text-to-video", None);
let mut builder = reqwest::Client::default().post(&url);
builder = builder.header("x-sideko-sdk-language", "rust");
builder = builder.header("content-type", "application/json");
builder = builder
.json(
&crate::models::V1TextToVideoCreateBody {
aspect_ratio: request.aspect_ratio,
audio: request.audio,
model: request.model,
name: request.name,
orientation: request.orientation,
references: request.references,
resolution: request.resolution,
end_seconds: request.end_seconds,
style: request.style,
},
);
builder = self
.base_client
.apply_auths_to_builder(builder, &["bearerAuth"])
.await?;
let mut response = builder.send().await?;
response = self.base_client.error_for_status("POST", response).await?;
crate::core::response::process_json::<
crate::models::V1TextToVideoCreateResponse,
>(response)
.await
}
}