Nova Canvas returned fewer images than asked: Sume n and data length
Nova Canvas can return fewer images than numberOfImages when moderation blocks some. How to count what you got and what you paid for on Sume.

Ask Nova Canvas for four images and you may get three. Amazon's docs (read 2026-10-06) say numberOfImages can return fewer images when responsible-AI moderation blocks some of them. Code that assumes four will index past the end of the list.
The Sume equivalent
n on Sume works the same way from the caller's side: you ask for a count, the response has a data array, and the per-model maximum comes from the catalog. The safe pattern is to never assume len(data) == n. Count the array and divide the billed amount by the count when you track cost per image.
usage.cost is the billed USD amount. A job that fails terminally returns a 502 error envelope with category, retryable and next_action, and failed jobs are not billed. For a slow request the response is a 202 job envelope, and the images come from the result URL, not from the first response.
Count first, then price
The function below handles three outcomes: a full result, a short result and a job that is still running.
import os, requests
def edit(n: int):
r = requests.post(
"https://api.sume.com/v1/images",
headers={"Authorization": f"Bearer {os.environ['SUME_API_KEY']}"},
json={"model": "google/nano-banana-2", "n": n,
"prompt": "Same mug, new table settings.",
"input_references": [{"type": "image_url", "image_url": {"url": "https://example.com/mug.jpg"}}]},
timeout=90)
if r.status_code == 202:
return None, r.json()
r.raise_for_status()
body = r.json()
got = len(body["data"])
per_image = body["usage"]["cost"] / got if got else 0
return got, per_image
print(edit(4))What to log
Log requested n, returned count and usage.cost on every call. A gap between the first two on a prompt that keeps coming back short usually points at the prompt, and it is cheaper to rewrite the prompt than to retry.
Sources
Related posts
More in Developers
- Nova Canvas rejects PNGs with transparent pixels: flatten before edits
Nova Canvas needs 8-bit PNG or JPEG with no transparent pixels in the alpha channel. Flatten cutouts onto white before any image edit, here and on Sume.
- Nuxt Nitro server route for an AI video webhook with readRawBody
A Nuxt server/api route calls readRawBody, checks Sume's sume-v1 HMAC and answers 401 on a mismatch before it queues the finished video download.
- One API key for Seedance 2.5, Wan 3.0, Kling 3 and MiniMax H3
Do you need a ByteDance, Alibaba, Kuaishou and MiniMax account to call their video models? On Sume one key and one wallet cover all four. How it works.
- One 6-minute b-roll, twelve Shorts episodes: source_in offsets
Slice one imported b-roll into twelve non-repeating 30-second episode backgrounds with Timeline 1.0 source_in, and plan the whole season unbilled in Python.
Written by Sume