@umituz/react-native-ai-fal-provider 3.0.2 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -111,3 +111,10 @@ export {
|
|
|
111
111
|
|
|
112
112
|
export type { FalJobMetadata, IJobStorage } from "../infrastructure/utils";
|
|
113
113
|
export { InMemoryJobStorage } from "../infrastructure/utils";
|
|
114
|
+
|
|
115
|
+
// Pricing Utilities
|
|
116
|
+
export {
|
|
117
|
+
calculateVideoCredits,
|
|
118
|
+
calculateImageCredits,
|
|
119
|
+
} from "../infrastructure/utils";
|
|
120
|
+
export type { GenerationResolution } from "../infrastructure/utils";
|
|
@@ -105,3 +105,9 @@ export {
|
|
|
105
105
|
|
|
106
106
|
export { FalGenerationStateManager } from "./fal-generation-state-manager.util";
|
|
107
107
|
export type { GenerationState } from "./fal-generation-state-manager.util";
|
|
108
|
+
|
|
109
|
+
export {
|
|
110
|
+
calculateVideoCredits,
|
|
111
|
+
calculateImageCredits,
|
|
112
|
+
} from "./pricing/fal-pricing.util";
|
|
113
|
+
export type { GenerationResolution } from "./pricing/fal-pricing.util";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FAL AI Pricing Utilities
|
|
3
|
+
* Single Responsibility: Credit calculations for FAL AI generation
|
|
4
|
+
*
|
|
5
|
+
* Pricing:
|
|
6
|
+
* - 480p video: $0.05/sec
|
|
7
|
+
* - 720p video: $0.07/sec
|
|
8
|
+
* - Image with input: +$0.002
|
|
9
|
+
* - Image generation: $0.03
|
|
10
|
+
* Markup: 3.5x, Credit price: $0.10
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const COSTS = {
|
|
14
|
+
VIDEO_480P_PER_SECOND: 0.05,
|
|
15
|
+
VIDEO_720P_PER_SECOND: 0.07,
|
|
16
|
+
IMAGE_INPUT: 0.002,
|
|
17
|
+
IMAGE: 0.03,
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
const MARKUP = 3.5;
|
|
21
|
+
const CREDIT_PRICE = 0.1;
|
|
22
|
+
|
|
23
|
+
export type GenerationResolution = "480p" | "720p";
|
|
24
|
+
|
|
25
|
+
export function calculateVideoCredits(
|
|
26
|
+
duration: number,
|
|
27
|
+
resolution: GenerationResolution,
|
|
28
|
+
hasImageInput: boolean = false,
|
|
29
|
+
): number {
|
|
30
|
+
const costPerSec =
|
|
31
|
+
resolution === "480p"
|
|
32
|
+
? COSTS.VIDEO_480P_PER_SECOND
|
|
33
|
+
: COSTS.VIDEO_720P_PER_SECOND;
|
|
34
|
+
let cost = costPerSec * duration;
|
|
35
|
+
if (hasImageInput) cost += COSTS.IMAGE_INPUT;
|
|
36
|
+
return Math.ceil((cost * MARKUP) / CREDIT_PRICE);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function calculateImageCredits(): number {
|
|
40
|
+
return Math.ceil((COSTS.IMAGE * MARKUP) / CREDIT_PRICE);
|
|
41
|
+
}
|