Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b7rnC7jppGGdHGESvy
72 lines
3.1 KiB
Java
72 lines
3.1 KiB
Java
package com.ankurm.imagegen;
|
|
|
|
import java.util.LinkedHashMap;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* Per-image prices copied from each provider's own pricing pages, read on {@link #READ_ON}.
|
|
* Prices change; the date is the whole claim. A provider or size missing here is missing because
|
|
* the official page did not state a per-image figure we could read.
|
|
*
|
|
* <p>Sources:
|
|
* <ul>
|
|
* <li>OpenAI: https://developers.openai.com/api/docs/guides/image-generation ("Calculating costs" table)
|
|
* and https://developers.openai.com/api/docs/pricing (token rates)</li>
|
|
* <li>Google: https://ai.google.dev/gemini-api/docs/pricing (Gemini image models)</li>
|
|
* <li>Stability AI: https://docs.stability.ai/pricing (credits; 1 credit = $0.01)</li>
|
|
* </ul>
|
|
*/
|
|
public final class CostModel {
|
|
|
|
public static final String READ_ON = "2026-10-28";
|
|
public static final double STABILITY_USD_PER_CREDIT = 0.01;
|
|
|
|
private CostModel() {}
|
|
|
|
/** OpenAI per-image output prices, 1024x1024 / 1024x1536 / 1536x1024, as printed on the guide. Text prompt tokens are extra. */
|
|
public static Map<String, double[]> openAiPerImage() {
|
|
Map<String, double[]> m = new LinkedHashMap<>();
|
|
m.put("gpt-image-2 low", new double[] {0.006, 0.005, 0.005});
|
|
m.put("gpt-image-2 medium", new double[] {0.053, 0.041, 0.041});
|
|
m.put("gpt-image-2 high", new double[] {0.211, 0.165, 0.165});
|
|
m.put("gpt-image-1.5 low", new double[] {0.009, 0.013, 0.013});
|
|
m.put("gpt-image-1.5 medium", new double[] {0.034, 0.05, 0.05});
|
|
m.put("gpt-image-1.5 high", new double[] {0.133, 0.2, 0.2});
|
|
m.put("gpt-image-1-mini low", new double[] {0.005, 0.006, 0.006});
|
|
m.put("gpt-image-1-mini medium", new double[] {0.011, 0.015, 0.015});
|
|
m.put("gpt-image-1-mini high", new double[] {0.036, 0.052, 0.052});
|
|
return m;
|
|
}
|
|
|
|
/** Google: dollars per output image at the stated resolution, standard tier. */
|
|
public static Map<String, Double> googlePerImage() {
|
|
Map<String, Double> m = new LinkedHashMap<>();
|
|
m.put("gemini-3.1-flash-lite-image 1K", 0.0336);
|
|
m.put("gemini-3.1-flash-image 0.5K", 0.045);
|
|
m.put("gemini-3.1-flash-image 1K", 0.067);
|
|
m.put("gemini-3.1-flash-image 2K", 0.101);
|
|
m.put("gemini-3.1-flash-image 4K", 0.151);
|
|
m.put("gemini-3-pro-image 1K-2K", 0.134);
|
|
m.put("gemini-3-pro-image 4K", 0.24);
|
|
m.put("gemini-2.5-flash-image 1K", 0.039);
|
|
return m;
|
|
}
|
|
|
|
/** Stability: credits per call. */
|
|
public static Map<String, Double> stabilityCredits() {
|
|
Map<String, Double> m = new LinkedHashMap<>();
|
|
m.put("Stable Image Ultra", 8.0);
|
|
m.put("Stable Diffusion 3.5 Large", 6.5);
|
|
m.put("Stable Diffusion 3.5 Large Turbo", 4.0);
|
|
m.put("Stable Diffusion 3.5 Medium", 3.5);
|
|
m.put("Stable Image Core", 3.0);
|
|
m.put("Stable Diffusion 3.5 Flash", 2.5);
|
|
return m;
|
|
}
|
|
|
|
/** Dollars for {@code images} images with a flat per-image price. */
|
|
public static double total(double perImage, int images) {
|
|
return perImage * images;
|
|
}
|
|
}
|