onAiDetectObjects detects objects in the photo for Obfuscate’s Detect. With it, Obfuscate’s pill shows Detect: one tap covers every face, license plate, document and screen in the photo with an area, in the look the person chose for the next one, and the person moves, resizes or removes each one as an area drawn by hand. obfuscate.detect() does the same from code, and with onAiChooseCommands the AI’s model gets it as its obfuscate_detect tool. Without it, Obfuscate has no Detect: the person draws each area.

onAiChooseCommands: “Hide every face and license plate” on a street with a parked car, for street photos and dashcam footage. The model calls obfuscate_detect, which covers the faces of the group, two in the background and the plate through this function, looks again up close, and covers 4 small faces left near a café itself. SAM 3’s and Claude Sonnet 5.5’s real answers; the commands in Use Cases.

Full and Trial only. The Free and the Lite accept
onAiDetectObjects and ignore it.Wire It
In the page,onAiDetectObjects posts the photo and the texts to your server:
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 was loaded, with the AI’s own edits on it (a Remove, a Generate, an Expand, a cut background), at most 1024 px on its longer side: no crop, rotation, adjustments, filter, frame, annotations or Obfuscate areas, and no mark of any kind, the badge included. So the boxes you give back map straight to the photo’s px, whatever the edit holds.
What to find, in English:
['face', 'license plate', 'document', 'screen'], every time, unless your aiPrompts replace any of them (detectFace, detectLicensePlate, detectDocument, detectScreen), in that order.Aborts when the person stops Detect (Escape, or Stop in a request of the AI’s), on
ask.stop() and ask.end(), when the editor closes, is destroyed or leaves the page, and when another image opens. Pass it on to your fetch and to your model’s call.What It Gives Back
Everything found, for every text: an empty list when nothing was found.The thing’s rectangle, as fractions from 0 to 1 of the image:
left and right along its width, top and bottom along its height. A box that strays off the photo is held to its edge, and one with nothing of the photo in it is left out, as is an entry with no box or a box that isn’t four numbers.From 0 to 1, when your model gives one. Detect leaves out a find under 0.5, and covers one with none.
obfuscate.detect() rejects with NOT_FOUND. When your function rejects, or resolves to something that is no list, the card says Couldn’t Detect Areas, with your error’s message under it when your function rejected. 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. In each case obfuscate.detect() rejects with AI_FAILED, your error as its cause when it rejected. Either line goes at the person’s next edit. Inside a request, when the model calls its obfuscate_detect tool, the card shows neither: the model gets the failure, or the nothing found, as its tool’s answer.
Which Model
On 2026-11-08 we tested the three models on four photos containing 11 faces, license plates, documents and screens. We checked each box by eye. The results are a small sample, not a guarantee that every item will be found.
SAM 3 is our recommendation: it found 10 of the 11 without false finds. Moondream 3 costs less but missed smaller and distant items. YOLOv8n Face detects faces only and returns at most 20, so it can miss people in a crowd. The smallest plate tested was about 13 px wide in the 1024 px image the editor sends. Prices are from November 2026.
Servers
Each server is one module for your server, with the samedetectObjects function: it takes the editor’s image, texts and signal, and resolves to the things found, in the editor’s shape.
SAM 3
Meta’s SAM 3, through fal, finds every instance of a thing named in words. fal’s endpoint takes one text a call, so the server puts the photo in fal’s storage once, then calls once per text, all at once, each job run byfal-job.ts. Each call costs US$ 0.005 on fal’s page of November 2026. It needs @fal-ai/client and FAL_KEY.
sam3.ts
Moondream 3
Moondream 3, through fal, finds every instance of a thing named in words, like SAM 3, and gives no score, so its finds come back with no confidence. fal bills it by tokens, about US$ 0.0003 a text in our measurements: the cheapest finder on fal. fal’s endpoint takes one text a call, so the server puts the photo in fal’s storage once, then calls once per text, all at once, each job run byfal-job.ts. It needs @fal-ai/client and FAL_KEY.
moondream.ts
YOLOv8n Face
YOLOv8n Face, through Runware, finds faces and nothing else, for a Detect that hides faces alone. Only a text that asks for faces sends the photo, as a data URL, in one task POSTed byrunware-task.ts; any other text finds nothing. Each face comes back for each text that asked for faces, with no confidence: YOLOv8n gives no score. Runware gives 20 faces at most. The boxes are fractions of the photo, whose size the server reads from the photo’s header with images.ts, on photon, which runs on Node and on Cloudflare Workers alike. It needs images.ts, runware-task.ts, limit.ts, @cf-wasm/photon and RUNWARE_API_KEY, and no SDK: a plain fetch.
faces-runware.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