async_openai/types/
video.rs

1use derive_builder::Builder;
2use serde::{Deserialize, Serialize};
3
4use crate::{error::OpenAIError, types::ImageInput};
5
6#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
7pub enum VideoSize {
8    #[default]
9    #[serde(rename = "720x1280")]
10    S720x1280,
11    #[serde(rename = "1280x720")]
12    S1280x720,
13    #[serde(rename = "1024x1792")]
14    S1024x1792,
15    #[serde(rename = "1792x1024")]
16    S1792x1024,
17}
18
19#[derive(Clone, Default, Debug, Builder, PartialEq)]
20#[builder(name = "CreateVideoRequestArgs")]
21#[builder(pattern = "mutable")]
22#[builder(setter(into, strip_option), default)]
23#[builder(derive(Debug))]
24#[builder(build_fn(error = "OpenAIError"))]
25pub struct CreateVideoRequest {
26    /// ID of the model to use.
27    pub model: String,
28
29    /// The prompt to generate video from.
30    pub prompt: String,
31
32    pub size: Option<VideoSize>,
33
34    pub seconds: Option<String>,
35
36    pub input_reference: Option<ImageInput>,
37}
38
39#[derive(Clone, Default, Debug, Builder, PartialEq, Serialize)]
40#[builder(name = "RemixVideoRequestArgs")]
41#[builder(pattern = "mutable")]
42#[builder(setter(into, strip_option), default)]
43#[builder(derive(Debug))]
44#[builder(build_fn(error = "OpenAIError"))]
45pub struct RemixVideoRequest {
46    pub prompt: String,
47}
48
49#[derive(Debug, Clone, Serialize, Deserialize)]
50pub struct VideoJobError {
51    pub code: String,
52    pub message: String,
53}
54
55/// Structured information describing a generated video job.
56#[derive(Debug, Clone, Serialize, Deserialize)]
57pub struct VideoJob {
58    /// Unix timestamp (seconds) for when the job completed, if finished.
59    pub completed_at: Option<u32>,
60
61    /// Unix timestamp (seconds) for when the job was created.
62    pub created_at: u32,
63
64    /// Error payload that explains why generation failed, if applicable.
65    pub error: Option<VideoJobError>,
66
67    /// Unix timestamp (seconds) for when the downloadable assets expire, if set.
68    pub expires_at: Option<u32>,
69
70    /// Unique identifier for the video job.
71    pub id: String,
72
73    /// The video generation model that produced the job.
74    pub model: String,
75
76    /// The object type, which is always video.
77    pub object: String,
78
79    /// Approximate completion percentage for the generation task.
80    pub progress: u8,
81
82    /// Identifier of the source video if this video is a remix.
83    pub remixed_from_video_id: Option<String>,
84
85    /// Duration of the generated clip in seconds.
86    pub seconds: String,
87
88    /// The resolution of the generated video.
89    pub size: String,
90
91    /// Current lifecycle status of the video job.
92    pub status: String,
93}
94
95#[derive(Debug, Clone, Serialize, Deserialize)]
96pub struct VideoJobMetadata {
97    pub id: String,
98    pub object: String,
99    pub deleted: bool,
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
103pub struct ListVideosResponse {
104    pub data: Vec<VideoJob>,
105    pub object: String,
106}
107
108#[derive(Debug, Clone, Serialize, Deserialize, Default)]
109#[serde(rename_all = "lowercase")]
110pub enum VideoVariant {
111    #[default]
112    Video,
113    Thumbnail,
114    Spritesheet,
115}