@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/CHANGELOG.md +15 -0
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/responses/xai-responses-api.ts +21 -17
- package/src/xai-chat-language-model.ts +27 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/xai",
|
|
3
|
-
"version": "3.0.
|
|
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.
|
|
33
|
-
"@ai-sdk/provider": "
|
|
34
|
-
"@ai-sdk/provider
|
|
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
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
.
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
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(),
|