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

# ABot World Halo tutorial

> Set up a world, play it with keys, hold actions, and change the scene live.

This tutorial builds a small browser app for ABot World Halo. It sets a first frame, character
pictures, and a scene prompt, then plays the world with the keyboard, holds actions, changes the scene while it plays, and
resets.

## Installation and setup

To start from a complete app, scaffold the example project:

> [tab] npm
>
> ```shell theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
> npx create-reactor-app my-abot-app --model=abot-world-halo
> ```

> [tab] pnpm
>
> ```shell theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
> pnpm create reactor-app my-abot-app --model=abot-world-halo
> ```

The [example app](https://github.com/reactor-team/create-reactor-app/tree/main/templates/abot-world-halo)
uses the typed SDK, `@reactor-models/abot-world-halo`.

To add ABot World Halo to your own app, install the typed SDK. The snippets below build on one
connected `AbotWorldHaloModel` instance. Provide your own page elements and token route.

> [tab] npm
>
> ```shell theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
> npm install @reactor-models/abot-world-halo
> ```

> [tab] pnpm
>
> ```shell theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
> pnpm add @reactor-models/abot-world-halo
> ```

## How ABot World Halo works

A session moves through three states: `idle`, `running`, and `paused`. In `idle` you set the
inputs. `start` begins the world, and it streams on two tracks until you call `reset` or leave:

| Track | What it carries |
| - | - |
| `main_video` | The game world at 24 fps. |
| `main_audio` | The world's sound, chunk by chunk. |

The world is made one chunk at a time. Movement, looking, actions, and scene changes are held
values: the model reads them as each chunk starts, so a change shows from the next chunk.

After every accepted command, the model sends a `state_update` with the whole session state. Render
from the latest one instead of tracking each command.

## Authentication

Issue a session token on your server, scoped to `reactor/abot-world-halo`. The browser's
`fetchToken()` helper calls that server route. Do not put an `rk_` API key in browser code. See
[Authentication](https://docs.reactor.inc/authentication.md) for the token exchange.

## 1. Connect and attach the tracks

Add a `<video>` element with `autoplay`, `playsinline`, and `muted`, and an `<audio>` element with
`controls` so the user can start the sound. Then connect:

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
import { AbotWorldHaloModel } from "@reactor-models/abot-world-halo";
import { fetchToken } from "./token";

const halo = new AbotWorldHaloModel();
const video = document.querySelector<HTMLVideoElement>("#world")!;
const audio = document.querySelector<HTMLAudioElement>("#sound")!;
const status = document.querySelector<HTMLElement>("#status")!;

halo.onMainVideo((_track, stream) => (video.srcObject = stream));
halo.onMainAudio((_track, stream) => (audio.srcObject = stream));
halo.onStateUpdate((state) => {
  status.textContent = `${state.state} · chunk ${state.chunks}`;
  if (state.error) status.textContent = state.error.message;
});

await halo.connect(await fetchToken());
```

Wait for the SDK's `ready` status before sending commands. The first `state_update` arrives on
connect, in `idle`.

## 2. Set the first frame, character, and scene

Upload the first frame and the character pictures with `uploadFile()`, then pass the references to
the commands. Send the character pictures in the order head, left, right, front, back, as far as
you have them. The [prompt guide](https://docs.reactor.inc/model-api-reference/abot-world-halo/prompt-guide.md) covers how to
choose each input.

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
// firstFrameFile, headFile, and the others are File objects from <input type="file"> elements.
const firstFrame = await halo.uploadFile(firstFrameFile);
await halo.setFirstFrame({ image: firstFrame });

const pictures = [headFile, leftFile, rightFile, frontFile, backFile];
const items = await Promise.all(pictures.map((file) => halo.uploadFile(file)));
await halo.setReferences({ items });

await halo.setPrompt({
  prompt:
    "A third-person fantasy game. A young wizard in a dark blue robe walks through the courtyard " +
    "of a stone castle at dusk. Torches burn along the walls. Painterly style.",
});
```

Each accepted command sends a `state_update`. `settings.first_frame_set`, `settings.references`,
and `settings.prompt` confirm what the model holds.

## 3. Start the world

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
halo.onGenerationStarted((started) => console.log("seed", started.seed));
await halo.start();
```

The state moves to `running` at once. The first chunk takes longer, because the session is built
from your inputs first. Then `generation_started` arrives and video and sound stream.

If the session cannot be built, a `state_update` returns to `idle` with `error` set and your inputs
kept. Fix the input and call `start` again.

## 4. Walk and look with the keyboard

`set_move` and `set_look` each take one held key per direction, `-1`, `0`, or `1`. Track the keys
that are down, and send the new values whenever one changes:

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
const held = new Set<string>();

function axis(plus: string, minus: string) {
  return (held.has(plus) ? 1 : 0) - (held.has(minus) ? 1 : 0);
}

function sendControls() {
  void halo.setMove({ forward: axis("w", "s"), right: axis("d", "a") });
  void halo.setLook({ yaw: axis("l", "j"), pitch: axis("i", "k") });
}

window.addEventListener("keydown", (event) => {
  if (event.repeat || event.target instanceof HTMLInputElement) return;
  held.add(event.key.toLowerCase());
  sendControls();
});
window.addEventListener("keyup", (event) => {
  held.delete(event.key.toLowerCase());
  sendControls();
});
window.addEventListener("blur", () => {
  held.clear();
  sendControls();
});
```

Releasing a key sends `0` on that axis, and the character stops. Clear the keys when the window
loses focus, or the character keeps walking.

## 5. Hold an action

Actions are held like keys too. Send one when the player presses its key, and `none` on release:

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
const actionKeys: Record<string, string> = {
  shift: "sprint",
  " ": "jump",
  c: "crouch",
  q: "shield",
};

window.addEventListener("keydown", (event) => {
  const name = actionKeys[event.key.toLowerCase()];
  if (name && !event.repeat) void halo.setAction({ name });
});
window.addEventListener("keyup", (event) => {
  if (actionKeys[event.key.toLowerCase()]) void halo.setAction({ name: "none" });
});
```

For an action of your own, use `custom` with a description:

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
await halo.setAction({
  name: "custom",
  text: "The character swings a glowing sword in a wide arc, then returns to a ready stance.",
});
```

The first chunk with a new custom text takes longer. Each `chunk_complete` reports the action it
ran with in `action` and `action_text`, which you can show in the UI.

## 6. Change the scene live

Send a new scene prompt while the world plays. It applies from the next chunk, or from the first
chunk after the new text is ready:

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
halo.onChunkComplete((chunk) => {
  if (chunk.scene_live) status.textContent = `Scene: ${chunk.scene}`;
});

await halo.setPrompt({
  prompt:
    "A third-person fantasy game. A young wizard in a dark blue robe walks through the courtyard " +
    "of a stone castle at night. Heavy snow falls, and lanterns glow along the walls. Painterly style.",
});
```

A live scene is refused with `not_ready` until the first chunk is out, and with `prompt_too_long`
when it needs more room than `applied.scene_max_tokens`.

## 7. Pause and reset

`set_paused` holds the world on its last frame and keeps everything else:

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
await halo.setPaused({ paused: true });
await halo.setPaused({ paused: false });
```

`reset` ends the session and clears every input. The connection stays open in `idle`, ready for new
inputs:

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
halo.onGenerationComplete((done) => console.log(done.reason, done.chunks));
await halo.reset();
```

To play again with the same inputs, set them again before `start`. A session also ends when the
client disconnects.

## Handle refusals

When the model refuses a command, the call resolves `undefined` and only your client is told. The
`error` event carries the model's code:

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
halo.on("error", (error) => {
  // A refused command: error.code is the model's code, such as "locked_while_running".
  if (error.operation === "sendCommand") status.textContent = error.message;
});
```

The commands that set up a session, such as `set_first_frame` and `set_references`, are refused
with `locked_while_running` during a session. Call `reset` first. The
[schema](https://docs.reactor.inc/model-api-reference/abot-world-halo/schema.md#refusals) lists every code.


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