@ai-sdk/xai 2.0.72 → 2.0.73

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,12 @@
1
1
  # @ai-sdk/xai
2
2
 
3
+ ## 2.0.73
4
+
5
+ ### Patch Changes
6
+
7
+ - b3c2af5: fix reasoning-start dedupe on multi-summary-part responses to prevent xai 400 on continuation requests
8
+ - a455654: surface full xai error detail in APICallError.message instead of falling back to http status text
9
+
3
10
  ## 2.0.72
4
11
 
5
12
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -46,14 +46,17 @@ declare const xaiProviderOptions: z.ZodObject<{
46
46
  }, z.core.$strip>;
47
47
  type XaiProviderOptions = z.infer<typeof xaiProviderOptions>;
48
48
 
49
- declare const xaiErrorDataSchema: z.ZodObject<{
49
+ declare const xaiErrorDataSchema: z.ZodUnion<readonly [z.ZodObject<{
50
50
  error: z.ZodObject<{
51
51
  message: z.ZodString;
52
52
  type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
53
53
  param: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
54
54
  code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
55
55
  }, z.core.$strip>;
56
- }, z.core.$strip>;
56
+ }, z.core.$strip>, z.ZodObject<{
57
+ code: z.ZodString;
58
+ error: z.ZodString;
59
+ }, z.core.$strip>]>;
57
60
  type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
58
61
 
59
62
  type XaiResponsesModelId = 'grok-4-1' | 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | 'grok-4-fast' | '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
@@ -46,14 +46,17 @@ declare const xaiProviderOptions: z.ZodObject<{
46
46
  }, z.core.$strip>;
47
47
  type XaiProviderOptions = z.infer<typeof xaiProviderOptions>;
48
48
 
49
- declare const xaiErrorDataSchema: z.ZodObject<{
49
+ declare const xaiErrorDataSchema: z.ZodUnion<readonly [z.ZodObject<{
50
50
  error: z.ZodObject<{
51
51
  message: z.ZodString;
52
52
  type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
53
53
  param: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
54
54
  code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
55
55
  }, z.core.$strip>;
56
- }, z.core.$strip>;
56
+ }, z.core.$strip>, z.ZodObject<{
57
+ code: z.ZodString;
58
+ error: z.ZodString;
59
+ }, z.core.$strip>]>;
57
60
  type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
58
61
 
59
62
  type XaiResponsesModelId = 'grok-4-1' | 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | 'grok-4-fast' | '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
@@ -289,7 +289,7 @@ var xaiProviderOptions = import_v4.z.object({
289
289
  // src/xai-error.ts
290
290
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
291
291
  var import_v42 = require("zod/v4");
292
- var xaiErrorDataSchema = import_v42.z.object({
292
+ var chatCompletionsErrorSchema = import_v42.z.object({
293
293
  error: import_v42.z.object({
294
294
  message: import_v42.z.string(),
295
295
  type: import_v42.z.string().nullish(),
@@ -297,9 +297,17 @@ var xaiErrorDataSchema = import_v42.z.object({
297
297
  code: import_v42.z.union([import_v42.z.string(), import_v42.z.number()]).nullish()
298
298
  })
299
299
  });
300
+ var responsesErrorSchema = import_v42.z.object({
301
+ code: import_v42.z.string(),
302
+ error: import_v42.z.string()
303
+ });
304
+ var xaiErrorDataSchema = import_v42.z.union([
305
+ chatCompletionsErrorSchema,
306
+ responsesErrorSchema
307
+ ]);
300
308
  var xaiFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResponseHandler)({
301
309
  errorSchema: xaiErrorDataSchema,
302
- errorToMessage: (data) => data.error.message
310
+ errorToMessage: (data) => "code" in data ? `${data.code}: ${data.error}` : data.error.message
303
311
  });
304
312
 
305
313
  // src/xai-prepare-tools.ts
@@ -1992,15 +2000,18 @@ var XaiResponsesLanguageModel = class {
1992
2000
  }
1993
2001
  if (event.type === "response.reasoning_summary_part.added") {
1994
2002
  const blockId = `reasoning-${event.item_id}`;
1995
- controller.enqueue({
1996
- type: "reasoning-start",
1997
- id: blockId,
1998
- providerMetadata: {
1999
- xai: {
2000
- itemId: event.item_id
2003
+ if (activeReasoning[event.item_id] == null) {
2004
+ activeReasoning[event.item_id] = {};
2005
+ controller.enqueue({
2006
+ type: "reasoning-start",
2007
+ id: blockId,
2008
+ providerMetadata: {
2009
+ xai: {
2010
+ itemId: event.item_id
2011
+ }
2001
2012
  }
2002
- }
2003
- });
2013
+ });
2014
+ }
2004
2015
  }
2005
2016
  if (event.type === "response.reasoning_summary_text.delta") {
2006
2017
  const blockId = `reasoning-${event.item_id}`;
@@ -2357,12 +2368,12 @@ var xaiTools = {
2357
2368
  };
2358
2369
 
2359
2370
  // src/version.ts
2360
- var VERSION = true ? "2.0.72" : "0.0.0-test";
2371
+ var VERSION = true ? "2.0.73" : "0.0.0-test";
2361
2372
 
2362
2373
  // src/xai-provider.ts
2363
2374
  var xaiErrorStructure = {
2364
2375
  errorSchema: xaiErrorDataSchema,
2365
- errorToMessage: (data) => data.error.message
2376
+ errorToMessage: (data) => "code" in data ? `${data.code}: ${data.error}` : data.error.message
2366
2377
  };
2367
2378
  function createXai(options = {}) {
2368
2379
  var _a;