@ai-sdk/xai 3.0.90 → 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/dist/index.mjs CHANGED
@@ -280,7 +280,7 @@ var xaiLanguageModelChatOptions = z.object({
280
280
  // src/xai-error.ts
281
281
  import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
282
282
  import { z as z2 } from "zod/v4";
283
- var xaiErrorDataSchema = z2.object({
283
+ var chatCompletionsErrorSchema = z2.object({
284
284
  error: z2.object({
285
285
  message: z2.string(),
286
286
  type: z2.string().nullish(),
@@ -288,9 +288,17 @@ var xaiErrorDataSchema = z2.object({
288
288
  code: z2.union([z2.string(), z2.number()]).nullish()
289
289
  })
290
290
  });
291
+ var responsesErrorSchema = z2.object({
292
+ code: z2.string(),
293
+ error: z2.string()
294
+ });
295
+ var xaiErrorDataSchema = z2.union([
296
+ chatCompletionsErrorSchema,
297
+ responsesErrorSchema
298
+ ]);
291
299
  var xaiFailedResponseHandler = createJsonErrorResponseHandler({
292
300
  errorSchema: xaiErrorDataSchema,
293
- errorToMessage: (data) => data.error.message
301
+ errorToMessage: (data) => "code" in data ? `${data.code}: ${data.error}` : data.error.message
294
302
  });
295
303
 
296
304
  // src/xai-prepare-tools.ts
@@ -2416,16 +2424,18 @@ var XaiResponsesLanguageModel = class {
2416
2424
  }
2417
2425
  if (event.type === "response.reasoning_summary_part.added") {
2418
2426
  const blockId = `reasoning-${event.item_id}`;
2419
- activeReasoning[event.item_id] = {};
2420
- controller.enqueue({
2421
- type: "reasoning-start",
2422
- id: blockId,
2423
- providerMetadata: {
2424
- xai: {
2425
- itemId: event.item_id
2427
+ if (activeReasoning[event.item_id] == null) {
2428
+ activeReasoning[event.item_id] = {};
2429
+ controller.enqueue({
2430
+ type: "reasoning-start",
2431
+ id: blockId,
2432
+ providerMetadata: {
2433
+ xai: {
2434
+ itemId: event.item_id
2435
+ }
2426
2436
  }
2427
- }
2428
- });
2437
+ });
2438
+ }
2429
2439
  }
2430
2440
  if (event.type === "response.reasoning_summary_text.delta") {
2431
2441
  const blockId = `reasoning-${event.item_id}`;
@@ -2841,7 +2851,7 @@ var xaiTools = {
2841
2851
  };
2842
2852
 
2843
2853
  // src/version.ts
2844
- var VERSION = true ? "3.0.90" : "0.0.0-test";
2854
+ var VERSION = true ? "3.0.91" : "0.0.0-test";
2845
2855
 
2846
2856
  // src/xai-video-model.ts
2847
2857
  import {