Installation and setup
Add the base JavaScript SDK to an app with a<video> and an <audio> element. This walkthrough assumes your app provides the token helper, file picker, and UI.
How FastH3-Omni works
The session starts idle.enqueue queues a clip for generation. When clip_generated arrives, play sends it to the output tracks. A command reply confirms that Reactor accepted the request. Watch later messages and the tracks for the result.
Authentication
Issue a session token on your server. The browser’sgetToken() helper calls that server route. Do not put an rk_ API key in browser code. See Authentication for the token exchange and limits.
1. Connect and show the tracks
Have the browser request a short-lived token from your server, then connect toreactor/fast-h3-omni. Render main_video in the video element and attach main_audio to the audio element. Connecting does not generate a clip.
ready status before sending commands. On connect, the model sends state_update with the current defaults, capacities, and valid_commands. It also sends queue_update with both queues.
2. Queue a clip from text
Choose a supported duration. Register the message listener beforeenqueue so it catches the first clip’s result. The clip_queued reply gives you the clip ID, but the clip cannot be continued or played until clip_generated arrives.
clip_failed supplies a reason.
3. Play when ready
Wait forclip_generated, then call the model’s play command. The model sends clip_started when playback begins and clip_finished when both tracks finish. The video and audio elements from step 1 render those tracks.
set_autoplay({ enabled: true }), remove the play call. Autoplay plays ready clips when the output is idle; it does not generate new ones.
4. Add a reference and continue
Only continue afterfirstClipReady resolves. Upload a JPEG, PNG, or WebP image through the SDK and pass its FileRef to reference_image. The default continuation carries the first clip’s motion, camera, and audio. Both clips must use the same canvas, and the model must still retain the first clip.
imageFile comes from your file picker. In the prompt, <Picture 1> names the first reference image; the brackets are prompt text, not API syntax. With the base JavaScript SDK 3.1.0 or later, pass FileRef values directly, including in reference_images and reference_audios arrays.
To start the next clip on the previous clip’s final frame instead, set continue_mode: "frame" and keep a reference image in that request. You can also add last_frame_image to pin its ending. A frame continuation supplies its own first frame, so do not send first_frame_image with continue_from_clip_id. See the schema for a keyframe example.
5. Manage state and errors
Readstate_update for the generation and playout capacities. A full generation queue refuses enqueue; a full playout queue pauses builds. Use move to reorder a queued clip, pop to remove one, or stop to cut playback. Use reset to clear the session.
Show the reason from command_error when the model refuses a command. If generation fails, clip_failed reports the reason and removes the clip from the queue. You can then submit another request. The model refuses stale continuation IDs, unsupported durations, invalid media, and over-budget prompts at enqueue time.