@ai-sdk/xai 3.0.126 → 3.0.128

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/xai",
3
- "version": "3.0.126",
3
+ "version": "3.0.128",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -29,9 +29,9 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@ai-sdk/openai-compatible": "2.0.72",
33
- "@ai-sdk/provider": "3.0.15",
34
- "@ai-sdk/provider-utils": "4.0.48"
32
+ "@ai-sdk/openai-compatible": "2.0.73",
33
+ "@ai-sdk/provider-utils": "4.0.49",
34
+ "@ai-sdk/provider": "3.0.15"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "20.17.24",
@@ -248,23 +248,27 @@ const outputItemSchema = z.discriminatedUnion('type', [
248
248
  }),
249
249
  ]);
250
250
 
251
- export const xaiResponsesUsageSchema = z.object({
252
- input_tokens: z.number(),
253
- output_tokens: z.number(),
254
- total_tokens: z.number().optional(),
255
- input_tokens_details: z
256
- .object({
257
- cached_tokens: z.number().optional(),
258
- })
259
- .optional(),
260
- output_tokens_details: z
261
- .object({
262
- reasoning_tokens: z.number().optional(),
263
- })
264
- .optional(),
265
- num_sources_used: z.number().optional(),
266
- num_server_side_tools_used: z.number().optional(),
267
- });
251
+ export const xaiResponsesUsageSchema = z
252
+ .object({
253
+ input_tokens: z.number(),
254
+ output_tokens: z.number(),
255
+ total_tokens: z.number().optional(),
256
+ input_tokens_details: z
257
+ .object({
258
+ cached_tokens: z.number().optional(),
259
+ })
260
+ .catchall(z.json())
261
+ .optional(),
262
+ output_tokens_details: z
263
+ .object({
264
+ reasoning_tokens: z.number().optional(),
265
+ })
266
+ .catchall(z.json())
267
+ .optional(),
268
+ num_sources_used: z.number().optional(),
269
+ num_server_side_tools_used: z.number().optional(),
270
+ })
271
+ .catchall(z.json());
268
272
 
269
273
  export const xaiResponsesResponseSchema = z.object({
270
274
  id: z.string().nullish(),
@@ -626,31 +626,36 @@ export class XaiChatLanguageModel implements LanguageModelV3 {
626
626
  }
627
627
 
628
628
  // XAI API Response Schemas
629
- const xaiUsageSchema = z.object({
630
- prompt_tokens: z.number(),
631
- completion_tokens: z.number(),
632
- total_tokens: z.number(),
633
- prompt_tokens_details: z
634
- .object({
635
- text_tokens: z.number().nullish(),
636
- audio_tokens: z.number().nullish(),
637
- image_tokens: z.number().nullish(),
638
- cached_tokens: z.number().nullish(),
639
- })
640
- .nullish(),
641
- completion_tokens_details: z
642
- .object({
643
- reasoning_tokens: z.number().nullish(),
644
- audio_tokens: z.number().nullish(),
645
- accepted_prediction_tokens: z.number().nullish(),
646
- rejected_prediction_tokens: z.number().nullish(),
647
- })
648
- .nullish(),
649
- });
629
+ const xaiUsageSchema = z
630
+ .object({
631
+ prompt_tokens: z.number(),
632
+ completion_tokens: z.number(),
633
+ total_tokens: z.number(),
634
+ cost_in_usd_ticks: z.number().nullish(),
635
+ prompt_tokens_details: z
636
+ .object({
637
+ text_tokens: z.number().nullish(),
638
+ audio_tokens: z.number().nullish(),
639
+ image_tokens: z.number().nullish(),
640
+ cached_tokens: z.number().nullish(),
641
+ })
642
+ .catchall(z.json())
643
+ .nullish(),
644
+ completion_tokens_details: z
645
+ .object({
646
+ reasoning_tokens: z.number().nullish(),
647
+ audio_tokens: z.number().nullish(),
648
+ accepted_prediction_tokens: z.number().nullish(),
649
+ rejected_prediction_tokens: z.number().nullish(),
650
+ })
651
+ .catchall(z.json())
652
+ .nullish(),
653
+ })
654
+ .catchall(z.json());
650
655
 
651
656
  export type XaiChatUsage = z.infer<typeof xaiUsageSchema>;
652
657
 
653
- const xaiChatResponseSchema = z.object({
658
+ export const xaiChatResponseSchema = z.object({
654
659
  id: z.string().nullish(),
655
660
  created: z.number().nullish(),
656
661
  model: z.string().nullish(),