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

# Deploy JoyAI Video Edit

> Deploy JoyAI-Video-Edit on one B200 and turn a live camera stream into edited video with a text instruction.

Turn your camera feed into a watercolor painting or change the scene with a text instruction.
In this example, you’ll deploy [JoyAI-Video-Edit](https://github.com/jd-opensource/JoyAI-Video-Edit) on one B200 and run a browser client that shows your camera beside the edited video.

![Screenshot of the upstream JoyAI demo showing three people on camera beside their cartoon-style edited video.](https://mintcdn.com/reactortechnologiesinc/AFS5VXMUwc0tUo4V/images/joy-video-edit/upstream-live-cartoon.jpg?fit=max\&auto=format\&n=AFS5VXMUwc0tUo4V\&q=85\&s=cd5bda3d4a9929a14394440a5b314a49)

Source camera and cartoon-style output from the upstream JoyAI-Video-Edit demo.

[Demo from JoyAI-Video-Edit](https://github.com/jd-opensource/JoyAI-Video-Edit/blob/main/assets/live_demo/live_cartoon_group.jpg).

## Key facts

| Item | Value |
| - | - |
| Model | JoyAI-Video-Edit, with a 16B diffusion transformer |
| Deployment GPU | One NVIDIA B200 |
| Host memory | Checkpoint loading peaks at about 63 GB in the cookbook’s tests |
| Input | A `camera` video track and an edit instruction; optional reference image |
| Output | Edited video on `main_video`, at 1248×720 |
| Chunk size | One frame to begin a run, then eight frames; context refreshes also begin with one frame |
| Cookbook benchmark | About 0.2 seconds per eight-frame chunk on one B200, reported by the cookbook |
| First startup | Downloads about 48 GB of checkpoints, loads the model, and warms up inference |

The benchmark measures inference, not camera-to-screen latency. Output playback adapts to inference throughput.

## What the app does

The client publishes its camera, sets an instruction, and sends `start`.
The model reads incoming frames in chunks and sends back edited frames without waiting for a complete video.
It takes the newest camera frames and drops older queued frames so input does not build up behind inference.

Each run keeps one instruction, reference image, and seed.
To change the edit, send `reset`, set the new instruction, and send `start` again.
The camera stays connected throughout.

## Requirements

* A Reactor account with Serve access, [remote builds](https://docs.reactor.inc/deploy/platform/build.md), and capacity for one B200 and a project configured by Reactor with a 128 GiB host-memory limit.
* The Reactor CLI and Git.
* A browser with a camera, Node.js 22.12 or later, and pnpm for the client.
* An [API key](https://reactor.inc/account/api-keys) for the account that owns the deployment.

No local GPU or Docker installation is needed for this remote deployment.
The cookbook's compiled kernels target Blackwell datacenter GPUs; keep the B200 configuration for this example.

## 1. Prepare the project

```sh theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
curl -fsSL https://reactor.inc/install | bash
```

Sign in and clone the cookbook:

```bash Terminal theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
reactor auth login
git clone https://github.com/reactor-team/reactor-cookbook.git
cd reactor-cookbook/models/joy-video-edit
```

In `reactor.yaml`, change `model.name` to `your-org/joy-video-edit`.
Replace `your-org` with your account or team slug. Keep the rest of the manifest unchanged.

Create the project before arranging its host-memory allocation:

```bash Terminal theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
reactor project create --exists-ok
```

Ask your Reactor contact to configure a 128 GiB host-memory limit for this project before deploying.
Checkpoint loading peaks at about 63 GB in the cookbook’s tests, above the default 32 GiB limit.
The projects CLI does not apply the cookbook’s `model.resources.memory` settings.

## 2. Deploy the editor

Deploy one B200 instance with enough host memory to load the checkpoint:

```bash Terminal theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
reactor deploy production --gpu NVIDIA_B200x1
```

The CLI builds the image remotely and deploys it to `production` with the project’s configured resources.

Wait for the deployment to become ready. In another terminal, from the same model directory, follow startup:

```bash Terminal theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
reactor logs production --follow
```

The first start includes checkpoint downloads and warmup. Keep this deployment running while you test the client.

## 3. Edit your camera stream

[Download the browser client](https://docs.reactor.inc/files/joy-video-edit-client.zip) and unzip it.
In a separate terminal, open the extracted folder:

```bash Terminal theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
cd joy-video-edit-client
pnpm install
cp .env.example .env
```

Set your API key and the model name from `reactor.yaml` in `.env`:

```text .env theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
REACTOR_API_KEY=YOUR_API_KEY
REACTOR_MODEL=your-org/joy-video-edit
```

Start the client:

```bash Terminal theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
pnpm dev
```

Open the local URL printed in the terminal. Select **Connect and edit** and allow camera access.
Your camera appears on the left; the edited video follows on the right.
The local server creates a session token for your model. Your API key stays on the server.

### Try a different edit

Move in front of the camera and check that the edited video follows you.
Change the instruction to “Make everything sepia” and select **Apply new edit**.
The camera stays connected while the model starts a new run with that instruction.

The status line reports `chunk_complete` messages with the frame count and processing time. A run begins with one frame, then usually produces eight per chunk.
Its timing measures model processing, not the full trip from camera to screen.

## How the client works

The starter includes the UI, token endpoint, and connection cleanup.
These are the SDK calls that connect the camera to the model.

### Connect and publish the camera

The local `/api/session` endpoint returns a model-scoped token and model name.
`connect()` waits until the session is ready before the client publishes its camera:

```javascript Connect and publish (selected calls) theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
import { Reactor } from "@reactor-team/js-sdk";

const response = await fetch("/api/session", { method: "POST" });
const { jwt, modelName } = await response.json();
const reactor = new Reactor({ modelName });

reactor.on("trackReceived", (name, track) => {
  if (name === "main_video") {
    document.getElementById("edited").srcObject = new MediaStream([track]);
  }
});

const camera = await navigator.mediaDevices.getUserMedia({
  video: true,
  audio: false,
});
await reactor.connect(jwt);
await reactor.publishTrack("camera", camera.getVideoTracks()[0]);
```

For an app you share, put the token endpoint on your server and authenticate its callers.
See [Authentication](https://docs.reactor.inc/authentication.md).

### Start an edit and change the instruction

The model snapshots the instruction when a run starts.
The starter checks replies before sending the next command:

```javascript Start an edit theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
async function command(name, data = {}) {
  const reply = await reactor.sendCommand(name, data);
  if (reply === undefined) throw new Error(`${name} failed`);
  return reply;
}

await command("set_prompt", { prompt: "Turn the video into a watercolor painting" });
await command("start");
```

**Apply new edit** ends the current run, updates the instruction, and starts again:

```javascript Change the edit theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
await reactor.sendCommand("reset");
await command("set_prompt", { prompt: "Make everything sepia" });
await command("start");
```

`reset` has no reply payload. Sending `set_prompt` alone updates the next run, not the active one.

## How the model runs

This recipe includes a custom `Dockerfile`.
It installs CUDA 13.2.1, Python 3.12, PyTorch 2.14.0, and
[Reactor Runtime 3.6.0](https://github.com/reactor-team/reactor-runtime/releases/tag/v3.6.0), then compiles the model's CUDA kernels.
`reactor deploy` builds this Dockerfile remotely.

The manifest connects the image to the application and its configuration:

```yaml reactor.yaml (selected settings) theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
runtime:
  import: joy_video_edit:JoyVideoEdit
  config: joy_video_edit.yaml
  recording:
    enabled: false

build:
  runtime_version: "3.6.0"
```

Keep the cookbook’s Dockerfile, runtime version, and checkpoint pins unchanged. The recipe uses `joyai_video_edit_dit_0811.pth`.
The Dockerfile's `RUNTIME_VERSION` must match `build.runtime_version`.
Recording is disabled because encoding a recording on the model's GPU reduces inference throughput.

At startup, the model downloads its pinned checkpoints and runs warmup sessions that capture its CUDA graphs.
The CLI waits for the model to finish startup and become ready.

### Process camera frames

The application reads camera frames and handles client commands.
The model class loads weights and edits each chunk.
These excerpts show how the two connect; the full implementation is in the cookbook.

The names in these declarations are the names the client publishes and receives:

```python joy_video_edit_types.py (selected declarations) theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
from reactor_runtime import MediaInput, Output, Video


class JoyVideoEditMedia(MediaInput):
    camera: Video


class JoyVideoEditOutput(Output):
    main_video: Video
```

`process_input()` waits for `start` and enough camera frames, then captures the inputs for one inference call.
`generate()` passes that input to the model:

```python joy_video_edit.py (generate) theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
def generate(self, input: JoyVideoEditInput) -> JoyVideoEditResult:
    return self.engine.generate(input)
```

After inference, `process_output()` reports progress before publishing the frames:

```python joy_video_edit.py (inside process_output) theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
emitted = int(result.frames.shape[0])
await self.send(ChunkComplete(
    chunk_index=self.state._chunk_index,
    frames_emitted=emitted,
    elapsed_ms=round(outcome.elapsed * 1000.0, 1),
))
```

The method also updates its counters and returns `JoyVideoEditOutput(main_video=result.frames)`.
The runtime streams those frames to the client on `main_video`.

## Add a reference image

To guide the appearance as well as the instruction, add a file input to the client.
With the session connected, upload the selected PNG or JPEG before starting a new run:

```javascript Apply a reference image theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
await reactor.sendCommand("reset");
const reference = await reactor.uploadFile(file);
await command("set_reference_image", { reference_image: reference });
await command("set_prompt", {
  prompt: "Put the hat from the reference image on the person",
});
await command("start");
```

Here, `file` is the browser `File` from your input. The reference stays selected across resets until you replace it.
The [client contract](https://github.com/reactor-team/reactor-cookbook/blob/main/models/joy-video-edit/model_behaviour.md) also covers seed controls, progress messages, and command errors.

## Stop the deployment

Select **Disconnect** to end the session and release the camera.
Then, from the cookbook model directory, stop the GPU instance:

```bash Terminal theme={"theme":{"light":"github-light","dark":"github-dark-high-contrast"}}
reactor scale production --desired 0
```

> [accordion] Troubleshoot the first run
>
> * **Startup takes a while:** follow `reactor logs production --follow` for checkpoint downloads, model loading, and warmup. A CLI wait timeout does not stop startup.
> * **Model loading runs out of host memory:** contact Reactor to check the host-memory allocation for your B200 deployment.
> * **The client cannot connect:** check the API key and qualified model name in `.env`, then restart `pnpm dev`.
> * **The camera works but no edited video appears:** check the browser console and model logs. The model needs both a published `camera` track and `start`.
> * **A command returns `already_generating`:** reset the active run before starting another run or setting a reference image.


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