Function: generateVideo()
function generateVideo<TAdapter, TStream>(options): TStream extends true ? AsyncIterable<AGUIEvent, any, any> : Promise<VideoJobResult>;
정의 위치: packages/ai/src/activities/generateVideo/index.ts:391
Experimental
텍스트 프롬프트로 비디오 생성 작업을 만듭니다.
AI 비디오 생성 모델을 사용하여 자연어 설명을 바탕으로 비디오를 생성합니다. 이미지 생성과 달리 비디오 생성은 비동기이며 완료될 때까지 폴링해야 합니다.
stream: true를 전달하면 전체 작업 수명 주기를 자동으로 처리합니다:
작업 생성 → 상태 폴링 → 업데이트 스트리밍 → 최종 결과 yield.
비디오 생성은 실험적 기능이며 변경될 수 있습니다.
타입 매개변수
TAdapter
TAdapter extends VideoAdapter<string, any, any, any, any, any>
TStream
TStream extends boolean = false
매개변수
options
VideoCreateOptions<TAdapter, TStream>
반환값
TStream extends true ? AsyncIterable<AGUIEvent, any, any> : Promise<VideoJobResult>
예제
비디오 생성 작업 만들기
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,
})
전체 비디오 생성 수명 주기 스트리밍
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)