Generate then cut out: an image-model result into RMBG, in Python
Two Sume calls: generate a product shot, then POST its URL to /v1/rmbg-1.0/remove. Runnable Python, the polling loop, and the $0.1225 total per cutout.

Generate with any image row, then send the returned URL to POST /v1/rmbg-1.0/remove. The pair costs $0.1225 with Nano Banana 2.1 at 1K plus $0.0225 RMBG. RMBG takes a public HTTPS image_url and returns a PNG with alpha as a job result.
The two calls
RMBG defaults to async, so it returns a job envelope with status_url and result_url. Poll the status, then read the result once it is ready; /result returns 409 job_not_completed before that.
import os, time, requests
H = {"Authorization": f"Bearer {os.environ['SUME_API_KEY']}"}
B = "https://api.sume.com"
g = requests.post(f"{B}/v1/images", headers=H, timeout=60, json={
"model": "google/nano-banana-2.1",
"prompt": "Leather wallet on a plain grey sweep, studio light",
})
url = g.json()["data"][0]["url"]
j = requests.post(f"{B}/v1/rmbg-1.0/remove", headers=H, timeout=60,
json={"image_url": url, "mode": "async"}).json()
j = j.get("data", j)
while True:
s = requests.get(j["status_url"], headers=H, timeout=30).json()
s = s.get("data", s)
if s.get("terminal"):
break
time.sleep(2)
print(requests.get(j["result_url"], headers=H, timeout=30).json())What it costs
| Generator | Generate | RMBG | Pair | Pair x 500 |
|---|---|---|---|---|
| nano-banana-2.1 | $0.10 | $0.0225 | $0.1225 | $61.25 |
| seedream-5-lite | $0.04375 | $0.0225 | $0.06625 | $33.125 |
| flux-2-pro | $0.0375 | $0.0225 | $0.06 | $30.00 |
| qwen-image | $0.025 | $0.0225 | $0.0475 | $23.75 |
Notes
- If the input already has a lot of fully transparent pixels, Sume flattens it onto mid-gray before the removal so edges stay clean; this is still one billed removal.
- Read the job record if a removal fails: the failure is on the job, not in the result.
- For many images, use
mode: "webhook"with awebhook_urlinstead of polling.
Scaling it
For hundreds of images, submit RMBG jobs with mode: "webhook" and a webhook_url; terminal events arrive as signed WebhookEvent payloads, so no poll loop runs.
- Verify the webhook signature and refuse an empty secret.
- Keep the generated URL until the cutout has fetched it.
- Store both the source and the PNG next to your SKU.
Sources
Related posts
More in Developers
- Go: net/http client for a 30-second Wan 3.0 clip, 30 lines
A 30-line Go program using only the standard library: submit wan-3.0 for 30 seconds, poll the job, write clip.mp4. Reserve and per-second rate included.
- gpt-image-2.5 quality auto reserves max: holds from $0.22 to $0.89
On Sume, gpt-image-2.5 with quality auto and auto size reserves $0.8895 per image, while omitting quality reserves $0.2224. Hold table and the safe request.
- Haiku 5.5 prompt caching for a Sume tool list: what breaks the cache
Haiku 5.5 cache hits cost $0.01 per million tokens. Keep the Sume tool list and effort setting stable so a long agent run keeps hitting the cache.
- Haiku 5.5 returns 400 for thinking disabled at xhigh: a Sume agent fix
Claude Haiku 5.5 rejects thinking disabled at xhigh or max effort. How that 400 shows up in an agent that calls Sume, and how to set the pair.
Written by Sume