Skip to main content
Reactor Runtime is a Python framework for turning an inference pipeline into a real-time, interactive video stream. You write 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
That is a complete Reactor model. 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_video above is an outbound video track; declare an Input the same way to receive a client’s webcam or microphone.
  • run() is your generation loop. It decides what to produce and calls emit() to hand each result to the transport, which throttles the loop to the rate clients are playing it back at.
  • Commands are the @event handlers 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.
Around all four sits the session: the lifecycle that starts before the first client arrives and ends after the last one leaves. Models that serve more than one viewer at a time care about the difference, and Sessions & Clients covers it.

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 the reactor 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.