Skip to main content
Reactor Runtime

Build real-time AI models in Python.

📖 Documentation · 🚀 Quickstart · 🌐 Reactor


Reactor Runtime turns an inference pipeline into a real-time, interactive media and data stream. You write load() and generate(); the runtime drives them one step at a time and handles the session lifecycle, the media transport (WebRTC, or a LiveKit room), and the wire protocol that connects clients to your model. Viewers watch frames as they are generated and change what the model is doing mid-stream, with no restart and no re-queue.

Highlights

  • 📡 Real-time streaming. Frames reach clients over WebRTC as your model produces them, not after a whole video is done. The runtime paces playout from the time each step took, so a model needs no rate limiter of its own.
  • 🎮 Live interaction. Clients send commands mid-generation: change a prompt, move a camera, adjust a parameter. The next frame reflects it.
  • 🔌 No transport code. You never import a WebRTC library, manage a WebSocket, or encode video. The runtime ships its own media engine as a wheel, so a plain Python container is all a model needs.
  • 🏠 LiveKit rooms. A session can join a LiveKit room: the model's tracks are published there, and every other participant in the room is a client.
  • ✅ Typed, validated commands. Declare the commands your model accepts with standard Python types and constraints. The runtime validates every payload before your handler runs and compiles the surface into an OpenAPI schema that drives typed client SDKs.
  • 🎬 Every session recorded. The runtime records each streamed session as it plays, and a client asks for the last seconds of it, or all of it, and fetches the clip over HTTP while the session is still running.
  • 🗂️ Step results. Start a session with its input and a number of steps, and keep each step's output as a folder of files.
  • 🧩 Many sessions, one copy of the weights. Split a model into a model half that one model server process loads once and an application half each session runtime runs, and every session shares its weights and GPU.
  • 🔎 Traceable logs. get_logger() writes structured records, and every record a session writes carries its id, so one filter recovers a whole run.
  • 📦 One container, anywhere. The reactor CLI scaffolds a workspace, builds a small image, and runs it locally. The same image deploys to Reactor's GPU cloud unchanged.

How it works

You ship one ReactorApp subclass: the application the runtime drives and the client talks to. Declare the media it sends and the state a client can set, load your weights once, and write what one step of generation does:

from pathlib import Path

from reactor_runtime import InputField, InputState, Output, ReactorApp, Video


class MyState(InputState):
    prompt: str = InputField(default="a sunny meadow", moderate=True, description="Scene to render.")
    paused: bool = InputField(default=False, description="Hold generation on the last frame.")


class MyOutput(Output):
    main_video: Video


class MyModel(ReactorApp):
    state: MyState

    def load(self, config_path: Path | None) -> None:
        self.pipe = load_my_pipeline()

    def generate(self, input: MyState) -> MyOutput:
        return MyOutput(main_video=self.pipe.forward(prompt=input.prompt))

That is a complete application. The runtime calls generate() in a loop for as long as someone is watching and emits what it returns. Every public field on MyState is a command the client can send: here set_prompt and set_paused, validated from the fields, and the next step reads the new values.

A step is three calls, and generate() is the one you must write. process_input() runs before it and decides whether a step can happen: return the input generate() gets, or raise ApplicationError("reason") to skip the step. process_output(outcome) runs after it, with the result or the error, and returns the media to emit; a message sent there with await self.send() reaches the client before the step's frames. Both have defaults, so the model above writes neither.

from reactor_runtime import ApplicationError, MessageField, ModelMessage, StepOutcome


class FrameReady(ModelMessage):
    prompt: str = MessageField(description="The prompt this frame was rendered from.")


class MyModel(ReactorApp):
    state: MyState

    async def process_input(self) -> MyState:
        if self.state.paused:
            raise ApplicationError("paused")
        return self.state

    def generate(self, input: MyState) -> MyOutput: ...

    async def process_output(self, outcome: StepOutcome) -> Output | None:
        if outcome.error is not None:
            raise outcome.error
        await self.send(FrameReady(prompt=self.state.prompt))
        return outcome.to_output()

generate() fails by raising, and the exception reaches process_output() as outcome.error. Recover an error you expect there and return None to go on to the next step. Re-raise anything else to end the session with an error, as the default process_output() does.

Commands and lifecycle hooks such as @session_started and @connected run between steps, never during one. A command handler refuses by raising CommandError(code, message), which fails the caller's own request. For a loop that is not one step per emit, override run() and write it against emit(), send(), and complete_step().

A session can also start with its setup in hand and run a set number of steps: POST /start_session takes a starting_input of state values and commands, and steps, and the session ends once the model has reported that many. Each step can be kept as a folder of files, turned on in reactor.yaml:

runtime:
  step_results:
    enabled: true
    video: {codec: h264, preset: veryfast, crf: 23}   # or codec: h265
    audio: {codec: aac, bitrate_kbps: 128}
    queue: 8

A step's tracks are saved as one output.mp4, with a result.json that lists the step's files, and GET /sessions/{id}/steps serves the folders.

A session can also be stepped: POST /start_session with "generation": "stepped" runs one step per RequestStep a client sends on the data channel instead of streaming, and answers each request with a StepResult that carries the step's media, so a stepped client must negotiate data-channel chunking. The model code is the same in both modes; a model that overrides run() or submit_command() cannot be stepped. Every example serves both; the echo example shows a stepped session end to end.

A session can join a LiveKit room. The room connection publishes the model's output tracks, and every other participant in the room is a client of the session. The model's reactor.yaml says which RPC methods, data topics, and byte streams reach which of its commands, messages, and input tracks:

runtime:
  livekit:
    rpc:
      - method: lk.clear_buffer        # a call to this method runs clear_buffer
        command: clear_buffer
      - method: lk.playback_finished   # sending playback_finished calls this method
        message: playback_finished
    topics: [avatar]                   # a data packet on avatar.<command> runs <command>
    media_inputs:
      lk.audio_stream: agent_audio     # byte streams on this topic feed agent_audio

The LiveKit SDK is an optional part of the runtime, so a model that joins rooms lists reactor-runtime[livekit] in its requirements.txt. A running session joins a room through a connection of its own:

POST /sessions/{session_id}/transport/livekit/connections
{"url": "wss://example.livekit.cloud", "token": "eyJhbGciOi..."}

Scaffold, build, and run it with the CLI:

reactor init my-model
cd my-model
reactor run

reactor run builds a container with the runtime inside and serves WebRTC signaling on port 8080. Point a browser at it with the JS SDK, or connect from the Reactor Sandbox and watch frames stream immediately.

Log from the same import, passing context as keyword arguments:

from reactor_runtime import get_logger

logger = get_logger(__name__)

logger.info("scene changed", prompt=self.prompt)

Records render as key=value text, or as one JSON object per line under REACTOR_LOG_FORMAT=json. Every record written during a session carries its id and the runtime's lifecycle state, including the records of logging.getLogger() and of the libraries your model imports.

Models can read deployment-managed secrets from the environment.

Install

Everything runs through the reactor CLI. There is nothing to install on your host but the CLI and Docker; the runtime ships inside the image the CLI builds for your workspace.

brew install reactor-team/tools/reactor-cli

Not on macOS, or pinning a release in CI? See Install the CLI.

Learn more

  • Quickstart: from zero to a model deployed on Reactor's GPUs
  • Runtime overview: what the runtime handles, and the outline of a model
  • Model anatomy: every member of a ReactorApp, line by line
  • The step loop: process_input(), generate(), process_output(), and the frame rate
  • Events and messages: commands, refusals with CommandError, and messages to clients
  • Video and audio tracks: output and input tracks, and how input is buffered
  • Starter example: the model reactor init scaffolds: one class, generate() alone, the smallest complete ReactorApp
  • Echo example: the client's webcam and microphone in, an effect applied, both sent back, in batches, streamed or one step per request
  • Waypoint example: a world model on a GPU, seeded from an upload and steered live

Development

This repository holds the runtime package itself: the authoring interface, the session runner, the media transport, and the wire protocol. To work on it, use mise, which pins the toolchain and forwards every task through a thin make shim:

mise run install      # install deps, generate wire bindings, and git hooks
mise run lint         # ruff check, ruff format --check, and mise.lock drift
mise run format       # apply ruff formatting
mise run typecheck    # ty (strict)
mise run test         # unit tests on the floor Python
mise run test-matrix  # unit tests on every supported Python

License

Licensed under the Apache License, Version 2.0.

Metadata

Release files for reactor-runtime 3.11.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for reactor-runtime 3.11.9
File Size Uploaded Provenance Actions
reactor_runtime-3.11.9.tar.gz 497.4 kB Without provenance Details for reactor_runtime-3.11.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for reactor-runtime 3.11.9
File Interpreter ABI Platform Actions
reactor_runtime-3.11.9-py3-none-any.whl Python 3 none any Details for reactor_runtime-3.11.9-py3-none-any.whl

Total release size: 1.1 MB

Release files / reactor_runtime-3.11.9.tar.gz

Download URL reactor_runtime-3.11.9.tar.gz
Size 497.4 kB
Tags Source
SHA-256 checksum
How to use checksums
90d072008b35a1a387d61655d27a4035e0f150e61c586713fac8ae5fa411a54d
BLAKE2b-256 checksum
How to use checksums
c5c9ba4d58dd22e3ec36d7a6c5fbb5c78c6664afa81253061afd9dbf44581efe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / reactor_runtime-3.11.9-py3-none-any.whl

Download URL reactor_runtime-3.11.9-py3-none-any.whl
Size 573.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55132ebad84031416bba3dbe17bb7b98209962b585bc467eab8b8d0d66396b75
BLAKE2b-256 checksum
How to use checksums
9717fd2cc30e44acd9d9a217a863536223c1a2a7f61c93f3d29bd11669b84ae6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for reactor-runtime 3.11.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.11.9 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page