@ai-sdk/xai 3.0.51 → 3.0.52
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 +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +575 -434
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +541 -393
- package/dist/index.mjs.map +1 -1
- package/docs/01-xai.mdx +60 -7
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/xai-image-model.ts +190 -0
- package/src/xai-image-options.ts +9 -0
- package/src/xai-image-settings.ts +4 -1
- package/src/xai-provider.ts +3 -13
package/dist/index.js
CHANGED
|
@@ -34,9 +34,8 @@ __export(src_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(src_exports);
|
|
35
35
|
|
|
36
36
|
// src/xai-provider.ts
|
|
37
|
-
var import_openai_compatible = require("@ai-sdk/openai-compatible");
|
|
38
37
|
var import_provider6 = require("@ai-sdk/provider");
|
|
39
|
-
var
|
|
38
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
40
39
|
|
|
41
40
|
// src/xai-chat-language-model.ts
|
|
42
41
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -878,12 +877,159 @@ var xaiStreamErrorSchema = import_v43.z.object({
|
|
|
878
877
|
error: import_v43.z.string()
|
|
879
878
|
});
|
|
880
879
|
|
|
880
|
+
// src/xai-image-model.ts
|
|
881
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
882
|
+
var import_v45 = require("zod/v4");
|
|
883
|
+
|
|
884
|
+
// src/xai-image-options.ts
|
|
885
|
+
var import_v44 = require("zod/v4");
|
|
886
|
+
var xaiImageProviderOptions = import_v44.z.object({
|
|
887
|
+
aspect_ratio: import_v44.z.string().optional(),
|
|
888
|
+
output_format: import_v44.z.string().optional(),
|
|
889
|
+
sync_mode: import_v44.z.boolean().optional()
|
|
890
|
+
});
|
|
891
|
+
|
|
892
|
+
// src/xai-image-model.ts
|
|
893
|
+
var XaiImageModel = class {
|
|
894
|
+
constructor(modelId, config) {
|
|
895
|
+
this.modelId = modelId;
|
|
896
|
+
this.config = config;
|
|
897
|
+
this.specificationVersion = "v3";
|
|
898
|
+
this.maxImagesPerCall = 1;
|
|
899
|
+
}
|
|
900
|
+
get provider() {
|
|
901
|
+
return this.config.provider;
|
|
902
|
+
}
|
|
903
|
+
async doGenerate({
|
|
904
|
+
prompt,
|
|
905
|
+
n,
|
|
906
|
+
size,
|
|
907
|
+
aspectRatio,
|
|
908
|
+
seed,
|
|
909
|
+
providerOptions,
|
|
910
|
+
headers,
|
|
911
|
+
abortSignal,
|
|
912
|
+
files,
|
|
913
|
+
mask
|
|
914
|
+
}) {
|
|
915
|
+
var _a, _b, _c, _d;
|
|
916
|
+
const warnings = [];
|
|
917
|
+
if (size != null) {
|
|
918
|
+
warnings.push({
|
|
919
|
+
type: "unsupported",
|
|
920
|
+
feature: "size",
|
|
921
|
+
details: "This model does not support the `size` option. Use `aspectRatio` instead."
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
if (seed != null) {
|
|
925
|
+
warnings.push({
|
|
926
|
+
type: "unsupported",
|
|
927
|
+
feature: "seed"
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
if (mask != null) {
|
|
931
|
+
warnings.push({
|
|
932
|
+
type: "unsupported",
|
|
933
|
+
feature: "mask"
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
const xaiOptions = await (0, import_provider_utils4.parseProviderOptions)({
|
|
937
|
+
provider: "xai",
|
|
938
|
+
providerOptions,
|
|
939
|
+
schema: xaiImageProviderOptions
|
|
940
|
+
});
|
|
941
|
+
const hasFiles = files != null && files.length > 0;
|
|
942
|
+
let imageUrl;
|
|
943
|
+
if (hasFiles) {
|
|
944
|
+
imageUrl = (0, import_provider_utils4.convertImageModelFileToDataUri)(files[0]);
|
|
945
|
+
if (files.length > 1) {
|
|
946
|
+
warnings.push({
|
|
947
|
+
type: "other",
|
|
948
|
+
message: "xAI only supports a single input image. Additional images are ignored."
|
|
949
|
+
});
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
const endpoint = hasFiles ? "/images/edits" : "/images/generations";
|
|
953
|
+
const body = {
|
|
954
|
+
model: this.modelId,
|
|
955
|
+
prompt,
|
|
956
|
+
n,
|
|
957
|
+
response_format: "url"
|
|
958
|
+
};
|
|
959
|
+
if (aspectRatio != null) {
|
|
960
|
+
body.aspect_ratio = aspectRatio;
|
|
961
|
+
}
|
|
962
|
+
if ((xaiOptions == null ? void 0 : xaiOptions.output_format) != null) {
|
|
963
|
+
body.output_format = xaiOptions.output_format;
|
|
964
|
+
}
|
|
965
|
+
if ((xaiOptions == null ? void 0 : xaiOptions.sync_mode) != null) {
|
|
966
|
+
body.sync_mode = xaiOptions.sync_mode;
|
|
967
|
+
}
|
|
968
|
+
if ((xaiOptions == null ? void 0 : xaiOptions.aspect_ratio) != null && aspectRatio == null) {
|
|
969
|
+
body.aspect_ratio = xaiOptions.aspect_ratio;
|
|
970
|
+
}
|
|
971
|
+
if (imageUrl != null) {
|
|
972
|
+
body.image = { url: imageUrl, type: "image_url" };
|
|
973
|
+
}
|
|
974
|
+
const baseURL = (_a = this.config.baseURL) != null ? _a : "https://api.x.ai/v1";
|
|
975
|
+
const currentDate = (_d = (_c = (_b = this.config._internal) == null ? void 0 : _b.currentDate) == null ? void 0 : _c.call(_b)) != null ? _d : /* @__PURE__ */ new Date();
|
|
976
|
+
const { value: response, responseHeaders } = await (0, import_provider_utils4.postJsonToApi)({
|
|
977
|
+
url: `${baseURL}${endpoint}`,
|
|
978
|
+
headers: (0, import_provider_utils4.combineHeaders)(this.config.headers(), headers),
|
|
979
|
+
body,
|
|
980
|
+
failedResponseHandler: xaiFailedResponseHandler,
|
|
981
|
+
successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
|
|
982
|
+
xaiImageResponseSchema
|
|
983
|
+
),
|
|
984
|
+
abortSignal,
|
|
985
|
+
fetch: this.config.fetch
|
|
986
|
+
});
|
|
987
|
+
const downloadedImages = await Promise.all(
|
|
988
|
+
response.data.map((image) => this.downloadImage(image.url, abortSignal))
|
|
989
|
+
);
|
|
990
|
+
return {
|
|
991
|
+
images: downloadedImages,
|
|
992
|
+
warnings,
|
|
993
|
+
response: {
|
|
994
|
+
timestamp: currentDate,
|
|
995
|
+
modelId: this.modelId,
|
|
996
|
+
headers: responseHeaders
|
|
997
|
+
},
|
|
998
|
+
providerMetadata: {
|
|
999
|
+
xai: {
|
|
1000
|
+
images: response.data.map((item) => ({
|
|
1001
|
+
...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {}
|
|
1002
|
+
}))
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
async downloadImage(url, abortSignal) {
|
|
1008
|
+
const { value } = await (0, import_provider_utils4.getFromApi)({
|
|
1009
|
+
url,
|
|
1010
|
+
abortSignal,
|
|
1011
|
+
failedResponseHandler: (0, import_provider_utils4.createStatusCodeErrorResponseHandler)(),
|
|
1012
|
+
successfulResponseHandler: (0, import_provider_utils4.createBinaryResponseHandler)(),
|
|
1013
|
+
fetch: this.config.fetch
|
|
1014
|
+
});
|
|
1015
|
+
return value;
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1018
|
+
var xaiImageResponseSchema = import_v45.z.object({
|
|
1019
|
+
data: import_v45.z.array(
|
|
1020
|
+
import_v45.z.object({
|
|
1021
|
+
url: import_v45.z.string(),
|
|
1022
|
+
revised_prompt: import_v45.z.string().nullish()
|
|
1023
|
+
})
|
|
1024
|
+
)
|
|
1025
|
+
});
|
|
1026
|
+
|
|
881
1027
|
// src/responses/xai-responses-language-model.ts
|
|
882
|
-
var
|
|
1028
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
883
1029
|
|
|
884
1030
|
// src/responses/convert-to-xai-responses-input.ts
|
|
885
1031
|
var import_provider4 = require("@ai-sdk/provider");
|
|
886
|
-
var
|
|
1032
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
887
1033
|
async function convertToXaiResponsesInput({
|
|
888
1034
|
prompt
|
|
889
1035
|
}) {
|
|
@@ -910,7 +1056,7 @@ async function convertToXaiResponsesInput({
|
|
|
910
1056
|
case "file": {
|
|
911
1057
|
if (block.mediaType.startsWith("image/")) {
|
|
912
1058
|
const mediaType = block.mediaType === "image/*" ? "image/jpeg" : block.mediaType;
|
|
913
|
-
const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${(0,
|
|
1059
|
+
const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils5.convertToBase64)(block.data)}`;
|
|
914
1060
|
contentParts.push({ type: "input_image", image_url: imageUrl });
|
|
915
1061
|
} else {
|
|
916
1062
|
throw new import_provider4.UnsupportedFunctionalityError({
|
|
@@ -1075,553 +1221,553 @@ function mapXaiResponsesFinishReason(finishReason) {
|
|
|
1075
1221
|
}
|
|
1076
1222
|
|
|
1077
1223
|
// src/responses/xai-responses-api.ts
|
|
1078
|
-
var
|
|
1079
|
-
var annotationSchema =
|
|
1080
|
-
|
|
1081
|
-
type:
|
|
1082
|
-
url:
|
|
1083
|
-
title:
|
|
1224
|
+
var import_v46 = require("zod/v4");
|
|
1225
|
+
var annotationSchema = import_v46.z.union([
|
|
1226
|
+
import_v46.z.object({
|
|
1227
|
+
type: import_v46.z.literal("url_citation"),
|
|
1228
|
+
url: import_v46.z.string(),
|
|
1229
|
+
title: import_v46.z.string().optional()
|
|
1084
1230
|
}),
|
|
1085
|
-
|
|
1086
|
-
type:
|
|
1231
|
+
import_v46.z.object({
|
|
1232
|
+
type: import_v46.z.string()
|
|
1087
1233
|
})
|
|
1088
1234
|
]);
|
|
1089
|
-
var messageContentPartSchema =
|
|
1090
|
-
type:
|
|
1091
|
-
text:
|
|
1092
|
-
logprobs:
|
|
1093
|
-
annotations:
|
|
1235
|
+
var messageContentPartSchema = import_v46.z.object({
|
|
1236
|
+
type: import_v46.z.string(),
|
|
1237
|
+
text: import_v46.z.string().optional(),
|
|
1238
|
+
logprobs: import_v46.z.array(import_v46.z.any()).optional(),
|
|
1239
|
+
annotations: import_v46.z.array(annotationSchema).optional()
|
|
1094
1240
|
});
|
|
1095
|
-
var reasoningSummaryPartSchema =
|
|
1096
|
-
type:
|
|
1097
|
-
text:
|
|
1241
|
+
var reasoningSummaryPartSchema = import_v46.z.object({
|
|
1242
|
+
type: import_v46.z.string(),
|
|
1243
|
+
text: import_v46.z.string()
|
|
1098
1244
|
});
|
|
1099
|
-
var toolCallSchema =
|
|
1100
|
-
name:
|
|
1101
|
-
arguments:
|
|
1102
|
-
input:
|
|
1103
|
-
call_id:
|
|
1104
|
-
id:
|
|
1105
|
-
status:
|
|
1106
|
-
action:
|
|
1245
|
+
var toolCallSchema = import_v46.z.object({
|
|
1246
|
+
name: import_v46.z.string().optional(),
|
|
1247
|
+
arguments: import_v46.z.string().optional(),
|
|
1248
|
+
input: import_v46.z.string().optional(),
|
|
1249
|
+
call_id: import_v46.z.string().optional(),
|
|
1250
|
+
id: import_v46.z.string(),
|
|
1251
|
+
status: import_v46.z.string(),
|
|
1252
|
+
action: import_v46.z.any().optional()
|
|
1107
1253
|
});
|
|
1108
|
-
var mcpCallSchema =
|
|
1109
|
-
name:
|
|
1110
|
-
arguments:
|
|
1111
|
-
output:
|
|
1112
|
-
error:
|
|
1113
|
-
id:
|
|
1114
|
-
status:
|
|
1115
|
-
server_label:
|
|
1254
|
+
var mcpCallSchema = import_v46.z.object({
|
|
1255
|
+
name: import_v46.z.string().optional(),
|
|
1256
|
+
arguments: import_v46.z.string().optional(),
|
|
1257
|
+
output: import_v46.z.string().optional(),
|
|
1258
|
+
error: import_v46.z.string().optional(),
|
|
1259
|
+
id: import_v46.z.string(),
|
|
1260
|
+
status: import_v46.z.string(),
|
|
1261
|
+
server_label: import_v46.z.string().optional()
|
|
1116
1262
|
});
|
|
1117
|
-
var outputItemSchema =
|
|
1118
|
-
|
|
1119
|
-
type:
|
|
1263
|
+
var outputItemSchema = import_v46.z.discriminatedUnion("type", [
|
|
1264
|
+
import_v46.z.object({
|
|
1265
|
+
type: import_v46.z.literal("web_search_call"),
|
|
1120
1266
|
...toolCallSchema.shape
|
|
1121
1267
|
}),
|
|
1122
|
-
|
|
1123
|
-
type:
|
|
1268
|
+
import_v46.z.object({
|
|
1269
|
+
type: import_v46.z.literal("x_search_call"),
|
|
1124
1270
|
...toolCallSchema.shape
|
|
1125
1271
|
}),
|
|
1126
|
-
|
|
1127
|
-
type:
|
|
1272
|
+
import_v46.z.object({
|
|
1273
|
+
type: import_v46.z.literal("code_interpreter_call"),
|
|
1128
1274
|
...toolCallSchema.shape
|
|
1129
1275
|
}),
|
|
1130
|
-
|
|
1131
|
-
type:
|
|
1276
|
+
import_v46.z.object({
|
|
1277
|
+
type: import_v46.z.literal("code_execution_call"),
|
|
1132
1278
|
...toolCallSchema.shape
|
|
1133
1279
|
}),
|
|
1134
|
-
|
|
1135
|
-
type:
|
|
1280
|
+
import_v46.z.object({
|
|
1281
|
+
type: import_v46.z.literal("view_image_call"),
|
|
1136
1282
|
...toolCallSchema.shape
|
|
1137
1283
|
}),
|
|
1138
|
-
|
|
1139
|
-
type:
|
|
1284
|
+
import_v46.z.object({
|
|
1285
|
+
type: import_v46.z.literal("view_x_video_call"),
|
|
1140
1286
|
...toolCallSchema.shape
|
|
1141
1287
|
}),
|
|
1142
|
-
|
|
1143
|
-
type:
|
|
1144
|
-
id:
|
|
1145
|
-
status:
|
|
1146
|
-
queries:
|
|
1147
|
-
results:
|
|
1148
|
-
|
|
1149
|
-
file_id:
|
|
1150
|
-
filename:
|
|
1151
|
-
score:
|
|
1152
|
-
text:
|
|
1288
|
+
import_v46.z.object({
|
|
1289
|
+
type: import_v46.z.literal("file_search_call"),
|
|
1290
|
+
id: import_v46.z.string(),
|
|
1291
|
+
status: import_v46.z.string(),
|
|
1292
|
+
queries: import_v46.z.array(import_v46.z.string()).optional(),
|
|
1293
|
+
results: import_v46.z.array(
|
|
1294
|
+
import_v46.z.object({
|
|
1295
|
+
file_id: import_v46.z.string(),
|
|
1296
|
+
filename: import_v46.z.string(),
|
|
1297
|
+
score: import_v46.z.number(),
|
|
1298
|
+
text: import_v46.z.string()
|
|
1153
1299
|
})
|
|
1154
1300
|
).nullish()
|
|
1155
1301
|
}),
|
|
1156
|
-
|
|
1157
|
-
type:
|
|
1302
|
+
import_v46.z.object({
|
|
1303
|
+
type: import_v46.z.literal("custom_tool_call"),
|
|
1158
1304
|
...toolCallSchema.shape
|
|
1159
1305
|
}),
|
|
1160
|
-
|
|
1161
|
-
type:
|
|
1306
|
+
import_v46.z.object({
|
|
1307
|
+
type: import_v46.z.literal("mcp_call"),
|
|
1162
1308
|
...mcpCallSchema.shape
|
|
1163
1309
|
}),
|
|
1164
|
-
|
|
1165
|
-
type:
|
|
1166
|
-
role:
|
|
1167
|
-
content:
|
|
1168
|
-
id:
|
|
1169
|
-
status:
|
|
1310
|
+
import_v46.z.object({
|
|
1311
|
+
type: import_v46.z.literal("message"),
|
|
1312
|
+
role: import_v46.z.string(),
|
|
1313
|
+
content: import_v46.z.array(messageContentPartSchema),
|
|
1314
|
+
id: import_v46.z.string(),
|
|
1315
|
+
status: import_v46.z.string()
|
|
1170
1316
|
}),
|
|
1171
|
-
|
|
1172
|
-
type:
|
|
1173
|
-
name:
|
|
1174
|
-
arguments:
|
|
1175
|
-
call_id:
|
|
1176
|
-
id:
|
|
1317
|
+
import_v46.z.object({
|
|
1318
|
+
type: import_v46.z.literal("function_call"),
|
|
1319
|
+
name: import_v46.z.string(),
|
|
1320
|
+
arguments: import_v46.z.string(),
|
|
1321
|
+
call_id: import_v46.z.string(),
|
|
1322
|
+
id: import_v46.z.string()
|
|
1177
1323
|
}),
|
|
1178
|
-
|
|
1179
|
-
type:
|
|
1180
|
-
id:
|
|
1181
|
-
summary:
|
|
1182
|
-
status:
|
|
1183
|
-
encrypted_content:
|
|
1324
|
+
import_v46.z.object({
|
|
1325
|
+
type: import_v46.z.literal("reasoning"),
|
|
1326
|
+
id: import_v46.z.string(),
|
|
1327
|
+
summary: import_v46.z.array(reasoningSummaryPartSchema),
|
|
1328
|
+
status: import_v46.z.string(),
|
|
1329
|
+
encrypted_content: import_v46.z.string().nullish()
|
|
1184
1330
|
})
|
|
1185
1331
|
]);
|
|
1186
|
-
var xaiResponsesUsageSchema =
|
|
1187
|
-
input_tokens:
|
|
1188
|
-
output_tokens:
|
|
1189
|
-
total_tokens:
|
|
1190
|
-
input_tokens_details:
|
|
1191
|
-
cached_tokens:
|
|
1332
|
+
var xaiResponsesUsageSchema = import_v46.z.object({
|
|
1333
|
+
input_tokens: import_v46.z.number(),
|
|
1334
|
+
output_tokens: import_v46.z.number(),
|
|
1335
|
+
total_tokens: import_v46.z.number().optional(),
|
|
1336
|
+
input_tokens_details: import_v46.z.object({
|
|
1337
|
+
cached_tokens: import_v46.z.number().optional()
|
|
1192
1338
|
}).optional(),
|
|
1193
|
-
output_tokens_details:
|
|
1194
|
-
reasoning_tokens:
|
|
1339
|
+
output_tokens_details: import_v46.z.object({
|
|
1340
|
+
reasoning_tokens: import_v46.z.number().optional()
|
|
1195
1341
|
}).optional(),
|
|
1196
|
-
num_sources_used:
|
|
1197
|
-
num_server_side_tools_used:
|
|
1342
|
+
num_sources_used: import_v46.z.number().optional(),
|
|
1343
|
+
num_server_side_tools_used: import_v46.z.number().optional()
|
|
1198
1344
|
});
|
|
1199
|
-
var xaiResponsesResponseSchema =
|
|
1200
|
-
id:
|
|
1201
|
-
created_at:
|
|
1202
|
-
model:
|
|
1203
|
-
object:
|
|
1204
|
-
output:
|
|
1345
|
+
var xaiResponsesResponseSchema = import_v46.z.object({
|
|
1346
|
+
id: import_v46.z.string().nullish(),
|
|
1347
|
+
created_at: import_v46.z.number().nullish(),
|
|
1348
|
+
model: import_v46.z.string().nullish(),
|
|
1349
|
+
object: import_v46.z.literal("response"),
|
|
1350
|
+
output: import_v46.z.array(outputItemSchema),
|
|
1205
1351
|
usage: xaiResponsesUsageSchema.nullish(),
|
|
1206
|
-
status:
|
|
1352
|
+
status: import_v46.z.string()
|
|
1207
1353
|
});
|
|
1208
|
-
var xaiResponsesChunkSchema =
|
|
1209
|
-
|
|
1210
|
-
type:
|
|
1354
|
+
var xaiResponsesChunkSchema = import_v46.z.union([
|
|
1355
|
+
import_v46.z.object({
|
|
1356
|
+
type: import_v46.z.literal("response.created"),
|
|
1211
1357
|
response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
|
|
1212
1358
|
}),
|
|
1213
|
-
|
|
1214
|
-
type:
|
|
1359
|
+
import_v46.z.object({
|
|
1360
|
+
type: import_v46.z.literal("response.in_progress"),
|
|
1215
1361
|
response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
|
|
1216
1362
|
}),
|
|
1217
|
-
|
|
1218
|
-
type:
|
|
1363
|
+
import_v46.z.object({
|
|
1364
|
+
type: import_v46.z.literal("response.output_item.added"),
|
|
1219
1365
|
item: outputItemSchema,
|
|
1220
|
-
output_index:
|
|
1366
|
+
output_index: import_v46.z.number()
|
|
1221
1367
|
}),
|
|
1222
|
-
|
|
1223
|
-
type:
|
|
1368
|
+
import_v46.z.object({
|
|
1369
|
+
type: import_v46.z.literal("response.output_item.done"),
|
|
1224
1370
|
item: outputItemSchema,
|
|
1225
|
-
output_index:
|
|
1371
|
+
output_index: import_v46.z.number()
|
|
1226
1372
|
}),
|
|
1227
|
-
|
|
1228
|
-
type:
|
|
1229
|
-
item_id:
|
|
1230
|
-
output_index:
|
|
1231
|
-
content_index:
|
|
1373
|
+
import_v46.z.object({
|
|
1374
|
+
type: import_v46.z.literal("response.content_part.added"),
|
|
1375
|
+
item_id: import_v46.z.string(),
|
|
1376
|
+
output_index: import_v46.z.number(),
|
|
1377
|
+
content_index: import_v46.z.number(),
|
|
1232
1378
|
part: messageContentPartSchema
|
|
1233
1379
|
}),
|
|
1234
|
-
|
|
1235
|
-
type:
|
|
1236
|
-
item_id:
|
|
1237
|
-
output_index:
|
|
1238
|
-
content_index:
|
|
1380
|
+
import_v46.z.object({
|
|
1381
|
+
type: import_v46.z.literal("response.content_part.done"),
|
|
1382
|
+
item_id: import_v46.z.string(),
|
|
1383
|
+
output_index: import_v46.z.number(),
|
|
1384
|
+
content_index: import_v46.z.number(),
|
|
1239
1385
|
part: messageContentPartSchema
|
|
1240
1386
|
}),
|
|
1241
|
-
|
|
1242
|
-
type:
|
|
1243
|
-
item_id:
|
|
1244
|
-
output_index:
|
|
1245
|
-
content_index:
|
|
1246
|
-
delta:
|
|
1247
|
-
logprobs:
|
|
1387
|
+
import_v46.z.object({
|
|
1388
|
+
type: import_v46.z.literal("response.output_text.delta"),
|
|
1389
|
+
item_id: import_v46.z.string(),
|
|
1390
|
+
output_index: import_v46.z.number(),
|
|
1391
|
+
content_index: import_v46.z.number(),
|
|
1392
|
+
delta: import_v46.z.string(),
|
|
1393
|
+
logprobs: import_v46.z.array(import_v46.z.any()).optional()
|
|
1248
1394
|
}),
|
|
1249
|
-
|
|
1250
|
-
type:
|
|
1251
|
-
item_id:
|
|
1252
|
-
output_index:
|
|
1253
|
-
content_index:
|
|
1254
|
-
text:
|
|
1255
|
-
logprobs:
|
|
1256
|
-
annotations:
|
|
1395
|
+
import_v46.z.object({
|
|
1396
|
+
type: import_v46.z.literal("response.output_text.done"),
|
|
1397
|
+
item_id: import_v46.z.string(),
|
|
1398
|
+
output_index: import_v46.z.number(),
|
|
1399
|
+
content_index: import_v46.z.number(),
|
|
1400
|
+
text: import_v46.z.string(),
|
|
1401
|
+
logprobs: import_v46.z.array(import_v46.z.any()).optional(),
|
|
1402
|
+
annotations: import_v46.z.array(annotationSchema).optional()
|
|
1257
1403
|
}),
|
|
1258
|
-
|
|
1259
|
-
type:
|
|
1260
|
-
item_id:
|
|
1261
|
-
output_index:
|
|
1262
|
-
content_index:
|
|
1263
|
-
annotation_index:
|
|
1404
|
+
import_v46.z.object({
|
|
1405
|
+
type: import_v46.z.literal("response.output_text.annotation.added"),
|
|
1406
|
+
item_id: import_v46.z.string(),
|
|
1407
|
+
output_index: import_v46.z.number(),
|
|
1408
|
+
content_index: import_v46.z.number(),
|
|
1409
|
+
annotation_index: import_v46.z.number(),
|
|
1264
1410
|
annotation: annotationSchema
|
|
1265
1411
|
}),
|
|
1266
|
-
|
|
1267
|
-
type:
|
|
1268
|
-
item_id:
|
|
1269
|
-
output_index:
|
|
1270
|
-
summary_index:
|
|
1412
|
+
import_v46.z.object({
|
|
1413
|
+
type: import_v46.z.literal("response.reasoning_summary_part.added"),
|
|
1414
|
+
item_id: import_v46.z.string(),
|
|
1415
|
+
output_index: import_v46.z.number(),
|
|
1416
|
+
summary_index: import_v46.z.number(),
|
|
1271
1417
|
part: reasoningSummaryPartSchema
|
|
1272
1418
|
}),
|
|
1273
|
-
|
|
1274
|
-
type:
|
|
1275
|
-
item_id:
|
|
1276
|
-
output_index:
|
|
1277
|
-
summary_index:
|
|
1419
|
+
import_v46.z.object({
|
|
1420
|
+
type: import_v46.z.literal("response.reasoning_summary_part.done"),
|
|
1421
|
+
item_id: import_v46.z.string(),
|
|
1422
|
+
output_index: import_v46.z.number(),
|
|
1423
|
+
summary_index: import_v46.z.number(),
|
|
1278
1424
|
part: reasoningSummaryPartSchema
|
|
1279
1425
|
}),
|
|
1280
|
-
|
|
1281
|
-
type:
|
|
1282
|
-
item_id:
|
|
1283
|
-
output_index:
|
|
1284
|
-
summary_index:
|
|
1285
|
-
delta:
|
|
1426
|
+
import_v46.z.object({
|
|
1427
|
+
type: import_v46.z.literal("response.reasoning_summary_text.delta"),
|
|
1428
|
+
item_id: import_v46.z.string(),
|
|
1429
|
+
output_index: import_v46.z.number(),
|
|
1430
|
+
summary_index: import_v46.z.number(),
|
|
1431
|
+
delta: import_v46.z.string()
|
|
1286
1432
|
}),
|
|
1287
|
-
|
|
1288
|
-
type:
|
|
1289
|
-
item_id:
|
|
1290
|
-
output_index:
|
|
1291
|
-
summary_index:
|
|
1292
|
-
text:
|
|
1433
|
+
import_v46.z.object({
|
|
1434
|
+
type: import_v46.z.literal("response.reasoning_summary_text.done"),
|
|
1435
|
+
item_id: import_v46.z.string(),
|
|
1436
|
+
output_index: import_v46.z.number(),
|
|
1437
|
+
summary_index: import_v46.z.number(),
|
|
1438
|
+
text: import_v46.z.string()
|
|
1293
1439
|
}),
|
|
1294
|
-
|
|
1295
|
-
type:
|
|
1296
|
-
item_id:
|
|
1297
|
-
output_index:
|
|
1298
|
-
content_index:
|
|
1299
|
-
delta:
|
|
1440
|
+
import_v46.z.object({
|
|
1441
|
+
type: import_v46.z.literal("response.reasoning_text.delta"),
|
|
1442
|
+
item_id: import_v46.z.string(),
|
|
1443
|
+
output_index: import_v46.z.number(),
|
|
1444
|
+
content_index: import_v46.z.number(),
|
|
1445
|
+
delta: import_v46.z.string()
|
|
1300
1446
|
}),
|
|
1301
|
-
|
|
1302
|
-
type:
|
|
1303
|
-
item_id:
|
|
1304
|
-
output_index:
|
|
1305
|
-
content_index:
|
|
1306
|
-
text:
|
|
1447
|
+
import_v46.z.object({
|
|
1448
|
+
type: import_v46.z.literal("response.reasoning_text.done"),
|
|
1449
|
+
item_id: import_v46.z.string(),
|
|
1450
|
+
output_index: import_v46.z.number(),
|
|
1451
|
+
content_index: import_v46.z.number(),
|
|
1452
|
+
text: import_v46.z.string()
|
|
1307
1453
|
}),
|
|
1308
|
-
|
|
1309
|
-
type:
|
|
1310
|
-
item_id:
|
|
1311
|
-
output_index:
|
|
1454
|
+
import_v46.z.object({
|
|
1455
|
+
type: import_v46.z.literal("response.web_search_call.in_progress"),
|
|
1456
|
+
item_id: import_v46.z.string(),
|
|
1457
|
+
output_index: import_v46.z.number()
|
|
1312
1458
|
}),
|
|
1313
|
-
|
|
1314
|
-
type:
|
|
1315
|
-
item_id:
|
|
1316
|
-
output_index:
|
|
1459
|
+
import_v46.z.object({
|
|
1460
|
+
type: import_v46.z.literal("response.web_search_call.searching"),
|
|
1461
|
+
item_id: import_v46.z.string(),
|
|
1462
|
+
output_index: import_v46.z.number()
|
|
1317
1463
|
}),
|
|
1318
|
-
|
|
1319
|
-
type:
|
|
1320
|
-
item_id:
|
|
1321
|
-
output_index:
|
|
1464
|
+
import_v46.z.object({
|
|
1465
|
+
type: import_v46.z.literal("response.web_search_call.completed"),
|
|
1466
|
+
item_id: import_v46.z.string(),
|
|
1467
|
+
output_index: import_v46.z.number()
|
|
1322
1468
|
}),
|
|
1323
|
-
|
|
1324
|
-
type:
|
|
1325
|
-
item_id:
|
|
1326
|
-
output_index:
|
|
1469
|
+
import_v46.z.object({
|
|
1470
|
+
type: import_v46.z.literal("response.x_search_call.in_progress"),
|
|
1471
|
+
item_id: import_v46.z.string(),
|
|
1472
|
+
output_index: import_v46.z.number()
|
|
1327
1473
|
}),
|
|
1328
|
-
|
|
1329
|
-
type:
|
|
1330
|
-
item_id:
|
|
1331
|
-
output_index:
|
|
1474
|
+
import_v46.z.object({
|
|
1475
|
+
type: import_v46.z.literal("response.x_search_call.searching"),
|
|
1476
|
+
item_id: import_v46.z.string(),
|
|
1477
|
+
output_index: import_v46.z.number()
|
|
1332
1478
|
}),
|
|
1333
|
-
|
|
1334
|
-
type:
|
|
1335
|
-
item_id:
|
|
1336
|
-
output_index:
|
|
1479
|
+
import_v46.z.object({
|
|
1480
|
+
type: import_v46.z.literal("response.x_search_call.completed"),
|
|
1481
|
+
item_id: import_v46.z.string(),
|
|
1482
|
+
output_index: import_v46.z.number()
|
|
1337
1483
|
}),
|
|
1338
|
-
|
|
1339
|
-
type:
|
|
1340
|
-
item_id:
|
|
1341
|
-
output_index:
|
|
1484
|
+
import_v46.z.object({
|
|
1485
|
+
type: import_v46.z.literal("response.file_search_call.in_progress"),
|
|
1486
|
+
item_id: import_v46.z.string(),
|
|
1487
|
+
output_index: import_v46.z.number()
|
|
1342
1488
|
}),
|
|
1343
|
-
|
|
1344
|
-
type:
|
|
1345
|
-
item_id:
|
|
1346
|
-
output_index:
|
|
1489
|
+
import_v46.z.object({
|
|
1490
|
+
type: import_v46.z.literal("response.file_search_call.searching"),
|
|
1491
|
+
item_id: import_v46.z.string(),
|
|
1492
|
+
output_index: import_v46.z.number()
|
|
1347
1493
|
}),
|
|
1348
|
-
|
|
1349
|
-
type:
|
|
1350
|
-
item_id:
|
|
1351
|
-
output_index:
|
|
1494
|
+
import_v46.z.object({
|
|
1495
|
+
type: import_v46.z.literal("response.file_search_call.completed"),
|
|
1496
|
+
item_id: import_v46.z.string(),
|
|
1497
|
+
output_index: import_v46.z.number()
|
|
1352
1498
|
}),
|
|
1353
|
-
|
|
1354
|
-
type:
|
|
1355
|
-
item_id:
|
|
1356
|
-
output_index:
|
|
1499
|
+
import_v46.z.object({
|
|
1500
|
+
type: import_v46.z.literal("response.code_execution_call.in_progress"),
|
|
1501
|
+
item_id: import_v46.z.string(),
|
|
1502
|
+
output_index: import_v46.z.number()
|
|
1357
1503
|
}),
|
|
1358
|
-
|
|
1359
|
-
type:
|
|
1360
|
-
item_id:
|
|
1361
|
-
output_index:
|
|
1504
|
+
import_v46.z.object({
|
|
1505
|
+
type: import_v46.z.literal("response.code_execution_call.executing"),
|
|
1506
|
+
item_id: import_v46.z.string(),
|
|
1507
|
+
output_index: import_v46.z.number()
|
|
1362
1508
|
}),
|
|
1363
|
-
|
|
1364
|
-
type:
|
|
1365
|
-
item_id:
|
|
1366
|
-
output_index:
|
|
1509
|
+
import_v46.z.object({
|
|
1510
|
+
type: import_v46.z.literal("response.code_execution_call.completed"),
|
|
1511
|
+
item_id: import_v46.z.string(),
|
|
1512
|
+
output_index: import_v46.z.number()
|
|
1367
1513
|
}),
|
|
1368
|
-
|
|
1369
|
-
type:
|
|
1370
|
-
item_id:
|
|
1371
|
-
output_index:
|
|
1514
|
+
import_v46.z.object({
|
|
1515
|
+
type: import_v46.z.literal("response.code_interpreter_call.in_progress"),
|
|
1516
|
+
item_id: import_v46.z.string(),
|
|
1517
|
+
output_index: import_v46.z.number()
|
|
1372
1518
|
}),
|
|
1373
|
-
|
|
1374
|
-
type:
|
|
1375
|
-
item_id:
|
|
1376
|
-
output_index:
|
|
1519
|
+
import_v46.z.object({
|
|
1520
|
+
type: import_v46.z.literal("response.code_interpreter_call.executing"),
|
|
1521
|
+
item_id: import_v46.z.string(),
|
|
1522
|
+
output_index: import_v46.z.number()
|
|
1377
1523
|
}),
|
|
1378
|
-
|
|
1379
|
-
type:
|
|
1380
|
-
item_id:
|
|
1381
|
-
output_index:
|
|
1524
|
+
import_v46.z.object({
|
|
1525
|
+
type: import_v46.z.literal("response.code_interpreter_call.interpreting"),
|
|
1526
|
+
item_id: import_v46.z.string(),
|
|
1527
|
+
output_index: import_v46.z.number()
|
|
1382
1528
|
}),
|
|
1383
|
-
|
|
1384
|
-
type:
|
|
1385
|
-
item_id:
|
|
1386
|
-
output_index:
|
|
1529
|
+
import_v46.z.object({
|
|
1530
|
+
type: import_v46.z.literal("response.code_interpreter_call.completed"),
|
|
1531
|
+
item_id: import_v46.z.string(),
|
|
1532
|
+
output_index: import_v46.z.number()
|
|
1387
1533
|
}),
|
|
1388
1534
|
// Code interpreter code streaming events
|
|
1389
|
-
|
|
1390
|
-
type:
|
|
1391
|
-
item_id:
|
|
1392
|
-
output_index:
|
|
1393
|
-
delta:
|
|
1535
|
+
import_v46.z.object({
|
|
1536
|
+
type: import_v46.z.literal("response.code_interpreter_call_code.delta"),
|
|
1537
|
+
item_id: import_v46.z.string(),
|
|
1538
|
+
output_index: import_v46.z.number(),
|
|
1539
|
+
delta: import_v46.z.string()
|
|
1394
1540
|
}),
|
|
1395
|
-
|
|
1396
|
-
type:
|
|
1397
|
-
item_id:
|
|
1398
|
-
output_index:
|
|
1399
|
-
code:
|
|
1541
|
+
import_v46.z.object({
|
|
1542
|
+
type: import_v46.z.literal("response.code_interpreter_call_code.done"),
|
|
1543
|
+
item_id: import_v46.z.string(),
|
|
1544
|
+
output_index: import_v46.z.number(),
|
|
1545
|
+
code: import_v46.z.string()
|
|
1400
1546
|
}),
|
|
1401
|
-
|
|
1402
|
-
type:
|
|
1403
|
-
item_id:
|
|
1404
|
-
output_index:
|
|
1405
|
-
delta:
|
|
1547
|
+
import_v46.z.object({
|
|
1548
|
+
type: import_v46.z.literal("response.custom_tool_call_input.delta"),
|
|
1549
|
+
item_id: import_v46.z.string(),
|
|
1550
|
+
output_index: import_v46.z.number(),
|
|
1551
|
+
delta: import_v46.z.string()
|
|
1406
1552
|
}),
|
|
1407
|
-
|
|
1408
|
-
type:
|
|
1409
|
-
item_id:
|
|
1410
|
-
output_index:
|
|
1411
|
-
input:
|
|
1553
|
+
import_v46.z.object({
|
|
1554
|
+
type: import_v46.z.literal("response.custom_tool_call_input.done"),
|
|
1555
|
+
item_id: import_v46.z.string(),
|
|
1556
|
+
output_index: import_v46.z.number(),
|
|
1557
|
+
input: import_v46.z.string()
|
|
1412
1558
|
}),
|
|
1413
|
-
|
|
1414
|
-
type:
|
|
1415
|
-
item_id:
|
|
1416
|
-
output_index:
|
|
1559
|
+
import_v46.z.object({
|
|
1560
|
+
type: import_v46.z.literal("response.mcp_call.in_progress"),
|
|
1561
|
+
item_id: import_v46.z.string(),
|
|
1562
|
+
output_index: import_v46.z.number()
|
|
1417
1563
|
}),
|
|
1418
|
-
|
|
1419
|
-
type:
|
|
1420
|
-
item_id:
|
|
1421
|
-
output_index:
|
|
1564
|
+
import_v46.z.object({
|
|
1565
|
+
type: import_v46.z.literal("response.mcp_call.executing"),
|
|
1566
|
+
item_id: import_v46.z.string(),
|
|
1567
|
+
output_index: import_v46.z.number()
|
|
1422
1568
|
}),
|
|
1423
|
-
|
|
1424
|
-
type:
|
|
1425
|
-
item_id:
|
|
1426
|
-
output_index:
|
|
1569
|
+
import_v46.z.object({
|
|
1570
|
+
type: import_v46.z.literal("response.mcp_call.completed"),
|
|
1571
|
+
item_id: import_v46.z.string(),
|
|
1572
|
+
output_index: import_v46.z.number()
|
|
1427
1573
|
}),
|
|
1428
|
-
|
|
1429
|
-
type:
|
|
1430
|
-
item_id:
|
|
1431
|
-
output_index:
|
|
1574
|
+
import_v46.z.object({
|
|
1575
|
+
type: import_v46.z.literal("response.mcp_call.failed"),
|
|
1576
|
+
item_id: import_v46.z.string(),
|
|
1577
|
+
output_index: import_v46.z.number()
|
|
1432
1578
|
}),
|
|
1433
|
-
|
|
1434
|
-
type:
|
|
1435
|
-
item_id:
|
|
1436
|
-
output_index:
|
|
1437
|
-
delta:
|
|
1579
|
+
import_v46.z.object({
|
|
1580
|
+
type: import_v46.z.literal("response.mcp_call_arguments.delta"),
|
|
1581
|
+
item_id: import_v46.z.string(),
|
|
1582
|
+
output_index: import_v46.z.number(),
|
|
1583
|
+
delta: import_v46.z.string()
|
|
1438
1584
|
}),
|
|
1439
|
-
|
|
1440
|
-
type:
|
|
1441
|
-
item_id:
|
|
1442
|
-
output_index:
|
|
1443
|
-
arguments:
|
|
1585
|
+
import_v46.z.object({
|
|
1586
|
+
type: import_v46.z.literal("response.mcp_call_arguments.done"),
|
|
1587
|
+
item_id: import_v46.z.string(),
|
|
1588
|
+
output_index: import_v46.z.number(),
|
|
1589
|
+
arguments: import_v46.z.string().optional()
|
|
1444
1590
|
}),
|
|
1445
|
-
|
|
1446
|
-
type:
|
|
1447
|
-
item_id:
|
|
1448
|
-
output_index:
|
|
1449
|
-
delta:
|
|
1591
|
+
import_v46.z.object({
|
|
1592
|
+
type: import_v46.z.literal("response.mcp_call_output.delta"),
|
|
1593
|
+
item_id: import_v46.z.string(),
|
|
1594
|
+
output_index: import_v46.z.number(),
|
|
1595
|
+
delta: import_v46.z.string()
|
|
1450
1596
|
}),
|
|
1451
|
-
|
|
1452
|
-
type:
|
|
1453
|
-
item_id:
|
|
1454
|
-
output_index:
|
|
1455
|
-
output:
|
|
1597
|
+
import_v46.z.object({
|
|
1598
|
+
type: import_v46.z.literal("response.mcp_call_output.done"),
|
|
1599
|
+
item_id: import_v46.z.string(),
|
|
1600
|
+
output_index: import_v46.z.number(),
|
|
1601
|
+
output: import_v46.z.string().optional()
|
|
1456
1602
|
}),
|
|
1457
|
-
|
|
1458
|
-
type:
|
|
1603
|
+
import_v46.z.object({
|
|
1604
|
+
type: import_v46.z.literal("response.done"),
|
|
1459
1605
|
response: xaiResponsesResponseSchema
|
|
1460
1606
|
}),
|
|
1461
|
-
|
|
1462
|
-
type:
|
|
1607
|
+
import_v46.z.object({
|
|
1608
|
+
type: import_v46.z.literal("response.completed"),
|
|
1463
1609
|
response: xaiResponsesResponseSchema
|
|
1464
1610
|
})
|
|
1465
1611
|
]);
|
|
1466
1612
|
|
|
1467
1613
|
// src/responses/xai-responses-options.ts
|
|
1468
|
-
var
|
|
1469
|
-
var xaiResponsesProviderOptions =
|
|
1614
|
+
var import_v47 = require("zod/v4");
|
|
1615
|
+
var xaiResponsesProviderOptions = import_v47.z.object({
|
|
1470
1616
|
/**
|
|
1471
1617
|
* Constrains how hard a reasoning model thinks before responding.
|
|
1472
1618
|
* Possible values are `low` (uses fewer reasoning tokens), `medium` and `high` (uses more reasoning tokens).
|
|
1473
1619
|
*/
|
|
1474
|
-
reasoningEffort:
|
|
1620
|
+
reasoningEffort: import_v47.z.enum(["low", "medium", "high"]).optional(),
|
|
1475
1621
|
/**
|
|
1476
1622
|
* Whether to store the input message(s) and model response for later retrieval.
|
|
1477
1623
|
* @default true
|
|
1478
1624
|
*/
|
|
1479
|
-
store:
|
|
1625
|
+
store: import_v47.z.boolean().optional(),
|
|
1480
1626
|
/**
|
|
1481
1627
|
* The ID of the previous response from the model.
|
|
1482
1628
|
*/
|
|
1483
|
-
previousResponseId:
|
|
1629
|
+
previousResponseId: import_v47.z.string().optional(),
|
|
1484
1630
|
/**
|
|
1485
1631
|
* Specify additional output data to include in the model response.
|
|
1486
1632
|
* Example values: 'file_search_call.results'.
|
|
1487
1633
|
*/
|
|
1488
|
-
include:
|
|
1634
|
+
include: import_v47.z.array(import_v47.z.enum(["file_search_call.results"])).nullish()
|
|
1489
1635
|
});
|
|
1490
1636
|
|
|
1491
1637
|
// src/responses/xai-responses-prepare-tools.ts
|
|
1492
1638
|
var import_provider5 = require("@ai-sdk/provider");
|
|
1493
|
-
var
|
|
1639
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
1494
1640
|
|
|
1495
1641
|
// src/tool/file-search.ts
|
|
1496
|
-
var
|
|
1497
|
-
var
|
|
1498
|
-
var fileSearchArgsSchema = (0,
|
|
1499
|
-
() => (0,
|
|
1500
|
-
|
|
1501
|
-
vectorStoreIds:
|
|
1502
|
-
maxNumResults:
|
|
1642
|
+
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
1643
|
+
var import_v48 = require("zod/v4");
|
|
1644
|
+
var fileSearchArgsSchema = (0, import_provider_utils6.lazySchema)(
|
|
1645
|
+
() => (0, import_provider_utils6.zodSchema)(
|
|
1646
|
+
import_v48.z.object({
|
|
1647
|
+
vectorStoreIds: import_v48.z.array(import_v48.z.string()),
|
|
1648
|
+
maxNumResults: import_v48.z.number().optional()
|
|
1503
1649
|
})
|
|
1504
1650
|
)
|
|
1505
1651
|
);
|
|
1506
|
-
var fileSearchOutputSchema = (0,
|
|
1507
|
-
() => (0,
|
|
1508
|
-
|
|
1509
|
-
queries:
|
|
1510
|
-
results:
|
|
1511
|
-
|
|
1512
|
-
fileId:
|
|
1513
|
-
filename:
|
|
1514
|
-
score:
|
|
1515
|
-
text:
|
|
1652
|
+
var fileSearchOutputSchema = (0, import_provider_utils6.lazySchema)(
|
|
1653
|
+
() => (0, import_provider_utils6.zodSchema)(
|
|
1654
|
+
import_v48.z.object({
|
|
1655
|
+
queries: import_v48.z.array(import_v48.z.string()),
|
|
1656
|
+
results: import_v48.z.array(
|
|
1657
|
+
import_v48.z.object({
|
|
1658
|
+
fileId: import_v48.z.string(),
|
|
1659
|
+
filename: import_v48.z.string(),
|
|
1660
|
+
score: import_v48.z.number().min(0).max(1),
|
|
1661
|
+
text: import_v48.z.string()
|
|
1516
1662
|
})
|
|
1517
1663
|
).nullable()
|
|
1518
1664
|
})
|
|
1519
1665
|
)
|
|
1520
1666
|
);
|
|
1521
|
-
var fileSearchToolFactory = (0,
|
|
1667
|
+
var fileSearchToolFactory = (0, import_provider_utils6.createProviderToolFactoryWithOutputSchema)({
|
|
1522
1668
|
id: "xai.file_search",
|
|
1523
|
-
inputSchema: (0,
|
|
1669
|
+
inputSchema: (0, import_provider_utils6.lazySchema)(() => (0, import_provider_utils6.zodSchema)(import_v48.z.object({}))),
|
|
1524
1670
|
outputSchema: fileSearchOutputSchema
|
|
1525
1671
|
});
|
|
1526
1672
|
var fileSearch = (args) => fileSearchToolFactory(args);
|
|
1527
1673
|
|
|
1528
1674
|
// src/tool/mcp-server.ts
|
|
1529
|
-
var
|
|
1530
|
-
var
|
|
1531
|
-
var mcpServerArgsSchema = (0,
|
|
1532
|
-
() => (0,
|
|
1533
|
-
|
|
1534
|
-
serverUrl:
|
|
1535
|
-
serverLabel:
|
|
1536
|
-
serverDescription:
|
|
1537
|
-
allowedTools:
|
|
1538
|
-
headers:
|
|
1539
|
-
authorization:
|
|
1675
|
+
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1676
|
+
var import_v49 = require("zod/v4");
|
|
1677
|
+
var mcpServerArgsSchema = (0, import_provider_utils7.lazySchema)(
|
|
1678
|
+
() => (0, import_provider_utils7.zodSchema)(
|
|
1679
|
+
import_v49.z.object({
|
|
1680
|
+
serverUrl: import_v49.z.string().describe("The URL of the MCP server"),
|
|
1681
|
+
serverLabel: import_v49.z.string().optional().describe("A label for the MCP server"),
|
|
1682
|
+
serverDescription: import_v49.z.string().optional().describe("Description of the MCP server"),
|
|
1683
|
+
allowedTools: import_v49.z.array(import_v49.z.string()).optional().describe("List of allowed tool names"),
|
|
1684
|
+
headers: import_v49.z.record(import_v49.z.string(), import_v49.z.string()).optional().describe("Custom headers to send"),
|
|
1685
|
+
authorization: import_v49.z.string().optional().describe("Authorization header value")
|
|
1540
1686
|
})
|
|
1541
1687
|
)
|
|
1542
1688
|
);
|
|
1543
|
-
var mcpServerOutputSchema = (0,
|
|
1544
|
-
() => (0,
|
|
1545
|
-
|
|
1546
|
-
name:
|
|
1547
|
-
arguments:
|
|
1548
|
-
result:
|
|
1689
|
+
var mcpServerOutputSchema = (0, import_provider_utils7.lazySchema)(
|
|
1690
|
+
() => (0, import_provider_utils7.zodSchema)(
|
|
1691
|
+
import_v49.z.object({
|
|
1692
|
+
name: import_v49.z.string(),
|
|
1693
|
+
arguments: import_v49.z.string(),
|
|
1694
|
+
result: import_v49.z.unknown()
|
|
1549
1695
|
})
|
|
1550
1696
|
)
|
|
1551
1697
|
);
|
|
1552
|
-
var mcpServerToolFactory = (0,
|
|
1698
|
+
var mcpServerToolFactory = (0, import_provider_utils7.createProviderToolFactoryWithOutputSchema)({
|
|
1553
1699
|
id: "xai.mcp",
|
|
1554
|
-
inputSchema: (0,
|
|
1700
|
+
inputSchema: (0, import_provider_utils7.lazySchema)(() => (0, import_provider_utils7.zodSchema)(import_v49.z.object({}))),
|
|
1555
1701
|
outputSchema: mcpServerOutputSchema
|
|
1556
1702
|
});
|
|
1557
1703
|
var mcpServer = (args) => mcpServerToolFactory(args);
|
|
1558
1704
|
|
|
1559
1705
|
// src/tool/web-search.ts
|
|
1560
|
-
var
|
|
1561
|
-
var
|
|
1562
|
-
var webSearchArgsSchema = (0,
|
|
1563
|
-
() => (0,
|
|
1564
|
-
|
|
1565
|
-
allowedDomains:
|
|
1566
|
-
excludedDomains:
|
|
1567
|
-
enableImageUnderstanding:
|
|
1706
|
+
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1707
|
+
var import_v410 = require("zod/v4");
|
|
1708
|
+
var webSearchArgsSchema = (0, import_provider_utils8.lazySchema)(
|
|
1709
|
+
() => (0, import_provider_utils8.zodSchema)(
|
|
1710
|
+
import_v410.z.object({
|
|
1711
|
+
allowedDomains: import_v410.z.array(import_v410.z.string()).max(5).optional(),
|
|
1712
|
+
excludedDomains: import_v410.z.array(import_v410.z.string()).max(5).optional(),
|
|
1713
|
+
enableImageUnderstanding: import_v410.z.boolean().optional()
|
|
1568
1714
|
})
|
|
1569
1715
|
)
|
|
1570
1716
|
);
|
|
1571
|
-
var webSearchOutputSchema = (0,
|
|
1572
|
-
() => (0,
|
|
1573
|
-
|
|
1574
|
-
query:
|
|
1575
|
-
sources:
|
|
1576
|
-
|
|
1577
|
-
title:
|
|
1578
|
-
url:
|
|
1579
|
-
snippet:
|
|
1717
|
+
var webSearchOutputSchema = (0, import_provider_utils8.lazySchema)(
|
|
1718
|
+
() => (0, import_provider_utils8.zodSchema)(
|
|
1719
|
+
import_v410.z.object({
|
|
1720
|
+
query: import_v410.z.string(),
|
|
1721
|
+
sources: import_v410.z.array(
|
|
1722
|
+
import_v410.z.object({
|
|
1723
|
+
title: import_v410.z.string(),
|
|
1724
|
+
url: import_v410.z.string(),
|
|
1725
|
+
snippet: import_v410.z.string()
|
|
1580
1726
|
})
|
|
1581
1727
|
)
|
|
1582
1728
|
})
|
|
1583
1729
|
)
|
|
1584
1730
|
);
|
|
1585
|
-
var webSearchToolFactory = (0,
|
|
1731
|
+
var webSearchToolFactory = (0, import_provider_utils8.createProviderToolFactoryWithOutputSchema)({
|
|
1586
1732
|
id: "xai.web_search",
|
|
1587
|
-
inputSchema: (0,
|
|
1733
|
+
inputSchema: (0, import_provider_utils8.lazySchema)(() => (0, import_provider_utils8.zodSchema)(import_v410.z.object({}))),
|
|
1588
1734
|
outputSchema: webSearchOutputSchema
|
|
1589
1735
|
});
|
|
1590
1736
|
var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
1591
1737
|
|
|
1592
1738
|
// src/tool/x-search.ts
|
|
1593
|
-
var
|
|
1594
|
-
var
|
|
1595
|
-
var xSearchArgsSchema = (0,
|
|
1596
|
-
() => (0,
|
|
1597
|
-
|
|
1598
|
-
allowedXHandles:
|
|
1599
|
-
excludedXHandles:
|
|
1600
|
-
fromDate:
|
|
1601
|
-
toDate:
|
|
1602
|
-
enableImageUnderstanding:
|
|
1603
|
-
enableVideoUnderstanding:
|
|
1739
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1740
|
+
var import_v411 = require("zod/v4");
|
|
1741
|
+
var xSearchArgsSchema = (0, import_provider_utils9.lazySchema)(
|
|
1742
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
1743
|
+
import_v411.z.object({
|
|
1744
|
+
allowedXHandles: import_v411.z.array(import_v411.z.string()).max(10).optional(),
|
|
1745
|
+
excludedXHandles: import_v411.z.array(import_v411.z.string()).max(10).optional(),
|
|
1746
|
+
fromDate: import_v411.z.string().optional(),
|
|
1747
|
+
toDate: import_v411.z.string().optional(),
|
|
1748
|
+
enableImageUnderstanding: import_v411.z.boolean().optional(),
|
|
1749
|
+
enableVideoUnderstanding: import_v411.z.boolean().optional()
|
|
1604
1750
|
})
|
|
1605
1751
|
)
|
|
1606
1752
|
);
|
|
1607
|
-
var xSearchOutputSchema = (0,
|
|
1608
|
-
() => (0,
|
|
1609
|
-
|
|
1610
|
-
query:
|
|
1611
|
-
posts:
|
|
1612
|
-
|
|
1613
|
-
author:
|
|
1614
|
-
text:
|
|
1615
|
-
url:
|
|
1616
|
-
likes:
|
|
1753
|
+
var xSearchOutputSchema = (0, import_provider_utils9.lazySchema)(
|
|
1754
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
1755
|
+
import_v411.z.object({
|
|
1756
|
+
query: import_v411.z.string(),
|
|
1757
|
+
posts: import_v411.z.array(
|
|
1758
|
+
import_v411.z.object({
|
|
1759
|
+
author: import_v411.z.string(),
|
|
1760
|
+
text: import_v411.z.string(),
|
|
1761
|
+
url: import_v411.z.string(),
|
|
1762
|
+
likes: import_v411.z.number()
|
|
1617
1763
|
})
|
|
1618
1764
|
)
|
|
1619
1765
|
})
|
|
1620
1766
|
)
|
|
1621
1767
|
);
|
|
1622
|
-
var xSearchToolFactory = (0,
|
|
1768
|
+
var xSearchToolFactory = (0, import_provider_utils9.createProviderToolFactoryWithOutputSchema)({
|
|
1623
1769
|
id: "xai.x_search",
|
|
1624
|
-
inputSchema: (0,
|
|
1770
|
+
inputSchema: (0, import_provider_utils9.lazySchema)(() => (0, import_provider_utils9.zodSchema)(import_v411.z.object({}))),
|
|
1625
1771
|
outputSchema: xSearchOutputSchema
|
|
1626
1772
|
});
|
|
1627
1773
|
var xSearch = (args = {}) => xSearchToolFactory(args);
|
|
@@ -1643,7 +1789,7 @@ async function prepareResponsesTools({
|
|
|
1643
1789
|
if (tool.type === "provider") {
|
|
1644
1790
|
switch (tool.id) {
|
|
1645
1791
|
case "xai.web_search": {
|
|
1646
|
-
const args = await (0,
|
|
1792
|
+
const args = await (0, import_provider_utils10.validateTypes)({
|
|
1647
1793
|
value: tool.args,
|
|
1648
1794
|
schema: webSearchArgsSchema
|
|
1649
1795
|
});
|
|
@@ -1656,7 +1802,7 @@ async function prepareResponsesTools({
|
|
|
1656
1802
|
break;
|
|
1657
1803
|
}
|
|
1658
1804
|
case "xai.x_search": {
|
|
1659
|
-
const args = await (0,
|
|
1805
|
+
const args = await (0, import_provider_utils10.validateTypes)({
|
|
1660
1806
|
value: tool.args,
|
|
1661
1807
|
schema: xSearchArgsSchema
|
|
1662
1808
|
});
|
|
@@ -1690,7 +1836,7 @@ async function prepareResponsesTools({
|
|
|
1690
1836
|
break;
|
|
1691
1837
|
}
|
|
1692
1838
|
case "xai.file_search": {
|
|
1693
|
-
const args = await (0,
|
|
1839
|
+
const args = await (0, import_provider_utils10.validateTypes)({
|
|
1694
1840
|
value: tool.args,
|
|
1695
1841
|
schema: fileSearchArgsSchema
|
|
1696
1842
|
});
|
|
@@ -1702,7 +1848,7 @@ async function prepareResponsesTools({
|
|
|
1702
1848
|
break;
|
|
1703
1849
|
}
|
|
1704
1850
|
case "xai.mcp": {
|
|
1705
|
-
const args = await (0,
|
|
1851
|
+
const args = await (0, import_provider_utils10.validateTypes)({
|
|
1706
1852
|
value: tool.args,
|
|
1707
1853
|
schema: mcpServerArgsSchema
|
|
1708
1854
|
});
|
|
@@ -1802,7 +1948,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1802
1948
|
}) {
|
|
1803
1949
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1804
1950
|
const warnings = [];
|
|
1805
|
-
const options = (_a = await (0,
|
|
1951
|
+
const options = (_a = await (0, import_provider_utils11.parseProviderOptions)({
|
|
1806
1952
|
provider: "xai",
|
|
1807
1953
|
providerOptions,
|
|
1808
1954
|
schema: xaiResponsesProviderOptions
|
|
@@ -1909,12 +2055,12 @@ var XaiResponsesLanguageModel = class {
|
|
|
1909
2055
|
responseHeaders,
|
|
1910
2056
|
value: response,
|
|
1911
2057
|
rawValue: rawResponse
|
|
1912
|
-
} = await (0,
|
|
2058
|
+
} = await (0, import_provider_utils11.postJsonToApi)({
|
|
1913
2059
|
url: `${(_a = this.config.baseURL) != null ? _a : "https://api.x.ai/v1"}/responses`,
|
|
1914
|
-
headers: (0,
|
|
2060
|
+
headers: (0, import_provider_utils11.combineHeaders)(this.config.headers(), options.headers),
|
|
1915
2061
|
body,
|
|
1916
2062
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
1917
|
-
successfulResponseHandler: (0,
|
|
2063
|
+
successfulResponseHandler: (0, import_provider_utils11.createJsonResponseHandler)(
|
|
1918
2064
|
xaiResponsesResponseSchema
|
|
1919
2065
|
),
|
|
1920
2066
|
abortSignal: options.abortSignal,
|
|
@@ -2078,12 +2224,12 @@ var XaiResponsesLanguageModel = class {
|
|
|
2078
2224
|
...args,
|
|
2079
2225
|
stream: true
|
|
2080
2226
|
};
|
|
2081
|
-
const { responseHeaders, value: response } = await (0,
|
|
2227
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils11.postJsonToApi)({
|
|
2082
2228
|
url: `${(_a = this.config.baseURL) != null ? _a : "https://api.x.ai/v1"}/responses`,
|
|
2083
|
-
headers: (0,
|
|
2229
|
+
headers: (0, import_provider_utils11.combineHeaders)(this.config.headers(), options.headers),
|
|
2084
2230
|
body,
|
|
2085
2231
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
2086
|
-
successfulResponseHandler: (0,
|
|
2232
|
+
successfulResponseHandler: (0, import_provider_utils11.createEventSourceResponseHandler)(
|
|
2087
2233
|
xaiResponsesChunkSchema
|
|
2088
2234
|
),
|
|
2089
2235
|
abortSignal: options.abortSignal,
|
|
@@ -2462,44 +2608,44 @@ var XaiResponsesLanguageModel = class {
|
|
|
2462
2608
|
};
|
|
2463
2609
|
|
|
2464
2610
|
// src/tool/code-execution.ts
|
|
2465
|
-
var
|
|
2466
|
-
var
|
|
2467
|
-
var codeExecutionOutputSchema =
|
|
2468
|
-
output:
|
|
2469
|
-
error:
|
|
2611
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
2612
|
+
var import_v412 = require("zod/v4");
|
|
2613
|
+
var codeExecutionOutputSchema = import_v412.z.object({
|
|
2614
|
+
output: import_v412.z.string().describe("the output of the code execution"),
|
|
2615
|
+
error: import_v412.z.string().optional().describe("any error that occurred")
|
|
2470
2616
|
});
|
|
2471
|
-
var codeExecutionToolFactory = (0,
|
|
2617
|
+
var codeExecutionToolFactory = (0, import_provider_utils12.createProviderToolFactoryWithOutputSchema)({
|
|
2472
2618
|
id: "xai.code_execution",
|
|
2473
|
-
inputSchema:
|
|
2619
|
+
inputSchema: import_v412.z.object({}).describe("no input parameters"),
|
|
2474
2620
|
outputSchema: codeExecutionOutputSchema
|
|
2475
2621
|
});
|
|
2476
2622
|
var codeExecution = (args = {}) => codeExecutionToolFactory(args);
|
|
2477
2623
|
|
|
2478
2624
|
// src/tool/view-image.ts
|
|
2479
|
-
var
|
|
2480
|
-
var
|
|
2481
|
-
var viewImageOutputSchema =
|
|
2482
|
-
description:
|
|
2483
|
-
objects:
|
|
2625
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
2626
|
+
var import_v413 = require("zod/v4");
|
|
2627
|
+
var viewImageOutputSchema = import_v413.z.object({
|
|
2628
|
+
description: import_v413.z.string().describe("description of the image"),
|
|
2629
|
+
objects: import_v413.z.array(import_v413.z.string()).optional().describe("objects detected in the image")
|
|
2484
2630
|
});
|
|
2485
|
-
var viewImageToolFactory = (0,
|
|
2631
|
+
var viewImageToolFactory = (0, import_provider_utils13.createProviderToolFactoryWithOutputSchema)({
|
|
2486
2632
|
id: "xai.view_image",
|
|
2487
|
-
inputSchema:
|
|
2633
|
+
inputSchema: import_v413.z.object({}).describe("no input parameters"),
|
|
2488
2634
|
outputSchema: viewImageOutputSchema
|
|
2489
2635
|
});
|
|
2490
2636
|
var viewImage = (args = {}) => viewImageToolFactory(args);
|
|
2491
2637
|
|
|
2492
2638
|
// src/tool/view-x-video.ts
|
|
2493
|
-
var
|
|
2494
|
-
var
|
|
2495
|
-
var viewXVideoOutputSchema =
|
|
2496
|
-
transcript:
|
|
2497
|
-
description:
|
|
2498
|
-
duration:
|
|
2639
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
2640
|
+
var import_v414 = require("zod/v4");
|
|
2641
|
+
var viewXVideoOutputSchema = import_v414.z.object({
|
|
2642
|
+
transcript: import_v414.z.string().optional().describe("transcript of the video"),
|
|
2643
|
+
description: import_v414.z.string().describe("description of the video content"),
|
|
2644
|
+
duration: import_v414.z.number().optional().describe("duration in seconds")
|
|
2499
2645
|
});
|
|
2500
|
-
var viewXVideoToolFactory = (0,
|
|
2646
|
+
var viewXVideoToolFactory = (0, import_provider_utils14.createProviderToolFactoryWithOutputSchema)({
|
|
2501
2647
|
id: "xai.view_x_video",
|
|
2502
|
-
inputSchema:
|
|
2648
|
+
inputSchema: import_v414.z.object({}).describe("no input parameters"),
|
|
2503
2649
|
outputSchema: viewXVideoOutputSchema
|
|
2504
2650
|
});
|
|
2505
2651
|
var viewXVideo = (args = {}) => viewXVideoToolFactory(args);
|
|
@@ -2516,21 +2662,17 @@ var xaiTools = {
|
|
|
2516
2662
|
};
|
|
2517
2663
|
|
|
2518
2664
|
// src/version.ts
|
|
2519
|
-
var VERSION = true ? "3.0.
|
|
2665
|
+
var VERSION = true ? "3.0.52" : "0.0.0-test";
|
|
2520
2666
|
|
|
2521
2667
|
// src/xai-provider.ts
|
|
2522
|
-
var xaiErrorStructure = {
|
|
2523
|
-
errorSchema: xaiErrorDataSchema,
|
|
2524
|
-
errorToMessage: (data) => data.error.message
|
|
2525
|
-
};
|
|
2526
2668
|
function createXai(options = {}) {
|
|
2527
2669
|
var _a;
|
|
2528
|
-
const baseURL = (0,
|
|
2670
|
+
const baseURL = (0, import_provider_utils15.withoutTrailingSlash)(
|
|
2529
2671
|
(_a = options.baseURL) != null ? _a : "https://api.x.ai/v1"
|
|
2530
2672
|
);
|
|
2531
|
-
const getHeaders = () => (0,
|
|
2673
|
+
const getHeaders = () => (0, import_provider_utils15.withUserAgentSuffix)(
|
|
2532
2674
|
{
|
|
2533
|
-
Authorization: `Bearer ${(0,
|
|
2675
|
+
Authorization: `Bearer ${(0, import_provider_utils15.loadApiKey)({
|
|
2534
2676
|
apiKey: options.apiKey,
|
|
2535
2677
|
environmentVariableName: "XAI_API_KEY",
|
|
2536
2678
|
description: "xAI API key"
|
|
@@ -2544,7 +2686,7 @@ function createXai(options = {}) {
|
|
|
2544
2686
|
provider: "xai.chat",
|
|
2545
2687
|
baseURL,
|
|
2546
2688
|
headers: getHeaders,
|
|
2547
|
-
generateId:
|
|
2689
|
+
generateId: import_provider_utils15.generateId,
|
|
2548
2690
|
fetch: options.fetch
|
|
2549
2691
|
});
|
|
2550
2692
|
};
|
|
@@ -2553,17 +2695,16 @@ function createXai(options = {}) {
|
|
|
2553
2695
|
provider: "xai.responses",
|
|
2554
2696
|
baseURL,
|
|
2555
2697
|
headers: getHeaders,
|
|
2556
|
-
generateId:
|
|
2698
|
+
generateId: import_provider_utils15.generateId,
|
|
2557
2699
|
fetch: options.fetch
|
|
2558
2700
|
});
|
|
2559
2701
|
};
|
|
2560
2702
|
const createImageModel = (modelId) => {
|
|
2561
|
-
return new
|
|
2703
|
+
return new XaiImageModel(modelId, {
|
|
2562
2704
|
provider: "xai.image",
|
|
2563
|
-
|
|
2705
|
+
baseURL,
|
|
2564
2706
|
headers: getHeaders,
|
|
2565
|
-
fetch: options.fetch
|
|
2566
|
-
errorStructure: xaiErrorStructure
|
|
2707
|
+
fetch: options.fetch
|
|
2567
2708
|
});
|
|
2568
2709
|
};
|
|
2569
2710
|
const provider = (modelId) => createChatLanguageModel(modelId);
|