fal/endpoints/fal_ai/veo2/mod.rs
1#[allow(unused_imports)]
2use crate::prelude::*;
3#[allow(unused_imports)]
4use serde::{Deserialize, Serialize};
5#[allow(unused_imports)]
6use std::collections::HashMap;
7
8#[cfg(any(
9 feature = "endpoints",
10 feature = "endpoints_fal-ai",
11 feature = "endpoints_fal-ai_veo2"
12))]
13#[cfg_attr(
14 docsrs,
15 doc(cfg(any(
16 feature = "endpoints",
17 feature = "endpoints_fal-ai",
18 feature = "endpoints_fal-ai_veo2"
19 )))
20)]
21pub mod image_to_video;
22
23#[derive(Debug, Serialize, Deserialize, Default)]
24pub struct File {
25 /// The mime type of the file.
26 /// "image/png"
27 #[serde(skip_serializing_if = "Option::is_none")]
28 pub content_type: Option<String>,
29 /// File data
30 #[serde(skip_serializing_if = "Option::is_none")]
31 pub file_data: Option<String>,
32 /// The name of the file. It will be auto-generated if not provided.
33 /// "z9RV14K95DvU.png"
34 #[serde(skip_serializing_if = "Option::is_none")]
35 pub file_name: Option<String>,
36 /// The size of the file in bytes.
37 /// 4404019
38 #[serde(skip_serializing_if = "Option::is_none")]
39 pub file_size: Option<i64>,
40 /// The URL where the file can be downloaded from.
41 pub url: String,
42}
43
44#[derive(Debug, Serialize, Deserialize, Default)]
45pub struct HTTPValidationError {
46 #[serde(skip_serializing_if = "Option::is_none")]
47 pub detail: Option<Vec<Option<ValidationError>>>,
48}
49
50#[derive(Debug, Serialize, Deserialize, Default)]
51pub struct ImageToVideoInput {
52 /// The aspect ratio of the generated video
53 #[serde(skip_serializing_if = "Option::is_none")]
54 pub aspect_ratio: Option<String>,
55 /// The duration of the generated video in seconds
56 #[serde(skip_serializing_if = "Option::is_none")]
57 pub duration: Option<String>,
58 /// URL of the input image to animate. Should be 720p or higher resolution.
59 /// "https://fal.media/files/elephant/6fq8JDSjb1osE_c3J_F2H.png"
60 pub image_url: String,
61 /// The text prompt describing how the image should be animated
62 /// "A lego chef cooking eggs"
63 pub prompt: String,
64}
65
66#[derive(Debug, Serialize, Deserialize, Default)]
67pub struct ImageToVideoOutput {
68 /// The generated video
69 /// {"url":"https://v3.fal.media/files/zebra/uNu-1qkbNt8be8iHA1hiB_output.mp4"}
70 pub video: File,
71}
72
73#[derive(Debug, Serialize, Deserialize, Default)]
74pub struct TextToVideoInput {
75 /// The aspect ratio of the generated video
76 #[serde(skip_serializing_if = "Option::is_none")]
77 pub aspect_ratio: Option<String>,
78 /// The duration of the generated video in seconds
79 #[serde(skip_serializing_if = "Option::is_none")]
80 pub duration: Option<String>,
81 /// The text prompt describing the video you want to generate
82 /// "The camera floats gently through rows of pastel-painted wooden beehives, buzzing honeybees gliding in and out of frame. The motion settles on the refined farmer standing at the center, his pristine white beekeeping suit gleaming in the golden afternoon light. He lifts a jar of honey, tilting it slightly to catch the light. Behind him, tall sunflowers sway rhythmically in the breeze, their petals glowing in the warm sunlight. The camera tilts upward to reveal a retro farmhouse with mint-green shutters, its walls dappled with shadows from swaying trees. Shot with a 35mm lens on Kodak Portra 400 film, the golden light creates rich textures on the farmer's gloves, marmalade jar, and weathered wood of the beehives."
83 pub prompt: String,
84}
85
86#[derive(Debug, Serialize, Deserialize)]
87pub struct TextToVideoOutput {
88 /// The generated video
89 /// {"url":"https://v3.fal.media/files/tiger/83-YzufmOlsnhqq5ed382_output.mp4"}
90 pub video: File,
91}
92
93#[derive(Debug, Serialize, Deserialize, Default)]
94pub struct ValidationError {
95 pub loc: Vec<serde_json::Value>,
96 pub msg: String,
97 #[serde(rename = "type")]
98 pub ty: String,
99}
100
101/// Veo 2 (Image to Video)
102///
103/// Category: image-to-video
104///
105///
106///
107/// Generate videos using Google's [Veo 2 text-to-video model](https://blog.google/technology/google-labs/video-image-generation-update-december-2024/).
108///
109/// For best results, prompts should be descriptive and clear. Include:
110/// - Subject: What you want in the video (object, person, animal, scenery)
111/// - Context: The background/setting
112/// - Action: What the subject is doing
113/// - Style: Film style keywords (horror, noir, cartoon etc.)
114/// - Camera motion (optional): aerial view, tracking shot etc.
115/// - Composition (optional): wide shot, close-up etc.
116/// - Ambiance (optional): Color and lighting details
117///
118/// More details are available in our [prompting guide](https://blog.fal.ai/mastering-video-generation-with-veo-2-a-comprehensive-guide/).
119///
120/// The model supports:
121/// - 720p resolution videos
122/// - 5-8 second duration at 24 FPS
123/// - Both 16:9 (landscape) and 9:16 (portrait) aspect ratios
124///
125/// Safety filters prevent generation of inappropriate content.
126pub fn veo2(params: TextToVideoInput) -> FalRequest<TextToVideoInput, TextToVideoOutput> {
127 FalRequest::new("fal-ai/veo2", params)
128}