async_openai/types/videos/
video.rs

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