Estimate a 60-image Sume batch in Python before sending it: $3.05

A short Python script that prices a 60-image plan from Sume's list prices: 40 Grok drafts, 8 Nano Banana 2.1 4K finals and 12 FLUX.2 Pro images come to $3.05.

5 min readSume
All posts

You can price an image batch before any request by multiplying counts by Sume's list prices. A plan of 40 Grok Image drafts ($1.00), 8 Nano Banana 2.1 4K finals ($1.60) and 12 FLUX.2 Pro images ($0.45) comes to $3.05. The script below does that sum and stops if the number is over a budget.

The script

It runs as written with Python 3 and makes no network calls. The model ids are placeholders for the catalog ids; read GET /v1/images/models for the exact strings and keep the price table in step with the catalog.

PRICES = {
    "google/gemini-nano-banana-2.1@1K": 0.10,
    "google/gemini-nano-banana-2.1@4K": 0.20,
    "openai/gpt-image-2.5@low": 0.02475,
    "openai/gpt-image-2.5@high4K": 0.2225,
    "x-ai/grok-image": 0.025,
    "black-forest-labs/flux-2-pro": 0.0375,
}

def estimate(plan):
    total = 0.0
    for key, n in plan.items():
        total += PRICES[key] * n
    return total

plan = {
    "x-ai/grok-image": 40,
    "google/gemini-nano-banana-2.1@4K": 8,
    "black-forest-labs/flux-2-pro": 12,
}
cost = estimate(plan)
print(f"estimate: ${cost:.4f}")
if cost > 5.00:
    raise SystemExit("over budget")

The arithmetic it performs

Sume prices are the provider list times 1.25. The docs describe billed amounts as rounded up to the cent, so treat the estimate as a floor of the order of a cent, and compare it to usage.cost after the first request.

Plan priced from Sume list prices, as of 2026-10-09
RowCountPriceSubtotal
Grok Image40$0.025$1.00
Nano Banana 2.1, 4K8$0.20$1.60
FLUX.2 Pro12$0.0375$0.45
Total60$3.05

Where to take it next

Put the table in a file the catalog refresh can overwrite, since prices can change. Add a hard check on n, because a single call can request up to 10 images and each model has a lower ceiling in its descriptors. Slow configurations such as 4K can return a 202 job envelope after 30 seconds instead of a 200, so a real client must handle both.

Keeping prices honest

Prices change, and a stale dictionary will quietly produce a wrong estimate. Treat the table as a cache of the Sume catalog: refresh it when the catalog changes, and fail the script if a model key is missing rather than defaulting to zero. The KeyError that Python raises on an unknown key is the behavior you want here.

Compare the estimate against the first real response. If usage.cost for one image differs from your table, fix the table before sending the other 59.

What the script leaves out

It does not call the API. It does not price input references on token-billed rows, retries, or image upscale and cutout steps. For those, add keys such as upscale at $0.20 and RMBG at $0.0225 per image, with the same count-times-price pattern.

It also does not assume a plan will succeed. Failed generations are not billed, so the real cost of a batch can be lower than the estimate, but not higher than the count of completed images times the price.

One more guard is worth adding for real use: compare the estimate to the wallet balance before the first call. A request that cannot be covered fails with 402 insufficient_credits, and a 60-image plan that dies at image 41 leaves a half-finished set. The script above stops at a budget of $5.00; change that constant to the amount you actually want to risk.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume