File size: 2,556 Bytes
e026dc9
 
 
 
 
da4a2eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e026dc9
 
 
da4a2eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
 * 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)}`;
}