Codia
返回所有文章

Remove Background API: Generate Clean Transparent PNG Cutouts

Engineering2026-04-23

What the Remove Background API Does

The Remove Background API takes an image URL and returns a transparent PNG cutout. It is designed for product upload flows, creative automation, design tools, and any workflow that needs clean alpha masks without a manual editing step.

The best image APIs are boring. You give them an image, you get back a result, and you move on with your product. Remove BG was designed with that standard in mind.

bash
curl 'https://api.codia.ai/v1/open/remove_bg' \ -H 'Authorization: Bearer {codia_api_key}' \ -H 'Content-Type: application/json' \ --data '{ "image_url": "https://example.com/product.jpg" }'
json
{ "code": 0, "message": "ok", "data": { "image_url": "https://processed-image-url.com/result.png" } }

That's it. One endpoint. One required field. One response shape. The rest of this post is about what we traded to keep the surface that small, and how the API behaves inside a real imaging pipeline.

What "clean" means for a cutout

The lazy version of a background-remove pipeline returns an image with a soft alpha channel that looks okay at thumbnail size and falls apart under a bright background or a crisp catalog layout. Remove BG targets the opposite: cutouts that hold up when a customer zooms in on a product page.

Concretely, the edge quality pass does three things that matter:

  • Sub-pixel alpha at the contour. The mask is matted, not thresholded — fine boundary hair, thin jewelry wires, lace, and glass rims retain soft edges rather than getting cut at the nearest whole pixel.
  • Color decontamination on the foreground. Pixels near the edge often carry green or red spill from the original background. The API removes that tint so the subject composites cleanly on any new background without a halo.
  • No shadow smear. If the original has a cast shadow on a white surface, the shadow goes with the background. If you want to keep shadows (some e-commerce teams do), the subject's own self-shadow on itself — the shaded underside of a shoe, the dark side of a mug — stays in place.

The practical test: composite the returned PNG on a #111 background. If you see a bright fringe, the cutout is not clean. Remove BG should pass this test on products, people, pets, food, furniture, and vehicles. It will struggle on motion-blurred subjects and on images where the subject shares a color palette with a busy background.

Latency budget

The advertised processing time is about 600 ms. That number is the model's inference time plus light I/O; end-to-end latency from your request to the returned URL is closer to 800–1200 ms depending on image size and region. For batch workloads the API parallelizes well — you can push hundreds of requests concurrently from a single key before rate limits kick in, which is typically enough for interactive product-upload flows.

If you're integrating into a synchronous UI — a user drags an image, wants to see the result immediately — 800 ms is a good feel. If you're ingesting a catalog of 50,000 SKUs overnight, run a worker pool, retry on transient failures, and size your concurrency off the rate limit.

Where the API fits

Five integration patterns that come up:

1. E-commerce product upload. When a merchant uploads a product photo, call Remove BG, store the transparent PNG next to the original, and let your template system composite against brand backgrounds: white for listings, campaign colors for ads, and seasonal backgrounds for promotions. You never re-run the model.

2. Design-tool asset pipeline. Drag an image into a canvas, background goes. This is the Figma / Canva model, and the latency budget we tuned for.

3. Photo apps. On-device models are getting good, but they're big, slow on older hardware, and expensive to update. If your app already has a network round-trip for other things, an API cutout is often the right call — smaller binary, better results, easier to improve.

4. Ad creative automation. Variable-background ad templates fed by a product feed: strip the background once, composite N times, ship N creatives. Remove BG is the "once" step.

5. AI generation pipelines. A generator produces a subject on a plain background, a second pipeline composites it into a scene. Clean alpha at this step is the difference between usable output and obvious AI smear.

Failure modes and how to handle them

Every image API has inputs it doesn't love. The ones to watch:

  • Very low-resolution images (below ~400px on the long edge). The model needs enough signal to matte an edge; below that, the cutout looks quantized. If you're building a user-facing product, reject images too small before calling.
  • Transparent inputs. If the source already has an alpha channel, the model will interpret the transparent regions as background. If you want to preserve existing transparency, flatten onto white first.
  • Extreme motion blur. Racing cars, action sports. The model keeps the subject but softens the edges further than a crisper capture would.
  • Subject-background color collision. White dress on white sheet; black dog on black couch. Results are still usable, but edge confidence drops. These are the cases worth a human review step.

The response includes a code field. 0 is success. Non-zero values (alongside a human-readable message) signal input issues — unreachable URLs, unsupported formats, images too large, rate-limit hits. Treat non-zero as a signal to either retry (network errors) or fail fast with the user (input errors).

Pricing and operational notes

The public plans are metered per successful call, with rollover credits so unused volume from one month doesn't evaporate. For high-volume use — think tens of millions of images a month — the enterprise tier is a flat-rate commit with a dedicated key, custom rate limits, and priority queue. There is no size tier on the free side: the quality is the same across plans, the only variables are volume and SLA.

Output images are served from a CDN URL that's valid long enough for you to download and cache. Don't hot-link; pull the result, store it in your own bucket, and serve from there. URLs are scoped to the request, not long-lived.

Start fast

  1. Key at codia.ai/dashboard/developer.
  2. Run the curl above against any product photo.
  3. Download the data.image_url, composite on a dark background, zoom in on the edge.
  4. If it looks good — and it should — wire it into your pipeline as the post-upload step.

Full reference, error codes, and volume pricing are at /api#remove-background.

The goal was a boring API. One endpoint, a fast clean cutout, reliable under load. If you don't have to think about the thing after you wire it up, that's the win.

FAQ

What output format does the Remove Background API return?

The API returns a processed image URL for a transparent PNG. Download the result and store it in your own asset bucket before serving it in production.

Can it remove backgrounds from product photos?

Yes. Product photography is one of the strongest use cases, especially for e-commerce listings, marketplace uploads, ad templates, and catalog normalization.

No. Treat the returned URL as a processing result. Download it, cache it, and serve the final asset from your own storage or CDN.

#remove-background-api#background-removal#transparent-png#image-processing#e-commerce