GPT Image 2.5 Python example: generate an image with the Sume API
A runnable Python example for GPT Image 2.5 on Sume: async httpx, POST /v1/images, read data[].url, and stop cleanly on a 202 job. Copy, set the key, run.

This is a complete Python script that generates one image with GPT Image 2.5 through Sume: it posts to https://api.sume.com/v1/images, prints the image URL on a 200, and prints the job URL on a 202 so you can poll it. It needs httpx and a SUME_API_KEY environment variable.
Request and response shapes come from Sume's Image API docs and Jobs and results, read 2026-09-29.
What does the script look like?
import asyncio, os
import httpx
async def main() -> None:
headers = {"Authorization": f"Bearer {os.environ['SUME_API_KEY']}"}
body = {
"model": "openai/gpt-image-2.5",
"prompt": "a lighthouse on a cliff at dusk, oil painting",
"quality": "medium",
"image_size": "1536x1024",
}
async with httpx.AsyncClient(timeout=60) as client:
r = await client.post("https://api.sume.com/v1/images", headers=headers, json=body)
if r.status_code == 200:
for image in r.json()["data"]:
print(image["url"])
elif r.status_code == 202:
print("still running:", r.json()["data"]["status_url"])
else:
r.raise_for_status()
asyncio.run(main())Why check the status code?
A 200 carries the images; a 202 carries a job. The docs say to check the status code, not the body shape. On 202, poll status_url, then read result_url.
| Status | Body | Script prints |
|---|---|---|
200 | data[].url per image | Each image URL |
202 | Job envelope with status_url | The status URL |
| Other | Error body | Raises httpx.HTTPStatusError |
Which size did the example use?
1536x1024: both edges are multiples of 16 and the total is 1,572,864 pixels, inside the 655,360 to 8,294,400 range.
Sources
Related posts
More in Developers
- GPT Image 2.5 reference images: how many you can send and how to use
GPT Image 2.5 on Sume accepts up to 16 reference images per request, six more than GPT Image 2. How to label each image's job in the prompt and what to check.
- GPT Image 2.5 transparent background: how to request a cutout by API
GPT Image 2.5 on Sume accepts background transparent. OpenAI says transparency needs png or webp output. The request, the catch, and when to use another route.
- GPT Image 2.5 400 unsupported_parameter: fields each model accepts
A 400 unsupported_parameter from Sume's image API means the model does not list that field. Which GPT Image ids accept quality, mask_url and background.
- Grok 4.7 remote MCP tool: connect Sume to the xAI Responses API
xAI's remote MCP tool works with grok-4.7 on the Responses API. Point server_url at Sume's hosted MCP, restrict allowed_tools, and cap spend on the Sume side.
Written by Sume