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.
Reactor is the base class for every model on the platform. It speaks raw JSON over the wire: open a session, send commands by name, and receive generic message events.
Typed SDKs like HeliosModel and other model-specific packages extend Reactor:
Inheritance
set_prompt(), send_image(), …). Under the hood they call send_command() on this base class. Same wire protocol, just typed. You can always drop down to Reactor directly to send any command as raw JSON; see the SDK Reference overview for when each path makes sense.
For the list of commands and events a specific model accepts, see the Model API Reference.
Constructor
Signature
The name of the model to connect to.
Your Reactor API key. The SDK automatically exchanges this for a token during
connect(). Required unless local=True.The API URL. Ignored if
local=True.If
True, connects to a local runtime at http://localhost:8080. No API key required.Example
Reactor class also supports async with for automatic cleanup:
Context manager
Methods
connect()
Establishes a connection to the coordinator, waits for GPU assignment, and opens a WebRTC connection to the model. If api_key was provided, fetches a token first.
Signature
RuntimeError if authentication fails or if already connected.
disconnect()
Closes the connection.
Signature
If
True, the session is kept alive on the server and can be resumed with reconnect(). If False, the session is terminated.reconnect()
Reconnects to an existing session after a recoverable disconnect.
Signature
session_id from a previous connection.
send_command()
Sends a command to the model.
Signature
The command name. Must match a command defined on the model.
The command payload. Shape depends on the command.
Example
FileRef values from upload_file() as parameters. See File Uploads for details.
upload_file()
Uploads a file and returns a FileRef that can be passed into send_command().
Signature
The file to upload. Accepts a file path, raw bytes, or a file-like object opened in binary mode.
Custom filename. Inferred from the file path or file object when not given. Defaults to
"upload" for raw bytes.MIME type. Guessed from the filename when not given. Defaults to
"application/octet-stream".Example
Can only be called when the status is
READY.publish_track()
Publishes a named media track to the model.
Signature
Track name. Must match a
sendonly track name from the model’s capabilities.An
aiortc.MediaStreamTrack to publish.unpublish_track()
Stops publishing a named track to the model.
Signature
The name of the track to stop publishing.
set_frame_callback()
Sets a callback to receive video frames as NumPy arrays. Equivalent to @reactor.on_frame.
Signature
A function that receives frames as
(H, W, 3) uint8 RGB NumPy arrays. Pass None to stop receiving frames.on()
Registers an event handler.
Signature
off()
Removes an event handler.
Signature
get_status()
Returns the current connection status.
Signature
ReactorStatus.DISCONNECTED, CONNECTING, WAITING, or READY.
get_state()
Returns the current status and last error.
Signature
get_session_id()
Returns the current session ID, or None if not connected.
Signature
get_last_error()
Returns the most recent error, or None if no errors have occurred.
Signature
get_capabilities()
Returns the model’s capabilities (tracks, commands, emission FPS), or None if not yet connected.
Signature
get_session_info()
Returns the full session response from the coordinator, or None if not connected.
Signature
get_remote_tracks()
Returns all remote tracks received from the model, keyed by track name.
Signature
Events
| Event | Payload | Description |
|---|---|---|
"status_changed" | ReactorStatus | Connection status changed |
"session_id_changed" | str | None | Session ID changed |
"message" | Any | Application message from the model |
"runtime_message" | Any | Internal platform message |
"track_received" | (name: str, track: MediaStreamTrack) | Named track received |
"error" | ReactorError | Error occurred |
"session_expiration_changed" | float | None | Session expiration time updated |
"capabilities_received" | Capabilities | Model capabilities received after session creation |
Python events use
snake_case (e.g., "status_changed") while the JavaScript SDK uses camelCase (e.g., "statusChanged").