ai 6.0.221 → 6.0.222

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -152,7 +152,7 @@ function detectMediaType({
152
152
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
153
153
 
154
154
  // src/version.ts
155
- var VERSION = true ? "6.0.221" : "0.0.0-test";
155
+ var VERSION = true ? "6.0.222" : "0.0.0-test";
156
156
 
157
157
  // src/util/download/download.ts
158
158
  var download = async ({
@@ -132,7 +132,7 @@ import {
132
132
  } from "@ai-sdk/provider-utils";
133
133
 
134
134
  // src/version.ts
135
- var VERSION = true ? "6.0.221" : "0.0.0-test";
135
+ var VERSION = true ? "6.0.222" : "0.0.0-test";
136
136
 
137
137
  // src/util/download/download.ts
138
138
  var download = async ({
@@ -111,10 +111,15 @@ Here are the capabilities of popular models:
111
111
 
112
112
  | Provider | Model | Image Input | Object Generation | Tool Usage | Tool Streaming |
113
113
  | -------------------------------------------------- | ------------------------------------------- | ------------------- | ------------------- | ------------------- | ------------------- |
114
+ | [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-4.5` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
114
115
  | [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-4` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
115
116
  | [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-3` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
116
117
  | [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-3-mini` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
117
118
  | [Vercel](/providers/ai-sdk-providers/vercel) | `v0-1.0-md` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
119
+ | [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-5.6` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
120
+ | [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-5.6-luna` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
121
+ | [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-5.6-sol` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
122
+ | [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-5.6-terra` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
118
123
  | [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-5.5` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
119
124
  | [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-5.4-pro` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
120
125
  | [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-5.4` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
@@ -37,7 +37,7 @@ const uint8Array = video.uint8Array; // Uint8Array video data
37
37
  The aspect ratio is specified as a string in the format `{width}:{height}`.
38
38
  Models only support a few aspect ratios, and the supported aspect ratios are different for each model and provider.
39
39
 
40
- ```tsx highlight={"7"}
40
+ ```tsx highlight={"6"}
41
41
  import { experimental_generateVideo as generateVideo } from 'ai';
42
42
  __PROVIDER_IMPORT__;
43
43
 
@@ -53,7 +53,7 @@ const { video } = await generateVideo({
53
53
  The resolution is specified as a string in the format `{width}x{height}`.
54
54
  Models only support specific resolutions, and the supported resolutions are different for each model and provider.
55
55
 
56
- ```tsx highlight={"7"}
56
+ ```tsx highlight={"6"}
57
57
  import { experimental_generateVideo as generateVideo } from 'ai';
58
58
  __PROVIDER_IMPORT__;
59
59
 
@@ -68,7 +68,7 @@ const { video } = await generateVideo({
68
68
 
69
69
  Some video models support specifying the duration of the generated video in seconds.
70
70
 
71
- ```tsx highlight={"7"}
71
+ ```tsx highlight={"6"}
72
72
  import { experimental_generateVideo as generateVideo } from 'ai';
73
73
  __PROVIDER_IMPORT__;
74
74
 
@@ -83,7 +83,7 @@ const { video } = await generateVideo({
83
83
 
84
84
  Some video models allow you to specify the frames per second for the generated video.
85
85
 
86
- ```tsx highlight={"7"}
86
+ ```tsx highlight={"6"}
87
87
  import { experimental_generateVideo as generateVideo } from 'ai';
88
88
  __PROVIDER_IMPORT__;
89
89
 
@@ -98,7 +98,7 @@ const { video } = await generateVideo({
98
98
 
99
99
  Some video models can generate audio alongside the video. Use the `generateAudio` option to control this:
100
100
 
101
- ```tsx highlight={"7"}
101
+ ```tsx highlight={"6"}
102
102
  import { experimental_generateVideo as generateVideo } from 'ai';
103
103
  __PROVIDER_IMPORT__;
104
104
 
@@ -113,7 +113,7 @@ const { video } = await generateVideo({
113
113
 
114
114
  `experimental_generateVideo` supports generating multiple videos at once:
115
115
 
116
- ```tsx highlight={"7"}
116
+ ```tsx highlight={"6"}
117
117
  import { experimental_generateVideo as generateVideo } from 'ai';
118
118
  __PROVIDER_IMPORT__;
119
119
 
@@ -146,7 +146,7 @@ const { videos } = await generateVideo({
146
146
 
147
147
  Some video models support generating videos from an input image. You can provide an image using the prompt object:
148
148
 
149
- ```tsx highlight={"7-10"}
149
+ ```tsx highlight={"5-7"}
150
150
  import { experimental_generateVideo as generateVideo } from 'ai';
151
151
  __PROVIDER_IMPORT__;
152
152
 
@@ -177,7 +177,7 @@ Some video models support first-last-frame generation, where you provide the
177
177
  starting and/or ending frames of the video. Use the `frameImages` option to pass
178
178
  role-tagged images in a provider-agnostic way:
179
179
 
180
- ```tsx highlight={"5-16"}
180
+ ```tsx highlight={"4-13"}
181
181
  const { video } = await generateVideo({
182
182
  model: __VIDEO_MODEL__,
183
183
  prompt: 'The cat walks across the scene and transforms into a dog by the end',
@@ -194,13 +194,13 @@ const { video } = await generateVideo({
194
194
  });
195
195
  ```
196
196
 
197
- ### Reference Images
197
+ ### Reference Inputs
198
198
 
199
199
  Some video models support reference-to-video generation, where you provide one or
200
- more reference images that the model incorporates into the generated video. Use the `inputReferences` option to pass
201
- these images in a provider-agnostic way:
200
+ more reference images or videos that the model incorporates into the generated video. Use the `inputReferences` option to pass
201
+ these inputs in a provider-agnostic way:
202
202
 
203
- ```tsx highlight={"5-8"}
203
+ ```tsx highlight={"4-7"}
204
204
  const { video } = await generateVideo({
205
205
  model: __VIDEO_MODEL__,
206
206
  prompt: 'The two characters meet in a bustling market',
@@ -211,12 +211,31 @@ const { video } = await generateVideo({
211
211
  });
212
212
  ```
213
213
 
214
+ For URL-based video references, use the object form with an explicit `mediaType`:
215
+
216
+ ```tsx highlight={"4-9"}
217
+ const { video } = await generateVideo({
218
+ model: __VIDEO_MODEL__,
219
+ prompt: 'Match the motion in the reference clip',
220
+ inputReferences: [
221
+ {
222
+ data: 'https://example.com/reference.mp4',
223
+ mediaType: 'video/mp4',
224
+ },
225
+ ],
226
+ });
227
+ ```
228
+
229
+ Providers route each reference by its media type (image vs. video) and emit a
230
+ warning when a reference kind is unsupported (for example, providers that accept
231
+ only image references warn and ignore a video reference).
232
+
214
233
  ### Providing a Seed
215
234
 
216
235
  You can provide a seed to the `experimental_generateVideo` function to control the output of the video generation process.
217
236
  If supported by the model, the same seed will always produce the same video.
218
237
 
219
- ```tsx highlight={"7"}
238
+ ```tsx highlight={"6"}
220
239
  import { experimental_generateVideo as generateVideo } from 'ai';
221
240
  __PROVIDER_IMPORT__;
222
241
 
@@ -254,7 +273,7 @@ const { video } = await generateVideo({
254
273
  type [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)
255
274
  that you can use to abort the video generation process or set a timeout.
256
275
 
257
- ```ts highlight={"7"}
276
+ ```ts highlight={"6"}
258
277
  import { experimental_generateVideo as generateVideo } from 'ai';
259
278
  __PROVIDER_IMPORT__;
260
279
 
@@ -276,7 +295,7 @@ Video generation is an asynchronous process that can take several minutes to com
276
295
 
277
296
  You can configure the polling timeout using provider-specific options. Each provider exports a type for its options that you can use with `satisfies` for type safety:
278
297
 
279
- ```tsx highlight={"10-12"}
298
+ ```tsx highlight={"9-11"}
280
299
  import { experimental_generateVideo as generateVideo } from 'ai';
281
300
  import { fal, type FalVideoModelOptions } from '@ai-sdk/fal';
282
301
 
@@ -303,7 +322,7 @@ const { video } = await generateVideo({
303
322
  `experimental_generateVideo` accepts an optional `headers` parameter of type `Record<string, string>`
304
323
  that you can use to add custom headers to the video generation request.
305
324
 
306
- ```ts highlight={"7"}
325
+ ```ts highlight={"6"}
307
326
  import { experimental_generateVideo as generateVideo } from 'ai';
308
327
  __PROVIDER_IMPORT__;
309
328
 
@@ -118,9 +118,10 @@ console.log(videos);
118
118
  },
119
119
  {
120
120
  name: 'inputReferences',
121
- type: 'Array<DataContent>',
121
+ type: 'Array<DataContent | { data: DataContent; mediaType?: string }>',
122
122
  isOptional: true,
123
- description: 'Reference image inputs for reference-to-video generation.',
123
+ description:
124
+ 'Reference image or video inputs for reference-to-video generation. Use the object form with an explicit mediaType for URL-based video references. Providers route each reference by its media type and warn when a reference kind is unsupported.',
124
125
  },
125
126
  {
126
127
  name: 'generateAudio',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "6.0.221",
3
+ "version": "6.0.222",
4
4
  "description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -45,9 +45,9 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@opentelemetry/api": "^1.9.0",
48
- "@ai-sdk/gateway": "3.0.145",
49
- "@ai-sdk/provider": "3.0.13",
50
- "@ai-sdk/provider-utils": "4.0.37"
48
+ "@ai-sdk/gateway": "3.0.146",
49
+ "@ai-sdk/provider": "3.0.14",
50
+ "@ai-sdk/provider-utils": "4.0.38"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@edge-runtime/vm": "^5.0.0",
@@ -32,7 +32,6 @@ import { prepareRetries } from '../util/prepare-retries';
32
32
  import { VERSION } from '../version';
33
33
  import type { GenerateVideoResult } from './generate-video-result';
34
34
  import { splitDataUrl } from '../prompt/split-data-url';
35
- import { convertDataContentToUint8Array } from '../prompt/data-content';
36
35
 
37
36
  export type GenerateVideoPrompt =
38
37
  | string
@@ -53,7 +52,7 @@ export type GenerateVideoPrompt =
53
52
  * @param fps - Frames per second for the video.
54
53
  * @param seed - Seed for the video generation.
55
54
  * @param frameImages - Role-tagged image inputs for image-to-video and first-last-frame generation.
56
- * @param inputReferences - Reference image inputs for reference-to-video generation.
55
+ * @param inputReferences - Reference image or video inputs for reference-to-video generation.
57
56
  * @param generateAudio - Whether the model should generate audio alongside the video.
58
57
  * @param providerOptions - Additional provider-specific options that are passed through to the provider
59
58
  * as body parameters.
@@ -145,9 +144,26 @@ export async function experimental_generateVideo({
145
144
  }>;
146
145
 
147
146
  /**
148
- * Reference image inputs for reference-to-video generation.
147
+ * Reference inputs for reference-to-video generation.
148
+ *
149
+ * Each entry may be a plain image/video ({@link DataContent}), or an object
150
+ * form that carries an explicit `mediaType`.
149
151
  */
150
- inputReferences?: Array<DataContent>;
152
+ inputReferences?: Array<
153
+ | DataContent
154
+ | {
155
+ /**
156
+ * The reference image or video.
157
+ */
158
+ data: DataContent;
159
+
160
+ /**
161
+ * The media type of the reference (e.g. 'image/png',
162
+ * 'video/mp4').
163
+ */
164
+ mediaType?: string;
165
+ }
166
+ >;
151
167
 
152
168
  /**
153
169
  * Whether the model should generate audio alongside the video.
@@ -205,16 +221,19 @@ export async function experimental_generateVideo({
205
221
 
206
222
  const normalizedFrameImages:
207
223
  | Array<Experimental_VideoModelV3FrameImage>
208
- | undefined = frameImages?.map(frame => ({
209
- image: normalizeImageData(frame.image),
210
- frameType: frame.frameType,
211
- }));
224
+ | undefined = frameImages?.flatMap(frame => {
225
+ const normalizedImage = normalizeImageData(frame.image);
226
+ return normalizedImage != null
227
+ ? [{ image: normalizedImage, frameType: frame.frameType }]
228
+ : [];
229
+ });
212
230
 
213
231
  const normalizedInputReferences:
214
232
  | Array<Experimental_VideoModelV3File>
215
- | undefined = inputReferences?.map(reference =>
216
- normalizeImageData(reference),
217
- );
233
+ | undefined = inputReferences?.flatMap(reference => {
234
+ const normalized = normalizeReferenceData(reference);
235
+ return normalized != null ? [normalized] : [];
236
+ });
218
237
 
219
238
  const effectiveInputReferences =
220
239
  normalizedFrameImages != null && normalizedFrameImages.length > 0
@@ -430,13 +449,25 @@ function normalizePrompt(promptArg: GenerateVideoPrompt): {
430
449
  };
431
450
  }
432
451
 
452
+ function detectFileMediaType(
453
+ data: Uint8Array,
454
+ restrictToImages: boolean,
455
+ ): string {
456
+ const detected = restrictToImages
457
+ ? detectMediaType({ data, signatures: imageMediaTypeSignatures })
458
+ : (detectMediaType({ data, signatures: imageMediaTypeSignatures }) ??
459
+ detectMediaType({ data, signatures: videoMediaTypeSignatures }));
460
+ return detected ?? 'image/png';
461
+ }
462
+
433
463
  /**
434
464
  * Normalizes a {@link DataContent} image into a {@link Experimental_VideoModelV3File}.
435
465
  * Accepts a URL string, a data URL, a base64 string, or binary image data.
436
466
  */
437
467
  function normalizeImageData(
438
468
  dataContent: DataContent,
439
- ): Experimental_VideoModelV3File {
469
+ { restrictToImages = true }: { restrictToImages?: boolean } = {},
470
+ ): Experimental_VideoModelV3File | undefined {
440
471
  if (typeof dataContent === 'string') {
441
472
  if (
442
473
  dataContent.startsWith('http://') ||
@@ -450,32 +481,73 @@ function normalizeImageData(
450
481
 
451
482
  if (dataContent.startsWith('data:')) {
452
483
  const { mediaType, base64Content } = splitDataUrl(dataContent);
484
+ const data = convertBase64ToUint8Array(base64Content ?? '');
453
485
  return {
454
486
  type: 'file',
455
- mediaType: mediaType ?? 'image/png',
456
- data: convertBase64ToUint8Array(base64Content ?? ''),
487
+ mediaType: mediaType ?? detectFileMediaType(data, restrictToImages),
488
+ data,
457
489
  };
458
490
  }
459
491
 
460
492
  const bytes = convertBase64ToUint8Array(dataContent);
461
493
  return {
462
494
  type: 'file',
463
- mediaType:
464
- detectMediaType({
465
- data: bytes,
466
- signatures: imageMediaTypeSignatures,
467
- }) ?? 'image/png',
495
+ mediaType: detectFileMediaType(bytes, restrictToImages),
468
496
  data: bytes,
469
497
  };
470
498
  }
471
499
 
472
- const bytes = convertDataContentToUint8Array(dataContent);
500
+ if (dataContent instanceof Uint8Array || dataContent instanceof ArrayBuffer) {
501
+ const bytes =
502
+ dataContent instanceof Uint8Array
503
+ ? dataContent
504
+ : new Uint8Array(dataContent);
505
+ return {
506
+ type: 'file',
507
+ mediaType: detectFileMediaType(bytes, restrictToImages),
508
+ data: bytes,
509
+ };
510
+ }
511
+
512
+ return undefined;
513
+ }
514
+
515
+ /**
516
+ * Normalizes a reference input into a {@link Experimental_VideoModelV3File},
517
+ * accepting either a plain {@link DataContent} or the object form that carries
518
+ * an explicit `mediaType`.
519
+ */
520
+ function normalizeReferenceData(
521
+ reference:
522
+ | DataContent
523
+ | {
524
+ data: DataContent;
525
+ mediaType?: string;
526
+ },
527
+ ): Experimental_VideoModelV3File | undefined {
528
+ const isObjectForm =
529
+ typeof reference === 'object' &&
530
+ reference != null &&
531
+ !(reference instanceof Uint8Array) &&
532
+ !(reference instanceof ArrayBuffer) &&
533
+ 'data' in reference;
534
+
535
+ if (!isObjectForm) {
536
+ return normalizeImageData(reference as DataContent, {
537
+ restrictToImages: false,
538
+ });
539
+ }
540
+
541
+ const normalized = normalizeImageData(reference.data, {
542
+ restrictToImages: false,
543
+ });
544
+ if (normalized == null) {
545
+ return normalized;
546
+ }
547
+
473
548
  return {
474
- type: 'file',
475
- mediaType:
476
- detectMediaType({ data: bytes, signatures: imageMediaTypeSignatures }) ??
477
- 'image/png',
478
- data: bytes,
549
+ ...normalized,
550
+ ...(reference.mediaType != null ? { mediaType: reference.mediaType } : {}),
479
551
  };
480
552
  }
481
553