@ai-sdk/xai 3.0.89 → 3.0.91
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 +13 -0
- package/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +44 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/remove-additional-properties.ts +24 -0
- package/src/responses/xai-responses-language-model.ts +11 -9
- package/src/responses/xai-responses-prepare-tools.ts +2 -1
- package/src/xai-error.ts +13 -3
- package/src/xai-prepare-tools.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 3.0.91
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 71c43dc: fix reasoning-start dedupe on multi-summary-part responses to prevent xai 400 on continuation requests
|
|
8
|
+
- 0e8ea74: surface full xai error detail in APICallError.message instead of falling back to http status text
|
|
9
|
+
|
|
10
|
+
## 3.0.90
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 1822d0c: fix(xai): stop emitting additionalProperties flag
|
|
15
|
+
|
|
3
16
|
## 3.0.89
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -48,14 +48,17 @@ declare const xaiLanguageModelChatOptions: z.ZodObject<{
|
|
|
48
48
|
}, z.core.$strip>;
|
|
49
49
|
type XaiLanguageModelChatOptions = z.infer<typeof xaiLanguageModelChatOptions>;
|
|
50
50
|
|
|
51
|
-
declare const xaiErrorDataSchema: z.ZodObject<{
|
|
51
|
+
declare const xaiErrorDataSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
52
52
|
error: z.ZodObject<{
|
|
53
53
|
message: z.ZodString;
|
|
54
54
|
type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
55
55
|
param: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
|
|
56
56
|
code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
57
57
|
}, z.core.$strip>;
|
|
58
|
-
}, z.core.$strip
|
|
58
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
59
|
+
code: z.ZodString;
|
|
60
|
+
error: z.ZodString;
|
|
61
|
+
}, z.core.$strip>]>;
|
|
59
62
|
type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
|
|
60
63
|
|
|
61
64
|
type XaiResponsesModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-0309-reasoning' | 'grok-4.20-multi-agent-0309' | (string & {});
|
package/dist/index.d.ts
CHANGED
|
@@ -48,14 +48,17 @@ declare const xaiLanguageModelChatOptions: z.ZodObject<{
|
|
|
48
48
|
}, z.core.$strip>;
|
|
49
49
|
type XaiLanguageModelChatOptions = z.infer<typeof xaiLanguageModelChatOptions>;
|
|
50
50
|
|
|
51
|
-
declare const xaiErrorDataSchema: z.ZodObject<{
|
|
51
|
+
declare const xaiErrorDataSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
52
52
|
error: z.ZodObject<{
|
|
53
53
|
message: z.ZodString;
|
|
54
54
|
type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
55
55
|
param: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
|
|
56
56
|
code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
57
57
|
}, z.core.$strip>;
|
|
58
|
-
}, z.core.$strip
|
|
58
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
59
|
+
code: z.ZodString;
|
|
60
|
+
error: z.ZodString;
|
|
61
|
+
}, z.core.$strip>]>;
|
|
59
62
|
type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
|
|
60
63
|
|
|
61
64
|
type XaiResponsesModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-0309-reasoning' | 'grok-4.20-multi-agent-0309' | (string & {});
|
package/dist/index.js
CHANGED
|
@@ -296,7 +296,7 @@ var xaiLanguageModelChatOptions = import_v4.z.object({
|
|
|
296
296
|
// src/xai-error.ts
|
|
297
297
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
298
298
|
var import_v42 = require("zod/v4");
|
|
299
|
-
var
|
|
299
|
+
var chatCompletionsErrorSchema = import_v42.z.object({
|
|
300
300
|
error: import_v42.z.object({
|
|
301
301
|
message: import_v42.z.string(),
|
|
302
302
|
type: import_v42.z.string().nullish(),
|
|
@@ -304,13 +304,41 @@ var xaiErrorDataSchema = import_v42.z.object({
|
|
|
304
304
|
code: import_v42.z.union([import_v42.z.string(), import_v42.z.number()]).nullish()
|
|
305
305
|
})
|
|
306
306
|
});
|
|
307
|
+
var responsesErrorSchema = import_v42.z.object({
|
|
308
|
+
code: import_v42.z.string(),
|
|
309
|
+
error: import_v42.z.string()
|
|
310
|
+
});
|
|
311
|
+
var xaiErrorDataSchema = import_v42.z.union([
|
|
312
|
+
chatCompletionsErrorSchema,
|
|
313
|
+
responsesErrorSchema
|
|
314
|
+
]);
|
|
307
315
|
var xaiFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResponseHandler)({
|
|
308
316
|
errorSchema: xaiErrorDataSchema,
|
|
309
|
-
errorToMessage: (data) => data.error.message
|
|
317
|
+
errorToMessage: (data) => "code" in data ? `${data.code}: ${data.error}` : data.error.message
|
|
310
318
|
});
|
|
311
319
|
|
|
312
320
|
// src/xai-prepare-tools.ts
|
|
313
321
|
var import_provider2 = require("@ai-sdk/provider");
|
|
322
|
+
|
|
323
|
+
// src/remove-additional-properties.ts
|
|
324
|
+
function removeAdditionalPropertiesFalse(value) {
|
|
325
|
+
if (Array.isArray(value)) {
|
|
326
|
+
return value.map(removeAdditionalPropertiesFalse);
|
|
327
|
+
}
|
|
328
|
+
if (value == null || typeof value !== "object") {
|
|
329
|
+
return value;
|
|
330
|
+
}
|
|
331
|
+
const result = {};
|
|
332
|
+
for (const [key, propertyValue] of Object.entries(value)) {
|
|
333
|
+
if (key === "additionalProperties" && propertyValue === false) {
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
result[key] = removeAdditionalPropertiesFalse(propertyValue);
|
|
337
|
+
}
|
|
338
|
+
return result;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// src/xai-prepare-tools.ts
|
|
314
342
|
function prepareTools({
|
|
315
343
|
tools,
|
|
316
344
|
toolChoice
|
|
@@ -333,7 +361,7 @@ function prepareTools({
|
|
|
333
361
|
function: {
|
|
334
362
|
name: tool.name,
|
|
335
363
|
description: tool.description,
|
|
336
|
-
parameters: tool.inputSchema,
|
|
364
|
+
parameters: removeAdditionalPropertiesFalse(tool.inputSchema),
|
|
337
365
|
...tool.strict != null ? { strict: tool.strict } : {}
|
|
338
366
|
}
|
|
339
367
|
});
|
|
@@ -1970,7 +1998,7 @@ async function prepareResponsesTools({
|
|
|
1970
1998
|
type: "function",
|
|
1971
1999
|
name: tool.name,
|
|
1972
2000
|
description: tool.description,
|
|
1973
|
-
parameters: tool.inputSchema,
|
|
2001
|
+
parameters: removeAdditionalPropertiesFalse(tool.inputSchema),
|
|
1974
2002
|
...tool.strict != null ? { strict: tool.strict } : {}
|
|
1975
2003
|
});
|
|
1976
2004
|
}
|
|
@@ -2375,16 +2403,18 @@ var XaiResponsesLanguageModel = class {
|
|
|
2375
2403
|
}
|
|
2376
2404
|
if (event.type === "response.reasoning_summary_part.added") {
|
|
2377
2405
|
const blockId = `reasoning-${event.item_id}`;
|
|
2378
|
-
activeReasoning[event.item_id]
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2406
|
+
if (activeReasoning[event.item_id] == null) {
|
|
2407
|
+
activeReasoning[event.item_id] = {};
|
|
2408
|
+
controller.enqueue({
|
|
2409
|
+
type: "reasoning-start",
|
|
2410
|
+
id: blockId,
|
|
2411
|
+
providerMetadata: {
|
|
2412
|
+
xai: {
|
|
2413
|
+
itemId: event.item_id
|
|
2414
|
+
}
|
|
2385
2415
|
}
|
|
2386
|
-
}
|
|
2387
|
-
}
|
|
2416
|
+
});
|
|
2417
|
+
}
|
|
2388
2418
|
}
|
|
2389
2419
|
if (event.type === "response.reasoning_summary_text.delta") {
|
|
2390
2420
|
const blockId = `reasoning-${event.item_id}`;
|
|
@@ -2800,7 +2830,7 @@ var xaiTools = {
|
|
|
2800
2830
|
};
|
|
2801
2831
|
|
|
2802
2832
|
// src/version.ts
|
|
2803
|
-
var VERSION = true ? "3.0.
|
|
2833
|
+
var VERSION = true ? "3.0.91" : "0.0.0-test";
|
|
2804
2834
|
|
|
2805
2835
|
// src/xai-video-model.ts
|
|
2806
2836
|
var import_provider6 = require("@ai-sdk/provider");
|