@ai-sdk/xai 3.0.104 → 3.0.105
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 +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +630 -591
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +640 -601
- package/dist/index.mjs.map +1 -1
- package/docs/01-xai.mdx +36 -0
- package/package.json +3 -3
- package/src/convert-to-xai-chat-messages.ts +47 -34
- package/src/index.ts +1 -0
- package/src/responses/convert-to-xai-responses-input.ts +15 -2
- package/src/responses/xai-responses-api.ts +5 -1
- package/src/xai-chat-language-model.ts +1 -1
- package/src/xai-chat-prompt.ts +4 -1
- package/src/xai-file-part-options.ts +21 -0
package/dist/index.js
CHANGED
|
@@ -40,12 +40,31 @@ var import_provider_utils17 = require("@ai-sdk/provider-utils");
|
|
|
40
40
|
// src/xai-chat-language-model.ts
|
|
41
41
|
var import_provider3 = require("@ai-sdk/provider");
|
|
42
42
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
43
|
-
var
|
|
43
|
+
var import_v44 = require("zod/v4");
|
|
44
44
|
|
|
45
45
|
// src/convert-to-xai-chat-messages.ts
|
|
46
46
|
var import_provider = require("@ai-sdk/provider");
|
|
47
47
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
48
|
-
|
|
48
|
+
|
|
49
|
+
// src/xai-file-part-options.ts
|
|
50
|
+
var import_v4 = require("zod/v4");
|
|
51
|
+
var xaiFilePartProviderOptions = import_v4.z.object({
|
|
52
|
+
/**
|
|
53
|
+
* Controls the resolution at which the model processes the image.
|
|
54
|
+
* `low` processes the image at reduced resolution and consumes fewer
|
|
55
|
+
* input tokens, `high` processes the image at full resolution, and
|
|
56
|
+
* `auto` lets the API decide. Defaults to full resolution when not set.
|
|
57
|
+
*
|
|
58
|
+
* Note: the xAI API silently ignores invalid values, so the value is
|
|
59
|
+
* validated client-side.
|
|
60
|
+
*
|
|
61
|
+
* @see https://docs.x.ai/developers/model-capabilities/images/understanding
|
|
62
|
+
*/
|
|
63
|
+
imageDetail: import_v4.z.enum(["low", "high", "auto"]).optional()
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// src/convert-to-xai-chat-messages.ts
|
|
67
|
+
async function convertToXaiChatMessages(prompt) {
|
|
49
68
|
var _a;
|
|
50
69
|
const messages = [];
|
|
51
70
|
const warnings = [];
|
|
@@ -60,31 +79,40 @@ function convertToXaiChatMessages(prompt) {
|
|
|
60
79
|
messages.push({ role: "user", content: content[0].text });
|
|
61
80
|
break;
|
|
62
81
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
const userContent = [];
|
|
83
|
+
for (const part of content) {
|
|
84
|
+
switch (part.type) {
|
|
85
|
+
case "text": {
|
|
86
|
+
userContent.push({ type: "text", text: part.text });
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
case "file": {
|
|
90
|
+
if (part.mediaType.startsWith("image/")) {
|
|
91
|
+
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
92
|
+
const filePartOptions = await (0, import_provider_utils.parseProviderOptions)({
|
|
93
|
+
provider: "xai",
|
|
94
|
+
providerOptions: part.providerOptions,
|
|
95
|
+
schema: xaiFilePartProviderOptions
|
|
96
|
+
});
|
|
97
|
+
userContent.push({
|
|
98
|
+
type: "image_url",
|
|
99
|
+
image_url: {
|
|
100
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils.convertToBase64)(part.data)}`,
|
|
101
|
+
...(filePartOptions == null ? void 0 : filePartOptions.imageDetail) != null && {
|
|
102
|
+
detail: filePartOptions.imageDetail
|
|
77
103
|
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
} else {
|
|
107
|
+
throw new import_provider.UnsupportedFunctionalityError({
|
|
108
|
+
functionality: `file part media type ${part.mediaType}`
|
|
109
|
+
});
|
|
84
110
|
}
|
|
111
|
+
break;
|
|
85
112
|
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
messages.push({ role: "user", content: userContent });
|
|
88
116
|
break;
|
|
89
117
|
}
|
|
90
118
|
case "assistant": {
|
|
@@ -209,53 +237,53 @@ function mapXaiFinishReason(finishReason) {
|
|
|
209
237
|
}
|
|
210
238
|
|
|
211
239
|
// src/xai-chat-options.ts
|
|
212
|
-
var
|
|
213
|
-
var webSourceSchema =
|
|
214
|
-
type:
|
|
215
|
-
country:
|
|
216
|
-
excludedWebsites:
|
|
217
|
-
allowedWebsites:
|
|
218
|
-
safeSearch:
|
|
240
|
+
var import_v42 = require("zod/v4");
|
|
241
|
+
var webSourceSchema = import_v42.z.object({
|
|
242
|
+
type: import_v42.z.literal("web"),
|
|
243
|
+
country: import_v42.z.string().length(2).optional(),
|
|
244
|
+
excludedWebsites: import_v42.z.array(import_v42.z.string()).max(5).optional(),
|
|
245
|
+
allowedWebsites: import_v42.z.array(import_v42.z.string()).max(5).optional(),
|
|
246
|
+
safeSearch: import_v42.z.boolean().optional()
|
|
219
247
|
});
|
|
220
|
-
var xSourceSchema =
|
|
221
|
-
type:
|
|
222
|
-
excludedXHandles:
|
|
223
|
-
includedXHandles:
|
|
224
|
-
postFavoriteCount:
|
|
225
|
-
postViewCount:
|
|
248
|
+
var xSourceSchema = import_v42.z.object({
|
|
249
|
+
type: import_v42.z.literal("x"),
|
|
250
|
+
excludedXHandles: import_v42.z.array(import_v42.z.string()).optional(),
|
|
251
|
+
includedXHandles: import_v42.z.array(import_v42.z.string()).optional(),
|
|
252
|
+
postFavoriteCount: import_v42.z.number().int().optional(),
|
|
253
|
+
postViewCount: import_v42.z.number().int().optional(),
|
|
226
254
|
/**
|
|
227
255
|
* @deprecated use `includedXHandles` instead
|
|
228
256
|
*/
|
|
229
|
-
xHandles:
|
|
257
|
+
xHandles: import_v42.z.array(import_v42.z.string()).optional()
|
|
230
258
|
});
|
|
231
|
-
var newsSourceSchema =
|
|
232
|
-
type:
|
|
233
|
-
country:
|
|
234
|
-
excludedWebsites:
|
|
235
|
-
safeSearch:
|
|
259
|
+
var newsSourceSchema = import_v42.z.object({
|
|
260
|
+
type: import_v42.z.literal("news"),
|
|
261
|
+
country: import_v42.z.string().length(2).optional(),
|
|
262
|
+
excludedWebsites: import_v42.z.array(import_v42.z.string()).max(5).optional(),
|
|
263
|
+
safeSearch: import_v42.z.boolean().optional()
|
|
236
264
|
});
|
|
237
|
-
var rssSourceSchema =
|
|
238
|
-
type:
|
|
239
|
-
links:
|
|
265
|
+
var rssSourceSchema = import_v42.z.object({
|
|
266
|
+
type: import_v42.z.literal("rss"),
|
|
267
|
+
links: import_v42.z.array(import_v42.z.string().url()).max(1)
|
|
240
268
|
// currently only supports one RSS link
|
|
241
269
|
});
|
|
242
|
-
var searchSourceSchema =
|
|
270
|
+
var searchSourceSchema = import_v42.z.discriminatedUnion("type", [
|
|
243
271
|
webSourceSchema,
|
|
244
272
|
xSourceSchema,
|
|
245
273
|
newsSourceSchema,
|
|
246
274
|
rssSourceSchema
|
|
247
275
|
]);
|
|
248
|
-
var xaiLanguageModelChatOptions =
|
|
249
|
-
reasoningEffort:
|
|
250
|
-
logprobs:
|
|
251
|
-
topLogprobs:
|
|
276
|
+
var xaiLanguageModelChatOptions = import_v42.z.object({
|
|
277
|
+
reasoningEffort: import_v42.z.enum(["none", "low", "medium", "high"]).optional(),
|
|
278
|
+
logprobs: import_v42.z.boolean().optional(),
|
|
279
|
+
topLogprobs: import_v42.z.number().int().min(0).max(8).optional(),
|
|
252
280
|
/**
|
|
253
281
|
* Whether to enable parallel function calling during tool use.
|
|
254
282
|
* When true, the model can call multiple functions in parallel.
|
|
255
283
|
* When false, the model will call functions sequentially.
|
|
256
284
|
* Defaults to true.
|
|
257
285
|
*/
|
|
258
|
-
parallel_function_calling:
|
|
286
|
+
parallel_function_calling: import_v42.z.boolean().optional(),
|
|
259
287
|
/**
|
|
260
288
|
* @deprecated xAI has deprecated Live Search (`search_parameters`) in favor
|
|
261
289
|
* of the Agent Tools API. Requests using this option now return a "Live
|
|
@@ -265,32 +293,32 @@ var xaiLanguageModelChatOptions = import_v4.z.object({
|
|
|
265
293
|
*
|
|
266
294
|
* @see https://docs.x.ai/docs/guides/tools/overview
|
|
267
295
|
*/
|
|
268
|
-
searchParameters:
|
|
296
|
+
searchParameters: import_v42.z.object({
|
|
269
297
|
/**
|
|
270
298
|
* search mode preference
|
|
271
299
|
* - "off": disables search completely
|
|
272
300
|
* - "auto": model decides whether to search (default)
|
|
273
301
|
* - "on": always enables search
|
|
274
302
|
*/
|
|
275
|
-
mode:
|
|
303
|
+
mode: import_v42.z.enum(["off", "auto", "on"]),
|
|
276
304
|
/**
|
|
277
305
|
* whether to return citations in the response
|
|
278
306
|
* defaults to true
|
|
279
307
|
*/
|
|
280
|
-
returnCitations:
|
|
308
|
+
returnCitations: import_v42.z.boolean().optional(),
|
|
281
309
|
/**
|
|
282
310
|
* start date for search data (ISO8601 format: YYYY-MM-DD)
|
|
283
311
|
*/
|
|
284
|
-
fromDate:
|
|
312
|
+
fromDate: import_v42.z.string().optional(),
|
|
285
313
|
/**
|
|
286
314
|
* end date for search data (ISO8601 format: YYYY-MM-DD)
|
|
287
315
|
*/
|
|
288
|
-
toDate:
|
|
316
|
+
toDate: import_v42.z.string().optional(),
|
|
289
317
|
/**
|
|
290
318
|
* maximum number of search results to consider
|
|
291
319
|
* defaults to 20
|
|
292
320
|
*/
|
|
293
|
-
maxSearchResults:
|
|
321
|
+
maxSearchResults: import_v42.z.number().min(1).max(50).optional(),
|
|
294
322
|
/**
|
|
295
323
|
* data sources to search from.
|
|
296
324
|
* defaults to [{ type: 'web' }, { type: 'x' }] if not specified.
|
|
@@ -298,26 +326,26 @@ var xaiLanguageModelChatOptions = import_v4.z.object({
|
|
|
298
326
|
* @example
|
|
299
327
|
* sources: [{ type: 'web', country: 'US' }, { type: 'x' }]
|
|
300
328
|
*/
|
|
301
|
-
sources:
|
|
329
|
+
sources: import_v42.z.array(searchSourceSchema).optional()
|
|
302
330
|
}).optional()
|
|
303
331
|
});
|
|
304
332
|
|
|
305
333
|
// src/xai-error.ts
|
|
306
334
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
307
|
-
var
|
|
308
|
-
var chatCompletionsErrorSchema =
|
|
309
|
-
error:
|
|
310
|
-
message:
|
|
311
|
-
type:
|
|
312
|
-
param:
|
|
313
|
-
code:
|
|
335
|
+
var import_v43 = require("zod/v4");
|
|
336
|
+
var chatCompletionsErrorSchema = import_v43.z.object({
|
|
337
|
+
error: import_v43.z.object({
|
|
338
|
+
message: import_v43.z.string(),
|
|
339
|
+
type: import_v43.z.string().nullish(),
|
|
340
|
+
param: import_v43.z.any().nullish(),
|
|
341
|
+
code: import_v43.z.union([import_v43.z.string(), import_v43.z.number()]).nullish()
|
|
314
342
|
})
|
|
315
343
|
});
|
|
316
|
-
var responsesErrorSchema =
|
|
317
|
-
code:
|
|
318
|
-
error:
|
|
344
|
+
var responsesErrorSchema = import_v43.z.object({
|
|
345
|
+
code: import_v43.z.string(),
|
|
346
|
+
error: import_v43.z.string()
|
|
319
347
|
});
|
|
320
|
-
var xaiErrorDataSchema =
|
|
348
|
+
var xaiErrorDataSchema = import_v43.z.union([
|
|
321
349
|
chatCompletionsErrorSchema,
|
|
322
350
|
responsesErrorSchema
|
|
323
351
|
]);
|
|
@@ -451,7 +479,7 @@ var XaiChatLanguageModel = class {
|
|
|
451
479
|
if (stopSequences != null) {
|
|
452
480
|
warnings.push({ type: "unsupported", feature: "stopSequences" });
|
|
453
481
|
}
|
|
454
|
-
const { messages, warnings: messageWarnings } = convertToXaiChatMessages(prompt);
|
|
482
|
+
const { messages, warnings: messageWarnings } = await convertToXaiChatMessages(prompt);
|
|
455
483
|
warnings.push(...messageWarnings);
|
|
456
484
|
const {
|
|
457
485
|
tools: xaiTools2,
|
|
@@ -839,100 +867,100 @@ var XaiChatLanguageModel = class {
|
|
|
839
867
|
};
|
|
840
868
|
}
|
|
841
869
|
};
|
|
842
|
-
var xaiUsageSchema =
|
|
843
|
-
prompt_tokens:
|
|
844
|
-
completion_tokens:
|
|
845
|
-
total_tokens:
|
|
846
|
-
prompt_tokens_details:
|
|
847
|
-
text_tokens:
|
|
848
|
-
audio_tokens:
|
|
849
|
-
image_tokens:
|
|
850
|
-
cached_tokens:
|
|
870
|
+
var xaiUsageSchema = import_v44.z.object({
|
|
871
|
+
prompt_tokens: import_v44.z.number(),
|
|
872
|
+
completion_tokens: import_v44.z.number(),
|
|
873
|
+
total_tokens: import_v44.z.number(),
|
|
874
|
+
prompt_tokens_details: import_v44.z.object({
|
|
875
|
+
text_tokens: import_v44.z.number().nullish(),
|
|
876
|
+
audio_tokens: import_v44.z.number().nullish(),
|
|
877
|
+
image_tokens: import_v44.z.number().nullish(),
|
|
878
|
+
cached_tokens: import_v44.z.number().nullish()
|
|
851
879
|
}).nullish(),
|
|
852
|
-
completion_tokens_details:
|
|
853
|
-
reasoning_tokens:
|
|
854
|
-
audio_tokens:
|
|
855
|
-
accepted_prediction_tokens:
|
|
856
|
-
rejected_prediction_tokens:
|
|
880
|
+
completion_tokens_details: import_v44.z.object({
|
|
881
|
+
reasoning_tokens: import_v44.z.number().nullish(),
|
|
882
|
+
audio_tokens: import_v44.z.number().nullish(),
|
|
883
|
+
accepted_prediction_tokens: import_v44.z.number().nullish(),
|
|
884
|
+
rejected_prediction_tokens: import_v44.z.number().nullish()
|
|
857
885
|
}).nullish()
|
|
858
886
|
});
|
|
859
|
-
var xaiChatResponseSchema =
|
|
860
|
-
id:
|
|
861
|
-
created:
|
|
862
|
-
model:
|
|
863
|
-
choices:
|
|
864
|
-
|
|
865
|
-
message:
|
|
866
|
-
role:
|
|
867
|
-
content:
|
|
868
|
-
reasoning_content:
|
|
869
|
-
tool_calls:
|
|
870
|
-
|
|
871
|
-
id:
|
|
872
|
-
type:
|
|
873
|
-
function:
|
|
874
|
-
name:
|
|
875
|
-
arguments:
|
|
887
|
+
var xaiChatResponseSchema = import_v44.z.object({
|
|
888
|
+
id: import_v44.z.string().nullish(),
|
|
889
|
+
created: import_v44.z.number().nullish(),
|
|
890
|
+
model: import_v44.z.string().nullish(),
|
|
891
|
+
choices: import_v44.z.array(
|
|
892
|
+
import_v44.z.object({
|
|
893
|
+
message: import_v44.z.object({
|
|
894
|
+
role: import_v44.z.literal("assistant"),
|
|
895
|
+
content: import_v44.z.string().nullish(),
|
|
896
|
+
reasoning_content: import_v44.z.string().nullish(),
|
|
897
|
+
tool_calls: import_v44.z.array(
|
|
898
|
+
import_v44.z.object({
|
|
899
|
+
id: import_v44.z.string(),
|
|
900
|
+
type: import_v44.z.literal("function"),
|
|
901
|
+
function: import_v44.z.object({
|
|
902
|
+
name: import_v44.z.string(),
|
|
903
|
+
arguments: import_v44.z.string()
|
|
876
904
|
})
|
|
877
905
|
})
|
|
878
906
|
).nullish()
|
|
879
907
|
}),
|
|
880
|
-
index:
|
|
881
|
-
finish_reason:
|
|
908
|
+
index: import_v44.z.number(),
|
|
909
|
+
finish_reason: import_v44.z.string().nullish()
|
|
882
910
|
})
|
|
883
911
|
).nullish(),
|
|
884
|
-
object:
|
|
912
|
+
object: import_v44.z.literal("chat.completion").nullish(),
|
|
885
913
|
usage: xaiUsageSchema.nullish(),
|
|
886
|
-
citations:
|
|
887
|
-
code:
|
|
888
|
-
error:
|
|
914
|
+
citations: import_v44.z.array(import_v44.z.string().url()).nullish(),
|
|
915
|
+
code: import_v44.z.string().nullish(),
|
|
916
|
+
error: import_v44.z.string().nullish()
|
|
889
917
|
});
|
|
890
|
-
var xaiChatChunkSchema =
|
|
891
|
-
id:
|
|
892
|
-
created:
|
|
893
|
-
model:
|
|
894
|
-
choices:
|
|
895
|
-
|
|
896
|
-
delta:
|
|
897
|
-
role:
|
|
898
|
-
content:
|
|
899
|
-
reasoning_content:
|
|
900
|
-
tool_calls:
|
|
901
|
-
|
|
902
|
-
id:
|
|
903
|
-
type:
|
|
904
|
-
function:
|
|
905
|
-
name:
|
|
906
|
-
arguments:
|
|
918
|
+
var xaiChatChunkSchema = import_v44.z.object({
|
|
919
|
+
id: import_v44.z.string().nullish(),
|
|
920
|
+
created: import_v44.z.number().nullish(),
|
|
921
|
+
model: import_v44.z.string().nullish(),
|
|
922
|
+
choices: import_v44.z.array(
|
|
923
|
+
import_v44.z.object({
|
|
924
|
+
delta: import_v44.z.object({
|
|
925
|
+
role: import_v44.z.enum(["assistant"]).optional(),
|
|
926
|
+
content: import_v44.z.string().nullish(),
|
|
927
|
+
reasoning_content: import_v44.z.string().nullish(),
|
|
928
|
+
tool_calls: import_v44.z.array(
|
|
929
|
+
import_v44.z.object({
|
|
930
|
+
id: import_v44.z.string(),
|
|
931
|
+
type: import_v44.z.literal("function"),
|
|
932
|
+
function: import_v44.z.object({
|
|
933
|
+
name: import_v44.z.string(),
|
|
934
|
+
arguments: import_v44.z.string()
|
|
907
935
|
})
|
|
908
936
|
})
|
|
909
937
|
).nullish()
|
|
910
938
|
}),
|
|
911
|
-
finish_reason:
|
|
912
|
-
index:
|
|
939
|
+
finish_reason: import_v44.z.string().nullish(),
|
|
940
|
+
index: import_v44.z.number()
|
|
913
941
|
})
|
|
914
942
|
),
|
|
915
943
|
usage: xaiUsageSchema.nullish(),
|
|
916
|
-
citations:
|
|
944
|
+
citations: import_v44.z.array(import_v44.z.string().url()).nullish()
|
|
917
945
|
});
|
|
918
|
-
var xaiStreamErrorSchema =
|
|
919
|
-
code:
|
|
920
|
-
error:
|
|
946
|
+
var xaiStreamErrorSchema = import_v44.z.object({
|
|
947
|
+
code: import_v44.z.string(),
|
|
948
|
+
error: import_v44.z.string()
|
|
921
949
|
});
|
|
922
950
|
|
|
923
951
|
// src/xai-image-model.ts
|
|
924
952
|
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
925
|
-
var
|
|
953
|
+
var import_v46 = require("zod/v4");
|
|
926
954
|
|
|
927
955
|
// src/xai-image-options.ts
|
|
928
|
-
var
|
|
929
|
-
var xaiImageModelOptions =
|
|
930
|
-
aspect_ratio:
|
|
931
|
-
output_format:
|
|
932
|
-
sync_mode:
|
|
933
|
-
resolution:
|
|
934
|
-
quality:
|
|
935
|
-
user:
|
|
956
|
+
var import_v45 = require("zod/v4");
|
|
957
|
+
var xaiImageModelOptions = import_v45.z.object({
|
|
958
|
+
aspect_ratio: import_v45.z.string().optional(),
|
|
959
|
+
output_format: import_v45.z.string().optional(),
|
|
960
|
+
sync_mode: import_v45.z.boolean().optional(),
|
|
961
|
+
resolution: import_v45.z.enum(["1k", "2k"]).optional(),
|
|
962
|
+
quality: import_v45.z.enum(["low", "medium", "high"]).optional(),
|
|
963
|
+
user: import_v45.z.string().optional()
|
|
936
964
|
});
|
|
937
965
|
|
|
938
966
|
// src/xai-image-model.ts
|
|
@@ -1067,16 +1095,16 @@ var XaiImageModel = class {
|
|
|
1067
1095
|
return value;
|
|
1068
1096
|
}
|
|
1069
1097
|
};
|
|
1070
|
-
var xaiImageResponseSchema =
|
|
1071
|
-
data:
|
|
1072
|
-
|
|
1073
|
-
url:
|
|
1074
|
-
b64_json:
|
|
1075
|
-
revised_prompt:
|
|
1098
|
+
var xaiImageResponseSchema = import_v46.z.object({
|
|
1099
|
+
data: import_v46.z.array(
|
|
1100
|
+
import_v46.z.object({
|
|
1101
|
+
url: import_v46.z.string().nullish(),
|
|
1102
|
+
b64_json: import_v46.z.string().nullish(),
|
|
1103
|
+
revised_prompt: import_v46.z.string().nullish()
|
|
1076
1104
|
})
|
|
1077
1105
|
),
|
|
1078
|
-
usage:
|
|
1079
|
-
cost_in_usd_ticks:
|
|
1106
|
+
usage: import_v46.z.object({
|
|
1107
|
+
cost_in_usd_ticks: import_v46.z.number().nullish()
|
|
1080
1108
|
}).nullish()
|
|
1081
1109
|
});
|
|
1082
1110
|
|
|
@@ -1113,7 +1141,18 @@ async function convertToXaiResponsesInput({
|
|
|
1113
1141
|
if (block.mediaType.startsWith("image/")) {
|
|
1114
1142
|
const mediaType = block.mediaType === "image/*" ? "image/jpeg" : block.mediaType;
|
|
1115
1143
|
const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils5.convertToBase64)(block.data)}`;
|
|
1116
|
-
|
|
1144
|
+
const filePartOptions = await (0, import_provider_utils5.parseProviderOptions)({
|
|
1145
|
+
provider: "xai",
|
|
1146
|
+
providerOptions: block.providerOptions,
|
|
1147
|
+
schema: xaiFilePartProviderOptions
|
|
1148
|
+
});
|
|
1149
|
+
contentParts.push({
|
|
1150
|
+
type: "input_image",
|
|
1151
|
+
image_url: imageUrl,
|
|
1152
|
+
...(filePartOptions == null ? void 0 : filePartOptions.imageDetail) != null && {
|
|
1153
|
+
detail: filePartOptions.imageDetail
|
|
1154
|
+
}
|
|
1155
|
+
});
|
|
1117
1156
|
} else if (block.data instanceof URL) {
|
|
1118
1157
|
contentParts.push({
|
|
1119
1158
|
type: "input_file",
|
|
@@ -1311,461 +1350,461 @@ function mapXaiResponsesFinishReason(finishReason) {
|
|
|
1311
1350
|
}
|
|
1312
1351
|
|
|
1313
1352
|
// src/responses/xai-responses-api.ts
|
|
1314
|
-
var
|
|
1315
|
-
var annotationSchema =
|
|
1316
|
-
|
|
1317
|
-
type:
|
|
1318
|
-
url:
|
|
1319
|
-
title:
|
|
1353
|
+
var import_v47 = require("zod/v4");
|
|
1354
|
+
var annotationSchema = import_v47.z.union([
|
|
1355
|
+
import_v47.z.object({
|
|
1356
|
+
type: import_v47.z.literal("url_citation"),
|
|
1357
|
+
url: import_v47.z.string(),
|
|
1358
|
+
title: import_v47.z.string().optional()
|
|
1320
1359
|
}),
|
|
1321
|
-
|
|
1322
|
-
type:
|
|
1360
|
+
import_v47.z.object({
|
|
1361
|
+
type: import_v47.z.string()
|
|
1323
1362
|
})
|
|
1324
1363
|
]);
|
|
1325
|
-
var messageContentPartSchema =
|
|
1326
|
-
type:
|
|
1327
|
-
text:
|
|
1328
|
-
logprobs:
|
|
1329
|
-
annotations:
|
|
1364
|
+
var messageContentPartSchema = import_v47.z.object({
|
|
1365
|
+
type: import_v47.z.string(),
|
|
1366
|
+
text: import_v47.z.string().optional(),
|
|
1367
|
+
logprobs: import_v47.z.array(import_v47.z.any()).optional(),
|
|
1368
|
+
annotations: import_v47.z.array(annotationSchema).optional()
|
|
1330
1369
|
});
|
|
1331
|
-
var reasoningSummaryPartSchema =
|
|
1332
|
-
type:
|
|
1333
|
-
text:
|
|
1370
|
+
var reasoningSummaryPartSchema = import_v47.z.object({
|
|
1371
|
+
type: import_v47.z.string(),
|
|
1372
|
+
text: import_v47.z.string()
|
|
1334
1373
|
});
|
|
1335
|
-
var toolCallSchema =
|
|
1336
|
-
name:
|
|
1337
|
-
arguments:
|
|
1338
|
-
input:
|
|
1339
|
-
call_id:
|
|
1340
|
-
id:
|
|
1341
|
-
status:
|
|
1342
|
-
action:
|
|
1374
|
+
var toolCallSchema = import_v47.z.object({
|
|
1375
|
+
name: import_v47.z.string().optional(),
|
|
1376
|
+
arguments: import_v47.z.string().optional(),
|
|
1377
|
+
input: import_v47.z.string().optional(),
|
|
1378
|
+
call_id: import_v47.z.string().optional(),
|
|
1379
|
+
id: import_v47.z.string(),
|
|
1380
|
+
status: import_v47.z.string(),
|
|
1381
|
+
action: import_v47.z.any().optional()
|
|
1343
1382
|
});
|
|
1344
|
-
var mcpCallSchema =
|
|
1345
|
-
name:
|
|
1346
|
-
arguments:
|
|
1347
|
-
output:
|
|
1348
|
-
error:
|
|
1349
|
-
id:
|
|
1350
|
-
status:
|
|
1351
|
-
server_label:
|
|
1383
|
+
var mcpCallSchema = import_v47.z.object({
|
|
1384
|
+
name: import_v47.z.string().optional(),
|
|
1385
|
+
arguments: import_v47.z.string().optional(),
|
|
1386
|
+
output: import_v47.z.string().optional(),
|
|
1387
|
+
error: import_v47.z.string().optional(),
|
|
1388
|
+
id: import_v47.z.string(),
|
|
1389
|
+
status: import_v47.z.string(),
|
|
1390
|
+
server_label: import_v47.z.string().optional()
|
|
1352
1391
|
});
|
|
1353
|
-
var outputItemSchema =
|
|
1354
|
-
|
|
1355
|
-
type:
|
|
1392
|
+
var outputItemSchema = import_v47.z.discriminatedUnion("type", [
|
|
1393
|
+
import_v47.z.object({
|
|
1394
|
+
type: import_v47.z.literal("web_search_call"),
|
|
1356
1395
|
...toolCallSchema.shape
|
|
1357
1396
|
}),
|
|
1358
|
-
|
|
1359
|
-
type:
|
|
1397
|
+
import_v47.z.object({
|
|
1398
|
+
type: import_v47.z.literal("x_search_call"),
|
|
1360
1399
|
...toolCallSchema.shape
|
|
1361
1400
|
}),
|
|
1362
|
-
|
|
1363
|
-
type:
|
|
1401
|
+
import_v47.z.object({
|
|
1402
|
+
type: import_v47.z.literal("code_interpreter_call"),
|
|
1364
1403
|
...toolCallSchema.shape
|
|
1365
1404
|
}),
|
|
1366
|
-
|
|
1367
|
-
type:
|
|
1405
|
+
import_v47.z.object({
|
|
1406
|
+
type: import_v47.z.literal("code_execution_call"),
|
|
1368
1407
|
...toolCallSchema.shape
|
|
1369
1408
|
}),
|
|
1370
|
-
|
|
1371
|
-
type:
|
|
1409
|
+
import_v47.z.object({
|
|
1410
|
+
type: import_v47.z.literal("view_image_call"),
|
|
1372
1411
|
...toolCallSchema.shape
|
|
1373
1412
|
}),
|
|
1374
|
-
|
|
1375
|
-
type:
|
|
1413
|
+
import_v47.z.object({
|
|
1414
|
+
type: import_v47.z.literal("view_x_video_call"),
|
|
1376
1415
|
...toolCallSchema.shape
|
|
1377
1416
|
}),
|
|
1378
|
-
|
|
1379
|
-
type:
|
|
1380
|
-
id:
|
|
1381
|
-
status:
|
|
1382
|
-
queries:
|
|
1383
|
-
results:
|
|
1384
|
-
|
|
1385
|
-
file_id:
|
|
1386
|
-
filename:
|
|
1387
|
-
score:
|
|
1388
|
-
text:
|
|
1417
|
+
import_v47.z.object({
|
|
1418
|
+
type: import_v47.z.literal("file_search_call"),
|
|
1419
|
+
id: import_v47.z.string(),
|
|
1420
|
+
status: import_v47.z.string(),
|
|
1421
|
+
queries: import_v47.z.array(import_v47.z.string()).optional(),
|
|
1422
|
+
results: import_v47.z.array(
|
|
1423
|
+
import_v47.z.object({
|
|
1424
|
+
file_id: import_v47.z.string(),
|
|
1425
|
+
filename: import_v47.z.string(),
|
|
1426
|
+
score: import_v47.z.number(),
|
|
1427
|
+
text: import_v47.z.string()
|
|
1389
1428
|
})
|
|
1390
1429
|
).nullish()
|
|
1391
1430
|
}),
|
|
1392
|
-
|
|
1393
|
-
type:
|
|
1431
|
+
import_v47.z.object({
|
|
1432
|
+
type: import_v47.z.literal("custom_tool_call"),
|
|
1394
1433
|
...toolCallSchema.shape
|
|
1395
1434
|
}),
|
|
1396
|
-
|
|
1397
|
-
type:
|
|
1435
|
+
import_v47.z.object({
|
|
1436
|
+
type: import_v47.z.literal("mcp_call"),
|
|
1398
1437
|
...mcpCallSchema.shape
|
|
1399
1438
|
}),
|
|
1400
|
-
|
|
1401
|
-
type:
|
|
1402
|
-
role:
|
|
1403
|
-
content:
|
|
1404
|
-
id:
|
|
1405
|
-
status:
|
|
1439
|
+
import_v47.z.object({
|
|
1440
|
+
type: import_v47.z.literal("message"),
|
|
1441
|
+
role: import_v47.z.string(),
|
|
1442
|
+
content: import_v47.z.array(messageContentPartSchema),
|
|
1443
|
+
id: import_v47.z.string(),
|
|
1444
|
+
status: import_v47.z.string()
|
|
1406
1445
|
}),
|
|
1407
|
-
|
|
1408
|
-
type:
|
|
1409
|
-
name:
|
|
1410
|
-
arguments:
|
|
1411
|
-
call_id:
|
|
1412
|
-
id:
|
|
1446
|
+
import_v47.z.object({
|
|
1447
|
+
type: import_v47.z.literal("function_call"),
|
|
1448
|
+
name: import_v47.z.string(),
|
|
1449
|
+
arguments: import_v47.z.string(),
|
|
1450
|
+
call_id: import_v47.z.string(),
|
|
1451
|
+
id: import_v47.z.string()
|
|
1413
1452
|
}),
|
|
1414
|
-
|
|
1415
|
-
type:
|
|
1416
|
-
id:
|
|
1417
|
-
summary:
|
|
1418
|
-
content:
|
|
1419
|
-
status:
|
|
1420
|
-
encrypted_content:
|
|
1453
|
+
import_v47.z.object({
|
|
1454
|
+
type: import_v47.z.literal("reasoning"),
|
|
1455
|
+
id: import_v47.z.string(),
|
|
1456
|
+
summary: import_v47.z.array(reasoningSummaryPartSchema),
|
|
1457
|
+
content: import_v47.z.array(import_v47.z.object({ type: import_v47.z.string(), text: import_v47.z.string() })).nullish(),
|
|
1458
|
+
status: import_v47.z.string(),
|
|
1459
|
+
encrypted_content: import_v47.z.string().nullish()
|
|
1421
1460
|
})
|
|
1422
1461
|
]);
|
|
1423
|
-
var xaiResponsesUsageSchema =
|
|
1424
|
-
input_tokens:
|
|
1425
|
-
output_tokens:
|
|
1426
|
-
total_tokens:
|
|
1427
|
-
input_tokens_details:
|
|
1428
|
-
cached_tokens:
|
|
1462
|
+
var xaiResponsesUsageSchema = import_v47.z.object({
|
|
1463
|
+
input_tokens: import_v47.z.number(),
|
|
1464
|
+
output_tokens: import_v47.z.number(),
|
|
1465
|
+
total_tokens: import_v47.z.number().optional(),
|
|
1466
|
+
input_tokens_details: import_v47.z.object({
|
|
1467
|
+
cached_tokens: import_v47.z.number().optional()
|
|
1429
1468
|
}).optional(),
|
|
1430
|
-
output_tokens_details:
|
|
1431
|
-
reasoning_tokens:
|
|
1469
|
+
output_tokens_details: import_v47.z.object({
|
|
1470
|
+
reasoning_tokens: import_v47.z.number().optional()
|
|
1432
1471
|
}).optional(),
|
|
1433
|
-
num_sources_used:
|
|
1434
|
-
num_server_side_tools_used:
|
|
1472
|
+
num_sources_used: import_v47.z.number().optional(),
|
|
1473
|
+
num_server_side_tools_used: import_v47.z.number().optional()
|
|
1435
1474
|
});
|
|
1436
|
-
var xaiResponsesResponseSchema =
|
|
1437
|
-
id:
|
|
1438
|
-
created_at:
|
|
1439
|
-
model:
|
|
1440
|
-
object:
|
|
1441
|
-
output:
|
|
1475
|
+
var xaiResponsesResponseSchema = import_v47.z.object({
|
|
1476
|
+
id: import_v47.z.string().nullish(),
|
|
1477
|
+
created_at: import_v47.z.number().nullish(),
|
|
1478
|
+
model: import_v47.z.string().nullish(),
|
|
1479
|
+
object: import_v47.z.literal("response"),
|
|
1480
|
+
output: import_v47.z.array(outputItemSchema),
|
|
1442
1481
|
usage: xaiResponsesUsageSchema.nullish(),
|
|
1443
|
-
status:
|
|
1482
|
+
status: import_v47.z.string()
|
|
1444
1483
|
});
|
|
1445
|
-
var xaiResponsesChunkSchema =
|
|
1446
|
-
|
|
1447
|
-
type:
|
|
1484
|
+
var xaiResponsesChunkSchema = import_v47.z.union([
|
|
1485
|
+
import_v47.z.object({
|
|
1486
|
+
type: import_v47.z.literal("response.created"),
|
|
1448
1487
|
response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
|
|
1449
1488
|
}),
|
|
1450
|
-
|
|
1451
|
-
type:
|
|
1489
|
+
import_v47.z.object({
|
|
1490
|
+
type: import_v47.z.literal("response.in_progress"),
|
|
1452
1491
|
response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
|
|
1453
1492
|
}),
|
|
1454
|
-
|
|
1455
|
-
type:
|
|
1493
|
+
import_v47.z.object({
|
|
1494
|
+
type: import_v47.z.literal("response.output_item.added"),
|
|
1456
1495
|
item: outputItemSchema,
|
|
1457
|
-
output_index:
|
|
1496
|
+
output_index: import_v47.z.number()
|
|
1458
1497
|
}),
|
|
1459
|
-
|
|
1460
|
-
type:
|
|
1498
|
+
import_v47.z.object({
|
|
1499
|
+
type: import_v47.z.literal("response.output_item.done"),
|
|
1461
1500
|
item: outputItemSchema,
|
|
1462
|
-
output_index:
|
|
1501
|
+
output_index: import_v47.z.number()
|
|
1463
1502
|
}),
|
|
1464
|
-
|
|
1465
|
-
type:
|
|
1466
|
-
item_id:
|
|
1467
|
-
output_index:
|
|
1468
|
-
content_index:
|
|
1503
|
+
import_v47.z.object({
|
|
1504
|
+
type: import_v47.z.literal("response.content_part.added"),
|
|
1505
|
+
item_id: import_v47.z.string(),
|
|
1506
|
+
output_index: import_v47.z.number(),
|
|
1507
|
+
content_index: import_v47.z.number(),
|
|
1469
1508
|
part: messageContentPartSchema
|
|
1470
1509
|
}),
|
|
1471
|
-
|
|
1472
|
-
type:
|
|
1473
|
-
item_id:
|
|
1474
|
-
output_index:
|
|
1475
|
-
content_index:
|
|
1510
|
+
import_v47.z.object({
|
|
1511
|
+
type: import_v47.z.literal("response.content_part.done"),
|
|
1512
|
+
item_id: import_v47.z.string(),
|
|
1513
|
+
output_index: import_v47.z.number(),
|
|
1514
|
+
content_index: import_v47.z.number(),
|
|
1476
1515
|
part: messageContentPartSchema
|
|
1477
1516
|
}),
|
|
1478
|
-
|
|
1479
|
-
type:
|
|
1480
|
-
item_id:
|
|
1481
|
-
output_index:
|
|
1482
|
-
content_index:
|
|
1483
|
-
delta:
|
|
1484
|
-
logprobs:
|
|
1517
|
+
import_v47.z.object({
|
|
1518
|
+
type: import_v47.z.literal("response.output_text.delta"),
|
|
1519
|
+
item_id: import_v47.z.string(),
|
|
1520
|
+
output_index: import_v47.z.number(),
|
|
1521
|
+
content_index: import_v47.z.number(),
|
|
1522
|
+
delta: import_v47.z.string(),
|
|
1523
|
+
logprobs: import_v47.z.array(import_v47.z.any()).optional()
|
|
1485
1524
|
}),
|
|
1486
|
-
|
|
1487
|
-
type:
|
|
1488
|
-
item_id:
|
|
1489
|
-
output_index:
|
|
1490
|
-
content_index:
|
|
1491
|
-
text:
|
|
1492
|
-
logprobs:
|
|
1493
|
-
annotations:
|
|
1525
|
+
import_v47.z.object({
|
|
1526
|
+
type: import_v47.z.literal("response.output_text.done"),
|
|
1527
|
+
item_id: import_v47.z.string(),
|
|
1528
|
+
output_index: import_v47.z.number(),
|
|
1529
|
+
content_index: import_v47.z.number(),
|
|
1530
|
+
text: import_v47.z.string(),
|
|
1531
|
+
logprobs: import_v47.z.array(import_v47.z.any()).optional(),
|
|
1532
|
+
annotations: import_v47.z.array(annotationSchema).optional()
|
|
1494
1533
|
}),
|
|
1495
|
-
|
|
1496
|
-
type:
|
|
1497
|
-
item_id:
|
|
1498
|
-
output_index:
|
|
1499
|
-
content_index:
|
|
1500
|
-
annotation_index:
|
|
1534
|
+
import_v47.z.object({
|
|
1535
|
+
type: import_v47.z.literal("response.output_text.annotation.added"),
|
|
1536
|
+
item_id: import_v47.z.string(),
|
|
1537
|
+
output_index: import_v47.z.number(),
|
|
1538
|
+
content_index: import_v47.z.number(),
|
|
1539
|
+
annotation_index: import_v47.z.number(),
|
|
1501
1540
|
annotation: annotationSchema
|
|
1502
1541
|
}),
|
|
1503
|
-
|
|
1504
|
-
type:
|
|
1505
|
-
item_id:
|
|
1506
|
-
output_index:
|
|
1507
|
-
summary_index:
|
|
1542
|
+
import_v47.z.object({
|
|
1543
|
+
type: import_v47.z.literal("response.reasoning_summary_part.added"),
|
|
1544
|
+
item_id: import_v47.z.string(),
|
|
1545
|
+
output_index: import_v47.z.number(),
|
|
1546
|
+
summary_index: import_v47.z.number(),
|
|
1508
1547
|
part: reasoningSummaryPartSchema
|
|
1509
1548
|
}),
|
|
1510
|
-
|
|
1511
|
-
type:
|
|
1512
|
-
item_id:
|
|
1513
|
-
output_index:
|
|
1514
|
-
summary_index:
|
|
1549
|
+
import_v47.z.object({
|
|
1550
|
+
type: import_v47.z.literal("response.reasoning_summary_part.done"),
|
|
1551
|
+
item_id: import_v47.z.string(),
|
|
1552
|
+
output_index: import_v47.z.number(),
|
|
1553
|
+
summary_index: import_v47.z.number(),
|
|
1515
1554
|
part: reasoningSummaryPartSchema
|
|
1516
1555
|
}),
|
|
1517
|
-
|
|
1518
|
-
type:
|
|
1519
|
-
item_id:
|
|
1520
|
-
output_index:
|
|
1521
|
-
summary_index:
|
|
1522
|
-
delta:
|
|
1556
|
+
import_v47.z.object({
|
|
1557
|
+
type: import_v47.z.literal("response.reasoning_summary_text.delta"),
|
|
1558
|
+
item_id: import_v47.z.string(),
|
|
1559
|
+
output_index: import_v47.z.number(),
|
|
1560
|
+
summary_index: import_v47.z.number(),
|
|
1561
|
+
delta: import_v47.z.string()
|
|
1523
1562
|
}),
|
|
1524
|
-
|
|
1525
|
-
type:
|
|
1526
|
-
item_id:
|
|
1527
|
-
output_index:
|
|
1528
|
-
summary_index:
|
|
1529
|
-
text:
|
|
1563
|
+
import_v47.z.object({
|
|
1564
|
+
type: import_v47.z.literal("response.reasoning_summary_text.done"),
|
|
1565
|
+
item_id: import_v47.z.string(),
|
|
1566
|
+
output_index: import_v47.z.number(),
|
|
1567
|
+
summary_index: import_v47.z.number(),
|
|
1568
|
+
text: import_v47.z.string()
|
|
1530
1569
|
}),
|
|
1531
|
-
|
|
1532
|
-
type:
|
|
1533
|
-
item_id:
|
|
1534
|
-
output_index:
|
|
1535
|
-
content_index:
|
|
1536
|
-
delta:
|
|
1570
|
+
import_v47.z.object({
|
|
1571
|
+
type: import_v47.z.literal("response.reasoning_text.delta"),
|
|
1572
|
+
item_id: import_v47.z.string(),
|
|
1573
|
+
output_index: import_v47.z.number(),
|
|
1574
|
+
content_index: import_v47.z.number(),
|
|
1575
|
+
delta: import_v47.z.string()
|
|
1537
1576
|
}),
|
|
1538
|
-
|
|
1539
|
-
type:
|
|
1540
|
-
item_id:
|
|
1541
|
-
output_index:
|
|
1542
|
-
content_index:
|
|
1543
|
-
text:
|
|
1577
|
+
import_v47.z.object({
|
|
1578
|
+
type: import_v47.z.literal("response.reasoning_text.done"),
|
|
1579
|
+
item_id: import_v47.z.string(),
|
|
1580
|
+
output_index: import_v47.z.number(),
|
|
1581
|
+
content_index: import_v47.z.number(),
|
|
1582
|
+
text: import_v47.z.string()
|
|
1544
1583
|
}),
|
|
1545
|
-
|
|
1546
|
-
type:
|
|
1547
|
-
item_id:
|
|
1548
|
-
output_index:
|
|
1584
|
+
import_v47.z.object({
|
|
1585
|
+
type: import_v47.z.literal("response.web_search_call.in_progress"),
|
|
1586
|
+
item_id: import_v47.z.string(),
|
|
1587
|
+
output_index: import_v47.z.number()
|
|
1549
1588
|
}),
|
|
1550
|
-
|
|
1551
|
-
type:
|
|
1552
|
-
item_id:
|
|
1553
|
-
output_index:
|
|
1589
|
+
import_v47.z.object({
|
|
1590
|
+
type: import_v47.z.literal("response.web_search_call.searching"),
|
|
1591
|
+
item_id: import_v47.z.string(),
|
|
1592
|
+
output_index: import_v47.z.number()
|
|
1554
1593
|
}),
|
|
1555
|
-
|
|
1556
|
-
type:
|
|
1557
|
-
item_id:
|
|
1558
|
-
output_index:
|
|
1594
|
+
import_v47.z.object({
|
|
1595
|
+
type: import_v47.z.literal("response.web_search_call.completed"),
|
|
1596
|
+
item_id: import_v47.z.string(),
|
|
1597
|
+
output_index: import_v47.z.number()
|
|
1559
1598
|
}),
|
|
1560
|
-
|
|
1561
|
-
type:
|
|
1562
|
-
item_id:
|
|
1563
|
-
output_index:
|
|
1599
|
+
import_v47.z.object({
|
|
1600
|
+
type: import_v47.z.literal("response.x_search_call.in_progress"),
|
|
1601
|
+
item_id: import_v47.z.string(),
|
|
1602
|
+
output_index: import_v47.z.number()
|
|
1564
1603
|
}),
|
|
1565
|
-
|
|
1566
|
-
type:
|
|
1567
|
-
item_id:
|
|
1568
|
-
output_index:
|
|
1604
|
+
import_v47.z.object({
|
|
1605
|
+
type: import_v47.z.literal("response.x_search_call.searching"),
|
|
1606
|
+
item_id: import_v47.z.string(),
|
|
1607
|
+
output_index: import_v47.z.number()
|
|
1569
1608
|
}),
|
|
1570
|
-
|
|
1571
|
-
type:
|
|
1572
|
-
item_id:
|
|
1573
|
-
output_index:
|
|
1609
|
+
import_v47.z.object({
|
|
1610
|
+
type: import_v47.z.literal("response.x_search_call.completed"),
|
|
1611
|
+
item_id: import_v47.z.string(),
|
|
1612
|
+
output_index: import_v47.z.number()
|
|
1574
1613
|
}),
|
|
1575
|
-
|
|
1576
|
-
type:
|
|
1577
|
-
item_id:
|
|
1578
|
-
output_index:
|
|
1614
|
+
import_v47.z.object({
|
|
1615
|
+
type: import_v47.z.literal("response.file_search_call.in_progress"),
|
|
1616
|
+
item_id: import_v47.z.string(),
|
|
1617
|
+
output_index: import_v47.z.number()
|
|
1579
1618
|
}),
|
|
1580
|
-
|
|
1581
|
-
type:
|
|
1582
|
-
item_id:
|
|
1583
|
-
output_index:
|
|
1619
|
+
import_v47.z.object({
|
|
1620
|
+
type: import_v47.z.literal("response.file_search_call.searching"),
|
|
1621
|
+
item_id: import_v47.z.string(),
|
|
1622
|
+
output_index: import_v47.z.number()
|
|
1584
1623
|
}),
|
|
1585
|
-
|
|
1586
|
-
type:
|
|
1587
|
-
item_id:
|
|
1588
|
-
output_index:
|
|
1624
|
+
import_v47.z.object({
|
|
1625
|
+
type: import_v47.z.literal("response.file_search_call.completed"),
|
|
1626
|
+
item_id: import_v47.z.string(),
|
|
1627
|
+
output_index: import_v47.z.number()
|
|
1589
1628
|
}),
|
|
1590
|
-
|
|
1591
|
-
type:
|
|
1592
|
-
item_id:
|
|
1593
|
-
output_index:
|
|
1629
|
+
import_v47.z.object({
|
|
1630
|
+
type: import_v47.z.literal("response.code_execution_call.in_progress"),
|
|
1631
|
+
item_id: import_v47.z.string(),
|
|
1632
|
+
output_index: import_v47.z.number()
|
|
1594
1633
|
}),
|
|
1595
|
-
|
|
1596
|
-
type:
|
|
1597
|
-
item_id:
|
|
1598
|
-
output_index:
|
|
1634
|
+
import_v47.z.object({
|
|
1635
|
+
type: import_v47.z.literal("response.code_execution_call.executing"),
|
|
1636
|
+
item_id: import_v47.z.string(),
|
|
1637
|
+
output_index: import_v47.z.number()
|
|
1599
1638
|
}),
|
|
1600
|
-
|
|
1601
|
-
type:
|
|
1602
|
-
item_id:
|
|
1603
|
-
output_index:
|
|
1639
|
+
import_v47.z.object({
|
|
1640
|
+
type: import_v47.z.literal("response.code_execution_call.completed"),
|
|
1641
|
+
item_id: import_v47.z.string(),
|
|
1642
|
+
output_index: import_v47.z.number()
|
|
1604
1643
|
}),
|
|
1605
|
-
|
|
1606
|
-
type:
|
|
1607
|
-
item_id:
|
|
1608
|
-
output_index:
|
|
1644
|
+
import_v47.z.object({
|
|
1645
|
+
type: import_v47.z.literal("response.code_interpreter_call.in_progress"),
|
|
1646
|
+
item_id: import_v47.z.string(),
|
|
1647
|
+
output_index: import_v47.z.number()
|
|
1609
1648
|
}),
|
|
1610
|
-
|
|
1611
|
-
type:
|
|
1612
|
-
item_id:
|
|
1613
|
-
output_index:
|
|
1649
|
+
import_v47.z.object({
|
|
1650
|
+
type: import_v47.z.literal("response.code_interpreter_call.executing"),
|
|
1651
|
+
item_id: import_v47.z.string(),
|
|
1652
|
+
output_index: import_v47.z.number()
|
|
1614
1653
|
}),
|
|
1615
|
-
|
|
1616
|
-
type:
|
|
1617
|
-
item_id:
|
|
1618
|
-
output_index:
|
|
1654
|
+
import_v47.z.object({
|
|
1655
|
+
type: import_v47.z.literal("response.code_interpreter_call.interpreting"),
|
|
1656
|
+
item_id: import_v47.z.string(),
|
|
1657
|
+
output_index: import_v47.z.number()
|
|
1619
1658
|
}),
|
|
1620
|
-
|
|
1621
|
-
type:
|
|
1622
|
-
item_id:
|
|
1623
|
-
output_index:
|
|
1659
|
+
import_v47.z.object({
|
|
1660
|
+
type: import_v47.z.literal("response.code_interpreter_call.completed"),
|
|
1661
|
+
item_id: import_v47.z.string(),
|
|
1662
|
+
output_index: import_v47.z.number()
|
|
1624
1663
|
}),
|
|
1625
1664
|
// Code interpreter code streaming events
|
|
1626
|
-
|
|
1627
|
-
type:
|
|
1628
|
-
item_id:
|
|
1629
|
-
output_index:
|
|
1630
|
-
delta:
|
|
1665
|
+
import_v47.z.object({
|
|
1666
|
+
type: import_v47.z.literal("response.code_interpreter_call_code.delta"),
|
|
1667
|
+
item_id: import_v47.z.string(),
|
|
1668
|
+
output_index: import_v47.z.number(),
|
|
1669
|
+
delta: import_v47.z.string()
|
|
1631
1670
|
}),
|
|
1632
|
-
|
|
1633
|
-
type:
|
|
1634
|
-
item_id:
|
|
1635
|
-
output_index:
|
|
1636
|
-
code:
|
|
1671
|
+
import_v47.z.object({
|
|
1672
|
+
type: import_v47.z.literal("response.code_interpreter_call_code.done"),
|
|
1673
|
+
item_id: import_v47.z.string(),
|
|
1674
|
+
output_index: import_v47.z.number(),
|
|
1675
|
+
code: import_v47.z.string()
|
|
1637
1676
|
}),
|
|
1638
|
-
|
|
1639
|
-
type:
|
|
1640
|
-
item_id:
|
|
1641
|
-
output_index:
|
|
1642
|
-
delta:
|
|
1677
|
+
import_v47.z.object({
|
|
1678
|
+
type: import_v47.z.literal("response.custom_tool_call_input.delta"),
|
|
1679
|
+
item_id: import_v47.z.string(),
|
|
1680
|
+
output_index: import_v47.z.number(),
|
|
1681
|
+
delta: import_v47.z.string()
|
|
1643
1682
|
}),
|
|
1644
|
-
|
|
1645
|
-
type:
|
|
1646
|
-
item_id:
|
|
1647
|
-
output_index:
|
|
1648
|
-
input:
|
|
1683
|
+
import_v47.z.object({
|
|
1684
|
+
type: import_v47.z.literal("response.custom_tool_call_input.done"),
|
|
1685
|
+
item_id: import_v47.z.string(),
|
|
1686
|
+
output_index: import_v47.z.number(),
|
|
1687
|
+
input: import_v47.z.string()
|
|
1649
1688
|
}),
|
|
1650
1689
|
// Function call arguments streaming events (standard function tools)
|
|
1651
|
-
|
|
1652
|
-
type:
|
|
1653
|
-
item_id:
|
|
1654
|
-
output_index:
|
|
1655
|
-
delta:
|
|
1690
|
+
import_v47.z.object({
|
|
1691
|
+
type: import_v47.z.literal("response.function_call_arguments.delta"),
|
|
1692
|
+
item_id: import_v47.z.string(),
|
|
1693
|
+
output_index: import_v47.z.number(),
|
|
1694
|
+
delta: import_v47.z.string()
|
|
1656
1695
|
}),
|
|
1657
|
-
|
|
1658
|
-
type:
|
|
1659
|
-
item_id:
|
|
1660
|
-
output_index:
|
|
1661
|
-
arguments:
|
|
1696
|
+
import_v47.z.object({
|
|
1697
|
+
type: import_v47.z.literal("response.function_call_arguments.done"),
|
|
1698
|
+
item_id: import_v47.z.string(),
|
|
1699
|
+
output_index: import_v47.z.number(),
|
|
1700
|
+
arguments: import_v47.z.string()
|
|
1662
1701
|
}),
|
|
1663
|
-
|
|
1664
|
-
type:
|
|
1665
|
-
item_id:
|
|
1666
|
-
output_index:
|
|
1702
|
+
import_v47.z.object({
|
|
1703
|
+
type: import_v47.z.literal("response.mcp_call.in_progress"),
|
|
1704
|
+
item_id: import_v47.z.string(),
|
|
1705
|
+
output_index: import_v47.z.number()
|
|
1667
1706
|
}),
|
|
1668
|
-
|
|
1669
|
-
type:
|
|
1670
|
-
item_id:
|
|
1671
|
-
output_index:
|
|
1707
|
+
import_v47.z.object({
|
|
1708
|
+
type: import_v47.z.literal("response.mcp_call.executing"),
|
|
1709
|
+
item_id: import_v47.z.string(),
|
|
1710
|
+
output_index: import_v47.z.number()
|
|
1672
1711
|
}),
|
|
1673
|
-
|
|
1674
|
-
type:
|
|
1675
|
-
item_id:
|
|
1676
|
-
output_index:
|
|
1712
|
+
import_v47.z.object({
|
|
1713
|
+
type: import_v47.z.literal("response.mcp_call.completed"),
|
|
1714
|
+
item_id: import_v47.z.string(),
|
|
1715
|
+
output_index: import_v47.z.number()
|
|
1677
1716
|
}),
|
|
1678
|
-
|
|
1679
|
-
type:
|
|
1680
|
-
item_id:
|
|
1681
|
-
output_index:
|
|
1717
|
+
import_v47.z.object({
|
|
1718
|
+
type: import_v47.z.literal("response.mcp_call.failed"),
|
|
1719
|
+
item_id: import_v47.z.string(),
|
|
1720
|
+
output_index: import_v47.z.number()
|
|
1682
1721
|
}),
|
|
1683
|
-
|
|
1684
|
-
type:
|
|
1685
|
-
item_id:
|
|
1686
|
-
output_index:
|
|
1687
|
-
delta:
|
|
1722
|
+
import_v47.z.object({
|
|
1723
|
+
type: import_v47.z.literal("response.mcp_call_arguments.delta"),
|
|
1724
|
+
item_id: import_v47.z.string(),
|
|
1725
|
+
output_index: import_v47.z.number(),
|
|
1726
|
+
delta: import_v47.z.string()
|
|
1688
1727
|
}),
|
|
1689
|
-
|
|
1690
|
-
type:
|
|
1691
|
-
item_id:
|
|
1692
|
-
output_index:
|
|
1693
|
-
arguments:
|
|
1728
|
+
import_v47.z.object({
|
|
1729
|
+
type: import_v47.z.literal("response.mcp_call_arguments.done"),
|
|
1730
|
+
item_id: import_v47.z.string(),
|
|
1731
|
+
output_index: import_v47.z.number(),
|
|
1732
|
+
arguments: import_v47.z.string().optional()
|
|
1694
1733
|
}),
|
|
1695
|
-
|
|
1696
|
-
type:
|
|
1697
|
-
item_id:
|
|
1698
|
-
output_index:
|
|
1699
|
-
delta:
|
|
1734
|
+
import_v47.z.object({
|
|
1735
|
+
type: import_v47.z.literal("response.mcp_call_output.delta"),
|
|
1736
|
+
item_id: import_v47.z.string(),
|
|
1737
|
+
output_index: import_v47.z.number(),
|
|
1738
|
+
delta: import_v47.z.string()
|
|
1700
1739
|
}),
|
|
1701
|
-
|
|
1702
|
-
type:
|
|
1703
|
-
item_id:
|
|
1704
|
-
output_index:
|
|
1705
|
-
output:
|
|
1740
|
+
import_v47.z.object({
|
|
1741
|
+
type: import_v47.z.literal("response.mcp_call_output.done"),
|
|
1742
|
+
item_id: import_v47.z.string(),
|
|
1743
|
+
output_index: import_v47.z.number(),
|
|
1744
|
+
output: import_v47.z.string().optional()
|
|
1706
1745
|
}),
|
|
1707
|
-
|
|
1708
|
-
type:
|
|
1709
|
-
response:
|
|
1710
|
-
incomplete_details:
|
|
1746
|
+
import_v47.z.object({
|
|
1747
|
+
type: import_v47.z.literal("response.incomplete"),
|
|
1748
|
+
response: import_v47.z.object({
|
|
1749
|
+
incomplete_details: import_v47.z.object({ reason: import_v47.z.string() }).nullish(),
|
|
1711
1750
|
usage: xaiResponsesUsageSchema.nullish()
|
|
1712
1751
|
})
|
|
1713
1752
|
}),
|
|
1714
|
-
|
|
1715
|
-
type:
|
|
1716
|
-
response:
|
|
1717
|
-
error:
|
|
1718
|
-
code:
|
|
1719
|
-
message:
|
|
1753
|
+
import_v47.z.object({
|
|
1754
|
+
type: import_v47.z.literal("response.failed"),
|
|
1755
|
+
response: import_v47.z.object({
|
|
1756
|
+
error: import_v47.z.object({
|
|
1757
|
+
code: import_v47.z.string().nullish(),
|
|
1758
|
+
message: import_v47.z.string()
|
|
1720
1759
|
}).nullish(),
|
|
1721
|
-
incomplete_details:
|
|
1760
|
+
incomplete_details: import_v47.z.object({ reason: import_v47.z.string() }).nullish(),
|
|
1722
1761
|
usage: xaiResponsesUsageSchema.nullish()
|
|
1723
1762
|
})
|
|
1724
1763
|
}),
|
|
1725
|
-
|
|
1726
|
-
type:
|
|
1727
|
-
code:
|
|
1728
|
-
message:
|
|
1729
|
-
param:
|
|
1764
|
+
import_v47.z.object({
|
|
1765
|
+
type: import_v47.z.literal("error"),
|
|
1766
|
+
code: import_v47.z.string().nullish(),
|
|
1767
|
+
message: import_v47.z.string(),
|
|
1768
|
+
param: import_v47.z.string().nullish()
|
|
1730
1769
|
}),
|
|
1731
|
-
|
|
1732
|
-
type:
|
|
1770
|
+
import_v47.z.object({
|
|
1771
|
+
type: import_v47.z.literal("response.done"),
|
|
1733
1772
|
response: xaiResponsesResponseSchema
|
|
1734
1773
|
}),
|
|
1735
|
-
|
|
1736
|
-
type:
|
|
1774
|
+
import_v47.z.object({
|
|
1775
|
+
type: import_v47.z.literal("response.completed"),
|
|
1737
1776
|
response: xaiResponsesResponseSchema
|
|
1738
1777
|
})
|
|
1739
1778
|
]);
|
|
1740
1779
|
|
|
1741
1780
|
// src/responses/xai-responses-options.ts
|
|
1742
|
-
var
|
|
1743
|
-
var xaiLanguageModelResponsesOptions =
|
|
1781
|
+
var import_v48 = require("zod/v4");
|
|
1782
|
+
var xaiLanguageModelResponsesOptions = import_v48.z.object({
|
|
1744
1783
|
/**
|
|
1745
1784
|
* Constrains how hard a reasoning model thinks before responding.
|
|
1746
1785
|
* Possible values are `none` (disables reasoning), `low` (uses fewer reasoning
|
|
1747
1786
|
* tokens), `medium` and `high` (uses more reasoning tokens). Not all models
|
|
1748
1787
|
* support reasoning effort; see xAI's docs for the values each model accepts.
|
|
1749
1788
|
*/
|
|
1750
|
-
reasoningEffort:
|
|
1751
|
-
logprobs:
|
|
1752
|
-
topLogprobs:
|
|
1789
|
+
reasoningEffort: import_v48.z.enum(["none", "low", "medium", "high"]).optional(),
|
|
1790
|
+
logprobs: import_v48.z.boolean().optional(),
|
|
1791
|
+
topLogprobs: import_v48.z.number().int().min(0).max(8).optional(),
|
|
1753
1792
|
/**
|
|
1754
1793
|
* Whether to store the input message(s) and model response for later retrieval.
|
|
1755
1794
|
* Must be set to `false` for teams with Zero Data Retention (ZDR) enabled,
|
|
1756
1795
|
* otherwise the API will return an error.
|
|
1757
1796
|
* @default true
|
|
1758
1797
|
*/
|
|
1759
|
-
store:
|
|
1798
|
+
store: import_v48.z.boolean().optional(),
|
|
1760
1799
|
/**
|
|
1761
1800
|
* The ID of the previous response from the model.
|
|
1762
1801
|
*/
|
|
1763
|
-
previousResponseId:
|
|
1802
|
+
previousResponseId: import_v48.z.string().optional(),
|
|
1764
1803
|
/**
|
|
1765
1804
|
* Specify additional output data to include in the model response.
|
|
1766
1805
|
* Example values: 'file_search_call.results'.
|
|
1767
1806
|
*/
|
|
1768
|
-
include:
|
|
1807
|
+
include: import_v48.z.array(import_v48.z.enum(["file_search_call.results"])).nullish()
|
|
1769
1808
|
});
|
|
1770
1809
|
|
|
1771
1810
|
// src/responses/xai-responses-prepare-tools.ts
|
|
@@ -1774,25 +1813,25 @@ var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
|
1774
1813
|
|
|
1775
1814
|
// src/tool/file-search.ts
|
|
1776
1815
|
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
1777
|
-
var
|
|
1816
|
+
var import_v49 = require("zod/v4");
|
|
1778
1817
|
var fileSearchArgsSchema = (0, import_provider_utils6.lazySchema)(
|
|
1779
1818
|
() => (0, import_provider_utils6.zodSchema)(
|
|
1780
|
-
|
|
1781
|
-
vectorStoreIds:
|
|
1782
|
-
maxNumResults:
|
|
1819
|
+
import_v49.z.object({
|
|
1820
|
+
vectorStoreIds: import_v49.z.array(import_v49.z.string()),
|
|
1821
|
+
maxNumResults: import_v49.z.number().optional()
|
|
1783
1822
|
})
|
|
1784
1823
|
)
|
|
1785
1824
|
);
|
|
1786
1825
|
var fileSearchOutputSchema = (0, import_provider_utils6.lazySchema)(
|
|
1787
1826
|
() => (0, import_provider_utils6.zodSchema)(
|
|
1788
|
-
|
|
1789
|
-
queries:
|
|
1790
|
-
results:
|
|
1791
|
-
|
|
1792
|
-
fileId:
|
|
1793
|
-
filename:
|
|
1794
|
-
score:
|
|
1795
|
-
text:
|
|
1827
|
+
import_v49.z.object({
|
|
1828
|
+
queries: import_v49.z.array(import_v49.z.string()),
|
|
1829
|
+
results: import_v49.z.array(
|
|
1830
|
+
import_v49.z.object({
|
|
1831
|
+
fileId: import_v49.z.string(),
|
|
1832
|
+
filename: import_v49.z.string(),
|
|
1833
|
+
score: import_v49.z.number().min(0).max(1),
|
|
1834
|
+
text: import_v49.z.string()
|
|
1796
1835
|
})
|
|
1797
1836
|
).nullable()
|
|
1798
1837
|
})
|
|
@@ -1800,64 +1839,64 @@ var fileSearchOutputSchema = (0, import_provider_utils6.lazySchema)(
|
|
|
1800
1839
|
);
|
|
1801
1840
|
var fileSearchToolFactory = (0, import_provider_utils6.createProviderToolFactoryWithOutputSchema)({
|
|
1802
1841
|
id: "xai.file_search",
|
|
1803
|
-
inputSchema: (0, import_provider_utils6.lazySchema)(() => (0, import_provider_utils6.zodSchema)(
|
|
1842
|
+
inputSchema: (0, import_provider_utils6.lazySchema)(() => (0, import_provider_utils6.zodSchema)(import_v49.z.object({}))),
|
|
1804
1843
|
outputSchema: fileSearchOutputSchema
|
|
1805
1844
|
});
|
|
1806
1845
|
var fileSearch = (args) => fileSearchToolFactory(args);
|
|
1807
1846
|
|
|
1808
1847
|
// src/tool/mcp-server.ts
|
|
1809
1848
|
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1810
|
-
var
|
|
1849
|
+
var import_v410 = require("zod/v4");
|
|
1811
1850
|
var mcpServerArgsSchema = (0, import_provider_utils7.lazySchema)(
|
|
1812
1851
|
() => (0, import_provider_utils7.zodSchema)(
|
|
1813
|
-
|
|
1814
|
-
serverUrl:
|
|
1815
|
-
serverLabel:
|
|
1816
|
-
serverDescription:
|
|
1817
|
-
allowedTools:
|
|
1818
|
-
headers:
|
|
1819
|
-
authorization:
|
|
1852
|
+
import_v410.z.object({
|
|
1853
|
+
serverUrl: import_v410.z.string().describe("The URL of the MCP server"),
|
|
1854
|
+
serverLabel: import_v410.z.string().optional().describe("A label for the MCP server"),
|
|
1855
|
+
serverDescription: import_v410.z.string().optional().describe("Description of the MCP server"),
|
|
1856
|
+
allowedTools: import_v410.z.array(import_v410.z.string()).optional().describe("List of allowed tool names"),
|
|
1857
|
+
headers: import_v410.z.record(import_v410.z.string(), import_v410.z.string()).optional().describe("Custom headers to send"),
|
|
1858
|
+
authorization: import_v410.z.string().optional().describe("Authorization header value")
|
|
1820
1859
|
})
|
|
1821
1860
|
)
|
|
1822
1861
|
);
|
|
1823
1862
|
var mcpServerOutputSchema = (0, import_provider_utils7.lazySchema)(
|
|
1824
1863
|
() => (0, import_provider_utils7.zodSchema)(
|
|
1825
|
-
|
|
1826
|
-
name:
|
|
1827
|
-
arguments:
|
|
1828
|
-
result:
|
|
1864
|
+
import_v410.z.object({
|
|
1865
|
+
name: import_v410.z.string(),
|
|
1866
|
+
arguments: import_v410.z.string(),
|
|
1867
|
+
result: import_v410.z.unknown()
|
|
1829
1868
|
})
|
|
1830
1869
|
)
|
|
1831
1870
|
);
|
|
1832
1871
|
var mcpServerToolFactory = (0, import_provider_utils7.createProviderToolFactoryWithOutputSchema)({
|
|
1833
1872
|
id: "xai.mcp",
|
|
1834
|
-
inputSchema: (0, import_provider_utils7.lazySchema)(() => (0, import_provider_utils7.zodSchema)(
|
|
1873
|
+
inputSchema: (0, import_provider_utils7.lazySchema)(() => (0, import_provider_utils7.zodSchema)(import_v410.z.object({}))),
|
|
1835
1874
|
outputSchema: mcpServerOutputSchema
|
|
1836
1875
|
});
|
|
1837
1876
|
var mcpServer = (args) => mcpServerToolFactory(args);
|
|
1838
1877
|
|
|
1839
1878
|
// src/tool/web-search.ts
|
|
1840
1879
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1841
|
-
var
|
|
1880
|
+
var import_v411 = require("zod/v4");
|
|
1842
1881
|
var webSearchArgsSchema = (0, import_provider_utils8.lazySchema)(
|
|
1843
1882
|
() => (0, import_provider_utils8.zodSchema)(
|
|
1844
|
-
|
|
1845
|
-
allowedDomains:
|
|
1846
|
-
excludedDomains:
|
|
1847
|
-
enableImageSearch:
|
|
1848
|
-
enableImageUnderstanding:
|
|
1883
|
+
import_v411.z.object({
|
|
1884
|
+
allowedDomains: import_v411.z.array(import_v411.z.string()).max(5).optional(),
|
|
1885
|
+
excludedDomains: import_v411.z.array(import_v411.z.string()).max(5).optional(),
|
|
1886
|
+
enableImageSearch: import_v411.z.boolean().optional(),
|
|
1887
|
+
enableImageUnderstanding: import_v411.z.boolean().optional()
|
|
1849
1888
|
})
|
|
1850
1889
|
)
|
|
1851
1890
|
);
|
|
1852
1891
|
var webSearchOutputSchema = (0, import_provider_utils8.lazySchema)(
|
|
1853
1892
|
() => (0, import_provider_utils8.zodSchema)(
|
|
1854
|
-
|
|
1855
|
-
query:
|
|
1856
|
-
sources:
|
|
1857
|
-
|
|
1858
|
-
title:
|
|
1859
|
-
url:
|
|
1860
|
-
snippet:
|
|
1893
|
+
import_v411.z.object({
|
|
1894
|
+
query: import_v411.z.string(),
|
|
1895
|
+
sources: import_v411.z.array(
|
|
1896
|
+
import_v411.z.object({
|
|
1897
|
+
title: import_v411.z.string(),
|
|
1898
|
+
url: import_v411.z.string(),
|
|
1899
|
+
snippet: import_v411.z.string()
|
|
1861
1900
|
})
|
|
1862
1901
|
)
|
|
1863
1902
|
})
|
|
@@ -1865,36 +1904,36 @@ var webSearchOutputSchema = (0, import_provider_utils8.lazySchema)(
|
|
|
1865
1904
|
);
|
|
1866
1905
|
var webSearchToolFactory = (0, import_provider_utils8.createProviderToolFactoryWithOutputSchema)({
|
|
1867
1906
|
id: "xai.web_search",
|
|
1868
|
-
inputSchema: (0, import_provider_utils8.lazySchema)(() => (0, import_provider_utils8.zodSchema)(
|
|
1907
|
+
inputSchema: (0, import_provider_utils8.lazySchema)(() => (0, import_provider_utils8.zodSchema)(import_v411.z.object({}))),
|
|
1869
1908
|
outputSchema: webSearchOutputSchema
|
|
1870
1909
|
});
|
|
1871
1910
|
var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
1872
1911
|
|
|
1873
1912
|
// src/tool/x-search.ts
|
|
1874
1913
|
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1875
|
-
var
|
|
1914
|
+
var import_v412 = require("zod/v4");
|
|
1876
1915
|
var xSearchArgsSchema = (0, import_provider_utils9.lazySchema)(
|
|
1877
1916
|
() => (0, import_provider_utils9.zodSchema)(
|
|
1878
|
-
|
|
1879
|
-
allowedXHandles:
|
|
1880
|
-
excludedXHandles:
|
|
1881
|
-
fromDate:
|
|
1882
|
-
toDate:
|
|
1883
|
-
enableImageUnderstanding:
|
|
1884
|
-
enableVideoUnderstanding:
|
|
1917
|
+
import_v412.z.object({
|
|
1918
|
+
allowedXHandles: import_v412.z.array(import_v412.z.string()).max(10).optional(),
|
|
1919
|
+
excludedXHandles: import_v412.z.array(import_v412.z.string()).max(10).optional(),
|
|
1920
|
+
fromDate: import_v412.z.string().optional(),
|
|
1921
|
+
toDate: import_v412.z.string().optional(),
|
|
1922
|
+
enableImageUnderstanding: import_v412.z.boolean().optional(),
|
|
1923
|
+
enableVideoUnderstanding: import_v412.z.boolean().optional()
|
|
1885
1924
|
})
|
|
1886
1925
|
)
|
|
1887
1926
|
);
|
|
1888
1927
|
var xSearchOutputSchema = (0, import_provider_utils9.lazySchema)(
|
|
1889
1928
|
() => (0, import_provider_utils9.zodSchema)(
|
|
1890
|
-
|
|
1891
|
-
query:
|
|
1892
|
-
posts:
|
|
1893
|
-
|
|
1894
|
-
author:
|
|
1895
|
-
text:
|
|
1896
|
-
url:
|
|
1897
|
-
likes:
|
|
1929
|
+
import_v412.z.object({
|
|
1930
|
+
query: import_v412.z.string(),
|
|
1931
|
+
posts: import_v412.z.array(
|
|
1932
|
+
import_v412.z.object({
|
|
1933
|
+
author: import_v412.z.string(),
|
|
1934
|
+
text: import_v412.z.string(),
|
|
1935
|
+
url: import_v412.z.string(),
|
|
1936
|
+
likes: import_v412.z.number()
|
|
1898
1937
|
})
|
|
1899
1938
|
)
|
|
1900
1939
|
})
|
|
@@ -1902,7 +1941,7 @@ var xSearchOutputSchema = (0, import_provider_utils9.lazySchema)(
|
|
|
1902
1941
|
);
|
|
1903
1942
|
var xSearchToolFactory = (0, import_provider_utils9.createProviderToolFactoryWithOutputSchema)({
|
|
1904
1943
|
id: "xai.x_search",
|
|
1905
|
-
inputSchema: (0, import_provider_utils9.lazySchema)(() => (0, import_provider_utils9.zodSchema)(
|
|
1944
|
+
inputSchema: (0, import_provider_utils9.lazySchema)(() => (0, import_provider_utils9.zodSchema)(import_v412.z.object({}))),
|
|
1906
1945
|
outputSchema: xSearchOutputSchema
|
|
1907
1946
|
});
|
|
1908
1947
|
var xSearch = (args = {}) => xSearchToolFactory(args);
|
|
@@ -2799,43 +2838,43 @@ var XaiResponsesLanguageModel = class {
|
|
|
2799
2838
|
|
|
2800
2839
|
// src/tool/code-execution.ts
|
|
2801
2840
|
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
2802
|
-
var
|
|
2803
|
-
var codeExecutionOutputSchema =
|
|
2804
|
-
output:
|
|
2805
|
-
error:
|
|
2841
|
+
var import_v413 = require("zod/v4");
|
|
2842
|
+
var codeExecutionOutputSchema = import_v413.z.object({
|
|
2843
|
+
output: import_v413.z.string().describe("the output of the code execution"),
|
|
2844
|
+
error: import_v413.z.string().optional().describe("any error that occurred")
|
|
2806
2845
|
});
|
|
2807
2846
|
var codeExecutionToolFactory = (0, import_provider_utils12.createProviderToolFactoryWithOutputSchema)({
|
|
2808
2847
|
id: "xai.code_execution",
|
|
2809
|
-
inputSchema:
|
|
2848
|
+
inputSchema: import_v413.z.object({}).describe("no input parameters"),
|
|
2810
2849
|
outputSchema: codeExecutionOutputSchema
|
|
2811
2850
|
});
|
|
2812
2851
|
var codeExecution = (args = {}) => codeExecutionToolFactory(args);
|
|
2813
2852
|
|
|
2814
2853
|
// src/tool/view-image.ts
|
|
2815
2854
|
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
2816
|
-
var
|
|
2817
|
-
var viewImageOutputSchema =
|
|
2818
|
-
description:
|
|
2819
|
-
objects:
|
|
2855
|
+
var import_v414 = require("zod/v4");
|
|
2856
|
+
var viewImageOutputSchema = import_v414.z.object({
|
|
2857
|
+
description: import_v414.z.string().describe("description of the image"),
|
|
2858
|
+
objects: import_v414.z.array(import_v414.z.string()).optional().describe("objects detected in the image")
|
|
2820
2859
|
});
|
|
2821
2860
|
var viewImageToolFactory = (0, import_provider_utils13.createProviderToolFactoryWithOutputSchema)({
|
|
2822
2861
|
id: "xai.view_image",
|
|
2823
|
-
inputSchema:
|
|
2862
|
+
inputSchema: import_v414.z.object({}).describe("no input parameters"),
|
|
2824
2863
|
outputSchema: viewImageOutputSchema
|
|
2825
2864
|
});
|
|
2826
2865
|
var viewImage = (args = {}) => viewImageToolFactory(args);
|
|
2827
2866
|
|
|
2828
2867
|
// src/tool/view-x-video.ts
|
|
2829
2868
|
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
2830
|
-
var
|
|
2831
|
-
var viewXVideoOutputSchema =
|
|
2832
|
-
transcript:
|
|
2833
|
-
description:
|
|
2834
|
-
duration:
|
|
2869
|
+
var import_v415 = require("zod/v4");
|
|
2870
|
+
var viewXVideoOutputSchema = import_v415.z.object({
|
|
2871
|
+
transcript: import_v415.z.string().optional().describe("transcript of the video"),
|
|
2872
|
+
description: import_v415.z.string().describe("description of the video content"),
|
|
2873
|
+
duration: import_v415.z.number().optional().describe("duration in seconds")
|
|
2835
2874
|
});
|
|
2836
2875
|
var viewXVideoToolFactory = (0, import_provider_utils14.createProviderToolFactoryWithOutputSchema)({
|
|
2837
2876
|
id: "xai.view_x_video",
|
|
2838
|
-
inputSchema:
|
|
2877
|
+
inputSchema: import_v415.z.object({}).describe("no input parameters"),
|
|
2839
2878
|
outputSchema: viewXVideoOutputSchema
|
|
2840
2879
|
});
|
|
2841
2880
|
var viewXVideo = (args = {}) => viewXVideoToolFactory(args);
|
|
@@ -2852,58 +2891,58 @@ var xaiTools = {
|
|
|
2852
2891
|
};
|
|
2853
2892
|
|
|
2854
2893
|
// src/version.ts
|
|
2855
|
-
var VERSION = true ? "3.0.
|
|
2894
|
+
var VERSION = true ? "3.0.105" : "0.0.0-test";
|
|
2856
2895
|
|
|
2857
2896
|
// src/xai-video-model.ts
|
|
2858
2897
|
var import_provider6 = require("@ai-sdk/provider");
|
|
2859
2898
|
var import_provider_utils16 = require("@ai-sdk/provider-utils");
|
|
2860
|
-
var
|
|
2899
|
+
var import_v417 = require("zod/v4");
|
|
2861
2900
|
|
|
2862
2901
|
// src/xai-video-options.ts
|
|
2863
2902
|
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
2864
|
-
var
|
|
2865
|
-
var nonEmptyStringSchema =
|
|
2866
|
-
var resolutionSchema =
|
|
2867
|
-
var modeSchema =
|
|
2903
|
+
var import_v416 = require("zod/v4");
|
|
2904
|
+
var nonEmptyStringSchema = import_v416.z.string().min(1);
|
|
2905
|
+
var resolutionSchema = import_v416.z.enum(["480p", "720p"]);
|
|
2906
|
+
var modeSchema = import_v416.z.enum(["edit-video", "extend-video", "reference-to-video"]);
|
|
2868
2907
|
var baseFields = {
|
|
2869
|
-
pollIntervalMs:
|
|
2870
|
-
pollTimeoutMs:
|
|
2908
|
+
pollIntervalMs: import_v416.z.number().positive().nullish(),
|
|
2909
|
+
pollTimeoutMs: import_v416.z.number().positive().nullish(),
|
|
2871
2910
|
resolution: resolutionSchema.nullish()
|
|
2872
2911
|
};
|
|
2873
|
-
var editVideoSchema =
|
|
2912
|
+
var editVideoSchema = import_v416.z.object({
|
|
2874
2913
|
...baseFields,
|
|
2875
|
-
mode:
|
|
2914
|
+
mode: import_v416.z.literal("edit-video"),
|
|
2876
2915
|
videoUrl: nonEmptyStringSchema,
|
|
2877
|
-
referenceImageUrls:
|
|
2916
|
+
referenceImageUrls: import_v416.z.undefined().optional()
|
|
2878
2917
|
});
|
|
2879
|
-
var extendVideoSchema =
|
|
2918
|
+
var extendVideoSchema = import_v416.z.object({
|
|
2880
2919
|
...baseFields,
|
|
2881
|
-
mode:
|
|
2920
|
+
mode: import_v416.z.literal("extend-video"),
|
|
2882
2921
|
videoUrl: nonEmptyStringSchema,
|
|
2883
|
-
referenceImageUrls:
|
|
2922
|
+
referenceImageUrls: import_v416.z.undefined().optional()
|
|
2884
2923
|
});
|
|
2885
|
-
var referenceToVideoSchema =
|
|
2924
|
+
var referenceToVideoSchema = import_v416.z.object({
|
|
2886
2925
|
...baseFields,
|
|
2887
|
-
mode:
|
|
2888
|
-
referenceImageUrls:
|
|
2889
|
-
videoUrl:
|
|
2926
|
+
mode: import_v416.z.literal("reference-to-video"),
|
|
2927
|
+
referenceImageUrls: import_v416.z.array(nonEmptyStringSchema).min(1).max(7),
|
|
2928
|
+
videoUrl: import_v416.z.undefined().optional()
|
|
2890
2929
|
});
|
|
2891
|
-
var autoDetectSchema =
|
|
2930
|
+
var autoDetectSchema = import_v416.z.object({
|
|
2892
2931
|
...baseFields,
|
|
2893
|
-
mode:
|
|
2932
|
+
mode: import_v416.z.undefined().optional(),
|
|
2894
2933
|
videoUrl: nonEmptyStringSchema.optional(),
|
|
2895
|
-
referenceImageUrls:
|
|
2934
|
+
referenceImageUrls: import_v416.z.array(nonEmptyStringSchema).min(1).max(7).optional()
|
|
2896
2935
|
});
|
|
2897
|
-
var xaiVideoModelOptions =
|
|
2936
|
+
var xaiVideoModelOptions = import_v416.z.union([
|
|
2898
2937
|
editVideoSchema,
|
|
2899
2938
|
extendVideoSchema,
|
|
2900
2939
|
referenceToVideoSchema,
|
|
2901
2940
|
autoDetectSchema
|
|
2902
2941
|
]);
|
|
2903
|
-
var runtimeSchema =
|
|
2942
|
+
var runtimeSchema = import_v416.z.object({
|
|
2904
2943
|
mode: modeSchema.optional(),
|
|
2905
2944
|
videoUrl: nonEmptyStringSchema.optional(),
|
|
2906
|
-
referenceImageUrls:
|
|
2945
|
+
referenceImageUrls: import_v416.z.array(nonEmptyStringSchema).min(1).max(7).optional(),
|
|
2907
2946
|
...baseFields
|
|
2908
2947
|
}).passthrough();
|
|
2909
2948
|
var xaiVideoModelOptionsSchema = (0, import_provider_utils15.lazySchema)(
|
|
@@ -3215,24 +3254,24 @@ var XaiVideoModel = class {
|
|
|
3215
3254
|
}
|
|
3216
3255
|
}
|
|
3217
3256
|
};
|
|
3218
|
-
var xaiCreateVideoResponseSchema =
|
|
3219
|
-
request_id:
|
|
3257
|
+
var xaiCreateVideoResponseSchema = import_v417.z.object({
|
|
3258
|
+
request_id: import_v417.z.string().nullish()
|
|
3220
3259
|
});
|
|
3221
|
-
var xaiVideoStatusResponseSchema =
|
|
3222
|
-
status:
|
|
3223
|
-
video:
|
|
3224
|
-
url:
|
|
3225
|
-
duration:
|
|
3226
|
-
respect_moderation:
|
|
3260
|
+
var xaiVideoStatusResponseSchema = import_v417.z.object({
|
|
3261
|
+
status: import_v417.z.string().nullish(),
|
|
3262
|
+
video: import_v417.z.object({
|
|
3263
|
+
url: import_v417.z.string(),
|
|
3264
|
+
duration: import_v417.z.number().nullish(),
|
|
3265
|
+
respect_moderation: import_v417.z.boolean().nullish()
|
|
3227
3266
|
}).nullish(),
|
|
3228
|
-
model:
|
|
3229
|
-
usage:
|
|
3230
|
-
cost_in_usd_ticks:
|
|
3267
|
+
model: import_v417.z.string().nullish(),
|
|
3268
|
+
usage: import_v417.z.object({
|
|
3269
|
+
cost_in_usd_ticks: import_v417.z.number().nullish()
|
|
3231
3270
|
}).nullish(),
|
|
3232
|
-
progress:
|
|
3233
|
-
error:
|
|
3234
|
-
code:
|
|
3235
|
-
message:
|
|
3271
|
+
progress: import_v417.z.number().nullish(),
|
|
3272
|
+
error: import_v417.z.object({
|
|
3273
|
+
code: import_v417.z.string().nullish(),
|
|
3274
|
+
message: import_v417.z.string().nullish()
|
|
3236
3275
|
}).nullish()
|
|
3237
3276
|
});
|
|
3238
3277
|
|