@ai-sdk/xai 3.0.90 → 3.0.92

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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @ai-sdk/xai
2
2
 
3
+ ## 3.0.92
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [e40e1d4]
8
+ - @ai-sdk/openai-compatible@2.0.48
9
+
10
+ ## 3.0.91
11
+
12
+ ### Patch Changes
13
+
14
+ - 71c43dc: fix reasoning-start dedupe on multi-summary-part responses to prevent xai 400 on continuation requests
15
+ - 0e8ea74: surface full xai error detail in APICallError.message instead of falling back to http status text
16
+
3
17
  ## 3.0.90
4
18
 
5
19
  ### 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 xaiErrorDataSchema = import_v42.z.object({
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,9 +304,17 @@ 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
@@ -2395,16 +2403,18 @@ var XaiResponsesLanguageModel = class {
2395
2403
  }
2396
2404
  if (event.type === "response.reasoning_summary_part.added") {
2397
2405
  const blockId = `reasoning-${event.item_id}`;
2398
- activeReasoning[event.item_id] = {};
2399
- controller.enqueue({
2400
- type: "reasoning-start",
2401
- id: blockId,
2402
- providerMetadata: {
2403
- xai: {
2404
- itemId: event.item_id
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
+ }
2405
2415
  }
2406
- }
2407
- });
2416
+ });
2417
+ }
2408
2418
  }
2409
2419
  if (event.type === "response.reasoning_summary_text.delta") {
2410
2420
  const blockId = `reasoning-${event.item_id}`;
@@ -2820,7 +2830,7 @@ var xaiTools = {
2820
2830
  };
2821
2831
 
2822
2832
  // src/version.ts
2823
- var VERSION = true ? "3.0.90" : "0.0.0-test";
2833
+ var VERSION = true ? "3.0.92" : "0.0.0-test";
2824
2834
 
2825
2835
  // src/xai-video-model.ts
2826
2836
  var import_provider6 = require("@ai-sdk/provider");