load() and run(). Reactor handles the networking, the media
transport, and the client connections.
Key features:
- Real-time streaming: frames reach clients over WebRTC as they are generated, not after the whole video is done.
- Live interaction: clients change inputs mid-generation. No restart, no re-queue.
- No transport code: you never import a WebRTC library, manage a WebSocket, or encode video.
- Typed, validated inputs: declare the commands your model accepts with types and constraints, and the runtime validates every payload before your handler runs.
The simplest model
model.py
run() produces frames for as long as someone is watching, and a
client can send set_prompt at any time to change what the next frame renders.
How the pieces fit
A model is four things, and the rest of this section takes them one at a time.- Tracks are the named media channels the model reads and writes.
MyOutput.main_videoabove is an outbound video track; declare anInputthe same way to receive a client’s webcam or microphone. run()is your generation loop. It decides what to produce and callsemit()to hand each result to the transport, which throttles the loop to the rate clients are playing it back at.- Commands are the
@eventhandlers clients call to change what the model is doing. The runtime validates each payload against the handler’s signature before invoking it. - Messages are the typed payloads your model sends back — progress, state snapshots, or a direct reply to a command.
From model to production
Once your model is wrapped with the runtime, you get two things for free: Client SDKs - Connect any frontend to your model with a few lines of JavaScript or Python. The SDK handles WebRTC, sessions, and real-time input. See Using the SDK. Deploy to Reactor - Register the model once, then publish and deploy each release straight from your workspace with thereactor CLI. It is live on Reactor’s GPU cloud in under 3 minutes, with no
infrastructure to manage.
Next
The Run Loop
Emitting frames, batches, and frame rates.
Model Anatomy
Understand every line of a Reactor model.