@ai-sdk/xai 3.0.108 → 3.0.109

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/docs/01-xai.mdx CHANGED
@@ -992,6 +992,7 @@ const { video } = await generateVideo({
992
992
  duration: 5,
993
993
  providerOptions: {
994
994
  xai: {
995
+ user: 'user-123',
995
996
  pollTimeoutMs: 600000, // 10 minutes
996
997
  } satisfies XaiVideoModelOptions,
997
998
  },
@@ -1254,6 +1255,14 @@ You can validate the provider options using the `XaiVideoModelOptions` type.
1254
1255
  `1280x720` maps to `720p` and `854x480` maps to `480p`.
1255
1256
  Use this provider option to pass the native format directly.
1256
1257
 
1258
+ - **user** _string_
1259
+
1260
+ Optional identifier for the end user responsible for the request. xAI uses
1261
+ this value for abuse monitoring. It is sent unchanged for video generation
1262
+ (including reference-to-video) and video editing requests, and is omitted
1263
+ when not configured. It is not sent for video extension requests. Use an
1264
+ opaque stable identifier and avoid sending unnecessary personal information.
1265
+
1257
1266
  - **mode** _'edit-video' | 'extend-video' | 'reference-to-video'_
1258
1267
 
1259
1268
  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": "3.0.108",
3
+ "version": "3.0.109",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -29,9 +29,9 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@ai-sdk/provider": "3.0.14",
32
+ "@ai-sdk/openai-compatible": "2.0.61",
33
33
  "@ai-sdk/provider-utils": "4.0.39",
34
- "@ai-sdk/openai-compatible": "2.0.61"
34
+ "@ai-sdk/provider": "3.0.14"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "20.17.24",
@@ -363,6 +363,10 @@ export class XaiVideoModel implements Experimental_VideoModelV3 {
363
363
  });
364
364
  }
365
365
 
366
+ if (!isExtension && xaiOptions?.user !== undefined) {
367
+ body.user = xaiOptions.user;
368
+ }
369
+
366
370
  if (xaiOptions != null) {
367
371
  for (const [key, value] of Object.entries(xaiOptions)) {
368
372
  if (
@@ -373,6 +377,7 @@ export class XaiVideoModel implements Experimental_VideoModelV3 {
373
377
  'resolution',
374
378
  'videoUrl',
375
379
  'referenceImageUrls',
380
+ 'user',
376
381
  ].includes(key)
377
382
  ) {
378
383
  body[key] = value;
@@ -14,7 +14,15 @@ interface XaiVideoSharedOptions {
14
14
  resolution?: XaiVideoResolution | null;
15
15
  }
16
16
 
17
- interface XaiVideoEditModeOptions extends XaiVideoSharedOptions {
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 extends XaiVideoSharedOptions {
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 extends XaiVideoSharedOptions {
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 extends XaiVideoSharedOptions {
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 extends XaiVideoSharedOptions {
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(),
@@ -134,6 +153,7 @@ const runtimeSchema = z
134
153
  mode: modeSchema.optional(),
135
154
  videoUrl: nonEmptyStringSchema.optional(),
136
155
  referenceImageUrls: z.array(nonEmptyStringSchema).min(1).max(7).optional(),
156
+ user: z.string().optional(),
137
157
  ...baseFields,
138
158
  })
139
159
  .passthrough();