httpx.
Installation
The package on PyPI is
poofbg, but the import name is poof.Quick Start
Authentication
api_key is required. The SDK does not read an environment variable for you, so load it yourself:
client.close() when you are done:
Usage Examples
From File Path
pathlib.Path objects work too.
From Bytes
From a File-like Object
From URL
Download the image first, then pass the bytes:With Options
channels="alpha", padding, aspect-ratio crop, the matte metadata fields and the width / height / fit output-size options are on the SDK’s main branch and ship in the next release (poofbg 0.2.0). The currently published 0.1.0 passes size and channels through unchanged but does not expose padding, the matte fields or the output-size options.Result Object
remove_background() returns a RemoveBackgroundResult:
Flagging Results for Review
matte_confidence (0–1) is how decisive the alpha mask is; matte_ambiguous_ratio (0–1) is the fraction of pixels with alpha between 0.1 and 0.9. Both are heuristics, not calibrated probabilities. The dashboard playground flags a result for review when the ambiguous ratio is above 0.15:
Account Info
client.me() returns the /me response as a plain dict. It is free and not rate limited.
Parallel Processing
The client is synchronous. To process several images at once, use a thread pool:Error Handling
All exceptions inherit fromPoofError and are chosen by HTTP status:
Every exception exposes
.message, .code, .details, .request_id and .status_code.
Retry with Backoff
Configuration
Type Hints
The SDK ships type hints and apy.typed marker, so mypy and IDEs understand Poof, RemoveBackgroundResult and the exception classes: