@ai-sdk/xai 3.0.52 → 3.0.54
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 +14 -0
- package/dist/index.d.mts +12 -12
- package/dist/index.d.ts +12 -12
- package/dist/index.js +42 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -14
- package/dist/index.mjs.map +1 -1
- package/docs/01-xai.mdx +29 -14
- package/package.json +2 -2
- package/src/index.ts +15 -3
- package/src/responses/xai-responses-api.ts +13 -0
- package/src/responses/xai-responses-language-model.ts +36 -10
- package/src/responses/xai-responses-options.ts +3 -3
- package/src/xai-chat-language-model.ts +5 -2
- package/src/xai-chat-options.ts +4 -2
- package/src/xai-image-model.ts +2 -2
- package/src/xai-image-options.ts +2 -2
package/dist/index.mjs
CHANGED
|
@@ -228,7 +228,7 @@ var searchSourceSchema = z.discriminatedUnion("type", [
|
|
|
228
228
|
newsSourceSchema,
|
|
229
229
|
rssSourceSchema
|
|
230
230
|
]);
|
|
231
|
-
var
|
|
231
|
+
var xaiLanguageModelChatOptions = z.object({
|
|
232
232
|
reasoningEffort: z.enum(["low", "high"]).optional(),
|
|
233
233
|
/**
|
|
234
234
|
* Whether to enable parallel function calling during tool use.
|
|
@@ -382,7 +382,7 @@ var XaiChatLanguageModel = class {
|
|
|
382
382
|
const options = (_a = await parseProviderOptions({
|
|
383
383
|
provider: "xai",
|
|
384
384
|
providerOptions,
|
|
385
|
-
schema:
|
|
385
|
+
schema: xaiLanguageModelChatOptions
|
|
386
386
|
})) != null ? _a : {};
|
|
387
387
|
if (topK != null) {
|
|
388
388
|
warnings.push({ type: "unsupported", feature: "topK" });
|
|
@@ -878,7 +878,7 @@ import { z as z5 } from "zod/v4";
|
|
|
878
878
|
|
|
879
879
|
// src/xai-image-options.ts
|
|
880
880
|
import { z as z4 } from "zod/v4";
|
|
881
|
-
var
|
|
881
|
+
var xaiImageModelOptions = z4.object({
|
|
882
882
|
aspect_ratio: z4.string().optional(),
|
|
883
883
|
output_format: z4.string().optional(),
|
|
884
884
|
sync_mode: z4.boolean().optional()
|
|
@@ -931,7 +931,7 @@ var XaiImageModel = class {
|
|
|
931
931
|
const xaiOptions = await parseProviderOptions2({
|
|
932
932
|
provider: "xai",
|
|
933
933
|
providerOptions,
|
|
934
|
-
schema:
|
|
934
|
+
schema: xaiImageModelOptions
|
|
935
935
|
});
|
|
936
936
|
const hasFiles = files != null && files.length > 0;
|
|
937
937
|
let imageUrl;
|
|
@@ -1559,6 +1559,19 @@ var xaiResponsesChunkSchema = z6.union([
|
|
|
1559
1559
|
output_index: z6.number(),
|
|
1560
1560
|
input: z6.string()
|
|
1561
1561
|
}),
|
|
1562
|
+
// Function call arguments streaming events (standard function tools)
|
|
1563
|
+
z6.object({
|
|
1564
|
+
type: z6.literal("response.function_call_arguments.delta"),
|
|
1565
|
+
item_id: z6.string(),
|
|
1566
|
+
output_index: z6.number(),
|
|
1567
|
+
delta: z6.string()
|
|
1568
|
+
}),
|
|
1569
|
+
z6.object({
|
|
1570
|
+
type: z6.literal("response.function_call_arguments.done"),
|
|
1571
|
+
item_id: z6.string(),
|
|
1572
|
+
output_index: z6.number(),
|
|
1573
|
+
arguments: z6.string()
|
|
1574
|
+
}),
|
|
1562
1575
|
z6.object({
|
|
1563
1576
|
type: z6.literal("response.mcp_call.in_progress"),
|
|
1564
1577
|
item_id: z6.string(),
|
|
@@ -1615,7 +1628,7 @@ var xaiResponsesChunkSchema = z6.union([
|
|
|
1615
1628
|
|
|
1616
1629
|
// src/responses/xai-responses-options.ts
|
|
1617
1630
|
import { z as z7 } from "zod/v4";
|
|
1618
|
-
var
|
|
1631
|
+
var xaiLanguageModelResponsesOptions = z7.object({
|
|
1619
1632
|
/**
|
|
1620
1633
|
* Constrains how hard a reasoning model thinks before responding.
|
|
1621
1634
|
* Possible values are `low` (uses fewer reasoning tokens), `medium` and `high` (uses more reasoning tokens).
|
|
@@ -1972,7 +1985,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1972
1985
|
const options = (_a = await parseProviderOptions3({
|
|
1973
1986
|
provider: "xai",
|
|
1974
1987
|
providerOptions,
|
|
1975
|
-
schema:
|
|
1988
|
+
schema: xaiLanguageModelResponsesOptions
|
|
1976
1989
|
})) != null ? _a : {};
|
|
1977
1990
|
if (stopSequences != null) {
|
|
1978
1991
|
warnings.push({ type: "unsupported", feature: "stopSequences" });
|
|
@@ -2264,6 +2277,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2264
2277
|
let isFirstChunk = true;
|
|
2265
2278
|
const contentBlocks = {};
|
|
2266
2279
|
const seenToolCalls = /* @__PURE__ */ new Set();
|
|
2280
|
+
const ongoingToolCalls = {};
|
|
2267
2281
|
const activeReasoning = {};
|
|
2268
2282
|
const self = this;
|
|
2269
2283
|
return {
|
|
@@ -2412,6 +2426,20 @@ var XaiResponsesLanguageModel = class {
|
|
|
2412
2426
|
if (event.type === "response.custom_tool_call_input.delta" || event.type === "response.custom_tool_call_input.done") {
|
|
2413
2427
|
return;
|
|
2414
2428
|
}
|
|
2429
|
+
if (event.type === "response.function_call_arguments.delta") {
|
|
2430
|
+
const toolCall = ongoingToolCalls[event.output_index];
|
|
2431
|
+
if (toolCall != null) {
|
|
2432
|
+
controller.enqueue({
|
|
2433
|
+
type: "tool-input-delta",
|
|
2434
|
+
id: toolCall.toolCallId,
|
|
2435
|
+
delta: event.delta
|
|
2436
|
+
});
|
|
2437
|
+
}
|
|
2438
|
+
return;
|
|
2439
|
+
}
|
|
2440
|
+
if (event.type === "response.function_call_arguments.done") {
|
|
2441
|
+
return;
|
|
2442
|
+
}
|
|
2415
2443
|
if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
|
|
2416
2444
|
const part = event.item;
|
|
2417
2445
|
if (part.type === "reasoning") {
|
|
@@ -2571,18 +2599,18 @@ var XaiResponsesLanguageModel = class {
|
|
|
2571
2599
|
}
|
|
2572
2600
|
}
|
|
2573
2601
|
} else if (part.type === "function_call") {
|
|
2574
|
-
if (
|
|
2575
|
-
|
|
2602
|
+
if (event.type === "response.output_item.added") {
|
|
2603
|
+
ongoingToolCalls[event.output_index] = {
|
|
2604
|
+
toolName: part.name,
|
|
2605
|
+
toolCallId: part.call_id
|
|
2606
|
+
};
|
|
2576
2607
|
controller.enqueue({
|
|
2577
2608
|
type: "tool-input-start",
|
|
2578
2609
|
id: part.call_id,
|
|
2579
2610
|
toolName: part.name
|
|
2580
2611
|
});
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
id: part.call_id,
|
|
2584
|
-
delta: part.arguments
|
|
2585
|
-
});
|
|
2612
|
+
} else if (event.type === "response.output_item.done") {
|
|
2613
|
+
ongoingToolCalls[event.output_index] = void 0;
|
|
2586
2614
|
controller.enqueue({
|
|
2587
2615
|
type: "tool-input-end",
|
|
2588
2616
|
id: part.call_id
|
|
@@ -2683,7 +2711,7 @@ var xaiTools = {
|
|
|
2683
2711
|
};
|
|
2684
2712
|
|
|
2685
2713
|
// src/version.ts
|
|
2686
|
-
var VERSION = true ? "3.0.
|
|
2714
|
+
var VERSION = true ? "3.0.54" : "0.0.0-test";
|
|
2687
2715
|
|
|
2688
2716
|
// src/xai-provider.ts
|
|
2689
2717
|
function createXai(options = {}) {
|