diff --git a/crates/api_clients/fal_client/src/requests/webhook/video/text/enqueue_hailuo_v2p3_pro_text_to_video_webhook.rs b/crates/api_clients/fal_client/src/requests/webhook/video/text/enqueue_hailuo_v2p3_pro_text_to_video_webhook.rs index 409d3a805f..7f67ce401a 100644 --- a/crates/api_clients/fal_client/src/requests/webhook/video/text/enqueue_hailuo_v2p3_pro_text_to_video_webhook.rs +++ b/crates/api_clients/fal_client/src/requests/webhook/video/text/enqueue_hailuo_v2p3_pro_text_to_video_webhook.rs @@ -1,6 +1,7 @@ use crate::creds::fal_api_key::FalApiKey; use crate::error::classify_fal_error::classify_fal_error; use crate::error::fal_error_plus::FalErrorPlus; +use crate::requests::traits::fal_request_cost_calculator_trait::{FalRequestCostCalculator, UsdCents}; use fal::endpoints::fal_ai::minimax::hailuo::hailuo_v2p3_pro_text_to_video::{hailuo_v2p3_pro_text_to_video, HailuoV2p3ProTextToVideoInput}; use fal::webhook::WebhookResponse; use reqwest::IntoUrl; @@ -17,6 +18,16 @@ pub struct EnqueueHailuoV2p3ProTextToVideoArgs<'a, R: IntoUrl> { pub api_key: &'a FalApiKey, } +impl FalRequestCostCalculator for EnqueueHailuoV2p3ProTextToVideoArgs<'_, U> { + fn calculate_cost_in_cents(&self) -> UsdCents { + /// "Your request will cost $0.49 per video generation." + 49 + } +} + + +/// Hailuo 2.3 Pro Text-to-Video +/// https://fal.ai/models/fal-ai/minimax/hailuo-2.3/pro/text-to-video pub async fn enqueue_hailuo_v2p3_pro_text_to_video_webhook( args: EnqueueHailuoV2p3ProTextToVideoArgs<'_, R> ) -> Result { diff --git a/crates/api_clients/fal_client/src/requests/webhook/video/text/enqueue_kling_v2p5_turbo_pro_text_to_video_webhook.rs b/crates/api_clients/fal_client/src/requests/webhook/video/text/enqueue_kling_v2p5_turbo_pro_text_to_video_webhook.rs index 92812cb169..6cee17b65e 100644 --- a/crates/api_clients/fal_client/src/requests/webhook/video/text/enqueue_kling_v2p5_turbo_pro_text_to_video_webhook.rs +++ b/crates/api_clients/fal_client/src/requests/webhook/video/text/enqueue_kling_v2p5_turbo_pro_text_to_video_webhook.rs @@ -1,6 +1,7 @@ use crate::creds::fal_api_key::FalApiKey; use crate::error::classify_fal_error::classify_fal_error; use crate::error::fal_error_plus::FalErrorPlus; +use crate::requests::traits::fal_request_cost_calculator_trait::{FalRequestCostCalculator, UsdCents}; use fal::endpoints::fal_ai::kling_video::v2_5::kling_v2p5_turbo_pro_text_to_video::{kling_v2p5_turbo_pro_text_to_video, KlingV2p5TurboProTextToVideoInput}; use fal::webhook::WebhookResponse; use reqwest::IntoUrl; @@ -32,6 +33,22 @@ pub enum EnqueueKlingV2p5TurboProTextToVideoAspectRatio { NineBySixteen, } + +impl FalRequestCostCalculator for EnqueueKlingV2p5TurboProTextToVideoArgs<'_, U> { + fn calculate_cost_in_cents(&self) -> UsdCents { + // "For 5s video your request will cost $0.35. + // For every additional second you will be charged $0.07." + match self.duration { + None => 35, // $0.35 + Some(EnqueueKlingV2p5TurboProTextToVideoDurationSeconds::Five) => 35, // $0.35 + Some(EnqueueKlingV2p5TurboProTextToVideoDurationSeconds::Ten) => 70, // $0.35 + (5 * $0.07) = $0.70 + } + } +} + + +/// Kling 2.5 Turbo Pro Text-to-Video +/// https://fal.ai/models/fal-ai/kling-video/v2.5-turbo/pro/text-to-video pub async fn enqueue_kling_v2p5_turbo_pro_text_to_video_webhook( args: EnqueueKlingV2p5TurboProTextToVideoArgs<'_, R> ) -> Result { diff --git a/crates/api_clients/fal_client/src/requests/webhook/video/text/enqueue_kling_v2p6_pro_text_to_video_webhook.rs b/crates/api_clients/fal_client/src/requests/webhook/video/text/enqueue_kling_v2p6_pro_text_to_video_webhook.rs index 7089149daf..5b79b93826 100644 --- a/crates/api_clients/fal_client/src/requests/webhook/video/text/enqueue_kling_v2p6_pro_text_to_video_webhook.rs +++ b/crates/api_clients/fal_client/src/requests/webhook/video/text/enqueue_kling_v2p6_pro_text_to_video_webhook.rs @@ -1,6 +1,7 @@ use crate::creds::fal_api_key::FalApiKey; use crate::error::classify_fal_error::classify_fal_error; use crate::error::fal_error_plus::FalErrorPlus; +use crate::requests::traits::fal_request_cost_calculator_trait::{FalRequestCostCalculator, UsdCents}; use fal::endpoints::fal_ai::kling_video::v2_6::kling_v2p6_pro_text_to_video::{kling_v2p6_pro_text_to_video, KlingV2p6ProTextToVideoInput}; use fal::webhook::WebhookResponse; use reqwest::IntoUrl; @@ -33,6 +34,26 @@ pub enum EnqueueKlingV2p6ProTextToVideoAspectRatio { NineBySixteen, } +impl FalRequestCostCalculator for EnqueueKlingV2p6ProTextToVideoArgs<'_, U> { + fn calculate_cost_in_cents(&self) -> UsdCents { + // "For every second of video you generated, you will be + // charged $0.07 (audio off) or $0.14 (audio on). + // For example, a 5s video with audio on will cost $0.70" + let generate_audio = self.generate_audio.unwrap_or(true); + let duration = self.duration.unwrap_or(EnqueueKlingV2p6ProTextToVideoDurationSeconds::Five); + + match (generate_audio, duration) { + (false, EnqueueKlingV2p6ProTextToVideoDurationSeconds::Five) => 35, // audio off: $0.07 * 5 = $0.35 + (false, EnqueueKlingV2p6ProTextToVideoDurationSeconds::Ten) => 70, // audio off: $0.07 * 10 = $0.70 + (true, EnqueueKlingV2p6ProTextToVideoDurationSeconds::Five) => 70, // audio on: $0.14 * 5 = $0.70 + (true, EnqueueKlingV2p6ProTextToVideoDurationSeconds::Ten) => 140, // audio on: $0.14 * 10 = $1.40 + } + } +} + + +/// Kling 2.6 Pro Text-to-Video +/// https://fal.ai/models/fal-ai/kling-video/v2.6/pro/text-to-video pub async fn enqueue_kling_v2p6_pro_text_to_video_webhook( args: EnqueueKlingV2p6ProTextToVideoArgs<'_, R> ) -> Result { @@ -74,9 +95,9 @@ pub async fn enqueue_kling_v2p6_pro_text_to_video_webhook( #[cfg(test)] mod tests { use crate::creds::fal_api_key::FalApiKey; + use crate::requests::webhook::video::text::enqueue_kling_v2p6_pro_text_to_video_webhook::{enqueue_kling_v2p6_pro_text_to_video_webhook, EnqueueKlingV2p6ProTextToVideoArgs, EnqueueKlingV2p6ProTextToVideoAspectRatio, EnqueueKlingV2p6ProTextToVideoDurationSeconds}; use errors::AnyhowResult; use std::fs::read_to_string; - use crate::requests::webhook::video::text::enqueue_kling_v2p6_pro_text_to_video_webhook::{enqueue_kling_v2p6_pro_text_to_video_webhook, EnqueueKlingV2p6ProTextToVideoArgs, EnqueueKlingV2p6ProTextToVideoAspectRatio, EnqueueKlingV2p6ProTextToVideoDurationSeconds}; #[tokio::test] #[ignore]