@ai-sdk/xai 3.0.108 → 3.0.110
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 +15 -0
- package/dist/index.d.mts +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.js +28 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -5
- package/dist/index.mjs.map +1 -1
- package/docs/01-xai.mdx +9 -0
- package/package.json +3 -3
- package/src/xai-video-model.ts +29 -3
- package/src/xai-video-options.ts +25 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 3.0.110
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 09ecf7b: fix(xai): handle empty HTTP 202 responses while polling videos
|
|
8
|
+
- Updated dependencies [19093fd]
|
|
9
|
+
- @ai-sdk/provider-utils@4.0.40
|
|
10
|
+
- @ai-sdk/openai-compatible@2.0.62
|
|
11
|
+
|
|
12
|
+
## 3.0.109
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- b0db900: feat(provider/xai): support end-user identifiers for video generation and editing
|
|
17
|
+
|
|
3
18
|
## 3.0.108
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -122,7 +122,13 @@ interface XaiVideoSharedOptions {
|
|
|
122
122
|
pollTimeoutMs?: number | null;
|
|
123
123
|
resolution?: XaiVideoResolution | null;
|
|
124
124
|
}
|
|
125
|
-
interface
|
|
125
|
+
interface XaiVideoUserOptions {
|
|
126
|
+
/**
|
|
127
|
+
* A unique identifier representing the end user, for abuse monitoring.
|
|
128
|
+
*/
|
|
129
|
+
user?: string;
|
|
130
|
+
}
|
|
131
|
+
interface XaiVideoEditModeOptions extends XaiVideoSharedOptions, XaiVideoUserOptions {
|
|
126
132
|
/**
|
|
127
133
|
* Select edit-video mode explicitly for best autocomplete and narrowing.
|
|
128
134
|
*/
|
|
@@ -138,7 +144,7 @@ interface XaiVideoExtendModeOptions extends XaiVideoSharedOptions {
|
|
|
138
144
|
/** Source video URL to extend from its last frame. */
|
|
139
145
|
videoUrl: string;
|
|
140
146
|
}
|
|
141
|
-
interface XaiVideoReferenceToVideoOptions extends XaiVideoSharedOptions {
|
|
147
|
+
interface XaiVideoReferenceToVideoOptions extends XaiVideoSharedOptions, XaiVideoUserOptions {
|
|
142
148
|
/**
|
|
143
149
|
* Select reference-to-video mode explicitly for best autocomplete and narrowing.
|
|
144
150
|
*/
|
|
@@ -146,12 +152,12 @@ interface XaiVideoReferenceToVideoOptions extends XaiVideoSharedOptions {
|
|
|
146
152
|
/** Reference image URLs (1-7) for R2V generation. */
|
|
147
153
|
referenceImageUrls: string[];
|
|
148
154
|
}
|
|
149
|
-
interface XaiVideoGenerationOptions extends XaiVideoSharedOptions {
|
|
155
|
+
interface XaiVideoGenerationOptions extends XaiVideoSharedOptions, XaiVideoUserOptions {
|
|
150
156
|
mode?: undefined;
|
|
151
157
|
videoUrl?: undefined;
|
|
152
158
|
referenceImageUrls?: undefined;
|
|
153
159
|
}
|
|
154
|
-
interface XaiLegacyEditVideoOptions extends XaiVideoSharedOptions {
|
|
160
|
+
interface XaiLegacyEditVideoOptions extends XaiVideoSharedOptions, XaiVideoUserOptions {
|
|
155
161
|
/**
|
|
156
162
|
* Legacy backward-compatible shape: omitting `mode` while providing
|
|
157
163
|
* `videoUrl` behaves like edit-video.
|
|
@@ -159,7 +165,7 @@ interface XaiLegacyEditVideoOptions extends XaiVideoSharedOptions {
|
|
|
159
165
|
mode?: undefined;
|
|
160
166
|
videoUrl: string;
|
|
161
167
|
}
|
|
162
|
-
interface XaiLegacyReferenceToVideoOptions extends XaiVideoSharedOptions {
|
|
168
|
+
interface XaiLegacyReferenceToVideoOptions extends XaiVideoSharedOptions, XaiVideoUserOptions {
|
|
163
169
|
/**
|
|
164
170
|
* Legacy backward-compatible shape: omitting `mode` while providing
|
|
165
171
|
* `referenceImageUrls` behaves like reference-to-video.
|
package/dist/index.d.ts
CHANGED
|
@@ -122,7 +122,13 @@ interface XaiVideoSharedOptions {
|
|
|
122
122
|
pollTimeoutMs?: number | null;
|
|
123
123
|
resolution?: XaiVideoResolution | null;
|
|
124
124
|
}
|
|
125
|
-
interface
|
|
125
|
+
interface XaiVideoUserOptions {
|
|
126
|
+
/**
|
|
127
|
+
* A unique identifier representing the end user, for abuse monitoring.
|
|
128
|
+
*/
|
|
129
|
+
user?: string;
|
|
130
|
+
}
|
|
131
|
+
interface XaiVideoEditModeOptions extends XaiVideoSharedOptions, XaiVideoUserOptions {
|
|
126
132
|
/**
|
|
127
133
|
* Select edit-video mode explicitly for best autocomplete and narrowing.
|
|
128
134
|
*/
|
|
@@ -138,7 +144,7 @@ interface XaiVideoExtendModeOptions extends XaiVideoSharedOptions {
|
|
|
138
144
|
/** Source video URL to extend from its last frame. */
|
|
139
145
|
videoUrl: string;
|
|
140
146
|
}
|
|
141
|
-
interface XaiVideoReferenceToVideoOptions extends XaiVideoSharedOptions {
|
|
147
|
+
interface XaiVideoReferenceToVideoOptions extends XaiVideoSharedOptions, XaiVideoUserOptions {
|
|
142
148
|
/**
|
|
143
149
|
* Select reference-to-video mode explicitly for best autocomplete and narrowing.
|
|
144
150
|
*/
|
|
@@ -146,12 +152,12 @@ interface XaiVideoReferenceToVideoOptions extends XaiVideoSharedOptions {
|
|
|
146
152
|
/** Reference image URLs (1-7) for R2V generation. */
|
|
147
153
|
referenceImageUrls: string[];
|
|
148
154
|
}
|
|
149
|
-
interface XaiVideoGenerationOptions extends XaiVideoSharedOptions {
|
|
155
|
+
interface XaiVideoGenerationOptions extends XaiVideoSharedOptions, XaiVideoUserOptions {
|
|
150
156
|
mode?: undefined;
|
|
151
157
|
videoUrl?: undefined;
|
|
152
158
|
referenceImageUrls?: undefined;
|
|
153
159
|
}
|
|
154
|
-
interface XaiLegacyEditVideoOptions extends XaiVideoSharedOptions {
|
|
160
|
+
interface XaiLegacyEditVideoOptions extends XaiVideoSharedOptions, XaiVideoUserOptions {
|
|
155
161
|
/**
|
|
156
162
|
* Legacy backward-compatible shape: omitting `mode` while providing
|
|
157
163
|
* `videoUrl` behaves like edit-video.
|
|
@@ -159,7 +165,7 @@ interface XaiLegacyEditVideoOptions extends XaiVideoSharedOptions {
|
|
|
159
165
|
mode?: undefined;
|
|
160
166
|
videoUrl: string;
|
|
161
167
|
}
|
|
162
|
-
interface XaiLegacyReferenceToVideoOptions extends XaiVideoSharedOptions {
|
|
168
|
+
interface XaiLegacyReferenceToVideoOptions extends XaiVideoSharedOptions, XaiVideoUserOptions {
|
|
163
169
|
/**
|
|
164
170
|
* Legacy backward-compatible shape: omitting `mode` while providing
|
|
165
171
|
* `referenceImageUrls` behaves like reference-to-video.
|
package/dist/index.js
CHANGED
|
@@ -2891,7 +2891,7 @@ var xaiTools = {
|
|
|
2891
2891
|
};
|
|
2892
2892
|
|
|
2893
2893
|
// src/version.ts
|
|
2894
|
-
var VERSION = true ? "3.0.
|
|
2894
|
+
var VERSION = true ? "3.0.110" : "0.0.0-test";
|
|
2895
2895
|
|
|
2896
2896
|
// src/xai-video-model.ts
|
|
2897
2897
|
var import_provider6 = require("@ai-sdk/provider");
|
|
@@ -2909,8 +2909,12 @@ var baseFields = {
|
|
|
2909
2909
|
pollTimeoutMs: import_v416.z.number().positive().nullish(),
|
|
2910
2910
|
resolution: resolutionSchema.nullish()
|
|
2911
2911
|
};
|
|
2912
|
+
var userField = {
|
|
2913
|
+
user: import_v416.z.string().optional()
|
|
2914
|
+
};
|
|
2912
2915
|
var editVideoSchema = import_v416.z.object({
|
|
2913
2916
|
...baseFields,
|
|
2917
|
+
...userField,
|
|
2914
2918
|
mode: import_v416.z.literal("edit-video"),
|
|
2915
2919
|
videoUrl: nonEmptyStringSchema,
|
|
2916
2920
|
referenceImageUrls: import_v416.z.undefined().optional()
|
|
@@ -2923,12 +2927,14 @@ var extendVideoSchema = import_v416.z.object({
|
|
|
2923
2927
|
});
|
|
2924
2928
|
var referenceToVideoSchema = import_v416.z.object({
|
|
2925
2929
|
...baseFields,
|
|
2930
|
+
...userField,
|
|
2926
2931
|
mode: import_v416.z.literal("reference-to-video"),
|
|
2927
2932
|
referenceImageUrls: import_v416.z.array(nonEmptyStringSchema).min(1).max(7),
|
|
2928
2933
|
videoUrl: import_v416.z.undefined().optional()
|
|
2929
2934
|
});
|
|
2930
2935
|
var autoDetectSchema = import_v416.z.object({
|
|
2931
2936
|
...baseFields,
|
|
2937
|
+
...userField,
|
|
2932
2938
|
mode: import_v416.z.undefined().optional(),
|
|
2933
2939
|
videoUrl: nonEmptyStringSchema.optional(),
|
|
2934
2940
|
referenceImageUrls: import_v416.z.array(nonEmptyStringSchema).min(1).max(7).optional()
|
|
@@ -2943,6 +2949,7 @@ var runtimeSchema = import_v416.z.object({
|
|
|
2943
2949
|
mode: modeSchema.optional(),
|
|
2944
2950
|
videoUrl: nonEmptyStringSchema.optional(),
|
|
2945
2951
|
referenceImageUrls: import_v416.z.array(nonEmptyStringSchema).min(1).max(7).optional(),
|
|
2952
|
+
user: import_v416.z.string().optional(),
|
|
2946
2953
|
...baseFields
|
|
2947
2954
|
}).passthrough();
|
|
2948
2955
|
var xaiVideoModelOptionsSchema = (0, import_provider_utils15.lazySchema)(
|
|
@@ -3166,6 +3173,9 @@ var XaiVideoModel = class {
|
|
|
3166
3173
|
details: "xAI only supports inputReferences for reference-to-video generation. The reference images were ignored."
|
|
3167
3174
|
});
|
|
3168
3175
|
}
|
|
3176
|
+
if (!isExtension && (xaiOptions == null ? void 0 : xaiOptions.user) !== void 0) {
|
|
3177
|
+
body.user = xaiOptions.user;
|
|
3178
|
+
}
|
|
3169
3179
|
if (xaiOptions != null) {
|
|
3170
3180
|
for (const [key, value] of Object.entries(xaiOptions)) {
|
|
3171
3181
|
if (![
|
|
@@ -3174,7 +3184,8 @@ var XaiVideoModel = class {
|
|
|
3174
3184
|
"pollTimeoutMs",
|
|
3175
3185
|
"resolution",
|
|
3176
3186
|
"videoUrl",
|
|
3177
|
-
"referenceImageUrls"
|
|
3187
|
+
"referenceImageUrls",
|
|
3188
|
+
"user"
|
|
3178
3189
|
].includes(key)) {
|
|
3179
3190
|
body[key] = value;
|
|
3180
3191
|
}
|
|
@@ -3222,9 +3233,7 @@ var XaiVideoModel = class {
|
|
|
3222
3233
|
const { value: statusResponse, responseHeaders: pollHeaders } = await (0, import_provider_utils16.getFromApi)({
|
|
3223
3234
|
url: `${baseURL}/videos/${requestId}`,
|
|
3224
3235
|
headers: (0, import_provider_utils16.combineHeaders)(this.config.headers(), options.headers),
|
|
3225
|
-
successfulResponseHandler:
|
|
3226
|
-
xaiVideoStatusResponseSchema
|
|
3227
|
-
),
|
|
3236
|
+
successfulResponseHandler: xaiVideoStatusResponseHandler,
|
|
3228
3237
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
3229
3238
|
abortSignal: options.abortSignal,
|
|
3230
3239
|
fetch: this.config.fetch
|
|
@@ -3303,6 +3312,20 @@ var xaiVideoStatusResponseSchema = import_v417.z.object({
|
|
|
3303
3312
|
message: import_v417.z.string().nullish()
|
|
3304
3313
|
}).nullish()
|
|
3305
3314
|
});
|
|
3315
|
+
var xaiVideoStatusJsonResponseHandler = (0, import_provider_utils16.createJsonResponseHandler)(
|
|
3316
|
+
xaiVideoStatusResponseSchema
|
|
3317
|
+
);
|
|
3318
|
+
var xaiVideoStatusResponseHandler = async (options) => {
|
|
3319
|
+
if (options.response.status === 202) {
|
|
3320
|
+
const responseHeaders = (0, import_provider_utils16.extractResponseHeaders)(options.response);
|
|
3321
|
+
await (0, import_provider_utils16.cancelResponseBody)(options.response);
|
|
3322
|
+
return {
|
|
3323
|
+
responseHeaders,
|
|
3324
|
+
value: { status: "pending" }
|
|
3325
|
+
};
|
|
3326
|
+
}
|
|
3327
|
+
return xaiVideoStatusJsonResponseHandler(options);
|
|
3328
|
+
};
|
|
3306
3329
|
|
|
3307
3330
|
// src/xai-provider.ts
|
|
3308
3331
|
function createXai(options = {}) {
|