Official Python SDK for RemoveBGVideo Public API (/v1)
📘 Full Documentation · 🧪 API Playground · 🔐 API Management · 🐙 GitHub
removebgvideo-python wraps /v1 endpoints with a Pythonic interface for:
- Authenticated job creation and status tracking
- Local upload support
- Usage analytics (
usage_summary,usage_events) - Admin key management via
X-Admin-Token - Structured API exceptions (
ApiError)
pip install removebgvideo- Python 3.9+
requests>=2.31.0(installed automatically)- RemoveBGVideo API key for public API
- Optional admin token for admin API
import os
from removebgvideo import RemoveBGVideoClient
client = RemoveBGVideoClient(api_key=os.environ["REMOVEBGVIDEO_API_KEY"])
job = client.create_job(
video_url="https://cdn.example.com/input.mp4",
model="original",
bg_type="transparent",
output_format="webm",
webhook_url="https://your-app.com/webhooks/removebgvideo",
auto_start=True,
)
result = client.wait_for_completion(job["id"], interval_seconds=2, timeout_seconds=600)
print(result.get("output_url"))from removebgvideo import RemoveBGVideoClient
client = RemoveBGVideoClient(
api_key="YOUR_API_KEY",
base_url="https://api.removebgvideo.com",
timeout=30,
)from removebgvideo import RemoveBGVideoAdminClient
admin = RemoveBGVideoAdminClient(
admin_token="YOUR_ADMIN_TOKEN",
base_url="https://api.removebgvideo.com",
timeout=30,
)job = client.create_job(
video_url="https://cdn.example.com/input.mp4",
model="human",
bg_type="transparent",
output_format="webm",
auto_start=True,
)
done = client.wait_for_completion(job["id"])
print(done["status"], done.get("output_url"))uploaded = client.upload("./input.mp4")
job = client.create_job(
video_url=uploaded["video_url"],
model="light",
output_format="webm",
auto_start=True,
)
done = client.wait_for_completion(job["id"])
print(done.get("output_url"))job = client.create_job(
video_url="https://cdn.example.com/input.mp4",
model="pro",
text_prompt="person wearing red jacket",
auto_start=False,
)
client.start_job(job["id"])
done = client.wait_for_completion(job["id"])# start later with overrides
client.start_job(
job["id"],
webhook_url="https://your-app.com/webhooks/removebgvideo",
)| Model | Speed | Quality | Best For | text_prompt |
|---|---|---|---|---|
original |
Standard | Highest | General quality-first segmentation | No |
light |
Fastest cost/perf | High | Simple scenes, throughput-first workloads | No |
pro |
Slowest | Highest | Complex objects with prompt-based targeting | Yes |
human |
Fast | High | Portraits / human subjects | No |
create_job(...) parameters:
video_url(str, required)model(original|light|pro|human, defaultoriginal)bg_type(str, defaultgreen)output_format(str, defaultwebm)text_prompt(str, optional, meaningful forpro)webhook_url(str, optional, receive async callbacks)bg_color(list[float], optional)auto_start(bool, defaultTrue)metadata(dict, optional)
RemoveBGVideoClient(api_key: str, base_url: str = "https://api.removebgvideo.com", timeout: int = 30)upload(file_path)->POST /v1/uploadscreate_job(...)->POST /v1/jobsstart_job(job_id, ...)->POST /v1/jobs/{id}/startget_job(job_id)->GET /v1/jobs/{id}list_jobs(limit=20, offset=0, status=None)->GET /v1/jobsusage_summary(days=7)->GET /v1/usage/summaryusage_events(limit=20)->GET /v1/usage/eventswait_for_completion(job_id, interval_seconds=2.0, timeout_seconds=600)-> polling helper
To receive callbacks, pass webhook_url in create_job(...) or start_job(...).
Events:
job.startedjob.completedjob.failed
Headers:
X-Webhook-EventX-Webhook-Delivery-IdX-Webhook-TimestampX-Webhook-Signature(when signing secret is configured server-side)
Python signature verification example:
import hmac
import hashlib
def verify_webhook(raw_body: str, timestamp: str, signature: str, secret: str) -> bool:
digest = hmac.new(
secret.encode("utf-8"),
f"{timestamp}.{raw_body}".encode("utf-8"),
hashlib.sha256,
).hexdigest()
expected = f"sha256={digest}"
return hmac.compare_digest(expected, signature or "")- Returns job payload when
status == "completed" - Raises
ApiErrorwhenstatus == "failed" - Raises
TimeoutErrorwhen elapsed time exceedstimeout_seconds
RemoveBGVideoAdminClient(admin_token: str, base_url: str = "https://api.removebgvideo.com", timeout: int = 30)get_config()->GET /v1/admin/configlist_keys()->GET /v1/admin/keyscreate_key(client_id, note=None)->POST /v1/admin/keysdisable_key(key_fingerprint)->POST /v1/admin/keys/disableenable_key(key_fingerprint)->POST /v1/admin/keys/enable
from removebgvideo import ApiError
try:
job = client.get_job("invalid-id")
except ApiError as err:
print("status:", err.status_code)
print("code:", err.code)
print("request_id:", err.request_id)
print("message:", str(err))Retry only transient failures:
- Retry:
429,500,502,503,504 - No blind retry:
400,401,403,404
import time
from removebgvideo import ApiError
def with_retry(fn, max_attempts=3):
for attempt in range(1, max_attempts + 1):
try:
return fn()
except ApiError as err:
retryable = err.status_code in {429, 500, 502, 503, 504}
if not retryable or attempt == max_attempts:
raise
time.sleep(attempt * 0.5)summary = client.usage_summary(days=7)
events = client.usage_events(limit=50)
print(summary)
print(events)Typical pattern:
- Use
usage_summaryfor high-level dashboard metrics. - Use
usage_eventsfor detailed event-level auditing.
examples/basic.py: basic create + waitexamples/upload_then_process.py: upload local file then processexamples/admin_key_ops.py: admin key operations
REMOVEBGVIDEO_API_KEYREMOVEBGVIDEO_ADMIN_TOKEN(admin only)
- Changelog: CHANGELOG.md
- Release process: RELEASING.md
Please read CONTRIBUTING.md.
MIT
