Check a GPT Image 2.5 size before you call it: a Python validator
Sume rejects GPT Image 2.5 sizes that break four rules: multiples of 16, edge 3840, ratio 3:1, 655,360 to 8,294,400 pixels. A Python check, run on 8 sizes.

The short answer
Check four things before you send a custom image_size to GPT Image 2.5 on Sume: both edges are multiples of 16, the longest edge is at most 3840, the aspect ratio is at most 3:1, and the total is between 655,360 and 8,294,400 pixels. The Sume Image API docs list those rules. A small function catches a bad size locally, so you do not spend a request on a 400.
The rules
These come straight from the Sume Image API docs for openai/gpt-image-2.5 and openai/gpt-image-2.5-sunburst. The docs also allow named presets and auto; the validator below is only for custom pixels.
- Both edges must be multiples of 16.
- The maximum edge is 3840.
- The aspect ratio must be at most 3:1.
- The image must have 655,360 to 8,294,400 pixels.
The validator
It returns a list of problems, empty when the size is legal. It uses only the standard library.
def check_gpt_size(w: int, h: int) -> list[str]:
problems = []
if w % 16 or h % 16:
problems.append("edges must be multiples of 16")
if max(w, h) > 3840:
problems.append("max edge is 3840")
if max(w, h) / min(w, h) > 3:
problems.append("ratio above 3:1")
px = w * h
if not 655_360 <= px <= 8_294_400:
problems.append(f"{px:,} px outside 655,360-8,294,400")
return problems
sizes = [(1024, 1024), (1920, 1080), (1920, 1088), (3840, 2160),
(1080, 1350), (1024, 1280), (4096, 2048), (800, 800)]
for w, h in sizes:
print(f"{w}x{h}", check_gpt_size(w, h) or "ok")What it says about common sizes
Running the eight sizes gives the results below. The pixel counts are width times height.
| Size | Pixels | Result | Reason |
|---|---|---|---|
| 1024x1024 | 1,048,576 | ok | All four rules pass |
| 1920x1080 | 2,073,600 | fails | 1080 is not a multiple of 16 (1080 / 16 = 67.5) |
| 1920x1088 | 2,088,960 | ok | 1088 / 16 = 68 |
| 3840x2160 | 8,294,400 | ok | Exactly the pixel maximum; 2160 / 16 = 135 |
| 1080x1350 | 1,458,000 | fails | Neither edge is a multiple of 16 |
| 1024x1280 | 1,310,720 | ok | A 4:5 box that is legal |
| 4096x2048 | 8,388,608 | fails | Edge over 3840 and pixels over 8,294,400 |
| 800x800 | 640,000 | fails | Below the 655,360 floor |
Fixing a size that fails
When a check fails, repair it in a fixed order. First round each edge to the nearest multiple of 16, for example 1080 up to 1088. Then clamp the longest edge to 3840. Then, if the ratio is above 3:1, shorten the long edge until it passes. Last, scale both edges together if the pixel total is outside the range. Re-run the check after each step, since a fix for one rule can break another.
For delivery sizes that GPT cannot render, such as 1080 x 1350, render the nearest legal box and resize afterwards. That is the approach the docs describe for 4:5, and it costs a few lines of Pillow.
Run the validator where the size is chosen, before the HTTP call, and raise an error with the failed rule in the message. A validation error you raise yourself is faster and clearer than a 400 from the API, and it keeps bad sizes out of retry loops, where they would fail again each time.
Keep the four limits in one constant block at the top of the module. If the docs change a limit, you will have one line to edit, and the table in this post is the place to compare the numbers against the current docs page.
Call check_gpt_size before you build the body. If it returns problems, round each edge to the nearest multiple of 16, or render at a legal size and crop or resize afterwards. For an Instagram 4:5 portrait, the Sume docs say to treat 1080 x 1350 as a post-step target, and the repo's size catalog uses 1024 x 1280 as the legal 4:5 box.
The docs also say Sume rejects a parameter it does not list with 400 unsupported_parameter, so a size that the model cannot take fails fast rather than being silently changed.
Sources
Related posts
More in Developers
- Check your image cost table against Sume /v1/images/models cost_usd
Read pricing lines from GET /v1/images/models/{id}/endpoints and compare cost_usd with your own table before a batch. Sume lines already include its margin.
- CI guard: fail the build when a new Sume pricing_skus key appears
A node:test file fetches GET /v1/videos/models and fails when a model uses a pricing_skus key your cost code cannot total. Wan, Omni and H3 rates in the table.
- Run an Agent Completion nightly from CI with curl and a spend cap
A 25-line bash job that starts a Sume Agent Completion with a cap and an idempotency key, polls the receipt, and fails the build unless the run completed.
- Egress firewall for a Claude agent in CI: Sume hosts to allow
Claude Agent SDK v0.2.164 hardens CI egress firewalls. Which Sume hosts a render job needs: api.sume.com, mcp.sume.com and media.sume.com, and what each is for.
Written by Sume