source and receive edited video on main_video. With the base SDK, send
commands through reactor.sendCommand(). The React
examples use useXmaxX21 from @reactor-models/xmax-x2-1 inside an XmaxX21Provider.
Tracks
The model has no audio track. A still image needs a client that publishes repeated video frames.
Session lifecycle
The model sendsstate_update on connect. A null prompt means no prompt was set. Call
set_prompt to enable generation, then provide source frames. An empty string is a valid prompt for
drag-only animation. There is no start command.
generation_started reports the output dimensions. Those dimensions stay fixed for the session,
including after reset. Prompt changes apply from the next generated block. Use the latest
state_update to display model state.
Await command replies on the connection that sends them. prompt_accepted, pointers_changed, and
reference_image_accepted answer their respective commands. A reply does not establish that the
edited frames are visible. Observe main_video and state messages separately.
Commands
set_prompt
Set the editing instruction. A prompt enables generation even when its value is "". During a run,
a replacement applies from the next block. Returns prompt_accepted and broadcasts state_update.
set_reference_image
Upload the file first, then pass the returned file reference. A successful command returns
reference_image_accepted with the decoded image’s original dimensions and broadcasts
state_update. A file that cannot decode as an image fails with invalid_image.
Replacing the image during a run applies the reference from the next block. The stream continues
without generation_stopped or a new generation_started. The block that applies the reference
takes longer, so expect one short pause. The visible edit moves to the new reference over the next
few blocks.
The image can have any aspect ratio. When its ratio is within 20% of the output ratio, the model
scales it to cover and center-crops it. Otherwise, it fits the whole image and adds white padding.
set_pointers
Each call contains exactly four frame samples, ordered from oldest to newest. Each sample is a list
of zero to eight drag points. For example, to steer two points, send four lists with two points in
each list.
Each point has x and y coordinates from 0 to 1, measured against the output frame. The
origin is the top-left corner.
At each source-frame tick, append the current positions and send the last four ticks. The latest
call replaces the pending window. A block uses each entry on its corresponding frame. The first
one-frame block uses the newest entry.
If no new call arrives before the next block, the model holds the previous window’s newest entry on
all frames. Send
[[], [], [], []] to end the drag. Invalid window length, too many points, or
coordinates outside the range fail with invalid_points.
The reply, pointers_changed, contains only the newest frame’s points as [x, y] pairs. The
state_update.pointers field has the same shape. These payloads differ from the command’s four
lists of objects.
reset
Stop generation and clear the prompt, reference image, and drag points. This command is valid at any
time. If a run is active, it emits generation_stopped with reason reset. It also broadcasts
state_update.
Reset has no parameters or reply payload. To generate again, publish source frames and call
set_prompt. The session keeps its output dimensions.
Messages
state_update payload
Complete example
This browser module requires a<video id="output" autoplay playsinline muted> element and the
token route from Authentication. Call
stop() when the page closes or the user disconnects.