Metadata-Version: 2.4
Name: reactor-sdk
Version: 0.5.0
Summary: Python SDK for Reactor - Real-time AI video streaming
Project-URL: Homepage, https://reactor.inc
Project-URL: Documentation, https://docs.reactor.inc
Project-URL: Repository, https://github.com/reactor-team/py-sdk
Author-email: Reactor Technologies <support@reactor.inc>
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Multimedia :: Video
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: aiohttp>=3.9.0
Requires-Dist: aiortc>=1.9.0
Requires-Dist: av>=12.0.0
Requires-Dist: numpy>=1.24.0
Provides-Extra: dev
Requires-Dist: aioresponses>=0.7.6; extra == 'dev'
Requires-Dist: mypy>=1.8.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest-mock>=3.12.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.3.0; extra == 'dev'
Description-Content-Type: text/markdown

# Reactor Python SDK

[![PyPI version](https://img.shields.io/pypi/v/reactor-sdk)](https://pypi.org/project/reactor-sdk/)
[![PyPI downloads](https://img.shields.io/pypi/dm/reactor-sdk)](https://pypi.org/project/reactor-sdk/)
[![build](https://img.shields.io/github/actions/workflow/status/reactor-team/py-sdk/ci.yml?branch=main)](https://github.com/reactor-team/py-sdk/actions)
[![license](https://img.shields.io/badge/license-MIT-blue)](./LICENSE)

Python SDK for Reactor — real-time AI video streaming platform.

For full documentation, see the **[Python SDK Guide](https://docs.reactor.inc/python-guide)**.

## Installation

```bash
pip install reactor-sdk
```

## Quick Start

```python
import asyncio
from reactor_sdk import Reactor, ReactorStatus, video

async def main():
    reactor = Reactor(
        model_name="my-model",
        api_key="REACTOR_API_KEY",
        receive=[video("main_video")],
    )

    @reactor.on_frame
    def handle_frame(frame):
        print(f"Received frame: {frame.shape}")

    @reactor.on_status(ReactorStatus.READY)
    def handle_ready(status):
        print("Connected and ready!")

    await reactor.connect()
    await reactor.send_command("setParameter", {"value": 0.5})

    try:
        while reactor.get_status() == ReactorStatus.READY:
            await asyncio.sleep(0.1)
    finally:
        await reactor.disconnect()

if __name__ == "__main__":
    asyncio.run(main())
```

## Features

- **WebRTC video streaming** via aiortc
- **Multi-track support** — named video and audio tracks with `video()` / `audio()` helpers
- **Event-driven API** matching the JavaScript SDK
- **Frame callbacks** for single-frame access (numpy arrays)
- **Video input** support for sending video to models
- **Local development** mode for testing without auth
- **Full type hints** for IDE support
- **Async context manager** — `async with Reactor(...) as r:`

## API Overview

### Constructor

```python
from reactor_sdk import Reactor, video, audio

reactor = Reactor(
    model_name="my-model",
    api_key="REACTOR_API_KEY",
    receive=[video("main_video")],
    send=[video("webcam")],
)
```

For local development, pass `local=True` instead of `api_key`.

### Key Methods

- `await reactor.connect()` — Connect to the model (auto-fetches JWT from API key)
- `await reactor.disconnect(recoverable=False)` — Disconnect
- `await reactor.reconnect()` — Reconnect to an existing session
- `await reactor.send_command(command, data)` — Send a command
- `await reactor.publish_track(name, track)` — Publish a named media track
- `await reactor.unpublish_track(name)` — Unpublish a named track
- `reactor.get_status()` — Current `ReactorStatus`
- `reactor.get_state()` — `ReactorState(status, last_error)`
- `reactor.get_session_id()` — Session ID
- `reactor.get_remote_tracks()` — Dict of received tracks by name
- `reactor.set_frame_callback(callback)` — Set frame callback

### Decorators

```python
@reactor.on_frame
def handle_frame(frame): ...

@reactor.on_track("main_video")
def handle_video(track): ...

@reactor.on_message
def handle_message(message): ...

@reactor.on_status(ReactorStatus.READY)
def handle_ready(status): ...

@reactor.on_error
def handle_error(error): ...
```

See the **[full documentation](https://docs.reactor.inc/python-guide)** for the complete API reference, event list, and usage patterns.

## Examples

See the `examples/` directory for complete examples:

- `pygame_app/` — Pygame application with dynamic UI controls
- `rtmp_app/` — Stream Reactor video to RTMP servers (Twitch, YouTube, etc.)

## License

MIT License — Copyright (c) 2026 Reactor Technologies, Inc.
