feat: Add cost estimator for image generation in BatchForm, ExtensiveForm, and GenerationForm
da4a2eb
| /** | |
| * Available image generation models | |
| * These match the MODEL_REGISTRY in services/image.py | |
| */ | |
| export const IMAGE_MODELS = [ | |
| { value: "", label: "Default (z-image-turbo) - $0.01/image", price: 0.01, priceNote: "per megapixel" }, | |
| // { value: "z-image-turbo", label: "Z-Image Turbo (Fast & High Quality) - $0.01/image", price: 0.01, priceNote: "per megapixel" }, | |
| { value: "gpt-image-1.5", label: "GPT Image 1.5 (OpenAI) - $0.136/image", price: 0.136 }, | |
| { value: "nano-banana", label: "Nano Banana (Google) - $0.039/image", price: 0.039 }, | |
| { value: "nano-banana-pro", label: "Nano Banana Pro (Google) - $0.15/image", price: 0.15 }, | |
| { value: "imagen-4", label: "Imagen-4 (Google) - $0.04/image", price: 0.04 }, | |
| { value: "imagen-4-ultra", label: "Imagen-4 Ultra (Google) - $0.06/image", price: 0.06 }, | |
| { value: "imagen-4-fast", label: "Imagen-4 Fast (Google) - $0.02/image", price: 0.02 }, | |
| { value: "gemini-2.5-flash-image", label: "Gemini 2.5 Flash Image (Google) - $0.039/image", price: 0.039 }, | |
| { value: "recraft-v3", label: "Recraft V3", price: null }, | |
| { value: "ideogram-v3", label: "Ideogram V3", price: null }, | |
| { value: "ideogram-v3-turbo", label: "Ideogram V3 Turbo - $0.03/image", price: 0.03 }, | |
| { value: "photon", label: "Photon (Luma)", price: null }, | |
| { value: "seedream-3", label: "Seedream-3 (ByteDance)", price: null }, | |
| { value: "seedream-4.5", label: "Seedream-4.5 (ByteDance) - $0.04/image", price: 0.04 }, | |
| { value: "flux-2-max", label: "Flux 2 Max (Black Forest Labs) - $0.04/image", price: 0.04 }, | |
| { value: "qwen-image", label: "Qwen Image (Pruna AI) - $0.025/image", price: 0.025 }, | |
| { value: "p-image", label: "P-Image (Pruna AI) - $0.005/image (200 for $1)", price: 0.005 }, | |
| ] as const; | |
| export type ImageModel = typeof IMAGE_MODELS[number]["value"]; | |
| /** | |
| * Get the estimated cost for generating images with a specific model | |
| * @param modelValue - The model identifier | |
| * @param imageCount - Number of images to generate (default: 1) | |
| * @returns Estimated cost in USD, or null if pricing is not available | |
| */ | |
| export function getModelCost(modelValue: string, imageCount: number = 1): number | null { | |
| const model = IMAGE_MODELS.find(m => m.value === modelValue); | |
| if (!model || model.price === null) return null; | |
| return model.price * imageCount; | |
| } | |
| /** | |
| * Format the cost for display | |
| * @param cost - Cost in USD | |
| * @returns Formatted cost string | |
| */ | |
| export function formatCost(cost: number | null): string { | |
| if (cost === null) return "Pricing not available"; | |
| return `$${cost.toFixed(3)}`; | |
| } | |