Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

getVideoJobStatus.md

91 lines2.5 KB

1---
2id: getVideoJobStatus
3title: getVideoJobStatus
4---
5​
6```ts
7function getVideoJobStatus<TAdapter>(options): Promise<VideoJobStatusResult>;
8```
9​
10Defined in: [packages/ai/src/activities/generateVideo/index.ts:917](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateVideo/index.ts#L917)
11​
12**`Experimental`**
13​
14Get video job status - returns the current status, progress, and URL if available.
15​
16This function combines status checking and URL retrieval. If the job is completed,
17it will automatically fetch and include the video URL.
18​
19It is also where a non-streaming `generateVideo()` run ENDS: pass the same
20`middleware` and `threadId`, and the poll that first sees a terminal job state
21finishes the run (recording the result and its artifacts) or fails it. The run
22is identified by `adapter` + `jobId`, exactly what the submission derived it
23from, so there is nothing else to carry between the two calls.
24​
25 Video generation is an experimental feature and may change.
26​
27## Type Parameters
28​
29### TAdapter
30​
31`TAdapter` *extends* [`VideoAdapter`](../interfaces/VideoAdapter.md)\<`string`, `any`, `any`, `any`, `any`, `any`\>
32​
33## Parameters
34​
35### options
36​
37`VideoJobStatusOptions`\<`TAdapter`\>
38​
39## Returns
40​
41`Promise`\<`VideoJobStatusResult`\>
42​
43## Examples
44​
45**Check job status**
46​
47```ts
48import { getVideoJobStatus } from '@tanstack/ai'
49import { openaiVideo } from '@tanstack/ai-openai'
50​
51const result = await getVideoJobStatus({
52 adapter: openaiVideo('sora-2'),
53 jobId: 'job-123'
54})
55​
56console.log('Status:', result.status)
57console.log('Progress:', result.progress)
58if (result.url) {
59 console.log('Video URL:', result.url)
61```
62​
63**Submit and poll one persisted run**
64​
65```ts
66import { generateVideo, getVideoJobStatus } from '@tanstack/ai'
67import { withGenerationPersistence } from '@tanstack/ai-persistence'
68import { openaiVideo } from '@tanstack/ai-openai'
69​
70const adapter = openaiVideo('sora-2')
71const middleware = [withGenerationPersistence(persistence)]
72​
73// Opens the run (status `running`, jobId recorded). Its run id is derived
74// from the provider job, so nothing has to be stored to resume it.
75const { jobId } = await generateVideo({
76 adapter,
77 prompt: 'A cat chasing a dog in a sunny park',
78 threadId,
79 middleware,
80})
81​
82// Completes the SAME run once the job settles — this is what writes the
83// video, its artifacts, and the terminal status. Works from a different
84// request or process: the jobId is the only correlation.
85const status = await getVideoJobStatus({
86 adapter,
87 jobId,
88 threadId,
89 middleware,
90})
91```