Official Python client for the NukeBG background removal API: transparent cutouts, white and marketplace-ready backgrounds, object removal, upscaling, batches, video jobs and webhooks. Standard library only, Python 3.8+.
Also a drop-in replacement for the removebg package. remove.bg's self-serve API closes on 1 December 2026; change one import and keep your code.
pip install nukebgCreate an API key at nukebg.com/account. New accounts get 50 free credits plus 20 a month, and one standard cutout is one credit.
from nukebg import NukeBG
client = NukeBG(api_key="nbg_live_...") # or set NUKEBG_API_KEY
# A file path, an https URL, bytes or an open binary file
result = client.remove_background("product.jpg")
result.save("product.png")
print(result.width, result.height, result.credits_remaining)listing = client.remove_background(
"https://example.com/shoe.jpg",
background="white", # or "#F4F4F4", "gradient:#fff,#eee", "scene:marble"
size="amazon", # original | amazon | shopify | etsy | ebay | instagram | story
shadow="soft",
format="jpg",
)
listing.save("shoe-amazon.jpg")All options: quality (preview | standard | hd | ultra), background, size, width, height, padding, crop, shadow, subject (all | main), despill, format, jpeg_quality, channels (rgba | alpha), idempotency_key.
- from removebg import RemoveBg
+ from nukebg.removebg import RemoveBg
- rmbg = RemoveBg("REMOVEBG_API_KEY", "error.log")
+ rmbg = RemoveBg("NUKEBG_API_KEY", "error.log")
rmbg.remove_background_from_img_file("joker.jpg") # writes joker.jpg_no_bg.png
rmbg.remove_background_from_img_url("https://example.com/joker.jpg")
rmbg.remove_background_from_base64_img(b64_string)The same methods and defaults; errors go to the error log, as before. Any other remove.bg parameter (crop, roi, scale, position, format, bg_image_url…) can be passed as a keyword. See the migration guide.
clean = client.erase("desk.jpg", prompt="the cables on the desk") # or mask="mask.png" (white = remove)
big = client.upscale("small.jpg", scale=4) # paid credits
print(client.account()["credits"])batch = client.create_batch("cutout", [{"image_url": u} for u in urls], params={"background": "white", "size": "shopify"})
status = client.get_batch(batch["batch_id"])
open("results.zip", "wb").write(client.batch_zip(batch["batch_id"]))
file_id = client.upload("clip.mp4")
job = client.create_job("video", {"file_id": file_id}, params={"format": "webm"})
done = client.wait_for_job(job["id"])
print(done["result"]["url"])
# In your webhook handler (use the raw body)
ok = NukeBG.verify_webhook(request.body, request.headers.get("X-NukeBG-Signature"), webhook_secret)Failed calls raise NukeBGError with status, code (for example insufficient_credits, invalid_api_key, no_subject) and request_id. Rate limits (429) and temporary engine errors (5xx) are retried twice, honouring Retry-After. Every POST sends an idempotency key, so a retry is never charged twice. Failed jobs are never charged.
- API reference
- MCP server for Claude, Cursor, VS Code and other AI assistants
- Pricing
MIT licensed. NukeBG is a product of VOLODS LTD. Not affiliated with remove.bg.