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.

3 min readSume
All posts

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

Sume price, read 2026-10-08
GeneratorGenerateRMBGPairPair 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 a webhook_url instead 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

All Developers posts

Written by Sume