Limited-time Thanksgiving offer · 50% off platform fees for new users’ first 7 days (1.25% instead of 2.5%). Sign up by Dec 1. Sign up now → Details
Discord

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.

ModelYou steer it withPriceResolution · longestCode
xmax/x2.1Prompt, reference image, drag points$0.0017/s · $6.15/h1080p · 30 minX2 / X2.1
xmax/x2.0Prompt, reference image, drag points$0.0017/s · $6.15/h832p · 30 minX2 / X2.1
reactor/xmax-x2-1Prompt, reference image, drag points$0.0017/s · $6.27/h832p · 30 minX2 / X2.1
reactor/x2Prompt, reference image, drag points$0.0017/s · $6.27/h832p · 30 minX2 / X2.1
reactor/sana-streamingText only$0.0017/s · $6.27/h704p · 30 minSANA-Streaming
reactor/eden-livePrompt + restyled opening frame$0.0017/s · $6.27/h704p · 30 minEdenLive
vidu/vidu-s2-editingReference image + one of 4 modes$0.0051/s · $18.45/h720p · 30 minVidu
reactor/vidu-s2-editing-reactorReference image, same model on a second host$0.0072/s · $25.83/h720p · 30 minReactor reference

The 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

I want to...Start with
Swap the person for a character at low cost and delayxmax/x2.1
Match a reference character, outfit or scene closelyvidu/vidu-s2-editing
Try a garment on the person on cameravidu/vidu-s2-editing (virtual_tryon)
Replace only the backgroundvidu/vidu-s2-editing (background_replacement)
Describe a change in words, with no reference imagereactor/sana-streaming
Restyle the whole pictureVidu style_transfer
Steer the subject by dragging pointsxmax/x2.1

We 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:

`reactor/xmax-x2-1``vidu/vidu-s2-editing`
Delay between movement and edited pictureabout 0.5 sabout 1.2 s
First edited frame after connectingabout 4.4 sabout 6 to 9 s
Likeness to the reference characterSame costume; the face and hair driftCloser: face, hair and clothes
Following movement and expressionClosest: mouth and gesturesArms and head follow

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 key

2. The same code for every model

npm install videorouter-live @xmaxai/web-sdk @reactor-team/js-sdk aliyun-rtc-sdk   # only the hosts you use
import { 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 settles

RealtimeEditModel 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.

ModelsPromptReference imageExtra
xmax/x2.1, xmax/x2.0, reactor/xmax-x2-1, reactor/x2required (a string)optionalxmax/… only: MoX drag, microphone and file inputs (X2 guide)
reactor/sana-streamingrequirednot usedtext-only editing
reactor/eden-liverequiredrequiredrestyling from a prepared opening frame
vidu/vidu-s2-editing, reactor/vidu-s2-editing-reactornot usedrequiredmode (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 Edge

Not 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.

modeThe reference image isWhat changes
virtual_tryonA garmentThe person's clothes
background_replacementA sceneThe background
subject_replacement (default)A characterThe person, who keeps your movements
style_transferA picture in the style you wantThe 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 runs

A 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-editing only): 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. onError is called with the reason. The session stays open and billed until you call model.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

Hold, then settleOpening a session holds max_duration_seconds × the price. If your credits cannot cover it you get 402. Ending it charges the real cost and releases the rest.
What is meteredWhole seconds the session ran, including idle time. Switching the prompt or image has no extra fee. A session that never became ready costs nothing.
Always end itCall 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.
Hard capA session ends at 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 modelsConnect within about 60 s, then report 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.

ErrorMeaning
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.

Next steps