Upload and enqueue
- Subscribe to
main_videoandmain_audio. Readstate_updatefor defaults, queue capacities, playback state, andvalid_commands. Readqueue_updatefor the full queues. - If you need a different canvas, call
set_canvasbefore adding clips, while both queues and playback are empty. - Upload up to nine JPEG, PNG, or WebP images through the file upload flow. Images are optional. To condition the soundtrack, upload up to three audio clips the same way, each 2–15 seconds long.
- Call
enqueuewith a nonemptyprompt. For images, pass either onereference_imageor an orderedreference_imageslist. Refer to list entries asPicture 1,Picture 2, and so on. Pass any audio asreference_audioorreference_audios, and name each clip in the prompt asAudio 1,Audio 2, and so on. - Keep the
clip_idfrom theclip_queuedreply. The accepted clip also reports its seed, effective duration, and frame count. Usemetadatafor a client string you want echoed unchanged.
clip_queued acknowledges acceptance. Wait for clip_generated, or find the clip in
queue_update.playout, before requesting playback.
Play and queue more
Callplay with the ready clip’s clip_id, or send {} to play the front of the playout queue.
clip_started reports when output starts. clip_finished reports when all video frames and
synchronized audio have been sent.
For automatic playback, call set_autoplay with enabled: true. Ready clips start whenever idle;
an empty queue waits for more clips. Each new enqueue supplies its own prompt and references.
Read generation_capacity and playout_capacity from state_update. A full generation queue
refuses new enqueues with queue_full. A full playout queue pauses building until room is available. valid_commands
reflects current state, but command arguments still need validation and state can change before a
request arrives.
Reorder or remove
Callmove with a clip_id and zero-based position to reorder a clip within its current queue. A
position past the end appends. Moving a clip does not affect a running build.
Call pop with a queued clip_id to remove it. If its build is already running, the work finishes
but its result is discarded. To cut a playing clip, use stop instead. It cannot be resumed.
With autoplay enabled, stop skips to the next ready clip. To stop without starting the next one,
disable autoplay before calling stop.
Handle failures and reset
A refused command changes no queue or default and fails its own call. In JavaScript the call resolvesundefined, and the error event with operation: "sendCommand" carries the code and the
reason. In Python, send_command() raises a ReactorError. The
schema lists every code.
clip_failed contains the failed clip and reason; that clip is removed and the queue continues. To
try again, submit a new enqueue request with the desired prompt and references.
Call reset to drop both queues, cut playback, restore defaults, and clear the tracks. Its
session_reset reply reports cleared_clips and was_playing. In-flight results are discarded.