@ai-sdk/xai 4.0.14 → 4.0.15
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.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +11 -5
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/docs/01-xai.mdx +9 -0
- package/package.json +5 -5
- package/src/xai-video-model-options.ts +25 -5
- package/src/xai-video-model.ts +5 -0
package/docs/01-xai.mdx
CHANGED
|
@@ -933,6 +933,7 @@ const { video } = await generateVideo({
|
|
|
933
933
|
duration: 5,
|
|
934
934
|
providerOptions: {
|
|
935
935
|
xai: {
|
|
936
|
+
user: 'user-123',
|
|
936
937
|
pollTimeoutMs: 600000, // 10 minutes
|
|
937
938
|
} satisfies XaiVideoModelOptions,
|
|
938
939
|
},
|
|
@@ -1203,6 +1204,14 @@ You can validate the provider options using the `XaiVideoModelOptions` type.
|
|
|
1203
1204
|
`1280x720` maps to `720p` and `854x480` maps to `480p`.
|
|
1204
1205
|
Use this provider option to pass the native format directly.
|
|
1205
1206
|
|
|
1207
|
+
- **user** _string_
|
|
1208
|
+
|
|
1209
|
+
Optional identifier for the end user responsible for the request. xAI uses
|
|
1210
|
+
this value for abuse monitoring. It is sent unchanged for video generation
|
|
1211
|
+
(including reference-to-video) and video editing requests, and is omitted
|
|
1212
|
+
when not configured. It is not sent for video extension requests. Use an
|
|
1213
|
+
opaque stable identifier and avoid sending unnecessary personal information.
|
|
1214
|
+
|
|
1206
1215
|
- **mode** _'edit-video' | 'extend-video' | 'reference-to-video'_
|
|
1207
1216
|
|
|
1208
1217
|
Selects the explicit video operation. Each mode is mutually exclusive:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/xai",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -30,16 +30,16 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@ai-sdk/openai-compatible": "3.0.11",
|
|
33
|
-
"@ai-sdk/provider
|
|
34
|
-
"@ai-sdk/provider": "
|
|
33
|
+
"@ai-sdk/provider": "4.0.3",
|
|
34
|
+
"@ai-sdk/provider-utils": "5.0.10"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "22.19.19",
|
|
38
38
|
"tsup": "^8.5.1",
|
|
39
39
|
"typescript": "5.8.3",
|
|
40
40
|
"zod": "3.25.76",
|
|
41
|
-
"@
|
|
42
|
-
"@ai-
|
|
41
|
+
"@ai-sdk/test-server": "2.0.0",
|
|
42
|
+
"@vercel/ai-tsconfig": "0.0.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"zod": "^3.25.76 || ^4.1.8"
|
|
@@ -14,7 +14,15 @@ interface XaiVideoSharedOptions {
|
|
|
14
14
|
resolution?: XaiVideoResolution | null;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
interface
|
|
17
|
+
interface XaiVideoUserOptions {
|
|
18
|
+
/**
|
|
19
|
+
* A unique identifier representing the end user, for abuse monitoring.
|
|
20
|
+
*/
|
|
21
|
+
user?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface XaiVideoEditModeOptions
|
|
25
|
+
extends XaiVideoSharedOptions, XaiVideoUserOptions {
|
|
18
26
|
/**
|
|
19
27
|
* Select edit-video mode explicitly for best autocomplete and narrowing.
|
|
20
28
|
*/
|
|
@@ -32,7 +40,8 @@ interface XaiVideoExtendModeOptions extends XaiVideoSharedOptions {
|
|
|
32
40
|
videoUrl: string;
|
|
33
41
|
}
|
|
34
42
|
|
|
35
|
-
interface XaiVideoReferenceToVideoOptions
|
|
43
|
+
interface XaiVideoReferenceToVideoOptions
|
|
44
|
+
extends XaiVideoSharedOptions, XaiVideoUserOptions {
|
|
36
45
|
/**
|
|
37
46
|
* Select reference-to-video mode explicitly for best autocomplete and narrowing.
|
|
38
47
|
*/
|
|
@@ -41,13 +50,15 @@ interface XaiVideoReferenceToVideoOptions extends XaiVideoSharedOptions {
|
|
|
41
50
|
referenceImageUrls: string[];
|
|
42
51
|
}
|
|
43
52
|
|
|
44
|
-
interface XaiVideoGenerationOptions
|
|
53
|
+
interface XaiVideoGenerationOptions
|
|
54
|
+
extends XaiVideoSharedOptions, XaiVideoUserOptions {
|
|
45
55
|
mode?: undefined;
|
|
46
56
|
videoUrl?: undefined;
|
|
47
57
|
referenceImageUrls?: undefined;
|
|
48
58
|
}
|
|
49
59
|
|
|
50
|
-
interface XaiLegacyEditVideoOptions
|
|
60
|
+
interface XaiLegacyEditVideoOptions
|
|
61
|
+
extends XaiVideoSharedOptions, XaiVideoUserOptions {
|
|
51
62
|
/**
|
|
52
63
|
* Legacy backward-compatible shape: omitting `mode` while providing
|
|
53
64
|
* `videoUrl` behaves like edit-video.
|
|
@@ -56,7 +67,8 @@ interface XaiLegacyEditVideoOptions extends XaiVideoSharedOptions {
|
|
|
56
67
|
videoUrl: string;
|
|
57
68
|
}
|
|
58
69
|
|
|
59
|
-
interface XaiLegacyReferenceToVideoOptions
|
|
70
|
+
interface XaiLegacyReferenceToVideoOptions
|
|
71
|
+
extends XaiVideoSharedOptions, XaiVideoUserOptions {
|
|
60
72
|
/**
|
|
61
73
|
* Legacy backward-compatible shape: omitting `mode` while providing
|
|
62
74
|
* `referenceImageUrls` behaves like reference-to-video.
|
|
@@ -94,8 +106,13 @@ const baseFields = {
|
|
|
94
106
|
resolution: resolutionSchema.nullish(),
|
|
95
107
|
};
|
|
96
108
|
|
|
109
|
+
const userField = {
|
|
110
|
+
user: z.string().optional(),
|
|
111
|
+
};
|
|
112
|
+
|
|
97
113
|
const editVideoSchema = z.object({
|
|
98
114
|
...baseFields,
|
|
115
|
+
...userField,
|
|
99
116
|
mode: z.literal('edit-video'),
|
|
100
117
|
videoUrl: nonEmptyStringSchema,
|
|
101
118
|
referenceImageUrls: z.undefined().optional(),
|
|
@@ -110,6 +127,7 @@ const extendVideoSchema = z.object({
|
|
|
110
127
|
|
|
111
128
|
const referenceToVideoSchema = z.object({
|
|
112
129
|
...baseFields,
|
|
130
|
+
...userField,
|
|
113
131
|
mode: z.literal('reference-to-video'),
|
|
114
132
|
referenceImageUrls: z.array(nonEmptyStringSchema).min(1).max(7),
|
|
115
133
|
videoUrl: z.undefined().optional(),
|
|
@@ -117,6 +135,7 @@ const referenceToVideoSchema = z.object({
|
|
|
117
135
|
|
|
118
136
|
const autoDetectSchema = z.object({
|
|
119
137
|
...baseFields,
|
|
138
|
+
...userField,
|
|
120
139
|
mode: z.undefined().optional(),
|
|
121
140
|
videoUrl: nonEmptyStringSchema.optional(),
|
|
122
141
|
referenceImageUrls: z.array(nonEmptyStringSchema).min(1).max(7).optional(),
|
|
@@ -133,6 +152,7 @@ const runtimeSchema = z.looseObject({
|
|
|
133
152
|
mode: modeSchema.optional(),
|
|
134
153
|
videoUrl: nonEmptyStringSchema.optional(),
|
|
135
154
|
referenceImageUrls: z.array(nonEmptyStringSchema).min(1).max(7).optional(),
|
|
155
|
+
user: z.string().optional(),
|
|
136
156
|
...baseFields,
|
|
137
157
|
});
|
|
138
158
|
|
package/src/xai-video-model.ts
CHANGED
|
@@ -359,6 +359,10 @@ export class XaiVideoModel implements Experimental_VideoModelV4 {
|
|
|
359
359
|
});
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
+
if (!isExtension && xaiOptions?.user !== undefined) {
|
|
363
|
+
body.user = xaiOptions.user;
|
|
364
|
+
}
|
|
365
|
+
|
|
362
366
|
if (xaiOptions != null) {
|
|
363
367
|
for (const [key, value] of Object.entries(xaiOptions)) {
|
|
364
368
|
if (
|
|
@@ -369,6 +373,7 @@ export class XaiVideoModel implements Experimental_VideoModelV4 {
|
|
|
369
373
|
'resolution',
|
|
370
374
|
'videoUrl',
|
|
371
375
|
'referenceImageUrls',
|
|
376
|
+
'user',
|
|
372
377
|
].includes(key)
|
|
373
378
|
) {
|
|
374
379
|
body[key] = value;
|