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.

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 within.n: a range withminandmax; 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.
| Rank | Model | Price per image |
|---|---|---|
| 1 | Qwen Image | $0.025 |
| 2 | Seedream 4 | $0.0325 |
| 3 | Flux 2 Pro | $0.0375 |
| 4 | Seedream 5 Lite | $0.04375 |
| 5 | Seedream 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
- Pick a video model from GET /v1/videos/models, not a constant
A new video model should not need a redeploy. Filter the Sume catalog by resolution, duration, audio and frame inputs at runtime, and survive a withdrawn model.
- Pocket TTS API: run it yourself or call a hosted TTS API
Kyutai's Pocket TTS installs with pip and serves from localhost. If you want a hosted API with job URLs instead, here is the Sume request and what changes.
- Debug an MCP OAuth handshake in Postman against Sume's server
Postman can step through an OAuth 2.1 MCP handshake. Use it to find where a Sume connection breaks before you blame the agent client.
- Prefect 3 task retries for a Sume job: same Idempotency-Key
Retry a Sume image job in Prefect 3 without paying twice: a tested flow with retry_condition_fn, delay list and an order-derived idempotency key.
Written by Sume