State-of-the-art background removal API for images and video โ open source, self-hostable, 10ร cheaper than remove.bg.
Playground ยท Docs ยท Quick Start ยท API Reference ยท Self-hosting
Drop an image in. Get a transparent PNG out. ~200ms per call.
A production-grade background removal API powered by BiRefNet โ the current SOTA on DIS5K, HRSOD, and COD benchmarks. Served on Modal's GPU infrastructure with scale-to-zero economics.
- SOTA quality โ matches or beats remove.bg, Photoroom, and Pixelcut on hair, fur, fine detail
- Fast โ ~200ms per image on a warm L4 GPU
- Cheap โ $0.02 per image pay-as-you-go (10x cheaper than remove.bg PAYG)
- Video too โ async video background removal with ProRes 4444 alpha output ($0.10/output-second)
- 28 documented endpoints โ cutouts, masks, PSD export, upscale, face restore, inpaint, collage, studio shots, video, and more
- MIT licensed โ model weights and code, commercial use OK
Works alpha-preserving (PNG with transparent bg) OR opaque (solid color / remote image as new bg).
Try it in your browser, no signup: useknockout.com/playground
Drag an image in, pick an operation, get the result back. It runs the live API. Also available as a Hugging Face Space.
Full docs (endpoints, SDKs): useknockout.com/docs
Base URL (for code): https://useknockout--api.modal.run
Input โ Output:
| Original | After |
|---|---|
| Complex hair | Clean wisps, no halo |
| Fur / pet photos | Soft edges preserved |
| Product shots | Sharp, clean cutout |
| Low-contrast subjects | Accurate separation |
Sign in, click to reveal your key on the dashboard, and paste it below. No credit card, ready in seconds.
- 10 full-resolution images/month free, forever โ no card needed
- Pay-as-you-go at $0.02/image unlocks all endpoints โ AI upscale, face restore, colorize, e-commerce presets, batch, video, and more (10ร cheaper than remove.bg's $0.20)
- $0.003/image at 100k+/month for volume
export KNOCKOUT_TOKEN=kno_live_your_key_hereThe examples below assume $KNOCKOUT_TOKEN is set.
curl -X POST "https://useknockout--api.modal.run/remove" \ -H "Authorization: Bearer $KNOCKOUT_TOKEN" \ -F "[email protected]" \ -o out.png
You get a PNG with a transparent alpha channel. Done.
curl -X POST "https://useknockout--api.modal.run/remove-url" \ -H "Authorization: Bearer $KNOCKOUT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"url":"https://example.com/cat.jpg"}' \ -o out.png
# solid color background curl -X POST "https://useknockout--api.modal.run/replace-bg" \ -H "Authorization: Bearer $KNOCKOUT_TOKEN" \ -F "[email protected]" \ -F "bg_color=#FF5733" \ -F "format=jpg" \ -o out.jpg # use a remote image as the new background curl -X POST "https://useknockout--api.modal.run/replace-bg" \ -H "Authorization: Bearer $KNOCKOUT_TOKEN" \ -F "[email protected]" \ -F "bg_url=https://example.com/mountains.jpg" \ -o out.png
# multipart batch curl -X POST "https://useknockout--api.modal.run/remove-batch?format=png" \ -H "Authorization: Bearer $KNOCKOUT_TOKEN" \ -F "[email protected]" -F "[email protected]" -F "[email protected]" # URL batch โ JSON body curl -X POST "https://useknockout--api.modal.run/remove-batch-url" \ -H "Authorization: Bearer $KNOCKOUT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"urls":["https://a.jpg","https://b.jpg"], "format":"png"}'
Both return JSON: { "count": N, "format": "png", "results": [{ "success": true, "data_base64": "..." }, ...] }.
# Sticker โ cutout + thick white outline (WhatsApp / iMessage sticker style) curl -X POST "https://useknockout--api.modal.run/sticker" \ -H "Authorization: Bearer $KNOCKOUT_TOKEN" \ -F "[email protected]" -F "stroke_width=24" -o sticker.png # Smart crop โ tight bounding box around subject curl -X POST "https://useknockout--api.modal.run/smart-crop" \ -H "Authorization: Bearer $KNOCKOUT_TOKEN" \ -F "[email protected]" -F "padding=32" -o cropped.png # Studio shot โ e-commerce preset (white bg + shadow + centered, 1:1 aspect) curl -X POST "https://useknockout--api.modal.run/studio-shot" \ -H "Authorization: Bearer $KNOCKOUT_TOKEN" \ -F "[email protected]" -F "aspect=1:1" -F "format=jpg" -o studio.jpg # Shadow โ subject composited onto new bg with a drop shadow curl -X POST "https://useknockout--api.modal.run/shadow" \ -H "Authorization: Bearer $KNOCKOUT_TOKEN" \ -F "[email protected]" -F "bg_color=#F3F4F6" -o shadow.png # Compare โ before/after side-by-side for marketing/social curl -X POST "https://useknockout--api.modal.run/compare" \ -H "Authorization: Bearer $KNOCKOUT_TOKEN" \ -F "[email protected]" -o compare.png # Mask โ just the black/white mask, for your own pipeline curl -X POST "https://useknockout--api.modal.run/mask" \ -H "Authorization: Bearer $KNOCKOUT_TOKEN" \ -F "[email protected]" -o mask.png # Outline โ subject on transparent bg with a thin outline curl -X POST "https://useknockout--api.modal.run/outline" \ -H "Authorization: Bearer $KNOCKOUT_TOKEN" \ -F "[email protected]" -F "outline_color=#000000" -F "outline_width=4" -o outline.png
# AI upscale โ Real-ESRGAN super-resolution (2x/4x) curl -X POST "https://useknockout--api.modal.run/upscale" \ -H "Authorization: Bearer $KNOCKOUT_TOKEN" \ -F "[email protected]" -F "scale=4" -o upscaled.png # PSD export โ layered Photoshop file (subject + background layers) curl -X POST "https://useknockout--api.modal.run/psd" \ -H "Authorization: Bearer $KNOCKOUT_TOKEN" \ -F "[email protected]" -o out.psd # Collage โ 2-9 photos, each cut out and laid out around a hero image curl -X POST "https://useknockout--api.modal.run/collage" \ -H "Authorization: Bearer $KNOCKOUT_TOKEN" \ -F "[email protected]" -F "[email protected]" -F "[email protected]" \ -F "main_position=BR" -F "aspect=1:1" -o collage.jpg
Removes the background from a clip (up to 15s) and returns ProRes 4444 with a real alpha channel โ or WebM/MP4 composited onto a color, image, or blur.
# submit the job curl -X POST "https://useknockout--api.modal.run/video/remove" \ -H "Authorization: Bearer $KNOCKOUT_TOKEN" \ -F "[email protected]" -F "format=prores4444" # -> {"job_id": "..."} # poll until done, then download curl "https://useknockout--api.modal.run/jobs/JOB_ID" \ -H "Authorization: Bearer $KNOCKOUT_TOKEN"
Billed at $0.10 per output second ($0.08 on Knockout Plus). Paid tiers only.
curl https://useknockout--api.modal.run/health
# {"status":"ok","model":"ZhengPeng7/BiRefNet"}The full endpoint-by-endpoint reference for all 28 documented endpoints, plus client examples for Python, Node.js, Go, and browser/TypeScript, lives in a dedicated doc:
โ API reference & client examples
Measured on Modal gpu="L4", Python 3.11, torch 2.4, batch size 1, 1024ร1024 model input.
| Image size | Warm latency (p50) | Cold start | Output format |
|---|---|---|---|
| 512ร512 | 180 ms | ~25 s | PNG / WebP |
| 1024ร1024 | 220 ms | ~25 s | PNG / WebP |
| 2048ร2048 | 310 ms | ~25 s | PNG / WebP |
| 4000ร4000 | 520 ms | ~25 s | PNG / WebP |
BiRefNet (the model we serve) consistently ranks first or second on public benchmarks:
- DIS5K (Dichotomous Image Segmentation): #1 F-measure as of 2024
- HRSOD (High-Resolution Salient Object Detection): #1 MAE
- COD10K (Camouflaged Object Detection): #1 or #2 depending on metric
See the BiRefNet paper and leaderboards for details.
Run your own instance on Modal in one command. Full prerequisites, deploy steps, and tuning guide:
โโโโโโโโโโโโโโ HTTPS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Client โ โโโโโโโโโโโโโโโโถ โ Modal ASGI (FastAPI) โ
โ (any lang) โ โ โโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโ โ โ Auth (bearer) โ โ
โ โ Validation โ โ
โ โ Image decode (PIL) โ โ
โ โ BiRefNet on L4 GPU โ โ
โ โ Encode (PNG/WebP) โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโ โ
โ Scale-to-zero, auto-HTTPS โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- One file (
main.py), single Modal class, 28 documented endpoints + auto-generated docs - Weights baked into image at build time โ cold starts are just image pull + GPU model load (~25 s)
- FastAPI handles multipart, JSON, CORS, OpenAPI schema generation
Sign up at useknockout.com/signin โ 30 images/month free, no card.
| Tier | Price | Best for |
|---|---|---|
| Free | 30 images / month, no card | Personal, eval, open source |
| Pay-as-you-go | $0.02 / image | Side projects, early startups |
| Knockout Plus | $10 / month, 250 images included, then $0.02 | Regular use + premium features |
| Volume | $0.003 / image at 100k+/mo | Production workloads |
| Enterprise | Custom, private endpoints | Compliance, BYO-cloud |
Add-ons: PSD export $0.10/image ยท Video $0.10 per output second ($0.08 on Plus).
For reference โ the same image on remove.bg is $0.20 at their PAYG rate.
Free tier includes the core background-removal endpoints:
/remove ยท /remove-url ยท /mask ยท /compare ยท /preview
Paid endpoints (any paid tier) add edits, AI enhancement, e-commerce presets, batch, and video:
/replace-bg ยท /smart-crop ยท /outline ยท /sticker ยท /shadow ยท /silhouette ยท /studio-shot ยท /headshot ยท /collage ยท /upscale ยท /face-restore ยท /colorize ยท /inpaint ยท /psd ยท /remove-batch ยท /remove-batch-url ยท /video/remove
Knockout Plus additionally unlocks layered PSD at a flat rate, edge despill, saved presets (/presets), custom watermarks, resizing, and compression control across all endpoints.
Try the API in your browser with no key at the playground. /estimate (pricing calculator) is free for everyone.
- GitHub Issues: https://github.com/useknockout/api/issues
- Twitter / X: @useknockout
MIT License โ see LICENSE. Model weights (BiRefNet) are also MIT. Commercial use is allowed for both.
Built in a few hours because someone said it couldn't be done.