@ai-sdk/xai 2.0.35 → 2.0.36
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 +3 -3
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
|
@@ -150,12 +150,14 @@ function convertToXaiChatMessages(prompt) {
|
|
|
150
150
|
function getResponseMetadata({
|
|
151
151
|
id,
|
|
152
152
|
model,
|
|
153
|
-
created
|
|
153
|
+
created,
|
|
154
|
+
created_at
|
|
154
155
|
}) {
|
|
156
|
+
const unixTime = created != null ? created : created_at;
|
|
155
157
|
return {
|
|
156
158
|
id: id != null ? id : void 0,
|
|
157
159
|
modelId: model != null ? model : void 0,
|
|
158
|
-
timestamp:
|
|
160
|
+
timestamp: unixTime != null ? new Date(unixTime * 1e3) : void 0
|
|
159
161
|
};
|
|
160
162
|
}
|
|
161
163
|
|
|
@@ -793,6 +795,10 @@ var messageContentPartSchema = import_v44.z.object({
|
|
|
793
795
|
logprobs: import_v44.z.array(import_v44.z.any()).optional(),
|
|
794
796
|
annotations: import_v44.z.array(annotationSchema).optional()
|
|
795
797
|
});
|
|
798
|
+
var reasoningSummaryPartSchema = import_v44.z.object({
|
|
799
|
+
type: import_v44.z.string(),
|
|
800
|
+
text: import_v44.z.string()
|
|
801
|
+
});
|
|
796
802
|
var toolCallSchema = import_v44.z.object({
|
|
797
803
|
name: import_v44.z.string(),
|
|
798
804
|
arguments: import_v44.z.string(),
|
|
@@ -838,6 +844,12 @@ var outputItemSchema = import_v44.z.discriminatedUnion("type", [
|
|
|
838
844
|
arguments: import_v44.z.string(),
|
|
839
845
|
call_id: import_v44.z.string(),
|
|
840
846
|
id: import_v44.z.string()
|
|
847
|
+
}),
|
|
848
|
+
import_v44.z.object({
|
|
849
|
+
type: import_v44.z.literal("reasoning"),
|
|
850
|
+
id: import_v44.z.string(),
|
|
851
|
+
summary: import_v44.z.array(reasoningSummaryPartSchema),
|
|
852
|
+
status: import_v44.z.string()
|
|
841
853
|
})
|
|
842
854
|
]);
|
|
843
855
|
var xaiResponsesUsageSchema = import_v44.z.object({
|
|
@@ -920,6 +932,34 @@ var xaiResponsesChunkSchema = import_v44.z.union([
|
|
|
920
932
|
annotation_index: import_v44.z.number(),
|
|
921
933
|
annotation: annotationSchema
|
|
922
934
|
}),
|
|
935
|
+
import_v44.z.object({
|
|
936
|
+
type: import_v44.z.literal("response.reasoning_summary_part.added"),
|
|
937
|
+
item_id: import_v44.z.string(),
|
|
938
|
+
output_index: import_v44.z.number(),
|
|
939
|
+
summary_index: import_v44.z.number(),
|
|
940
|
+
part: reasoningSummaryPartSchema
|
|
941
|
+
}),
|
|
942
|
+
import_v44.z.object({
|
|
943
|
+
type: import_v44.z.literal("response.reasoning_summary_part.done"),
|
|
944
|
+
item_id: import_v44.z.string(),
|
|
945
|
+
output_index: import_v44.z.number(),
|
|
946
|
+
summary_index: import_v44.z.number(),
|
|
947
|
+
part: reasoningSummaryPartSchema
|
|
948
|
+
}),
|
|
949
|
+
import_v44.z.object({
|
|
950
|
+
type: import_v44.z.literal("response.reasoning_summary_text.delta"),
|
|
951
|
+
item_id: import_v44.z.string(),
|
|
952
|
+
output_index: import_v44.z.number(),
|
|
953
|
+
summary_index: import_v44.z.number(),
|
|
954
|
+
delta: import_v44.z.string()
|
|
955
|
+
}),
|
|
956
|
+
import_v44.z.object({
|
|
957
|
+
type: import_v44.z.literal("response.reasoning_summary_text.done"),
|
|
958
|
+
item_id: import_v44.z.string(),
|
|
959
|
+
output_index: import_v44.z.number(),
|
|
960
|
+
summary_index: import_v44.z.number(),
|
|
961
|
+
text: import_v44.z.string()
|
|
962
|
+
}),
|
|
923
963
|
import_v44.z.object({
|
|
924
964
|
type: import_v44.z.literal("response.done"),
|
|
925
965
|
response: xaiResponsesResponseSchema
|
|
@@ -951,7 +991,20 @@ function mapXaiResponsesFinishReason(finishReason) {
|
|
|
951
991
|
// src/responses/xai-responses-options.ts
|
|
952
992
|
var import_v45 = require("zod/v4");
|
|
953
993
|
var xaiResponsesProviderOptions = import_v45.z.object({
|
|
954
|
-
|
|
994
|
+
/**
|
|
995
|
+
* Constrains how hard a reasoning model thinks before responding.
|
|
996
|
+
* Possible values are `low` (uses fewer reasoning tokens), `medium` and `high` (uses more reasoning tokens).
|
|
997
|
+
*/
|
|
998
|
+
reasoningEffort: import_v45.z.enum(["low", "medium", "high"]).optional(),
|
|
999
|
+
/**
|
|
1000
|
+
* Whether to store the input message(s) and model response for later retrieval.
|
|
1001
|
+
* @default true
|
|
1002
|
+
*/
|
|
1003
|
+
store: import_v45.z.boolean().optional(),
|
|
1004
|
+
/**
|
|
1005
|
+
* The ID of the previous response from the model.
|
|
1006
|
+
*/
|
|
1007
|
+
previousResponseId: import_v45.z.string().optional()
|
|
955
1008
|
});
|
|
956
1009
|
|
|
957
1010
|
// src/responses/convert-to-xai-responses-input.ts
|
|
@@ -1412,7 +1465,16 @@ var XaiResponsesLanguageModel = class {
|
|
|
1412
1465
|
temperature,
|
|
1413
1466
|
top_p: topP,
|
|
1414
1467
|
seed,
|
|
1415
|
-
|
|
1468
|
+
...options.reasoningEffort != null && {
|
|
1469
|
+
reasoning: { effort: options.reasoningEffort }
|
|
1470
|
+
},
|
|
1471
|
+
...options.store === false && {
|
|
1472
|
+
store: options.store,
|
|
1473
|
+
include: ["reasoning.encrypted_content"]
|
|
1474
|
+
},
|
|
1475
|
+
...options.previousResponseId != null && {
|
|
1476
|
+
previous_response_id: options.previousResponseId
|
|
1477
|
+
}
|
|
1416
1478
|
};
|
|
1417
1479
|
if (xaiTools2 && xaiTools2.length > 0) {
|
|
1418
1480
|
baseArgs.tools = xaiTools2;
|
|
@@ -1600,6 +1662,29 @@ var XaiResponsesLanguageModel = class {
|
|
|
1600
1662
|
}
|
|
1601
1663
|
return;
|
|
1602
1664
|
}
|
|
1665
|
+
if (event.type === "response.reasoning_summary_part.added") {
|
|
1666
|
+
const blockId = `reasoning-${event.item_id}`;
|
|
1667
|
+
controller.enqueue({
|
|
1668
|
+
type: "reasoning-start",
|
|
1669
|
+
id: blockId
|
|
1670
|
+
});
|
|
1671
|
+
}
|
|
1672
|
+
if (event.type === "response.reasoning_summary_text.delta") {
|
|
1673
|
+
const blockId = `reasoning-${event.item_id}`;
|
|
1674
|
+
controller.enqueue({
|
|
1675
|
+
type: "reasoning-delta",
|
|
1676
|
+
id: blockId,
|
|
1677
|
+
delta: event.delta
|
|
1678
|
+
});
|
|
1679
|
+
return;
|
|
1680
|
+
}
|
|
1681
|
+
if (event.type === "response.reasoning_summary_text.done") {
|
|
1682
|
+
const blockId = `reasoning-${event.item_id}`;
|
|
1683
|
+
controller.enqueue({
|
|
1684
|
+
type: "reasoning-end",
|
|
1685
|
+
id: blockId
|
|
1686
|
+
});
|
|
1687
|
+
}
|
|
1603
1688
|
if (event.type === "response.output_text.delta") {
|
|
1604
1689
|
const blockId = `text-${event.item_id}`;
|
|
1605
1690
|
if (contentBlocks[blockId] == null) {
|
|
@@ -1839,7 +1924,7 @@ var xaiTools = {
|
|
|
1839
1924
|
};
|
|
1840
1925
|
|
|
1841
1926
|
// src/version.ts
|
|
1842
|
-
var VERSION = true ? "2.0.
|
|
1927
|
+
var VERSION = true ? "2.0.36" : "0.0.0-test";
|
|
1843
1928
|
|
|
1844
1929
|
// src/xai-provider.ts
|
|
1845
1930
|
var xaiErrorStructure = {
|