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

VideoAdapter.md

282 lines5.7 KB

1---
2id: VideoAdapter
3title: VideoAdapter
4---
5​
6Defined in: packages/ai/src/activities/generateVideo/adapter.ts:69
7​
8**`Experimental`**
9​
10Video adapter interface with pre-resolved generics.
11​
12An adapter is created by a provider function: `provider('model')` → `adapter`
13All type resolution happens at the provider call site, not in this interface.
14​
15 Video generation is an experimental feature and may change.
16​
17Generic parameters:
18- TModel: The specific model name (e.g., 'sora-2')
19- TProviderOptions: Provider-specific options (already resolved)
20- TModelProviderOptionsByName: Map from model name to its specific provider options
21- TModelSizeByName: Map from model name to its supported sizes
22- TModelInputModalitiesByName: Map from model name to the non-text prompt
23 modalities it accepts (constrains the `prompt` part types at compile time)
24- TModelDurationByName: Map from model name to its supported duration
25 union. Defaults to `Record<string, number>` so adapters that haven't
26 declared a map keep today's `duration?: number` typing.
27​
28## Type Parameters
29​
30### TModel
31​
32`TModel` *extends* `string` = `string`
33​
34### TProviderOptions
35​
36`TProviderOptions` *extends* `object` = `Record`\<`string`, `unknown`\>
37​
38### TModelProviderOptionsByName
39​
40`TModelProviderOptionsByName` *extends* `Record`\<`string`, `any`\> = `Record`\<`string`, `any`\>
41​
42### TModelSizeByName
43​
44`TModelSizeByName` *extends* `Record`\<`string`, `string` \| `undefined`\> = `Record`\<`string`, `string`\>
45​
46### TModelInputModalitiesByName
47​
48`TModelInputModalitiesByName` *extends* [`ModelInputModalitiesByName`](../type-aliases/ModelInputModalitiesByName.md) = [`ModelInputModalitiesByName`](../type-aliases/ModelInputModalitiesByName.md)
49​
50### TModelDurationByName
51​
52`TModelDurationByName` *extends* `Record`\<`string`, `string` \| `number` \| `undefined`\> = `Record`\<`string`, `number`\>
53​
54## Properties
55​
56### ~types
57​
58```ts
59~types: object;
60```
61​
62Defined in: packages/ai/src/activities/generateVideo/adapter.ts:99
63​
64**`Internal`**
65​
66Type-only properties for inference. Not assigned at runtime.
67​
68#### modelDurationByName
69​
70```ts
71modelDurationByName: TModelDurationByName;
72```
73​
74#### modelInputModalitiesByName
75​
76```ts
77modelInputModalitiesByName: TModelInputModalitiesByName;
78```
79​
80#### modelProviderOptionsByName
81​
82```ts
83modelProviderOptionsByName: TModelProviderOptionsByName;
84```
85​
86#### modelSizeByName
87​
88```ts
89modelSizeByName: TModelSizeByName;
90```
91​
92#### providerOptions
93​
94```ts
95providerOptions: TProviderOptions;
96```
97​
98***
99​
100### availableDurations
101​
102```ts
103availableDurations: () => DurationOptions<TModelDurationByName[TModel]>;
104```
105​
106Defined in: packages/ai/src/activities/generateVideo/adapter.ts:136
107​
108**`Experimental`**
109​
110Describe the durations this adapter's model accepts. Returns a tagged
111union so consumers can render UI / coerce input without provider-specific
112knowledge.
113​
114#### Returns
115​
116`DurationOptions`\<`TModelDurationByName`\[`TModel`\]\>
117​
118***
119​
120### createVideoJob
121​
122```ts
123createVideoJob: (options) => Promise<VideoJobResult>;
124```
125​
126Defined in: packages/ai/src/activities/generateVideo/adapter.ts:111
127​
128**`Experimental`**
129​
130Create a new video generation job.
131Returns a job ID that can be used to poll for status and retrieve the video.
132​
133#### Parameters
134​
135##### options
136​
137[`VideoGenerationOptions`](VideoGenerationOptions.md)\<`TProviderOptions`, `TModelSizeByName`\[`TModel`\], `TModelDurationByName`\[`TModel`\]\>
138​
139#### Returns
140​
141`Promise`\<[`VideoJobResult`](VideoJobResult.md)\>
142​
143***
144​
145### getVideo
146​
147```ts
148getVideo: (jobId) => Promise<
149 | VideoUrlResult
150| VideoStreamResult>;
151```
152​
153Defined in: packages/ai/src/activities/generateVideo/adapter.ts:129
154​
155**`Experimental`**
156​
157Get the finished video: a public URL when the provider has one, or the
158download stream for generation middleware to host. Call only after
159status is 'completed'.
160​
161#### Parameters
162​
163##### jobId
164​
165`string`
166​
167#### Returns
168​
169`Promise`\<
170 \| [`VideoUrlResult`](VideoUrlResult.md)
171 \| [`VideoStreamResult`](VideoStreamResult.md)\>
172​
173***
174​
175### getVideoStatus
176​
177```ts
178getVideoStatus: (jobId) => Promise<VideoStatusResult>;
179```
180​
181Defined in: packages/ai/src/activities/generateVideo/adapter.ts:122
182​
183**`Experimental`**
184​
185Get the current status of a video generation job.
186​
187#### Parameters
188​
189##### jobId
190​
191`string`
192​
193#### Returns
194​
195`Promise`\<[`VideoStatusResult`](VideoStatusResult.md)\>
196​
197***
198​
199### kind
200​
201```ts
202readonly kind: "video";
203```
204​
205Defined in: packages/ai/src/activities/generateVideo/adapter.ts:83
206​
207**`Experimental`**
208​
209Discriminator for adapter kind - used to determine API shape
210​
211***
212​
213### model
214​
215```ts
216readonly model: TModel;
217```
218​
219Defined in: packages/ai/src/activities/generateVideo/adapter.ts:94
220​
221**`Experimental`**
222​
223The model this adapter is configured for
224​
225***
226​
227### name
228​
229```ts
230readonly name: string;
231```
232​
233Defined in: packages/ai/src/activities/generateVideo/adapter.ts:85
234​
235**`Experimental`**
236​
237Adapter name identifier
238​
239***
240​
241### snapDuration
242​
243```ts
244snapDuration: (input) => TModelDurationByName[TModel] | undefined;
245```
246​
247Defined in: packages/ai/src/activities/generateVideo/adapter.ts:145
248​
249**`Experimental`**
250​
251Coerce `input` to the closest duration this model accepts.
252`input` may be seconds (`7`), a numeric string (`"7"`), a template
253(`"6s"`), or a keyword the model lists (`"auto"`).
254Returns `undefined` when the model has no duration field, or when
255`input` is a keyword that model does not list.
256​
257#### Parameters
258​
259##### input
260​
261`string` \| `number`
262​
263#### Returns
264​
265`TModelDurationByName`\[`TModel`\] \| `undefined`
266​
267***
268​
269### supportsFileSources?
270​
271```ts
272readonly optional supportsFileSources?: boolean;
273```
274​
275Defined in: packages/ai/src/activities/generateVideo/adapter.ts:92
276​
277**`Experimental`**
278​
279Declares that this adapter can consume `{ type: 'file' }` content
280sources (provider Files API references). The activity dispatcher rejects
281file sources in preflight for adapters that don't declare this, so
282adapters written before the file arm existed fail closed.