Live video & world models
Realtime video editing
Overview
A real-time editing model changes video while it is being captured. Your page sends a camera or any other video stream, you say what to change with a prompt, a reference image or a drag, and the edited stream comes back during the same session. You can send a new instruction at any moment without restarting.
VideoRouter gives you these models through one live video session API (/v1/live-video/*), with one key and one balance. We check your credits, get a short-lived credential from the model's host and bill the session by the second. The video goes directly between the browser and the host, not through our servers. One JavaScript interface drives every model: to change models, you change the model id.
Editing a finished file is a different thing: you submit it and get a new file back. Use Video edit for that.
What you can build
Character swap
Show the person on camera as a character from a picture, still moving as they move.
Start with xmax/x2.1 or vidu/vidu-s2-editing
Virtual try-on
Preview a garment on the person in front of the camera.
Start with vidu/vidu-s2-editing or xmax/x2.1
Restyle
Give the whole picture a different visual style, such as anime or watercolor.
Start with xmax/x2.1 or vidu/vidu-s2-editing
Add a character to the scene
Keep everyone in the shot and add a new subject from a reference picture.
Start with xmax/x2.1
Drag to move
Drag on the picture to move what is in it.
Start with xmax/x2.1
Demo videos by Xmax AI, showing its realtime models. We have not reproduced these clips ourselves, so results with your own footage and model can differ.
Models and prices
Prices include the platform fee and are as of 2026-11-27. They can change, and a model whose host is unavailable may not be offered. GET /v1/live-video/models is the live list: every row with "kind": "edit" is an editing model, with its current price.
reactor/vidu-s2-editing-reactorReference image, same model on a second host$0.0072/s · $25.83/h720p · 30 minReactor referenceThe reactor/… X2 rows are the same Xmax models on a second host. RealtimeEditModel falls back to them from the xmax/… ids.
Which model to use
xmax/x2.1vidu/vidu-s2-editingvidu/vidu-s2-editing (virtual_tryon)vidu/vidu-s2-editing (background_replacement)reactor/sana-streamingstyle_transferxmax/x2.1We compared two of these on a character swap. These are our measurements on 2026-11-25 from one 5-second clip and one reference picture, with a simulated camera, so treat them as a starting point and test your own footage:
One interface for every model
Every editing model uses the same calls. To change models, change the model id. VideoRouter's JavaScript SDK handles each host's protocol: your page passes a MediaStream in and gets a MediaStream back.
1. Mint a browser token
On your server. The token can open sessions only for the models you list, and can upload reference images; nothing else.
curl https://videorouter.sh/api/v1/live-video/tokens \
-H "Authorization: Bearer $VIDEOROUTER_API_KEY" -H "Content-Type: application/json" \
-d '{"models": ["xmax/x2.1", "reactor/xmax-x2-1"], "expires_in": 600, "max_sessions": 1, "max_session_duration_seconds": 300}'
# -> {"token": "...", ...} send "token" to the browser, never your API key2. The same code for every model
npm install videorouter-live @xmaxai/web-sdk @reactor-team/js-sdk aliyun-rtc-sdk # only the hosts you useimport { RealtimeEditModel } from "videorouter-live";
import * as xmax from "@xmaxai/web-sdk";
import * as reactor from "@reactor-team/js-sdk";
const MODEL = "xmax/x2.1"; // or "reactor/xmax-x2-1", … — nothing else changes
const model = new RealtimeEditModel({ model: MODEL, maxDurationSeconds: 120, hostSdk: { xmax, reactor } });
await model.connect(token);
const camera = await navigator.mediaDevices.getUserMedia({ video: { width: 1280, height: 720, frameRate: 30 } });
await model.start(camera, {
prompt: "Replace the person with the character in the reference image",
image: file, // File / Blob / data URI / uploaded URL
onRemoteStream: (stream) => (output.srcObject = stream), // <video autoplay playsinline>
onError: (error) => console.error(error),
onNotice: (n) => console.warn(n.model, "does not use", n.input),
});
await model.setPrompt("Now outside in heavy snow"); // the image is kept
await model.setPrompt(undefined, { image: otherFile }); // the text is kept
await model.end(); // stops and settlesRealtimeEditModel and lv.upload() need videorouter-live 0.3.0 or newer. The SDK opens the session, sends its heartbeat and settles it. Reference images are passed as files and handled for you; to upload one yourself, use lv.upload(file) or POST /v1/uploads, never a model host's storage.
What each model takes
Most models take both a prompt and a reference image. Where a model cannot use an input, the same code still runs: that input is skipped and reported to onNotice. Pass strict: true to get an error instead. If an input a model needs is missing, start() fails before anything is booked.
| Models | Prompt | Reference image | Extra |
|---|---|---|---|
xmax/x2.1, xmax/x2.0, reactor/xmax-x2-1, reactor/x2 | required (a string) | optional | xmax/… only: MoX drag, microphone and file inputs (X2 guide) |
reactor/sana-streaming | required | not used | text-only editing |
reactor/eden-live | required | required | restyling from a prepared opening frame |
vidu/vidu-s2-editing, reactor/vidu-s2-editing-reactor | not used | required | mode (below) |
Where the same model has two hosts at about the same price (X2.1, X2.0), the other takes over if one cannot open or connect; model.activeModel says which served, and your token must list both ids. fallback: false turns this off.
Other video sources
start() accepts any MediaStream with a video track, such as a playing clip:
const player = Object.assign(document.createElement("video"), { src: "clip.mp4", muted: true, loop: true, playsInline: true });
await player.play();
await model.start(player.captureStream(), { prompt, image, onRemoteStream }); // Chrome and EdgeNot using JavaScript in a browser? The Live video API opens the same sessions; you then connect with the host's own client.
Character swap with X2.1
const model = new RealtimeEditModel({ model: "xmax/x2.1", hostSdk: { xmax, reactor } }); // or "reactor/xmax-x2-1"Use the code above with a character picture as image. Preset modes (character swap, try-on, animate a reference, add a subject, drag to move) and the X2-only features are in the X2 guide.
Try-on, background and character with Vidu S2 Editing
Vidu is steered by one reference image and one mode at a time, so you cannot stack a new outfit and a new background. It takes no text prompt.
mode | The reference image is | What changes |
|---|---|---|
| virtual_tryon | A garment | The person's clothes |
| background_replacement | A scene | The background |
| subject_replacement (default) | A character | The person, who keeps your movements |
| style_transfer | A picture in the style you want | The look of the whole picture |
const model = new RealtimeEditModel({ model: "vidu/vidu-s2-editing" });
await model.connect(token);
await model.start(camera, { image: garmentFile, mode: "virtual_tryon", onRemoteStream });
await model.setPrompt(undefined, { image: sceneFile, mode: "background_replacement" }); // switch while it runsA switch takes a few seconds to appear. reactor/vidu-s2-editing-reactor takes the same calls; it is the same model on a second host at a higher price, so it is never chosen for you.
- Vidu's browser library (
vidu/vidu-s2-editingonly): with a bundler,npm install aliyun-rtc-sdk. On a plain page, load it with a<script>tag before you start. It asks for camera and microphone permission even if your video is a file or a canvas; what is sent is the video track you pass in, and no audio. start()takes 10 to 15 seconds: it resolves when the first edited video arrives.- Vidu can end an edit by itself, for example under its content policy.
onErroris called with the reason. The session stays open and billed until you callmodel.end(), so always end it there.
Decart Lucy is unavailable
Every Decart Lucy model, on both of its hosts, has been offline since 2026-11-28. A request for one gets a 503 provider_disabled. Use one of the models above. The Lucy guide is kept for reference.
Text-only editing with SANA-Streaming
reactor/sana-streaming applies a change you describe in words and leaves the rest of the picture alone. It takes no reference image.
const model = new RealtimeEditModel({ model: "reactor/sana-streaming", hostSdk: { reactor } });
await model.connect(token);
await model.start(camera, { prompt: "Make the jacket bright red", onRemoteStream });Restyling from an opening frame with EdenLive
reactor/eden-live needs both a prompt and a reference image, and it uses the image differently from the other models. The image is what the first output frame should look like, not a sample of a style, character or garment. Take a frame from your camera, restyle or edit it with an image model, and pass the result.
In our tests on 2026-11-27 (two short sessions, sample clips as the camera), a restyled version of the same shot followed the motion in the video. An unrelated picture was reproduced almost as it was, and the camera had little effect. Fine details, such as a number on a shirt, changed or disappeared within 30 seconds, and a prompt change made no visible difference in the few seconds we watched. Test your own footage before you rely on it.
const model = new RealtimeEditModel({ model: "reactor/eden-live", hostSdk: { reactor } });
await model.connect(token);
await model.start(camera, { prompt: "A handmade claymation street", image: restyledFirstFrame, onRemoteStream });Calling setPrompt(text, { image }) with a new image pauses the session and starts the picture again from it. This model needs videorouter-live 0.3.1 or later.
Billing and session rules
max_duration_seconds × the price. If your credits cannot cover it you get 402. Ending it charges the real cost and releases the rest.end in every exit path, including errors. If heartbeats stop, we settle the session at the host's timeout. Decart sessions need no heartbeat while connected; sending one does no harm.max_duration_seconds. The longest allowed is in the model table. For a longer show, open a new session; the edit does not carry over, so send your prompt and reference again.reactor.getSessionId(). If you run several sessions of one model and do not report them, each is billed its full booked time. A booking you never connect is free.The full rules are on Live video. For an estimate before booking, use POST /v1/pricing/estimate.
400Unknown or unavailable model id, or an option the model does not take.402Not enough credits for the hold. Lower max_duration_seconds or add credits.403The browser token does not allow this model or call.429A concurrency or rate limit, or host_capacity. Retry shortly.502host_unavailable or pricing_unavailable. Nothing is held; try another model.Consent and safety
Editing can change who a person appears to be. Only use a face, likeness or picture you have the right to use, tell your audience when the picture is AI-edited, and do not use it to pass as another person or to get through identity checks. What you send straight to a host after connecting (video, prompts and reference images) does not pass through VideoRouter, so we cannot moderate it. The host's own rules apply.
Next steps
- Edit a finished file instead: Video edit.
- Every endpoint and parameter: Live video API reference.
- Client libraries: Python and JavaScript SDKs.