Image API 200 or 202: branch on the status code, not the body
POST /v1/images returns images with 200 or a job envelope with 202. A small Python handler that branches on the code and prints the URLs to poll.

POST /v1/images waits up to 30 seconds. If the image is ready it returns 200 with data[].url; if not, it returns 202 with a job envelope that carries status_url and result_url. The two bodies have different shapes, so a client must branch on the status code first and read the body second.
When you get a 202
The Image API docs list three triggers: the generation did not finish inside the budget, you sent mode "async", or you sent mode "webhook" with a webhook_url. Slow settings such as 4K, high quality and large n are the likeliest to degrade to 202. The job result is then read from the standard job endpoints described in Jobs and results.
A handler
This function makes the one request and returns either the image URLs or the two job URLs. It uses only fields shown in the docs.
import os
import requests
URL = "https://api.sume.com/v1/images"
HEAD = {"Authorization": "Bearer " + os.environ["SUME_API_KEY"]}
def generate(prompt):
r = requests.post(URL, headers=HEAD, json={
"model": "openai/gpt-image-2.5",
"prompt": prompt,
"quality": "medium",
}, timeout=60)
r.raise_for_status()
body = r.json()
if r.status_code == 200:
return {"urls": [d["url"] for d in body["data"]]}
data = body["data"]
return {"status_url": data["status_url"], "result_url": data["result_url"]}
if __name__ == "__main__":
print(generate("a ceramic mug on a wooden table"))What the handler leaves out
It does not poll. When you get the job URLs, call status_url until the job ends, then fetch result_url. Pass an Idempotency-Key header on retries so a repeat does not create a second job. Failed or cancelled generations are not billed, so a retry after a failure does not double-charge.
| Status | Body | What to read |
|---|---|---|
| 200 | Image response | data[].url, usage.cost |
| 202 | Job envelope | data.job.id, data.status_url, data.result_url |
| 400 | Error | unsupported_parameter if a field is not listed for the model |
Sources
Related posts
More in Developers
- Image API n: 10 per call in the schema, lower for each model
The Sume Image API schema allows n from 1 to 10, but each model lists its own n range. How to read the ceiling and what you pay for n images.
- Image burst after a model launch: 429 queue_full vs 503 retry plan
Launch week means batches. On Sume, 429 rate_limited, 429 queue_full and 503 provider_capacity_exceeded each need a different retry, plus idempotency keys.
- Sume /v1/images returns 200 or 202: branch on the status code
A slow 4K or xhigh image request on Sume returns 202 with a job envelope, not the image body. A Python client that handles 200, 202 and 502 correctly.
- image_size, aspect_ratio or size: which field wins on Sume
Sume's image API has three size fields. image_size beats aspect_ratio, size takes only a tier, and 4:5 is 1080x1350 portrait. Examples for GPT and Nano Banana.
Written by Sume