--- title: Reactor id: reactor-adapter description: "Stream live worlds and live video from Reactor models in TanStack AI with @tanstack/ai-reactor. The server mints a session token, and the browser plays and steers the stream." keywords: - tanstack ai - reactor - world generation - live generation - orbis - helios - generateWorld - generateLiveVideo - adapter --- The Reactor adapter opens a live world or live video session. The server mints a session token. The browser plays and steers the stream. It has no chat. - `reactorWorld()` with `generateWorld()`: a world the user can look at and move through. - `reactorVideo()` with `generateLiveVideo()`: a live video session. ## 1. Install The server needs `@tanstack/ai-reactor`. The browser needs `@reactor-team/js-sdk` to connect and play the stream. react: @tanstack/ai @tanstack/ai-reactor @reactor-team/js-sdk vue: @tanstack/ai @tanstack/ai-reactor @reactor-team/js-sdk solid: @tanstack/ai @tanstack/ai-reactor @reactor-team/js-sdk svelte: @tanstack/ai @tanstack/ai-reactor @reactor-team/js-sdk preact: @tanstack/ai @tanstack/ai-reactor @reactor-team/js-sdk angular: @tanstack/ai @tanstack/ai-reactor @reactor-team/js-sdk vanilla: @tanstack/ai @tanstack/ai-reactor @reactor-team/js-sdk octane: @tanstack/ai @tanstack/ai-reactor @reactor-team/js-sdk ## 2. Set the API key Create a key in the [Reactor dashboard](https://www.reactor.inc/dashboard). Keys start with `rk_`. Put the key in the environment of your server: ```bash REACTOR_API_KEY=rk_... ``` `reactorWorld` and `reactorVideo` read `REACTOR_API_KEY`. To pass the key in code, use `createReactorWorld` or `createReactorVideo`: ```ts import { createReactorWorld } from '@tanstack/ai-reactor' const adapter = createReactorWorld('visko-orbis-stable', process.env.REACTOR_API_KEY!) ``` ## 3. Mint a world session on the server Add a `POST` route at `/api/world`: ```ts import { generateWorld } from '@tanstack/ai' import { reactorWorld } from '@tanstack/ai-reactor' export async function POST() { const world = await generateWorld({ adapter: reactorWorld('visko-orbis-stable'), prompt: 'A neon cyberpunk city at night, slow aerial drift', threadId: 'thread-1', }) return Response.json({ token: world.token, model: world.model, prompt: world.prompt, expiresAt: world.expiresAt, }) } ``` The token works for this one model only. The API key stays on the server. `world.model` is the Reactor connect slug, here `reactor/visko-orbis-stable`. ## 4. Play the world in the browser Connect with the token and play the stream in a `