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

> ## Agent Instructions
> To build and serve your own model, start at /deploy/development/quickstart and /deploy/development/overview. Authenticate with reactor auth login, scaffold with reactor init, then run reactor deploy production from the workspace. Deploy builds remotely by default, creates a missing workspace project and its production environment, and waits for rollout. No local Docker or model.version bump is needed. Projects own images and weight sets; environments select the image, weights, GPU, instance count, and variables. Create staging explicitly with reactor environment create staging before deploying to it. Use reactor scale for capacity and reactor rollback for an earlier revision’s image and weights. See /deploy/platform/projects and /deploy/platform/deploy. Client SDK modelName remains account-qualified and selects production by default. Model code imports reactor_runtime; Python client code imports reactor_sdk. Local testing is optional; /deploy/development/local-testing covers reactor run, which needs Docker.
> Reactor hosts multiple models, each with its own connect slug (modelName) and command/event schema. The video model catalog — slug, typed SDK package, and links to its schema — is at /model-api-reference/overview. Robotics policy documentation starts at /robotics/overview; The launch policies are Cosmos Nano DROID (/robotics/cosmos/nano-policy-droid/), DreamZero DROID (/robotics/dreamzero/droid/), and FLUX Action DROID (/robotics/flux-action/droid/), organized by model family and embodiment. Some models expose one slug per experience (e.g. HappyOyster); always take the slug from the model's own pages, never guess it.
> Fastest path to a working app: `npx create-reactor-app my-app --model=<slug>` scaffolds a complete app with secure auth wired up. Typed TypeScript SDKs are published as @reactor-models/<model>; Python uses the base reactor-sdk package.
> Auth: exchange an API key (rk_...) for a JWT via POST https://api.reactor.inc/tokens from your server. Never put the API key in client-side code.
> Append .md to any docs URL for clean Markdown. Search these docs via the MCP server at https://docs.reactor.inc/mcp.

# Waypoint model walkthrough

> The files, contract, loading, and step of the Waypoint world model on Reactor Runtime.

Waypoint serves Overworld's Waypoint 1.5 as a Reactor model. Its source is
[`examples/waypoint`](https://github.com/reactor-team/reactor-runtime/tree/v3.11.9/examples/waypoint) in Reactor
Runtime 3.11.9, and the code below is simplified from it.

## Files

```text examples/waypoint/ highlight={5-6} theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
examples/waypoint/
├── reactor.yaml
├── requirements.txt
├── config.yml
├── waypoint.py         # Model class: contract, step, commands
├── waypoint_model.py   # World model class: runs the weights
└── README.md
```

The runtime drives `Waypoint`, the model class. `Waypoint` calls `WaypointModel`, which runs the weights through
Overworld's [`world_engine`](https://github.com/Overworldai/world_engine) and imports nothing from Reactor. The two
classes exchange `WaypointInput` and `WaypointResult`. [Model Structure](https://docs.reactor.inc/deploy/development/reactor-app/application-and-model.md)
describes this split.

## Contract

The contract declares the output track and the controls that a client can set:

```python waypoint.py (simplified) theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
class WaypointOutput(Output):
    main_video: Video


class WaypointState(InputState):
    paused: bool = InputField(default=False)
    action: str = InputField(default="idle", choices=list(_ACTION_KEYS))
    buttons: str = InputField(default="", max_length=128)
    mouse_x: float = InputField(default=0.0)
    mouse_y: float = InputField(default=0.0)
    scroll_wheel: int = InputField(default=0, ge=-1, le=1)
```

* **Video track:** `WaypointOutput` declares the outbound `main_video` track. The attribute name is the track name that
  the client receives.
* **Commands:** each field becomes a command named `set_<field>`. For example, `set_action` sets `action`. The runtime
  rejects a value outside the field's limits, such as `choices` or `ge` and `le`.

The model class also declares 2 commands with `@event`: `set_image` and `reset`.

## Loading

The runtime calls `load()` once, when the instance starts and before any session:

```python waypoint.py (simplified) theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
class Waypoint(ReactorApp):
    def load(self, config_path):
        self.engine = WaypointModel()
        self.engine.load(config_path, get_weights_path())
```

`config_path` points to `config.yml`. `get_weights_path()` returns the folder that holds the Waypoint-1.5-1B weights:
the weights the deploy pinned with `--weights`, or `runtime.weights_path` in `reactor.yaml` for a local run.
`Waypoint` passes the folder to `WaypointModel`, so the world model class still imports nothing from Reactor.

`WaypointModel.load()` reads `config.yml`, loads the weights from the folder onto the GPU, and runs 50 warmup steps.
The warmup compiles the kernels, so the first session does not wait for them. The engine also downloads a small
autoencoder, about 23 MB, from Hugging Face, because the checkpoint's own configuration names it.

## The step

The runtime runs the model in a loop of steps. Each step calls 3 methods in order:

![A clockwise loop inside the Waypoint model class. Commands update the session state. process\_input() reads the controls, generate() makes 4 frames, and process\_output() sends them to clients on main\_video. Then the next step starts. A step is skipped while the session is paused or has no seed image.](https://mintcdn.com/reactortechnologiesinc/AFS5VXMUwc0tUo4V/diagrams/waypoint-step-loop.svg?fit=max\&auto=format\&n=AFS5VXMUwc0tUo4V\&q=85\&s=5804fd085a88a944d0add1d2bac2b8c7)

[Generation Loop](https://docs.reactor.inc/deploy/development/reactor-app/step-loop.md) explains this loop for every model.

### Read the controls

`process_input()` builds the input for each step:

```python waypoint.py (simplified) theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
class Waypoint(ReactorApp):
    async def process_input(self) -> WaypointInput:
        if self.state.paused:
            raise ApplicationError("paused")
        if self.state._seed is None:
            raise ApplicationError("no seed image")

        new_seed = self.state._seed_id != self.state._applied_seed_id
        return WaypointInput(
            buttons=self.state.button_set(),
            mouse=(self.state.mouse_x, self.state.mouse_y),
            scroll_wheel=self.state.scroll_wheel,
            seed=self.state._seed if new_seed else None,
            seed_id=self.state._seed_id,
        )
```

`process_input()` turns the session state into a `WaypointInput`, the input that `WaypointModel` can generate from.
The state holds the controls the way a client sets them: a movement name such as `forward`, extra key codes, and mouse
and scroll values. The world engine reads a set of pressed keys instead, so `button_set()` converts `action` and
`buttons` into one set of key codes. For example, `forward` becomes the W key. The mouse and scroll values pass
through unchanged.

The seed image is the image that starts the world: the client uploads it with `set_image`, and it becomes the first
frame. The input carries it only on the first step after `set_image` or `reset`. On every other step, `seed` is
`None`, and the world model continues the world that it holds.

When the state is not enough to make frames, the step is skipped. While the session is paused, or before a seed image
arrives, `process_input()` raises `ApplicationError`. The runtime skips the step and calls `process_input()` again on
the next one.

### Make the frames

Each step then calls `generate()` with the `WaypointInput` from `process_input()`. On `Waypoint`, it only passes the
input on to the model:

```python waypoint.py (simplified) theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
class Waypoint(ReactorApp):
    def generate(self, input: WaypointInput) -> WaypointResult:
        return self.engine.generate(input)
```

`WaypointModel.generate()` does the GPU work. When the seed has changed, it starts a new world from it. Then it makes
the next 4 frames and returns them in a `WaypointResult`:

```python waypoint_model.py (simplified) theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
class WaypointModel:
    def generate(self, input: WaypointInput) -> WaypointResult:
        if input.seed_id != self.seed_id:
            self.reset_engine(input.seed)

        frames = self.engine.gen_frame(input.controls)
        return WaypointResult(frames=frames)
```

The world model keeps the world between steps, so each step continues from the frames before it.

### Send the frames

`process_output()` receives the result of `generate()` and sends the 4 frames to the client on `main_video`:

```python waypoint.py (simplified) theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
class Waypoint(ReactorApp):
    async def process_output(self, outcome: StepOutcome) -> WaypointOutput:
        if outcome.error is not None:
            raise outcome.error
        return WaypointOutput(main_video=outcome.result.frames)
```

If `generate()` fails, the error arrives in `outcome.error`. `process_output()` raises it again, and the runtime ends the
session with an error that the client sees.

The full method also tags each frame with its step number, notes which seed the world model holds, and sends
`waypoint_status` every 50 steps.

## Commands written by hand

Two commands need more than a field write, so the model class declares them with `@event`:

```python waypoint.py (simplified) theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
class Waypoint(ReactorApp):
    @event(name="set_image")
    async def set_image(self, image: UploadedFile = InputField()) -> WaypointStatus:
        self.state._seed = decode_and_fit(image.data)
        self.state._seed_id += 1
        return WaypointStatus.of(self.state)

    @event(name="reset")
    def reset(self) -> WaypointStatus:
        self.engine.reset()
        self.state._applied_seed_id = None
        return WaypointStatus.of(self.state)
```

* **`set_image`** stores the uploaded image as the new seed. The new `_seed_id` tells the next step to start a new world
  from it.
* **`reset`** clears the world model. The next step starts again from the seed image that the session already has.

Both commands reply with `waypoint_status`.

## Sessions and reset

* **Client connects:** `@connected` sends the current `waypoint_status` to the client that joined.
* **Session end:** `@session_ended` calls `WaypointModel.reset()` and drops the frames that are not sent yet. The seed
  image and the controls reset with the rest of the state, so the next session starts with no world.
* **`reset` command:** starts the world again from the current seed image, in the same session.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.