Lucy real-time video editing
Lucy (by Decart) edits a live camera or video stream as it plays: swap characters, add, replace or remove things, change the background, restyle the picture, or try on clothes. Your server mints a token, and your user's browser streams to the host with short-lived credentials. Every Lucy model uses the same code: only the model id changes.
| Model id | Use it for | Browser package | Price | Output |
|---|---|---|---|---|
decart/lucy-2.6 | General editing (latest) | @decartai/sdk | $0.0205/s (fast $0.0410/s) | 720p |
decart/lucy-2.5 | General editing | @decartai/sdk | $0.0205/s (fast $0.0410/s) | 720p |
decart/lucy-2.1 | General editing (previous generation) | @decartai/sdk | $0.0205/s | 720p |
decart/lucy-vton-3.6 | Virtual try-on (latest) | @decartai/sdk | $0.0205/s (fast $0.0410/s) | 720p |
decart/lucy-vton-3.5 | Virtual try-on | @decartai/sdk | $0.0205/s (fast $0.0410/s) | 720p |
decart/lucy-restyle-2 | Restyle the whole picture | @decartai/sdk | $0.0102/s | 704p |
decart/lucy-2.6/fal | Lucy 2.6, second host | none | $0.0205/s | 720p |
decart/lucy-2.5/fal | Lucy 2.5, second host | none | $0.0205/s | 720p |
fal/lucy-vton-2.1-webrtc | Try-on (previous generation), second host | none | $0.0205/s | 720p |
Prices include the platform fee and can change; GET /v1/live-video/models is the live list, and a model whose host is unavailable may not be offered. A session lasts 10 to 600 seconds (default 120). Booking holds price × maxDurationSeconds; you pay for the seconds the host meters, and the rest is released. A session that never starts generating costs nothing.
Test status: as of 2026-11-27 we have not run the Lucy models through RealtimeEditModel against a live host session. The code on this page is tested against simulated hosts only, so test your integration before you rely on it.
Quickstart
Install
npm install videorouter-live @decartai/sdk # the fal rows need no extra packageRealtimeEditModel and lv.upload() need videorouter-live 0.3.0 or newer. The page must be served over HTTPS or localhost, and the camera must be requested from a user action. Inside an iframe, allow it: <iframe allow="camera; autoplay">.
1. Mint a browser token on your server
curl https://videorouter.sh/api/v1/live-video/tokens \
-H "Authorization: Bearer $VIDEOROUTER_API_KEY" -H "Content-Type: application/json" \
-d '{"models": ["decart/lucy-2.6", "decart/lucy-2.6/fal"], "expires_in": 3600, "max_sessions": 1, "max_session_duration_seconds": 300}'
# -> {"token": "...", "expires_at": "...", ...} send "token" to the browser, never your API keyList every model id your page may use. For failover on Lucy 2.6 or 2.5, list both hosts.
2. Connect and edit
import { RealtimeEditModel } from "videorouter-live";
import * as decart from "@decartai/sdk";
const model = new RealtimeEditModel({ model: "decart/lucy-2.6", maxDurationSeconds: 300, hostSdk: { decart } });
await model.connect(token);
const camera = await navigator.mediaDevices.getUserMedia({ video: { width: 1280, height: 720, frameRate: 30 } });
await model.start(camera, {
prompt: "Add a red knit beanie to the person's head",
onRemoteStream: (stream) => (video.srcObject = stream), // <video autoplay playsinline>
onState: ({ host, state }) => console.log(host, state),
onError: (error) => console.error(error), // the stream failed after it had started
});
await model.setPrompt("Set the background to a tropical beach with palm trees"); // change it while it runs
await model.end(); // stops the stream and settles the billSend the camera at 1280×720 and 30 fps (1280×704 for decart/lucy-restyle-2). start() takes any MediaStream with a video track, such as a camera, a canvas or a playing video; audio is not sent. end() also stops its tracks. The session heartbeat is sent for you.
Reference images
A reference image shows Lucy what to put in the picture: a character, a garment, an object or a style. Pass a File, Blob, data URI or image URL as image, at the start or at any time after. A file is handled for you; you never upload to a model host.
await model.start(camera, { prompt: "Substitute the person with the character in the reference image", image: file, onRemoteStream });
await model.setPrompt("Same character, standing in the rain"); // the image is kept
await model.setPrompt(undefined, { image: anotherFile }); // new image, the text is keptRealtimeEditModel keeps the part you do not change. (Decart's own set() replaces both at once.)
To upload once and reuse the link, use VideoRouter's upload, which works with the browser token: const { url } = await lv.upload(file), or POST /v1/uploads. The link lives 30 minutes.
| Image rule | Recommendation |
|---|---|
| Format | JPEG, PNG or WebP |
| Size | At least 512×512 (required on the fal rows); under about 5 MB uploads quickly |
| Character | One clear, well-lit, front-facing face, head and shoulders |
| Garment | The item alone on a plain or white background, not worn by someone |
Virtual try-on
Use decart/lucy-vton-3.6 (or 3.5). Give a garment image, a sentence that names what to change, or both; both together gives the clearest signal.
const model = new RealtimeEditModel({ model: "decart/lucy-vton-3.6", hostSdk: { decart } });
await model.connect(token); // a token that allows "decart/lucy-vton-3.6"
await model.start(camera, {
image: garmentFile,
prompt: "Substitute the upper body garment with a black bomber jacket with a blue chest logo and a zip front",
enhance: false, // keep your wording
onRemoteStream,
});
await model.setPrompt("Substitute the upper body garment with a grey crewneck sweatshirt", { image: nextGarment });| Changing | Prompt pattern |
|---|---|
| Tops, jackets, hoodies, sweaters | Substitute the upper body garment with <description>. |
| Pants, skirts, shorts | Substitute the lower body garment with <description>. |
| Dresses, sets, full looks | Substitute the outfit with <description>. |
| Shoes / hat / necklace | Substitute the footwear (hat, necklace) with <description>. |
| Accessories to add | Add <description> to the outfit. |
Use one action per prompt, and describe only what is visible in the garment image: color, fabric, fit, sleeves, neckline, closures and pattern. Ask for no unrelated changes.
fal/lucy-vton-2.1-webrtc takes the same calls. Always pass your own prompt and image to it.
Writing edit prompts
Start with the action, then name the target and what it should become. These patterns are Decart's recommendations for Lucy 2.6.
| Edit | Example |
|---|---|
| Substitute (replace a person) | Substitute the man with a cartoon astronaut in a white spacesuit with a gold visor. |
| Add | Add a red knit beanie to the woman's head. |
| Swap clothes, same person | Swap the man's gray hoodie for a navy denim jacket with brass buttons. |
| Background | Set the background to a tropical beach with white sand and palm trees. |
| Remove | Remove the red backpack from the floor near the sofa. |
| Change an attribute | Make the silver headphones metallic gold. |
| Restyle everything | Restyle the entire scene as a colorful comic book with bold black outlines. |
enhance (on by default) lets Decart expand your prompt. If you turn it off, write two sentences: the command, then one that starts with “The output will show” and describes the result.
decart/lucy-restyle-2 restyles the whole picture. Describe the style ("Restyle the scene as a watercolor painting") or give a style image as image.
Failover and the fast tier
Two hosts for Lucy 2.6 and 2.5
decart/lucy-2.6 and decart/lucy-2.6/fal (and the same for 2.5) are one model on two hosts at the same price. With fallback on (the default), if the host you named cannot open the session it opens on the other, and if the stream does not connect within connectTimeout (45 s) the other host is tried. model.activeModel says which one served, and your code does not change. Pass fallback: false to pin a host. A stream that drops after it started is not moved: handle onError.
To start on fal, set model: "decart/lucy-2.6/fal". fal needs no extra package.
Fast tier
const model = new RealtimeEditModel({ model: "decart/lucy-2.6", speed: "fast", hostSdk: { decart } });fast costs 2× and is offered by decart/lucy-2.6, lucy-2.5, lucy-vton-3.6 and lucy-vton-3.5. It stays on Decart: there is no failover to fal.
Other models
The same RealtimeEditModel code runs every real-time editing model, including X2.1 and Vidu.
SDK reference
| Constructor option | Default | What it does |
|---|---|---|
model | required | A model id from the table above |
maxDurationSeconds | 120 | Session cap; the price of this much time is held |
speed | standard | "fast" on the models that have it |
fallback | true | Use the model's other host if needed (2.6 and 2.5) |
connectTimeout | 45000 ms | How long to wait for the stream |
hostSdk | dynamic import | { decart }, the @decartai/sdk module |
| Method or callback | What it does |
|---|---|
connect(token) | Give the browser token |
start(stream, { prompt, image, enhance }) | Book and start. A prompt, an image, or both. |
setPrompt(text, { image, enhance }) | Change the edit; the part you leave out is kept |
end() | Stop and settle. Call it on every exit path. |
onRemoteStream(stream) | The edited video |
onState({ host, state }) | Connection states; the values are the host's own |
onError(error) | The stream failed after it started |
activeModel, session.billedSeconds, session.costUsd | Who served, and what it cost |
host | The host's own objects, for anything else: { name: "decart", client, realtime } or { name: "fal", socket, peer } |
Errors and troubleshooting
| Response | Meaning |
|---|---|
400 unknown model or option | The id is not offered, or the model has no fast tier |
402 insufficient_credits | Your balance cannot cover the hold. Add credit or lower maxDurationSeconds. |
403 model_not_allowed | The token does not list this model id (list both hosts for failover) |
429 concurrency_limit / host_capacity | Too many open sessions, or the host is full. Retry after Retry-After. |
502 host_unavailable | No host could take the session; nothing is held or billed. On Lucy 2.6 and 2.5 the other host has already been tried. |
| Symptom | Check |
|---|---|
| "did not connect within … ms" | Network, VPN and firewall (video uses WebRTC). The first connection to fal/lucy-vton-2.1-webrtc can take about 30 seconds. |
| The reference image has no effect | Use a clear image of at least 512×512. An expired upload link does nothing: upload again. |
| The result ignores part of your prompt | Make one clear change per prompt and name the target |