onAiRemoveBackground takes the background off the photo. With it, the AI offers Remove Background on its selector, with no brush and one button, Remove, a tip on the photo saying it removes the background and keeps the main subject: one tap, and the photo’s subject stands on a transparent background, shown as a checkerboard; saved as a PNG or a WebP, it stays transparent, and as a JPEG, it comes out white. After it, with onAiEditImage, the mode’s row is the new background’s field, Describe the new background, and its Generate has the fill paint it in, your function told it is the new background by its operation, 'GENERATE_BACKGROUND', which the recommended server sends, in words, to Bria FIBO 2.0 Edit, the model that followed the words in our measurements; without onAiEditImage, the cut photo leaves Remove alone, off, until an Undo brings the uncut photo back. With it, the AI’s conversation gets the retouch_remove_background tool too, and retouch.removeBackground() runs it from code. Without it, the button doesn’t show.




Full and Trial only. The Free and the Lite accept
onAiRemoveBackground and ignore it. It works alone: a site that gives only this function gets the AI’s ✦ and Remove Background’s Remove, with no selector, and nothing more.Wire It
In the page,onAiRemoveBackground posts the photo to your server and reads the cut back:
page.ts
route.ts
EmbedEditor, or as the same option of mountEditor and openEditor.
What the Editor Sends
A JPEG of the photo as it is at that moment, at most 2048 px on its longer side: the photo with the AI’s own edits, such as an earlier fill, and none of the rest: no crop, rotation, adjustments, filter, frame, annotations or Obfuscate areas, and no mark of any kind, the badge included. So the cut fits the whole photo, even when the person crops it afterward.
What to keep, in words, as the person typed them in Remove Background’s own field, Describe what to keep, before tapping its Remove (
'the woman and her dog'), for a model that cuts by words. Only with enableAiRemoveBackgroundPrompt, with which the tip on the photo says Leave it blank to keep the main subject; '' with no words and without it. The words leave the field as the call goes, and come back to it when your function rejects or its cut separates nothing, for another try with other words. Once the photo is cut, without onAiEditImage, the field gives way to Remove, off, until an Undo brings the uncut photo back. retouch.removeBackground({ prompt }) sends them too, and rejects with NOT_AVAILABLE for words without the prop. Of the servers below, only Bria RMBG 2.0’s reads them: turn the prop on with it.Aborts when the request stops: the Stop on the AI’s card, Escape,
ask.stop() or ask.end(), the editor closing or leaving the page, or another image opening. Pass it on to your fetch and to your model’s call.What It Gives Back
The photo with its background transparent: a PNG, or any image with alpha the browser reads, such as a WebP, at any size. The editor uses its alpha alone, stretched to the photo, and keeps the photo’s own pixels, so the subject’s edge is the one your model drew, hair and fur included. Where your model separates almost nothing (less than 0.5 % of the pixels below half alpha, or less than 0.5 % at half or above), the editor says Nothing Found and keeps the photo as it was; where the brush shows, it points the person to marking it by hand. The cut is one undo step. Its pixels are part of the photo, never of the state a host keeps: Save’ssrc holds them.
When your function rejects, the AI’s card says Couldn’t Remove the Background, with your error’s message under it, and the photo stays as it was. A rejection that is no Error, an Error with no message, or one of the editor’s own (EmbedEditorError) shows Try again. under the title, and so does an answer that is no image. retouch.removeBackground() rejects with AI_FAILED in each case, your error as its cause when it rejected. Inside a request, when the model calls its retouch_remove_background tool, the card shows neither: the model gets the failure, or the nothing found, as its tool’s answer.
Which Model
We tested the models on three photos on 2026-11-08, then tested additional models on two editor requests on 2026-11-09. We graded the cuts by eye; the sample is small, so try the models on your own images too.
Bria RMBG 2.0 is our recommendation. BiRefNet v2 is the inexpensive alternative; Cloudflare Images is an option when your server runs on Workers. Prices are from November 2026. The time for Bria includes the editor’s uploads; the other times do not measure the same path.
Servers
Each server is one module for your server, with the sameremoveBackground function: it takes the editor’s image and signal, Bria RMBG 2.0’s its prompt too (Cloudflare Images’ takes the Worker’s env in place of signal), and resolves to { cost, image }, the photo with its background transparent and what the call cost, in US$. The fal servers’ calls have two minutes, past which they reject with “The model took too long.” The person’s Stop ends the wait at once and asks fal to cancel the job, which fal’s own client doesn’t do: fal drops a job it hasn’t started yet but finishes, and bills, one it has (the fal job).
Bria RMBG 2.0
Bria’s RMBG 2.0, through fal. The photo goes up to fal’s storage, then one job, run byfal-job.ts, gives the cut back. The words of what to keep go to the same endpoint, which then cuts by them: on our plate, “the plate with the food and the hand” added the whole hand. They cost US$ 0.03 a call, against 0.018 without. It needs @fal-ai/client and FAL_KEY. The editor’s playground runs this file, word for word.
background.ts
BiRefNet v2
BiRefNet v2, through fal, at 1024 px, its job run byfal-job.ts. fal bills it by the second it runs, US$ 0.000575 a second, so the server asks fal how long the call ran, and gives back the cut with no cost (null) where fal doesn’t say or fails to answer. It needs @fal-ai/client and FAL_KEY.
background-cheap.ts
Cloudflare Images
For a site whose server is a Cloudflare Worker: the Worker’s Images binding cuts the subject out withsegment: 'foreground', BiRefNet run on Workers AI. Bind Images in the Worker’s Wrangler file ("images": { "binding": "IMAGES" }), on an Images Paid plan. The binding takes no signal, so the function takes the Worker’s env in its place: call it from the Worker’s fetch with the env it gets. Cloudflare bills each call as a unique transformation, the first 5,000 a month included, then US$ 0.50 for 1,000.
Cloudflare says its segment runs BiRefNet. On our plate photo it answered in 1.1 s, run with wrangler dev --remote, and cut the food alone, where Bria RMBG 2.0 cut the plate with it: see Which Model.
background-cloudflare.ts
The fal job
fal’s client, when its signal aborts, stops waiting for the job but doesn’t cancel it. The fal servers run each job through this module: when the person stops or the time limit passes, it stops waiting and asks fal to cancel the job by its id, even where the stop comes before fal gives the id, and it fetches the job’s image within the same limit. A cancel drops a job fal hasn’t started yet. A job fal has already started runs to its end and is billed: fal answers the cancel and finishes the job anyway (on 2026-11-10, a Bria cut canceled 6 seconds in completed at 25.5 seconds). It needs@fal-ai/client and limit.ts beside it.
fal-job.ts
The time limit
Every call to a model gets two minutes, its image’s fetch included: over twice the slowest call we measured of a model our servers run, Object Eraser’s 50 seconds on Runware, which fills a Remove. This module gives the call a signal that aborts when the person stops or the two minutes pass, whichever comes first, and past them rejects with “The model took too long.”, the words the editor shows. The fal job and the Runware server both run their calls through it.limit.ts