@ai-sdk/xai 3.0.0-beta.40 → 3.0.0-beta.41
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 +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +90 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -57,11 +57,17 @@ declare const xaiErrorDataSchema: z.ZodObject<{
|
|
|
57
57
|
type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
|
|
58
58
|
|
|
59
59
|
type XaiResponsesModelId = 'grok-4' | 'grok-4-fast' | 'grok-4-fast-non-reasoning' | (string & {});
|
|
60
|
+
/**
|
|
61
|
+
* @see https://docs.x.ai/docs/api-reference#create-new-response
|
|
62
|
+
*/
|
|
60
63
|
declare const xaiResponsesProviderOptions: z.ZodObject<{
|
|
61
64
|
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
62
65
|
low: "low";
|
|
63
66
|
high: "high";
|
|
67
|
+
medium: "medium";
|
|
64
68
|
}>>;
|
|
69
|
+
store: z.ZodOptional<z.ZodBoolean>;
|
|
70
|
+
previousResponseId: z.ZodOptional<z.ZodString>;
|
|
65
71
|
}, z.core.$strip>;
|
|
66
72
|
type XaiResponsesProviderOptions = z.infer<typeof xaiResponsesProviderOptions>;
|
|
67
73
|
|
package/dist/index.d.ts
CHANGED
|
@@ -57,11 +57,17 @@ declare const xaiErrorDataSchema: z.ZodObject<{
|
|
|
57
57
|
type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
|
|
58
58
|
|
|
59
59
|
type XaiResponsesModelId = 'grok-4' | 'grok-4-fast' | 'grok-4-fast-non-reasoning' | (string & {});
|
|
60
|
+
/**
|
|
61
|
+
* @see https://docs.x.ai/docs/api-reference#create-new-response
|
|
62
|
+
*/
|
|
60
63
|
declare const xaiResponsesProviderOptions: z.ZodObject<{
|
|
61
64
|
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
62
65
|
low: "low";
|
|
63
66
|
high: "high";
|
|
67
|
+
medium: "medium";
|
|
64
68
|
}>>;
|
|
69
|
+
store: z.ZodOptional<z.ZodBoolean>;
|
|
70
|
+
previousResponseId: z.ZodOptional<z.ZodString>;
|
|
65
71
|
}, z.core.$strip>;
|
|
66
72
|
type XaiResponsesProviderOptions = z.infer<typeof xaiResponsesProviderOptions>;
|
|
67
73
|
|
package/dist/index.js
CHANGED
|
@@ -154,12 +154,14 @@ function convertToXaiChatMessages(prompt) {
|
|
|
154
154
|
function getResponseMetadata({
|
|
155
155
|
id,
|
|
156
156
|
model,
|
|
157
|
-
created
|
|
157
|
+
created,
|
|
158
|
+
created_at
|
|
158
159
|
}) {
|
|
160
|
+
const unixTime = created != null ? created : created_at;
|
|
159
161
|
return {
|
|
160
162
|
id: id != null ? id : void 0,
|
|
161
163
|
modelId: model != null ? model : void 0,
|
|
162
|
-
timestamp:
|
|
164
|
+
timestamp: unixTime != null ? new Date(unixTime * 1e3) : void 0
|
|
163
165
|
};
|
|
164
166
|
}
|
|
165
167
|
|
|
@@ -797,6 +799,10 @@ var messageContentPartSchema = import_v44.z.object({
|
|
|
797
799
|
logprobs: import_v44.z.array(import_v44.z.any()).optional(),
|
|
798
800
|
annotations: import_v44.z.array(annotationSchema).optional()
|
|
799
801
|
});
|
|
802
|
+
var reasoningSummaryPartSchema = import_v44.z.object({
|
|
803
|
+
type: import_v44.z.string(),
|
|
804
|
+
text: import_v44.z.string()
|
|
805
|
+
});
|
|
800
806
|
var toolCallSchema = import_v44.z.object({
|
|
801
807
|
name: import_v44.z.string(),
|
|
802
808
|
arguments: import_v44.z.string(),
|
|
@@ -842,6 +848,12 @@ var outputItemSchema = import_v44.z.discriminatedUnion("type", [
|
|
|
842
848
|
arguments: import_v44.z.string(),
|
|
843
849
|
call_id: import_v44.z.string(),
|
|
844
850
|
id: import_v44.z.string()
|
|
851
|
+
}),
|
|
852
|
+
import_v44.z.object({
|
|
853
|
+
type: import_v44.z.literal("reasoning"),
|
|
854
|
+
id: import_v44.z.string(),
|
|
855
|
+
summary: import_v44.z.array(reasoningSummaryPartSchema),
|
|
856
|
+
status: import_v44.z.string()
|
|
845
857
|
})
|
|
846
858
|
]);
|
|
847
859
|
var xaiResponsesUsageSchema = import_v44.z.object({
|
|
@@ -924,6 +936,34 @@ var xaiResponsesChunkSchema = import_v44.z.union([
|
|
|
924
936
|
annotation_index: import_v44.z.number(),
|
|
925
937
|
annotation: annotationSchema
|
|
926
938
|
}),
|
|
939
|
+
import_v44.z.object({
|
|
940
|
+
type: import_v44.z.literal("response.reasoning_summary_part.added"),
|
|
941
|
+
item_id: import_v44.z.string(),
|
|
942
|
+
output_index: import_v44.z.number(),
|
|
943
|
+
summary_index: import_v44.z.number(),
|
|
944
|
+
part: reasoningSummaryPartSchema
|
|
945
|
+
}),
|
|
946
|
+
import_v44.z.object({
|
|
947
|
+
type: import_v44.z.literal("response.reasoning_summary_part.done"),
|
|
948
|
+
item_id: import_v44.z.string(),
|
|
949
|
+
output_index: import_v44.z.number(),
|
|
950
|
+
summary_index: import_v44.z.number(),
|
|
951
|
+
part: reasoningSummaryPartSchema
|
|
952
|
+
}),
|
|
953
|
+
import_v44.z.object({
|
|
954
|
+
type: import_v44.z.literal("response.reasoning_summary_text.delta"),
|
|
955
|
+
item_id: import_v44.z.string(),
|
|
956
|
+
output_index: import_v44.z.number(),
|
|
957
|
+
summary_index: import_v44.z.number(),
|
|
958
|
+
delta: import_v44.z.string()
|
|
959
|
+
}),
|
|
960
|
+
import_v44.z.object({
|
|
961
|
+
type: import_v44.z.literal("response.reasoning_summary_text.done"),
|
|
962
|
+
item_id: import_v44.z.string(),
|
|
963
|
+
output_index: import_v44.z.number(),
|
|
964
|
+
summary_index: import_v44.z.number(),
|
|
965
|
+
text: import_v44.z.string()
|
|
966
|
+
}),
|
|
927
967
|
import_v44.z.object({
|
|
928
968
|
type: import_v44.z.literal("response.done"),
|
|
929
969
|
response: xaiResponsesResponseSchema
|
|
@@ -955,7 +995,20 @@ function mapXaiResponsesFinishReason(finishReason) {
|
|
|
955
995
|
// src/responses/xai-responses-options.ts
|
|
956
996
|
var import_v45 = require("zod/v4");
|
|
957
997
|
var xaiResponsesProviderOptions = import_v45.z.object({
|
|
958
|
-
|
|
998
|
+
/**
|
|
999
|
+
* Constrains how hard a reasoning model thinks before responding.
|
|
1000
|
+
* Possible values are `low` (uses fewer reasoning tokens), `medium` and `high` (uses more reasoning tokens).
|
|
1001
|
+
*/
|
|
1002
|
+
reasoningEffort: import_v45.z.enum(["low", "medium", "high"]).optional(),
|
|
1003
|
+
/**
|
|
1004
|
+
* Whether to store the input message(s) and model response for later retrieval.
|
|
1005
|
+
* @default true
|
|
1006
|
+
*/
|
|
1007
|
+
store: import_v45.z.boolean().optional(),
|
|
1008
|
+
/**
|
|
1009
|
+
* The ID of the previous response from the model.
|
|
1010
|
+
*/
|
|
1011
|
+
previousResponseId: import_v45.z.string().optional()
|
|
959
1012
|
});
|
|
960
1013
|
|
|
961
1014
|
// src/responses/convert-to-xai-responses-input.ts
|
|
@@ -1419,7 +1472,16 @@ var XaiResponsesLanguageModel = class {
|
|
|
1419
1472
|
temperature,
|
|
1420
1473
|
top_p: topP,
|
|
1421
1474
|
seed,
|
|
1422
|
-
|
|
1475
|
+
...options.reasoningEffort != null && {
|
|
1476
|
+
reasoning: { effort: options.reasoningEffort }
|
|
1477
|
+
},
|
|
1478
|
+
...options.store === false && {
|
|
1479
|
+
store: options.store,
|
|
1480
|
+
include: ["reasoning.encrypted_content"]
|
|
1481
|
+
},
|
|
1482
|
+
...options.previousResponseId != null && {
|
|
1483
|
+
previous_response_id: options.previousResponseId
|
|
1484
|
+
}
|
|
1423
1485
|
};
|
|
1424
1486
|
if (xaiTools2 && xaiTools2.length > 0) {
|
|
1425
1487
|
baseArgs.tools = xaiTools2;
|
|
@@ -1607,6 +1669,29 @@ var XaiResponsesLanguageModel = class {
|
|
|
1607
1669
|
}
|
|
1608
1670
|
return;
|
|
1609
1671
|
}
|
|
1672
|
+
if (event.type === "response.reasoning_summary_part.added") {
|
|
1673
|
+
const blockId = `reasoning-${event.item_id}`;
|
|
1674
|
+
controller.enqueue({
|
|
1675
|
+
type: "reasoning-start",
|
|
1676
|
+
id: blockId
|
|
1677
|
+
});
|
|
1678
|
+
}
|
|
1679
|
+
if (event.type === "response.reasoning_summary_text.delta") {
|
|
1680
|
+
const blockId = `reasoning-${event.item_id}`;
|
|
1681
|
+
controller.enqueue({
|
|
1682
|
+
type: "reasoning-delta",
|
|
1683
|
+
id: blockId,
|
|
1684
|
+
delta: event.delta
|
|
1685
|
+
});
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
if (event.type === "response.reasoning_summary_text.done") {
|
|
1689
|
+
const blockId = `reasoning-${event.item_id}`;
|
|
1690
|
+
controller.enqueue({
|
|
1691
|
+
type: "reasoning-end",
|
|
1692
|
+
id: blockId
|
|
1693
|
+
});
|
|
1694
|
+
}
|
|
1610
1695
|
if (event.type === "response.output_text.delta") {
|
|
1611
1696
|
const blockId = `text-${event.item_id}`;
|
|
1612
1697
|
if (contentBlocks[blockId] == null) {
|
|
@@ -1846,7 +1931,7 @@ var xaiTools = {
|
|
|
1846
1931
|
};
|
|
1847
1932
|
|
|
1848
1933
|
// src/version.ts
|
|
1849
|
-
var VERSION = true ? "3.0.0-beta.
|
|
1934
|
+
var VERSION = true ? "3.0.0-beta.41" : "0.0.0-test";
|
|
1850
1935
|
|
|
1851
1936
|
// src/xai-provider.ts
|
|
1852
1937
|
var xaiErrorStructure = {
|