function generateVideo<TAdapter, TStream>(options): TStream extends true ? AsyncIterable<AGUIEvent, any, any> : Promise<VideoJobResult>;Defined in: packages/ai/src/activities/generateVideo/index.ts:391
Experimental
Generate video - creates a video generation job from a text prompt.
Uses AI video generation models to create videos based on natural language descriptions. Unlike image generation, video generation is asynchronous and requires polling for completion.
When stream: true is passed, handles the full job lifecycle automatically: create job → poll for status → stream updates → yield final result.
Video generation is an experimental feature and may change.
TAdapter extends VideoAdapter<string, any, any, any, any, any>
TStream extends boolean = false
VideoCreateOptions<TAdapter, TStream>
TStream extends true ? AsyncIterable<AGUIEvent, any, any> : Promise<VideoJobResult>
Create a video generation job
import { generateVideo, getVideoJobStatus } from '@tanstack/ai'
import { openaiVideo } from '@tanstack/ai-openai'
// Start a video generation job
const { jobId } = await generateVideo({
adapter: openaiVideo('sora-2'),
prompt: 'A cat chasing a dog in a sunny park'
})
console.log('Job started:', jobId)
// The submission only OPENS the run; the poll that sees a terminal state is
// what completes it. The `jobId` is the whole correlation — pass the same
// `middleware` and `threadId` when you use them.
const status = await getVideoJobStatus({
adapter: openaiVideo('sora-2'),
jobId,
})Stream the full video generation lifecycle
import { generateVideo, toServerSentEventsResponse } from '@tanstack/ai'
import { openaiVideo } from '@tanstack/ai-openai'
const stream = generateVideo({
adapter: openaiVideo('sora-2'),
prompt: 'A cat chasing a dog in a sunny park',
stream: true,
pollingInterval: 3000,
})
return toServerSentEventsResponse(stream)