Image Generation / Cost Calculator

Pricing Table

Gemini model price table used to calculate the cost of generations, with values in dollars per million tokens and per image.

On this page

    Source: src/image_generation/cost_calculator/pricing_table.py. This page's original notebook was empty; the content was written from the code.

    #Overview

    The file defines the ModelPricing dataclass, the PricingTable class and the BEST_TO_WORST_MODELS list. The prices follow the Gemini API pricing page, cited in a comment in the code. The table version is in PricingTable.VERSION (2026-02-11).

    #ModelPricing

    FieldTypeDescription
    input_per_million_tokensfloatPrice per million input tokens.
    output_per_million_tokensfloatPrice per million output tokens.
    image_price_per_unitfloat or NonePrice per generated image.
    cache_input_per_million_tokensfloat or NonePrice per million input tokens read from the cache.
    cache_storage_per_million_tokens_per_hourfloat or NoneCache storage price, per million tokens per hour.

    The dataclass is frozen: the values do not change after creation.

    #Registered prices

    ModelInputOutputPer imageCache (input)Cache (storage/hour)
    gemini-3-flash-preview0.503.00-0.051.00
    gemini-3-pro-image-preview2.0012.000.134--
    gemini-2.5-flash0.302.50-0.031.00
    gemini-2.5-flash-preview-09-20250.302.50-0.031.00
    gemini-2.5-flash-lite0.100.40-0.011.00
    gemini-2.5-flash-lite-preview-09-20250.100.40-0.011.00
    gemini-2.5-flash-image0.300.00.039--
    gemini-2.0-flash0.100.400.0390.0251.00

    Values in dollars: input, output and cache per million tokens; image per unit. A dash means None.

    In gemini-2.5-flash-image, the output is an image; that is why the per-token output price is 0.0 and the cost comes from the per-image price.

    Single resolution. The price of gemini-3-pro-image-preview (0.134) applies to 1K and 2K. The comment in the code records that 4K costs 0.24 and that the table does not yet distinguish the resolution.

    #get

    PricingTable.get(model) is a classmethod that returns the model's ModelPricing. If the model is not registered, it raises ValueError ("Modelo sem precificação cadastrada").

    from src.image_generation.cost_calculator.pricing_table import PricingTable
    
    # Look up the price of a model
    pricing = PricingTable.get("gemini-2.5-flash-image")
    print(pricing.image_price_per_unit)
    
    # Price table version
    print(PricingTable.VERSION)

    #BEST_TO_WORST_MODELS

    List of the models, from best to worst, in the order defined in the code:

    1. gemini-3-pro-image-preview
    2. gemini-3-flash-preview
    3. gemini-2.5-flash
    4. gemini-2.5-flash-preview-09-2025
    5. gemini-2.5-flash-image
    6. gemini-2.0-flash
    7. gemini-2.5-flash-lite-preview-09-2025
    8. gemini-2.5-flash-lite

    The use of this table is in Cost Calculator.

    Source: src/image_generation/cost_calculator/pricing_table.py

    Esc
    ↑↓navigate Enteropen