Pick the cheapest Sume image model for an aspect ratio (Python)

A short Python script that reads GET /v1/images/models, keeps models that list your ratio, reference count and n, then prices them from the endpoint records.

5 min readSume
All posts

Do not hard-code which model takes which ratio. Ask the catalog: GET /v1/images/models returns each model's supported_parameters, with aspect_ratio as an enum, n and input_references as ranges, and the endpoints URL gives the price. The script below filters by ratio, reference count and n, then sorts by the price on the endpoint record. A parameter a model does not list gives a 400 unsupported_parameter, so filtering first saves a failed call.

What the catalog gives you

Image API docs list these fields on each model (read 2026-10-03): id, supported_parameters, supports_streaming and endpoints. The price is on the per-endpoint record, in a pricing list of billable lines with cost_usd. The endpoint price is the list price times 1.25; usage.cost on a response is the billed USD.

  • aspect_ratio: an enum, so test membership with in.
  • n: a range with min and max; Grok Imagine's maximum is 1.
  • input_references: a range; 0 means text-to-image only.
  • quality, resolution, background: listed only on models that take them.

The script

It needs one request for the list and one per candidate for the price. With 19 models, a ratio shared by many costs many requests, so cache the result for the day. The pricing list can have several lines; the script takes the lowest.

import os, requests

H = {"Authorization": f"Bearer {os.environ['SUME_API_KEY']}"}
BASE = "https://api.sume.com/v1/images/models"
def cheapest(ratio, n=1, refs=0):
    out = []
    for m in requests.get(BASE, headers=H, timeout=60).json()["data"]:
        sp = m["supported_parameters"]
        if ratio not in sp.get("aspect_ratio", {}).get("values", []):
            continue
        if sp.get("n", {}).get("max", 1) < n:
            continue
        if sp.get("input_references", {}).get("max", 0) < refs:
            continue
        ep = requests.get(f"{BASE}/{m['id']}/endpoints", headers=H, timeout=60).json()
        price = min(p["cost_usd"] for p in ep["endpoints"][0]["pricing"])
        out.append((price, m["id"]))
    return sorted(out)
for price, mid in cheapest("4:5", n=4, refs=1)[:5]:
    print(f"${price:.4f}  {mid}")

Reading the output

For 4:5 with four images per call and one reference, the cheapest rows by the catalog on 2026-10-03 start at $0.025 an image. Grok Imagine drops out on both counts: it does not list 4:5 and its n maximum is 1.

Expected order for 4:5, n=4, one reference (read 2026-10-03)
RankModelPrice per image
1Qwen Image$0.025
2Seedream 4$0.0325
3Flux 2 Pro$0.0375
4Seedream 5 Lite$0.04375
5Seedream 4.5$0.05

What the script does not decide

Price is only one filter. A cheap model may draw text badly or follow a reference loosely, so test your own prompt on the top three before you commit. The GPT Image 2.5 price depends on quality and size, so the single catalog figure ($0.0659 for the default high) is a rough guide.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume