oleksiv.com

oleksiv.com > Notes

Every AI step falls back to its input

From LIVEDAB, a SaaS where a visitor at an event uploads a photo and gets back a branded AI image or video.

The rule

If a step fails, it returns its input. Background removal fails: the original photo goes on to the next step. Face swap fails: the photo without the swap goes on. Video matting fails: the unmatted video goes on. The visitor always gets a usable result. A slightly worse photo beats an error page, every time, because the visitor is standing at a booth and will not try again.

Where it saves money too

Face swap is skipped, without spending a provider credit, whenever a prompt variable cannot be resolved on the server. There is no point paying a model to do a job whose inputs are already known to be wrong.

Making the rule impossible to forget

The chain is a strategy registry. The set of server-side transforms is typed as a complete record over every transformation type the product knows, so the build fails until each type has a server implementation. Nobody can add a new transform to the editor and forget the server side. Each entry shares one core with the matching API route, so the browser preview and the server workflow run the same code.

A media-kind guard sits in front of every step and stops a chain that would feed a video into an image step. That is the kind of bug that only appears when a customer builds a campaign nobody tested.

Providers behind the steps

Background removal on Replicate (BiRefNet), face swap on Gemini, image-to-video on Kling, video matting on Replicate. Stills render in-app; video still renders on Remotion Lambda. Providers get swapped as better models appear. The fallback rule does not change when they do.

See also a durable workflow for a multi-step AI chain.

All notes | Home