Skip to main content

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.

FileRef

A reference to an uploaded file, returned by upload_file(). Pass into send_command() to attach files to a command.
Definition
@dataclass(frozen=True)
class FileRef:
    upload_id: str    # Upload identifier
    name: str         # Filename
    mime_type: str    # MIME type (e.g. "image/jpeg")
    size: int         # File size in bytes
See File Uploads for usage examples.

ReactorStatus

Connection state enum.
Definition
from reactor_sdk import ReactorStatus

class ReactorStatus(Enum):
    DISCONNECTED = "disconnected"  # No active connection
    CONNECTING   = "connecting"    # Negotiating with the coordinator
    WAITING      = "waiting"       # Waiting for a GPU to be assigned
    READY        = "ready"         # Connected to the model

ReactorState

Definition
@dataclass
class ReactorState:
    status: ReactorStatus
    last_error: ReactorError | None = None

ReactorError

Definition
@dataclass
class ReactorError:
    code: str
    message: str
    timestamp: float          # Unix timestamp
    recoverable: bool
    component: Literal["api", "gpu"]
    retry_after: float | None = None  # Suggested retry delay in seconds
Supports string conversion:
Example
print(error)  # "[api:CONNECTION_FAILED] Failed to connect"

Error codes

CodeComponentRecoverableDescription
CONNECTION_FAILEDapiYesFailed to establish a connection
GPU_CONNECTION_ERRORgpuYesConnection to GPU dropped
RECONNECTION_FAILEDgpuYesFailed to reconnect to existing session

ReactorEvent

Definition
ReactorEvent = Literal[
    "status_changed",
    "session_id_changed",
    "message",
    "runtime_message",
    "track_received",
    "error",
    "session_expiration_changed",
    "capabilities_received",
]

FrameCallback

Definition
FrameCallback = Callable[[NDArray[np.uint8]], None]
The callback receives a NumPy array with:
  • Shape: (H, W, 3): height, width, 3 color channels
  • Dtype: uint8: values 0 to 255
  • Color order: RGB

ConflictError

Raised when a connection is superseded by a newer request to the same session.
Definition
class ConflictError(Exception):
    pass

VersionMismatchError

Raised when the SDK’s protocol version is incompatible with the server. Update your SDK to resolve.
Definition
class VersionMismatchError(Exception):
    pass

fetch_jwt_token()

Fetches a token from the Reactor API using an API key.
Signature
async def fetch_jwt_token(
    api_key: str,
    api_url: str = "https://api.reactor.inc",
) -> str
api_key
str
required
Your Reactor API key (rk_...).
api_url
str
default:"https://api.reactor.inc"
The API URL.
Returns the token as a str. Raises RuntimeError if authentication fails.
In most cases you don’t need this directly. Pass api_key to the Reactor constructor and the SDK handles the exchange automatically during connect().