Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.reactor.inc/llms.txt

Use this file to discover all available pages before exploring further.

Connect to a real-time world model with the imperative Reactor client and render frames into a <video> element. By the end of this guide you’ll have real-time AI video streaming wired into your app.

Prerequisites

1

Install the SDK

npm install @reactor-team/js-sdk
2

Mint a token on your server

Exchange your API key for a short-lived token on the server so the key never reaches the browser:
token.ts
const r = await fetch("https://api.reactor.inc/tokens", {
  method: "POST",
  headers: { "Reactor-API-Key": process.env.REACTOR_API_KEY! },
});
const { jwt } = await r.json();
For more information, see Authentication.
3

Connect and render frames

Create a Reactor object, attach the model’s video track to a <video> element, then connect with the token from your server. Helios stays idle until it has a prompt and a start command, so send those once the session is ready:
main.ts
import { Reactor } from "@reactor-team/js-sdk";

const video = document.querySelector("video")!;

const reactor = new Reactor({ modelName: "helios" });

reactor.on("trackReceived", (name: string, track: MediaStreamTrack) => {
  if (name !== "main_video") return;
  video.srcObject = new MediaStream([track]);
  void video.play();
});

// Once the session is ready, send a prompt and start generating.
reactor.on("statusChanged", async (status: string) => {
  if (status !== "ready") return;
  await reactor.sendCommand("set_prompt", { prompt: "A serene mountain landscape at sunrise" });
  await reactor.sendCommand("start", {});
});

const jwt = await getToken(); // fetch the token minted on your server
await reactor.connect(jwt);
4

Run your app

Serve the page and open it in your browser.
The <video> element starts playing once the track arrives, and real-time AI video streams to your page. Try editing the prompt to steer what the model generates. See the Helios reference for the full set of commands.

Next steps

Authentication

How to set up secure, production-ready auth for your app.

Using the SDK

Connect, send commands, receive video, and publish input from JavaScript, React, or Python.

Helios model

All available commands and the messages Helios emits.