API

@imgly/background-removal (In-Browser) vs a Background Removal API: When to Use Which

September 6, 20266 min readBy BG Clear Editorial

"imgly/background removal" is one of the most-searched developer phrases in this space because it promises the dream: remove backgrounds in the user's browser, no server, no upload, no per-image bill. The package delivers that — with a model download, a device-speed problem on cheap phones, and a licence you should read. This post is the honest comparison against a hosted API, and the hybrid that many products actually ship. Disclosure: bgclear sells the API side.

In this guide

What @imgly/background-removal does

IMG.LY publishes an npm package that runs a segmentation model in the browser through ONNX Runtime Web (WebAssembly, with GPU acceleration where the browser supports it). You pass an image (URL, Blob or ImageData) and get back a Blob with the background removed; there is also a Node variant for server-side use.

import { removeBackground } from "@imgly/background-removal";

const blob = await removeBackground(file, {
  // model: "small" | "medium" (larger = better edges, bigger download)
  progress: (key, current, total) => console.log(`${key}: ${current}/${total}`),
});
imgEl.src = URL.createObjectURL(blob);

The first call downloads the model and runtime assets — tens of megabytes, depending on the model you choose — and caches them; subsequent calls are local. Check the package README for the current model options, sizes and the licence terms (the package has been published under an AGPL-style licence with a commercial licence available from IMG.LY; verify what applies to your use before shipping).

What it costs, and it is not zero

Download: a model of tens of megabytes on first use is fine on a desktop with fibre and painful on a phone on 4G — many products gate the feature behind a "this may take a moment" screen, which is exactly the friction the API avoids.

Device time: on a recent laptop a photo takes a few seconds; on a mid-range Android phone it can take much longer, and memory pressure can crash the tab on very large images. You are shipping a GPU workload to hardware you do not control.

Quality: the browser models are smaller than server models by necessity. On clean subjects the result is good; hair, glass and low-contrast edges are where a server model has the headroom. Test your own images — the comparison is free on both sides.

Licensing: this is the one that surprises teams. Read the package licence and decide whether your product's licence is compatible or whether you need IMG.LY's commercial terms. An API has no such question; you pay per image and the code that calls it is yours.

When in-browser is the right call

Choose in-browser when the image genuinely must not leave the device (medical, legal, children's photos, regulated environments), when users are offline, when you want zero marginal cost at very high volumes of small images and can accept variable quality, or when the feature is a nice-to-have in a desktop-first app. It is also a fine free preview: run the in-browser model for the instant on-screen result, then send the image to an API for the final export.

When the API is the right call

Choose the API when quality on hair and product edges is the product, when your users are on phones and mobile data, when you need consistent timing (a few seconds regardless of device), when the workload is server-side anyway (catalogues, cron jobs, bots), or when you would rather not ship a large model and its licence. bgclear's endpoint is one call, returns PNG/WebP/JPG at full resolution, and preview-size results (≤800 px) are free without limit; full-resolution images are one credit — $9 for 100, $39 for 500, $129 for 2,000, no subscription (pricing). Never call it from the browser directly, though: the key would ship in your bundle. Proxy through a route on your server — the Next.js and Node guides show a 30-line one.

The hybrid many apps ship

Instant preview in the browser, final export through the API. The user drops an image, sees a cutout within seconds with no upload (imgly), and clicks "Export HD" — which posts the original to your server route, which calls the API at size=full and returns the high-quality PNG. Previews are free on both sides, so the only cost is the export the user actually asked for.

// preview (client): instant, no upload
const previewBlob = await removeBackground(file, { model: "small" });

// export (client → your server → API)
const form = new FormData();
form.append("image", file);
const res = await fetch("/api/cutout?size=full", { method: "POST", body: form });
const hdPng = await res.blob();

The server route forwards image as image_file with your Bearer key and an Idempotency-Key so a retried export is never charged twice. If you are consolidating after remove.bg's shutdown on 1 December 2026, the API side uses remove.bg's field names — see the migration page. For a self-hosted server model instead of a browser one, the rembg comparison covers that trade-off.

Frequently asked questions

Is @imgly/background-removal free?

The package is open source under a copyleft-style licence, with a commercial licence offered by IMG.LY; read the current LICENSE in the package before using it in a proprietary product. Running it costs nothing per image but shifts the compute to the user's device.

Does it work on mobile?

Yes, but the model download and processing time are noticeably heavier on mid-range phones and mobile data. Test on your slowest target device before committing.

Which gives better cutouts?

Server-side models are larger and generally lead on hair, glass and low-contrast edges; on clean subjects the browser model is close. Compare on your own images — both are free to test.

Can I use the bgclear API from the browser?

Not directly — the key would be exposed. Call it from a small server route; previews are free and full-resolution images cost one credit.

Ship it with the bgclear API

remove.bg-compatible endpoints, credits from $9 for 100 images, no subscription. Pay, get a key, make your first call in under two minutes.

Get API credits →

Tools for this guide

Background Removal API Free

background removal api free

Cheapest Background Remover API

cheapest background remover api

Image Segmentation API

image segmentation api

Keep reading

API

rembg vs a Background Removal API: Cost, Quality and Ops — and When to Use Each

What rembg actually is, what it costs to run properly, where its models fall short, and the honest decision rule between self-hosting an open-source model and paying per image for an API.

API

Next.js: Remove Image Backgrounds with a Route Handler and a React Upload Component

App Router route handler that forwards uploads to a background removal API (key stays on the server), a drop-zone client component with preview and HD export, and the streaming/limits details that bite in production.

API

Remove Image Backgrounds in Node.js with fetch and FormData (No SDK)

Node 18+ built-in fetch, a file upload, a URL input, an Express proxy endpoint so your browser never sees the key, and retries that cannot double-charge.

API

7 remove.bg API Alternatives Compared (2026): Price per Image, Free Tier, Drop-in Compatibility

With remove.bg closing on 1 Dec 2026, here is what the alternatives actually charge per image, what you get free, and which ones let you keep your existing request code.