Estimate a Sume image batch cost from endpoint pricing lines in Python

Estimate an image batch before you run it: read cost_usd from the model's endpoint pricing line and multiply by n. A short Python script, with a caveat.

4 min readSume
All posts

The Image API docs state that endpoint pricing lines are the amount charged to your wallet, with margin already applied, so cost_usd times n is what you pay. For a batch, fetch the model's endpoint, take the output_image line and multiply by the number of images. Where a model prices by token or by quality, the line may not be a flat per-image number, so read what it lists.

What the docs say

From the Image API docs.

Pricing facts, read 2026-10-02
ItemFact
EndpointGET /v1/images/models/{model_id}/endpoints
Pricing linebillable, unit, cost_usd; for example output_image per image
Chargecost_usd times n, margin already applied
Failed generationsNot billed

The estimator

It handles only flat per-image lines and says so otherwise.

import os, requests

def estimate(model, n_total):
    r = requests.get(
        f"https://api.sume.com/v1/images/models/{model}/endpoints",
        headers={"Authorization": f"Bearer {os.environ['SUME_API_KEY']}"},
        timeout=30,
    )
    lines = r.json()["endpoints"][0]["pricing"]
    flat = [p for p in lines if p["billable"] == "output_image" and p["unit"] == "image"]
    if not flat:
        raise ValueError(f"no flat per-image line: {lines}")
    return round(flat[0]["cost_usd"] * n_total, 4)

print(estimate("bytedance-seed/seedream-4.5", 200))

Caveats

The catalog changes, so read prices at run time. Quality and size can change the charge on some models; for ChatGPT Image 2.5 the docs say auto quality reserves the max amount, so pin quality before you estimate. Confirm after the run with GET /v1/usage.

Sources

Related posts

More in Pricing

All Pricing posts

Written by Sume