> ## 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.

# Runtime Overview

> Build real-time interactive video models with Python.

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

```python model.py theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
from pathlib import Path

from reactor_runtime import InputField, Output, ReactorModel, Video, event


class MyOutput(Output):
    main_video: Video


class MyModel(ReactorModel):
    def load(self, config_path: Path | None) -> None:
        self.pipe = load_my_model()
        self.prompt = "a sunny meadow"

    @event(name="set_prompt", description="Scene the model renders")
    async def set_prompt(self, prompt: str = InputField(default="a sunny meadow")) -> None:
        self.prompt = prompt

    async def run(self) -> None:
        while True:
            await self.connected.wait()
            while self.connected.is_set():
                frame = self.pipe.forward(prompt=self.prompt)
                await self.emit(MyOutput(main_video=frame))
```

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](/deploy/development/reactor-model/lifecycle) 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](/sdk-reference/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

<CardGroup cols={2}>
  <Card title="The Run Loop" icon="play" href="/deploy/development/reactor-model/run-loop">
    Emitting frames, batches, and frame rates.
  </Card>

  <Card title="Model Anatomy" icon="microscope" href="/deploy/development/reactor-model/model-anatomy">
    Understand every line of a Reactor model.
  </Card>
</CardGroup>
