- MCP Server ToolsUpdated
- Managed MCP with chat()Updated
- Manual MCPUpdated
- MCP Type GenerationUpdated
- MCP Client InputUpdated
- MCP Server Tools: AdvancedNew
- MCP EventsNew
- MCP AppsUpdated
- Serve Tools over HTTPUpdated
- Serve Resources and PromptsUpdated
- Ask for InputUpdated
- Draft Text from a ToolUpdated
- MCP Server TasksUpdated
- MCP Server AuthUpdated
- MCP Server SessionsUpdated
- MCP Server on stdioUpdated
Persistence (Advanced)
- GenerationsUpdated
- Realtime Voice ChatUpdated
- Text-to-SpeechUpdated
- TranscriptionUpdated
- Transcription: AdvancedNew
- Voice CreationUpdated
- Audio RecordingUpdated
- Audio GenerationUpdated
- Image GenerationUpdated
- Image Generation: AdvancedNew
- Video GenerationUpdated
- Video Generation: AdvancedNew
- Live GenerationUpdated
- World GenerationUpdated
- Generation HooksUpdated
- Build your first harnessUpdated
- Host optionsNew
- Send and show mediaUpdated
- Connect clientsUpdated
- Write a client in any languageNew
- Access and tenantsNew
- Run in the terminalUpdated
- Deploy a harnessUpdated
- Send inputs safelyUpdated
- Run a tool without a model
- Durable sessionsUpdated
- Run background work on workersNew
- List, rename, and fork sessionsUpdated
- Lifecycle and retentionNew
- Run side effects onceUpdated
- Wait for a personNew
- Build on the session logUpdated
- Control how a turn endsUpdated
- Store settings per threadUpdated
- Compact a long sessionUpdated
- Fork and reset a threadUpdated
- One log for a session treeUpdated
- Write a pluginUpdated
- Track usage and costUpdated
- Ask before risky tool callsUpdated
- Give your agent coding toolsUpdated
- Sandbox and extend the coding toolsUpdated
- Run the coding tools for many threadsNew
- Undo a turnUpdated
- Build a coding agentUpdated
- Delegate to coding agentsUpdated
- Switch between agent profilesUpdated
- Auth and connectorsUpdated
- Share a thread between peopleUpdated
- Connect model providersUpdated
- Build your own UIUpdated
- Code mode in a harnessUpdated
- Work until a goal is metUpdated
- Run agents from a harnessUpdated
- Hand off a conversationNew
- Add skillsUpdated
- Use MCP serversUpdated
- Give your agent a computerNew
- Use from any MCP clientUpdated
- Use a harness from an editor (ACP)Updated
- OverviewUpdated
- Quick StartUpdated
- ProvidersUpdated
- HarnessesUpdated
- Harness AuthUpdated
- WorkspaceUpdated
- ToolsUpdated
- PolicyUpdated
- Lifecycle & SnapshotsUpdated
- Portable SnapshotsUpdated
- Keep Files After ReloadUpdated
- Save a Named VersionUpdated
- Branch From a VersionUpdated
- Send a Frozen FileUpdated
- Let the Agent Save and ForkUpdated
- Pick Which Files to KeepUpdated
- What a Snapshot StoresUpdated
- Instance DurabilityUpdated
- Durable RunsUpdated
- EventsUpdated
Sandboxes (Advanced)
- Runtime ContextUpdated
- Bring Your Own KeyUpdated
- Keep Keys on the ServerNew
- Debug LoggingUpdated
- Multimodal ContentUpdated
- Files APIUpdated
- Per-Model Type SafetyUpdated
- Runtime Adapter SwitchingUpdated
- Tree-ShakingUpdated
- Extend AdapterUpdated
- Extend Adapter: AdvancedNew
- Typed Pre-Configured OptionsUpdated
- Test with a Fake ModelUpdated
- Prompt CachingUpdated
- Mid-Conversation ChangesUpdated
- Approval Flow ProcessingUpdated
Live Generation
generateLiveVideo() opens a live video session. The server mints the session. The browser plays it and can change the prompt while it plays.
Warning
Live generation is experimental. The API can change. Live models bill for each second that a session holds a GPU.
Quick setup#
This streams a live video from Reactor Helios. It takes about 10 minutes.
- Install the packages:
npm i @tanstack/ai @tanstack/ai-reactor @reactor-team/js-sdkpnpm add @tanstack/ai @tanstack/ai-reactor @reactor-team/js-sdkyarn add @tanstack/ai @tanstack/ai-reactor @reactor-team/js-sdkbun add @tanstack/ai @tanstack/ai-reactor @reactor-team/js-sdk- Put your key in .env on the server:
REACTOR_API_KEY=your-reactor-key- Add a POST route at /api/live that mints a session:
import { generateLiveVideo } from '@tanstack/ai'
import { reactorVideo } from '@tanstack/ai-reactor'
export async function POST() {
const live = await generateLiveVideo({
adapter: reactorVideo('helios'),
prompt: 'A chef tosses noodles in a steel wok, flames leaping',
threadId: 'thread-1',
})
return Response.json({
token: live.token,
model: live.model,
prompt: live.prompt,
})
}- In the browser, connect and play the stream in a <video> element:
import { Reactor } from '@reactor-team/js-sdk'
const live = await fetch('/api/live', { method: 'POST' }).then((r) => r.json())
const token = typeof live.token === 'string' ? live.token : ''
const model = typeof live.model === 'string' ? live.model : ''
const prompt = typeof live.prompt === 'string' ? live.prompt : ''
const reactor = new Reactor({ modelName: model })
const video = document.querySelector('video')
reactor.on('trackReceived', (name, _track, stream) => {
if (name !== 'main_video') return
if (!video) return
video.muted = true
const attach = () => {
video.srcObject = null
video.srcObject = stream
void video.play().catch((error: unknown) => {
if (error instanceof DOMException && error.name === 'AbortError') return
})
}
attach()
for (const track of stream.getTracks()) {
track.addEventListener('unmute', attach)
}
})
await reactor.connect(token)
await reactor.sendCommand('set_sr_scale', { sr_scale: '2x' })
await reactor.sendCommand('set_prompt', { prompt })
await reactor.sendCommand('start', {})The video element now plays the live stream. To steer it, send a new set_prompt. The shot changes at the next chunk.
A full app is in examples/ts-react-media. Open the Live tab.
How it works#
The work splits in two:
- The server calls generateLiveVideo(). It returns a connect payload: model (the id the browser connects to), prompt, and a short-lived token. The API key stays on the server.
- The browser uses the provider SDK to connect, play the stream, and send new prompts.
The server half is the same for every live adapter. The browser half is different for each provider. There is no client hook, and there is no file at the end. For the shared model of other media types, see Generations.
Set the key with REACTOR_API_KEY or FAL_KEY, or pass apiKey in the adapter config. Do not put the key in the JSON body.
Models#
| Adapter | Id | What it does |
|---|---|---|
| reactorVideo() | helios | Interactive live video |
| reactorVideo() | fast-h3 | Fast live clips on a live track |
| reactorVideo() | longlive-v2 | Live clips, one shot at a time |
| reactorVideo() | ltx2 | LTX live video |
| falLiveVideo() | minimax/h3-max/director | Steerable live stream over fal WMA |
Each Reactor model takes its own start commands:
- Helios: set_sr_scale, then set_prompt, then start.
- FastH3: enqueue only.
- LongLive: set_shot, then start.
See the Reactor adapter for every id.
For a navigable world (Orbis, LingBot), use World Generation. For a video file that finishes, use Video Generation.
fal H3 Max Director#
The server half uses falLiveVideo():
import { generateLiveVideo } from '@tanstack/ai'
import { falLiveVideo } from '@tanstack/ai-fal'
const live = await generateLiveVideo({
adapter: falLiveVideo('minimax/h3-max/director'),
prompt: 'Live shopping stream: a host holds up a gold watch to camera',
threadId: 'thread-1',
})
// live.model is 'fal-ai/minimax-h3-max-director'. Send it to the browser.The browser opens the stream with @fal-ai/client@alpha. Follow these rules:
- Keep FAL_KEY on the server.
- live.model is the WMA app id.
- Open WMA through a proxy on your server that attaches the key.
- Do not send live.token as Key credentials.
The example proxy is src/routes/api.fal.proxy.ts in examples/ts-react-media. It attaches the key. It forwards only to wma.fal.run (/ice, /session, /session/heartbeat) and to the Director /ice.
import { createFalClient } from '@fal-ai/client'
import { wma } from '@fal-ai/client/realtime'
const fal = createFalClient({ proxyUrl: '/api/fal/proxy' })
const video = document.querySelector('video')
const session = fal.realtime.open(wma(live.model), {
receive: ['video', 'audio'],
onError: (error) => {
console.error(error)
},
onMedia: (stream) => {
if (!video) return
video.muted = true
video.srcObject = stream
void video.play().catch((error: unknown) => {
if (error instanceof DOMException && error.name === 'AbortError') return
})
},
})
session.send({
type: 'configure',
prompt: live.prompt,
prompt_version: 1,
protocol_version: 1,
})
await session.readyTo steer, send { type: 'prompt', prompt, prompt_version }. Increase prompt_version each time. To stop, send { type: 'stop' } and close the session.
Director bills a minimum of 60 seconds. The resolution is 480p or 768p. See the fal adapter.
Advanced#
Start Helios from a seed image#
Helios can start from an image. Pass a File from <input type="file">. Do not send base64. The SDK uploads the file:
const picker = document.querySelector('input[type="file"]')
if (!(picker instanceof HTMLInputElement)) {
throw new Error('Pick a seed image')
}
const file = picker.files?.[0]
if (file === undefined) {
throw new Error('Pick a seed image')
}
const image = await reactor.uploadFile(file)
await reactor.sendCommand('set_conditioning', { prompt, image })
await reactor.sendCommand('start', {})The connect payload#
generateLiveVideo() returns these fields:
| Field | Description |
|---|---|
| id | The id of this generation |
| model | The id the browser connects to. Reactor: a slug such as reactor/helios. fal: the WMA app id. |
| token | A short-lived session token. Reactor uses it to connect. fal does not. |
| expiresAt | The token expiry, in milliseconds since epoch |
| prompt | The prompt that the browser sends when it starts the session |
| status | 'ready' or 'waiting' |
| sessionId | The provider session id, when the adapter creates one |
| usage | Usage and billing, when the adapter reports it |