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
- Read a Sume job's events to time the wait before generation
Read GET /v1/jobs/:id/events, find generation.submitted, and compute how long a job sat between created, queued and started. A Python helper with tested math.
- Get a 30-second track from Music 1.0 when there is no duration field
Music 1.0 rejects duration and duration_seconds. Steer length in the prompt, for example 'a 30-second track' with timestamped sections; a generation is $0.125.
- GET /v1/jobs returns 404 for a job another key created: Sume's rules
A Sume API key reads only jobs its own member created. A reconciler on a different member's key gets 404 not_found for a real job. How to design for it.
- GLM 5.3 Flash JSON output vs Sume's strict output_schema rules
GLM-5.3-Flash supports JSON output. Sume's run output_schema is stricter: object root, additionalProperties false, all properties required. A schema that works.
Written by Sume