Metadata-Version: 2.5
Name: nukebg
Version: 1.0.0
Summary: Official Python client for the NukeBG background removal API, with a drop-in replacement for the removebg package.
Project-URL: Homepage, https://nukebg.com
Project-URL: Documentation, https://nukebg.com/docs
Project-URL: Source, https://github.com/nukebg/nukebg-python
Project-URL: Issues, https://github.com/nukebg/nukebg-python/issues
Project-URL: remove.bg migration, https://nukebg.com/migrate-from-remove-bg
Author-email: VOLODS LTD <nukebg@volods.com>
License: MIT
License-File: LICENSE
Keywords: background removal,image api,nukebg,remove background,remove.bg,removebg,transparent png
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Multimedia :: Graphics
Classifier: Typing :: Typed
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# nukebg

Official Python client for the [NukeBG](https://nukebg.com) 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.

```bash
pip install nukebg
```

Create an API key at [nukebg.com/account](https://nukebg.com/account). New accounts get 50 free credits plus 20 a month, and one standard cutout is one credit.

## Remove a background

```python
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)
```

### On white, at Amazon size

```python
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`.

## Switching from remove.bg

```diff
- 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](https://nukebg.com/migrate-from-remove-bg).

## Other tools

```python
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"])
```

## Batches, video and webhooks

```python
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)
```

## Errors and retries

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.

## Links

- [API reference](https://nukebg.com/docs)
- [MCP server](https://nukebg.com/mcp-server) for Claude, Cursor, VS Code and other AI assistants
- [Pricing](https://nukebg.com/pricing)

MIT licensed. NukeBG is a product of VOLODS LTD. Not affiliated with remove.bg.
