Export Sume image model prices to CSV from the endpoints API

Loop the model list, read each endpoint's pricing lines and write one CSV row per model and billable. A Python snapshot you can diff for price changes.

5 min readSume
All posts

To export Sume's image prices, call GET /v1/images/models for the model ids, call GET /v1/images/models/{id}/endpoints for each one, and write every entry of the endpoint's pricing array (billable, unit, cost_usd) as a CSV row with today's date. Sume documents endpoint pricing as the amount charged to your wallet, with margin already applied, so cost_usd times n is what a call costs; the file is a cost table you can diff, not a list price to adjust.

Run it on a schedule and commit the CSV. A price change then shows up as a one-line diff instead of a surprise on the next invoice.

What is in each pricing line?

From the Sume Image API page (read 2026-10-04), each line has three fields.

Fields in an endpoint pricing line, read 2026-10-04
FieldExampleMeaning
billableoutput_imageWhat is being charged for
unitimageThe unit of the charge
cost_usd0.033Charge per unit in USD, margin applied

What is the script?

Some models, such as ChatGPT Image 2.5, bill by tokens, so one model can produce several lines. The script writes them all and leaves the interpretation to you.

import csv, datetime, os, requests

BASE = "https://api.sume.com/v1/images/models"
H = {"Authorization": f"Bearer {os.environ['SUME_API_KEY']}"}

def get(url):
    r = requests.get(url, headers=H, timeout=30)
    r.raise_for_status()
    return r.json()

def main():
    today = datetime.date.today().isoformat()
    with open(f"sume-image-prices-{today}.csv", "w", newline="") as f:
        w = csv.writer(f)
        w.writerow(["date", "model", "billable", "unit", "cost_usd"])
        for m in get(BASE)["data"]:
            for ep in get(f"{BASE}/{m['id']}/endpoints")["endpoints"]:
                for p in ep["pricing"]:
                    w.writerow([today, m["id"], p["billable"], p["unit"], p["cost_usd"]])

if __name__ == "__main__":
    main()

How do I read the diff?

Keep one file per run and compare the latest two with diff or a spreadsheet. New rows mean a new model, removed rows mean a retired one, and a changed cost_usd means a price move. Check the id list before a deploy so a retired model does not become a runtime error.

Is this the same as the price on a finished call?

For per-image models it should match the usage.cost on a 200 response for one image. Token-billed models depend on quality and size, so use the pricing lines as inputs to an estimate and take the real figure from usage.cost. See the model chooser post for ranking models by these numbers.

Sources

Related posts

More in Pricing

All Pricing posts

Written by Sume