@ai-sdk/xai 4.0.8 → 4.0.10
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 +20 -0
- package/dist/index.d.ts +12 -3
- package/dist/index.js +760 -694
- package/dist/index.js.map +1 -1
- package/docs/01-xai.mdx +63 -40
- package/package.json +4 -4
- package/src/convert-to-xai-chat-messages.ts +61 -43
- package/src/index.ts +1 -0
- package/src/responses/convert-to-xai-responses-input.ts +11 -0
- package/src/responses/xai-responses-api.ts +5 -1
- package/src/responses/xai-responses-language-model-options.ts +1 -0
- package/src/xai-chat-language-model-options.ts +1 -0
- 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/src/xai-video-model.ts +51 -9
package/dist/index.js
CHANGED
|
@@ -20,14 +20,14 @@ import {
|
|
|
20
20
|
extractResponseHeaders,
|
|
21
21
|
isCustomReasoning,
|
|
22
22
|
mapReasoningToProviderEffort,
|
|
23
|
-
parseProviderOptions,
|
|
23
|
+
parseProviderOptions as parseProviderOptions2,
|
|
24
24
|
postJsonToApi,
|
|
25
25
|
safeParseJSON,
|
|
26
26
|
serializeModelOptions,
|
|
27
27
|
WORKFLOW_SERIALIZE,
|
|
28
28
|
WORKFLOW_DESERIALIZE
|
|
29
29
|
} from "@ai-sdk/provider-utils";
|
|
30
|
-
import { z as
|
|
30
|
+
import { z as z4 } from "zod/v4";
|
|
31
31
|
|
|
32
32
|
// src/convert-to-xai-chat-messages.ts
|
|
33
33
|
import {
|
|
@@ -36,10 +36,30 @@ import {
|
|
|
36
36
|
import {
|
|
37
37
|
convertToBase64,
|
|
38
38
|
getTopLevelMediaType,
|
|
39
|
+
parseProviderOptions,
|
|
39
40
|
resolveFullMediaType,
|
|
40
41
|
resolveProviderReference
|
|
41
42
|
} from "@ai-sdk/provider-utils";
|
|
42
|
-
|
|
43
|
+
|
|
44
|
+
// src/xai-file-part-options.ts
|
|
45
|
+
import { z } from "zod/v4";
|
|
46
|
+
var xaiFilePartProviderOptions = z.object({
|
|
47
|
+
/**
|
|
48
|
+
* Controls the resolution at which the model processes the image.
|
|
49
|
+
* `low` processes the image at reduced resolution and consumes fewer
|
|
50
|
+
* input tokens, `high` processes the image at full resolution, and
|
|
51
|
+
* `auto` lets the API decide. Defaults to full resolution when not set.
|
|
52
|
+
*
|
|
53
|
+
* Note: the xAI API silently ignores invalid values, so the value is
|
|
54
|
+
* validated client-side.
|
|
55
|
+
*
|
|
56
|
+
* @see https://docs.x.ai/developers/model-capabilities/images/understanding
|
|
57
|
+
*/
|
|
58
|
+
imageDetail: z.enum(["low", "high", "auto"]).optional()
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// src/convert-to-xai-chat-messages.ts
|
|
62
|
+
async function convertToXaiChatMessages(prompt) {
|
|
43
63
|
var _a;
|
|
44
64
|
const messages = [];
|
|
45
65
|
const warnings = [];
|
|
@@ -54,51 +74,62 @@ function convertToXaiChatMessages(prompt) {
|
|
|
54
74
|
messages.push({ role: "user", content: content[0].text });
|
|
55
75
|
break;
|
|
56
76
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
const userContent = [];
|
|
78
|
+
for (const part of content) {
|
|
79
|
+
switch (part.type) {
|
|
80
|
+
case "text": {
|
|
81
|
+
userContent.push({ type: "text", text: part.text });
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
case "file": {
|
|
85
|
+
switch (part.data.type) {
|
|
86
|
+
case "reference": {
|
|
87
|
+
userContent.push({
|
|
88
|
+
type: "file",
|
|
89
|
+
file: {
|
|
90
|
+
file_id: resolveProviderReference({
|
|
91
|
+
reference: part.data.reference,
|
|
92
|
+
provider: "xai"
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case "text": {
|
|
99
|
+
throw new UnsupportedFunctionalityError({
|
|
100
|
+
functionality: "text file parts"
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
case "url":
|
|
104
|
+
case "data": {
|
|
105
|
+
if (getTopLevelMediaType(part.mediaType) === "image") {
|
|
106
|
+
const filePartOptions = await parseProviderOptions({
|
|
107
|
+
provider: "xai",
|
|
108
|
+
providerOptions: part.providerOptions,
|
|
109
|
+
schema: xaiFilePartProviderOptions
|
|
110
|
+
});
|
|
111
|
+
userContent.push({
|
|
112
|
+
type: "image_url",
|
|
113
|
+
image_url: {
|
|
114
|
+
url: part.data.type === "url" ? part.data.url.toString() : `data:${resolveFullMediaType({ part })};base64,${convertToBase64(part.data.data)}`,
|
|
115
|
+
...(filePartOptions == null ? void 0 : filePartOptions.imageDetail) != null && {
|
|
116
|
+
detail: filePartOptions.imageDetail
|
|
117
|
+
}
|
|
74
118
|
}
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
case "text": {
|
|
119
|
+
});
|
|
120
|
+
} else {
|
|
78
121
|
throw new UnsupportedFunctionalityError({
|
|
79
|
-
functionality:
|
|
122
|
+
functionality: `file part media type ${part.mediaType}`
|
|
80
123
|
});
|
|
81
124
|
}
|
|
82
|
-
|
|
83
|
-
case "data": {
|
|
84
|
-
if (getTopLevelMediaType(part.mediaType) === "image") {
|
|
85
|
-
return {
|
|
86
|
-
type: "image_url",
|
|
87
|
-
image_url: {
|
|
88
|
-
url: part.data.type === "url" ? part.data.url.toString() : `data:${resolveFullMediaType({ part })};base64,${convertToBase64(part.data.data)}`
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
} else {
|
|
92
|
-
throw new UnsupportedFunctionalityError({
|
|
93
|
-
functionality: `file part media type ${part.mediaType}`
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
125
|
+
break;
|
|
97
126
|
}
|
|
98
127
|
}
|
|
128
|
+
break;
|
|
99
129
|
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
messages.push({ role: "user", content: userContent });
|
|
102
133
|
break;
|
|
103
134
|
}
|
|
104
135
|
case "assistant": {
|
|
@@ -229,43 +260,43 @@ function supportsReasoningEffort(modelId) {
|
|
|
229
260
|
}
|
|
230
261
|
|
|
231
262
|
// src/xai-chat-language-model-options.ts
|
|
232
|
-
import { z } from "zod/v4";
|
|
233
|
-
var webSourceSchema =
|
|
234
|
-
type:
|
|
235
|
-
country:
|
|
236
|
-
excludedWebsites:
|
|
237
|
-
allowedWebsites:
|
|
238
|
-
safeSearch:
|
|
263
|
+
import { z as z2 } from "zod/v4";
|
|
264
|
+
var webSourceSchema = z2.object({
|
|
265
|
+
type: z2.literal("web"),
|
|
266
|
+
country: z2.string().length(2).optional(),
|
|
267
|
+
excludedWebsites: z2.array(z2.string()).max(5).optional(),
|
|
268
|
+
allowedWebsites: z2.array(z2.string()).max(5).optional(),
|
|
269
|
+
safeSearch: z2.boolean().optional()
|
|
239
270
|
});
|
|
240
|
-
var xSourceSchema =
|
|
241
|
-
type:
|
|
242
|
-
excludedXHandles:
|
|
243
|
-
includedXHandles:
|
|
244
|
-
postFavoriteCount:
|
|
245
|
-
postViewCount:
|
|
271
|
+
var xSourceSchema = z2.object({
|
|
272
|
+
type: z2.literal("x"),
|
|
273
|
+
excludedXHandles: z2.array(z2.string()).optional(),
|
|
274
|
+
includedXHandles: z2.array(z2.string()).optional(),
|
|
275
|
+
postFavoriteCount: z2.number().int().optional(),
|
|
276
|
+
postViewCount: z2.number().int().optional(),
|
|
246
277
|
/**
|
|
247
278
|
* @deprecated use `includedXHandles` instead
|
|
248
279
|
*/
|
|
249
|
-
xHandles:
|
|
280
|
+
xHandles: z2.array(z2.string()).optional()
|
|
250
281
|
});
|
|
251
|
-
var newsSourceSchema =
|
|
252
|
-
type:
|
|
253
|
-
country:
|
|
254
|
-
excludedWebsites:
|
|
255
|
-
safeSearch:
|
|
282
|
+
var newsSourceSchema = z2.object({
|
|
283
|
+
type: z2.literal("news"),
|
|
284
|
+
country: z2.string().length(2).optional(),
|
|
285
|
+
excludedWebsites: z2.array(z2.string()).max(5).optional(),
|
|
286
|
+
safeSearch: z2.boolean().optional()
|
|
256
287
|
});
|
|
257
|
-
var rssSourceSchema =
|
|
258
|
-
type:
|
|
259
|
-
links:
|
|
288
|
+
var rssSourceSchema = z2.object({
|
|
289
|
+
type: z2.literal("rss"),
|
|
290
|
+
links: z2.array(z2.string().url()).max(1)
|
|
260
291
|
// currently only supports one RSS link
|
|
261
292
|
});
|
|
262
|
-
var searchSourceSchema =
|
|
293
|
+
var searchSourceSchema = z2.discriminatedUnion("type", [
|
|
263
294
|
webSourceSchema,
|
|
264
295
|
xSourceSchema,
|
|
265
296
|
newsSourceSchema,
|
|
266
297
|
rssSourceSchema
|
|
267
298
|
]);
|
|
268
|
-
var xaiLanguageModelChatOptions =
|
|
299
|
+
var xaiLanguageModelChatOptions = z2.object({
|
|
269
300
|
/**
|
|
270
301
|
* Constrains how hard a reasoning model thinks before responding.
|
|
271
302
|
*
|
|
@@ -280,16 +311,16 @@ var xaiLanguageModelChatOptions = z.object({
|
|
|
280
311
|
*
|
|
281
312
|
* @see https://docs.x.ai/docs/guides/reasoning
|
|
282
313
|
*/
|
|
283
|
-
reasoningEffort:
|
|
284
|
-
logprobs:
|
|
285
|
-
topLogprobs:
|
|
314
|
+
reasoningEffort: z2.enum(["none", "low", "medium", "high"]).optional(),
|
|
315
|
+
logprobs: z2.boolean().optional(),
|
|
316
|
+
topLogprobs: z2.number().int().min(0).max(8).optional(),
|
|
286
317
|
/**
|
|
287
318
|
* Whether to enable parallel function calling during tool use.
|
|
288
319
|
* When true, the model can call multiple functions in parallel.
|
|
289
320
|
* When false, the model will call functions sequentially.
|
|
290
321
|
* Defaults to true.
|
|
291
322
|
*/
|
|
292
|
-
parallel_function_calling:
|
|
323
|
+
parallel_function_calling: z2.boolean().optional(),
|
|
293
324
|
/**
|
|
294
325
|
* @deprecated xAI has deprecated Live Search (`search_parameters`) in favor
|
|
295
326
|
* of the Agent Tools API. Requests using this option now return a "Live
|
|
@@ -299,32 +330,32 @@ var xaiLanguageModelChatOptions = z.object({
|
|
|
299
330
|
*
|
|
300
331
|
* @see https://docs.x.ai/docs/guides/tools/overview
|
|
301
332
|
*/
|
|
302
|
-
searchParameters:
|
|
333
|
+
searchParameters: z2.object({
|
|
303
334
|
/**
|
|
304
335
|
* search mode preference
|
|
305
336
|
* - "off": disables search completely
|
|
306
337
|
* - "auto": model decides whether to search (default)
|
|
307
338
|
* - "on": always enables search
|
|
308
339
|
*/
|
|
309
|
-
mode:
|
|
340
|
+
mode: z2.enum(["off", "auto", "on"]),
|
|
310
341
|
/**
|
|
311
342
|
* whether to return citations in the response
|
|
312
343
|
* defaults to true
|
|
313
344
|
*/
|
|
314
|
-
returnCitations:
|
|
345
|
+
returnCitations: z2.boolean().optional(),
|
|
315
346
|
/**
|
|
316
347
|
* start date for search data (ISO8601 format: YYYY-MM-DD)
|
|
317
348
|
*/
|
|
318
|
-
fromDate:
|
|
349
|
+
fromDate: z2.string().optional(),
|
|
319
350
|
/**
|
|
320
351
|
* end date for search data (ISO8601 format: YYYY-MM-DD)
|
|
321
352
|
*/
|
|
322
|
-
toDate:
|
|
353
|
+
toDate: z2.string().optional(),
|
|
323
354
|
/**
|
|
324
355
|
* maximum number of search results to consider
|
|
325
356
|
* defaults to 20
|
|
326
357
|
*/
|
|
327
|
-
maxSearchResults:
|
|
358
|
+
maxSearchResults: z2.number().min(1).max(50).optional(),
|
|
328
359
|
/**
|
|
329
360
|
* data sources to search from.
|
|
330
361
|
* defaults to [{ type: 'web' }, { type: 'x' }] if not specified.
|
|
@@ -332,26 +363,26 @@ var xaiLanguageModelChatOptions = z.object({
|
|
|
332
363
|
* @example
|
|
333
364
|
* sources: [{ type: 'web', country: 'US' }, { type: 'x' }]
|
|
334
365
|
*/
|
|
335
|
-
sources:
|
|
366
|
+
sources: z2.array(searchSourceSchema).optional()
|
|
336
367
|
}).optional()
|
|
337
368
|
});
|
|
338
369
|
|
|
339
370
|
// src/xai-error.ts
|
|
340
371
|
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
341
|
-
import { z as
|
|
342
|
-
var chatCompletionsErrorSchema =
|
|
343
|
-
error:
|
|
344
|
-
message:
|
|
345
|
-
type:
|
|
346
|
-
param:
|
|
347
|
-
code:
|
|
372
|
+
import { z as z3 } from "zod/v4";
|
|
373
|
+
var chatCompletionsErrorSchema = z3.object({
|
|
374
|
+
error: z3.object({
|
|
375
|
+
message: z3.string(),
|
|
376
|
+
type: z3.string().nullish(),
|
|
377
|
+
param: z3.any().nullish(),
|
|
378
|
+
code: z3.union([z3.string(), z3.number()]).nullish()
|
|
348
379
|
})
|
|
349
380
|
});
|
|
350
|
-
var responsesErrorSchema =
|
|
351
|
-
code:
|
|
352
|
-
error:
|
|
381
|
+
var responsesErrorSchema = z3.object({
|
|
382
|
+
code: z3.string(),
|
|
383
|
+
error: z3.string()
|
|
353
384
|
});
|
|
354
|
-
var xaiErrorDataSchema =
|
|
385
|
+
var xaiErrorDataSchema = z3.union([
|
|
355
386
|
chatCompletionsErrorSchema,
|
|
356
387
|
responsesErrorSchema
|
|
357
388
|
]);
|
|
@@ -480,7 +511,7 @@ var XaiChatLanguageModel = class _XaiChatLanguageModel {
|
|
|
480
511
|
}) {
|
|
481
512
|
var _a, _b, _c;
|
|
482
513
|
const warnings = [];
|
|
483
|
-
const options = (_a = await
|
|
514
|
+
const options = (_a = await parseProviderOptions2({
|
|
484
515
|
provider: "xai",
|
|
485
516
|
providerOptions,
|
|
486
517
|
schema: xaiLanguageModelChatOptions
|
|
@@ -497,7 +528,7 @@ var XaiChatLanguageModel = class _XaiChatLanguageModel {
|
|
|
497
528
|
if (stopSequences != null) {
|
|
498
529
|
warnings.push({ type: "unsupported", feature: "stopSequences" });
|
|
499
530
|
}
|
|
500
|
-
const { messages, warnings: messageWarnings } = convertToXaiChatMessages(prompt);
|
|
531
|
+
const { messages, warnings: messageWarnings } = await convertToXaiChatMessages(prompt);
|
|
501
532
|
warnings.push(...messageWarnings);
|
|
502
533
|
const {
|
|
503
534
|
tools: xaiTools2,
|
|
@@ -909,85 +940,85 @@ var XaiChatLanguageModel = class _XaiChatLanguageModel {
|
|
|
909
940
|
};
|
|
910
941
|
}
|
|
911
942
|
};
|
|
912
|
-
var xaiUsageSchema =
|
|
913
|
-
prompt_tokens:
|
|
914
|
-
completion_tokens:
|
|
915
|
-
total_tokens:
|
|
916
|
-
prompt_tokens_details:
|
|
917
|
-
text_tokens:
|
|
918
|
-
audio_tokens:
|
|
919
|
-
image_tokens:
|
|
920
|
-
cached_tokens:
|
|
943
|
+
var xaiUsageSchema = z4.object({
|
|
944
|
+
prompt_tokens: z4.number(),
|
|
945
|
+
completion_tokens: z4.number(),
|
|
946
|
+
total_tokens: z4.number(),
|
|
947
|
+
prompt_tokens_details: z4.object({
|
|
948
|
+
text_tokens: z4.number().nullish(),
|
|
949
|
+
audio_tokens: z4.number().nullish(),
|
|
950
|
+
image_tokens: z4.number().nullish(),
|
|
951
|
+
cached_tokens: z4.number().nullish()
|
|
921
952
|
}).nullish(),
|
|
922
|
-
completion_tokens_details:
|
|
923
|
-
reasoning_tokens:
|
|
924
|
-
audio_tokens:
|
|
925
|
-
accepted_prediction_tokens:
|
|
926
|
-
rejected_prediction_tokens:
|
|
953
|
+
completion_tokens_details: z4.object({
|
|
954
|
+
reasoning_tokens: z4.number().nullish(),
|
|
955
|
+
audio_tokens: z4.number().nullish(),
|
|
956
|
+
accepted_prediction_tokens: z4.number().nullish(),
|
|
957
|
+
rejected_prediction_tokens: z4.number().nullish()
|
|
927
958
|
}).nullish()
|
|
928
959
|
});
|
|
929
|
-
var xaiChatResponseSchema =
|
|
930
|
-
id:
|
|
931
|
-
created:
|
|
932
|
-
model:
|
|
933
|
-
choices:
|
|
934
|
-
|
|
935
|
-
message:
|
|
936
|
-
role:
|
|
937
|
-
content:
|
|
938
|
-
reasoning_content:
|
|
939
|
-
tool_calls:
|
|
940
|
-
|
|
941
|
-
id:
|
|
942
|
-
type:
|
|
943
|
-
function:
|
|
944
|
-
name:
|
|
945
|
-
arguments:
|
|
960
|
+
var xaiChatResponseSchema = z4.object({
|
|
961
|
+
id: z4.string().nullish(),
|
|
962
|
+
created: z4.number().nullish(),
|
|
963
|
+
model: z4.string().nullish(),
|
|
964
|
+
choices: z4.array(
|
|
965
|
+
z4.object({
|
|
966
|
+
message: z4.object({
|
|
967
|
+
role: z4.literal("assistant"),
|
|
968
|
+
content: z4.string().nullish(),
|
|
969
|
+
reasoning_content: z4.string().nullish(),
|
|
970
|
+
tool_calls: z4.array(
|
|
971
|
+
z4.object({
|
|
972
|
+
id: z4.string(),
|
|
973
|
+
type: z4.literal("function"),
|
|
974
|
+
function: z4.object({
|
|
975
|
+
name: z4.string(),
|
|
976
|
+
arguments: z4.string()
|
|
946
977
|
})
|
|
947
978
|
})
|
|
948
979
|
).nullish()
|
|
949
980
|
}),
|
|
950
|
-
index:
|
|
951
|
-
finish_reason:
|
|
981
|
+
index: z4.number(),
|
|
982
|
+
finish_reason: z4.string().nullish()
|
|
952
983
|
})
|
|
953
984
|
).nullish(),
|
|
954
|
-
object:
|
|
985
|
+
object: z4.literal("chat.completion").nullish(),
|
|
955
986
|
usage: xaiUsageSchema.nullish(),
|
|
956
|
-
citations:
|
|
957
|
-
code:
|
|
958
|
-
error:
|
|
987
|
+
citations: z4.array(z4.string().url()).nullish(),
|
|
988
|
+
code: z4.string().nullish(),
|
|
989
|
+
error: z4.string().nullish()
|
|
959
990
|
});
|
|
960
|
-
var xaiChatChunkSchema =
|
|
961
|
-
id:
|
|
962
|
-
created:
|
|
963
|
-
model:
|
|
964
|
-
choices:
|
|
965
|
-
|
|
966
|
-
delta:
|
|
967
|
-
role:
|
|
968
|
-
content:
|
|
969
|
-
reasoning_content:
|
|
970
|
-
tool_calls:
|
|
971
|
-
|
|
972
|
-
id:
|
|
973
|
-
type:
|
|
974
|
-
function:
|
|
975
|
-
name:
|
|
976
|
-
arguments:
|
|
991
|
+
var xaiChatChunkSchema = z4.object({
|
|
992
|
+
id: z4.string().nullish(),
|
|
993
|
+
created: z4.number().nullish(),
|
|
994
|
+
model: z4.string().nullish(),
|
|
995
|
+
choices: z4.array(
|
|
996
|
+
z4.object({
|
|
997
|
+
delta: z4.object({
|
|
998
|
+
role: z4.enum(["assistant"]).optional(),
|
|
999
|
+
content: z4.string().nullish(),
|
|
1000
|
+
reasoning_content: z4.string().nullish(),
|
|
1001
|
+
tool_calls: z4.array(
|
|
1002
|
+
z4.object({
|
|
1003
|
+
id: z4.string(),
|
|
1004
|
+
type: z4.literal("function"),
|
|
1005
|
+
function: z4.object({
|
|
1006
|
+
name: z4.string(),
|
|
1007
|
+
arguments: z4.string()
|
|
977
1008
|
})
|
|
978
1009
|
})
|
|
979
1010
|
).nullish()
|
|
980
1011
|
}),
|
|
981
|
-
finish_reason:
|
|
982
|
-
index:
|
|
1012
|
+
finish_reason: z4.string().nullish(),
|
|
1013
|
+
index: z4.number()
|
|
983
1014
|
})
|
|
984
1015
|
),
|
|
985
1016
|
usage: xaiUsageSchema.nullish(),
|
|
986
|
-
citations:
|
|
1017
|
+
citations: z4.array(z4.string().url()).nullish()
|
|
987
1018
|
});
|
|
988
|
-
var xaiStreamErrorSchema =
|
|
989
|
-
code:
|
|
990
|
-
error:
|
|
1019
|
+
var xaiStreamErrorSchema = z4.object({
|
|
1020
|
+
code: z4.string(),
|
|
1021
|
+
error: z4.string()
|
|
991
1022
|
});
|
|
992
1023
|
|
|
993
1024
|
// src/xai-image-model.ts
|
|
@@ -998,23 +1029,23 @@ import {
|
|
|
998
1029
|
createJsonResponseHandler as createJsonResponseHandler2,
|
|
999
1030
|
createStatusCodeErrorResponseHandler,
|
|
1000
1031
|
getFromApi,
|
|
1001
|
-
parseProviderOptions as
|
|
1032
|
+
parseProviderOptions as parseProviderOptions3,
|
|
1002
1033
|
postJsonToApi as postJsonToApi2,
|
|
1003
1034
|
serializeModelOptions as serializeModelOptions2,
|
|
1004
1035
|
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
|
|
1005
1036
|
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2
|
|
1006
1037
|
} from "@ai-sdk/provider-utils";
|
|
1007
|
-
import { z as
|
|
1038
|
+
import { z as z6 } from "zod/v4";
|
|
1008
1039
|
|
|
1009
1040
|
// src/xai-image-model-options.ts
|
|
1010
|
-
import { z as
|
|
1011
|
-
var xaiImageModelOptions =
|
|
1012
|
-
aspect_ratio:
|
|
1013
|
-
output_format:
|
|
1014
|
-
sync_mode:
|
|
1015
|
-
resolution:
|
|
1016
|
-
quality:
|
|
1017
|
-
user:
|
|
1041
|
+
import { z as z5 } from "zod/v4";
|
|
1042
|
+
var xaiImageModelOptions = z5.object({
|
|
1043
|
+
aspect_ratio: z5.string().optional(),
|
|
1044
|
+
output_format: z5.string().optional(),
|
|
1045
|
+
sync_mode: z5.boolean().optional(),
|
|
1046
|
+
resolution: z5.enum(["1k", "2k"]).optional(),
|
|
1047
|
+
quality: z5.enum(["low", "medium", "high"]).optional(),
|
|
1048
|
+
user: z5.string().optional()
|
|
1018
1049
|
});
|
|
1019
1050
|
|
|
1020
1051
|
// src/xai-image-model.ts
|
|
@@ -1070,7 +1101,7 @@ var XaiImageModel = class _XaiImageModel {
|
|
|
1070
1101
|
feature: "mask"
|
|
1071
1102
|
});
|
|
1072
1103
|
}
|
|
1073
|
-
const xaiOptions = await
|
|
1104
|
+
const xaiOptions = await parseProviderOptions3({
|
|
1074
1105
|
provider: "xai",
|
|
1075
1106
|
providerOptions,
|
|
1076
1107
|
schema: xaiImageModelOptions
|
|
@@ -1158,16 +1189,16 @@ var XaiImageModel = class _XaiImageModel {
|
|
|
1158
1189
|
return value;
|
|
1159
1190
|
}
|
|
1160
1191
|
};
|
|
1161
|
-
var xaiImageResponseSchema =
|
|
1162
|
-
data:
|
|
1163
|
-
|
|
1164
|
-
url:
|
|
1165
|
-
b64_json:
|
|
1166
|
-
revised_prompt:
|
|
1192
|
+
var xaiImageResponseSchema = z6.object({
|
|
1193
|
+
data: z6.array(
|
|
1194
|
+
z6.object({
|
|
1195
|
+
url: z6.string().nullish(),
|
|
1196
|
+
b64_json: z6.string().nullish(),
|
|
1197
|
+
revised_prompt: z6.string().nullish()
|
|
1167
1198
|
})
|
|
1168
1199
|
),
|
|
1169
|
-
usage:
|
|
1170
|
-
cost_in_usd_ticks:
|
|
1200
|
+
usage: z6.object({
|
|
1201
|
+
cost_in_usd_ticks: z6.number().nullish()
|
|
1171
1202
|
}).nullish()
|
|
1172
1203
|
});
|
|
1173
1204
|
|
|
@@ -1178,7 +1209,7 @@ import {
|
|
|
1178
1209
|
createJsonResponseHandler as createJsonResponseHandler3,
|
|
1179
1210
|
isCustomReasoning as isCustomReasoning2,
|
|
1180
1211
|
mapReasoningToProviderEffort as mapReasoningToProviderEffort2,
|
|
1181
|
-
parseProviderOptions as
|
|
1212
|
+
parseProviderOptions as parseProviderOptions5,
|
|
1182
1213
|
postJsonToApi as postJsonToApi3,
|
|
1183
1214
|
serializeModelOptions as serializeModelOptions3,
|
|
1184
1215
|
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE3,
|
|
@@ -1192,6 +1223,7 @@ import {
|
|
|
1192
1223
|
import {
|
|
1193
1224
|
convertToBase64 as convertToBase642,
|
|
1194
1225
|
getTopLevelMediaType as getTopLevelMediaType2,
|
|
1226
|
+
parseProviderOptions as parseProviderOptions4,
|
|
1195
1227
|
resolveFullMediaType as resolveFullMediaType2,
|
|
1196
1228
|
resolveProviderReference as resolveProviderReference2
|
|
1197
1229
|
} from "@ai-sdk/provider-utils";
|
|
@@ -1239,9 +1271,17 @@ async function convertToXaiResponsesInput({
|
|
|
1239
1271
|
case "data": {
|
|
1240
1272
|
if (getTopLevelMediaType2(block.mediaType) === "image") {
|
|
1241
1273
|
const imageUrl = block.data.type === "url" ? block.data.url.toString() : `data:${resolveFullMediaType2({ part: block })};base64,${convertToBase642(block.data.data)}`;
|
|
1274
|
+
const filePartOptions = await parseProviderOptions4({
|
|
1275
|
+
provider: "xai",
|
|
1276
|
+
providerOptions: block.providerOptions,
|
|
1277
|
+
schema: xaiFilePartProviderOptions
|
|
1278
|
+
});
|
|
1242
1279
|
contentParts.push({
|
|
1243
1280
|
type: "input_image",
|
|
1244
|
-
image_url: imageUrl
|
|
1281
|
+
image_url: imageUrl,
|
|
1282
|
+
...(filePartOptions == null ? void 0 : filePartOptions.imageDetail) != null && {
|
|
1283
|
+
detail: filePartOptions.imageDetail
|
|
1284
|
+
}
|
|
1245
1285
|
});
|
|
1246
1286
|
} else if (block.data.type === "url") {
|
|
1247
1287
|
contentParts.push({
|
|
@@ -1445,437 +1485,437 @@ function mapXaiResponsesFinishReason(finishReason) {
|
|
|
1445
1485
|
}
|
|
1446
1486
|
|
|
1447
1487
|
// src/responses/xai-responses-api.ts
|
|
1448
|
-
import { z as
|
|
1449
|
-
var annotationSchema =
|
|
1450
|
-
|
|
1451
|
-
type:
|
|
1452
|
-
url:
|
|
1453
|
-
title:
|
|
1488
|
+
import { z as z7 } from "zod/v4";
|
|
1489
|
+
var annotationSchema = z7.union([
|
|
1490
|
+
z7.object({
|
|
1491
|
+
type: z7.literal("url_citation"),
|
|
1492
|
+
url: z7.string(),
|
|
1493
|
+
title: z7.string().optional()
|
|
1454
1494
|
}),
|
|
1455
|
-
|
|
1456
|
-
type:
|
|
1495
|
+
z7.object({
|
|
1496
|
+
type: z7.string()
|
|
1457
1497
|
})
|
|
1458
1498
|
]);
|
|
1459
|
-
var messageContentPartSchema =
|
|
1460
|
-
type:
|
|
1461
|
-
text:
|
|
1462
|
-
logprobs:
|
|
1463
|
-
annotations:
|
|
1499
|
+
var messageContentPartSchema = z7.object({
|
|
1500
|
+
type: z7.string(),
|
|
1501
|
+
text: z7.string().optional(),
|
|
1502
|
+
logprobs: z7.array(z7.any()).optional(),
|
|
1503
|
+
annotations: z7.array(annotationSchema).optional()
|
|
1464
1504
|
});
|
|
1465
|
-
var reasoningSummaryPartSchema =
|
|
1466
|
-
type:
|
|
1467
|
-
text:
|
|
1505
|
+
var reasoningSummaryPartSchema = z7.object({
|
|
1506
|
+
type: z7.string(),
|
|
1507
|
+
text: z7.string()
|
|
1468
1508
|
});
|
|
1469
|
-
var toolCallSchema =
|
|
1470
|
-
name:
|
|
1471
|
-
arguments:
|
|
1472
|
-
input:
|
|
1473
|
-
call_id:
|
|
1474
|
-
id:
|
|
1475
|
-
status:
|
|
1476
|
-
action:
|
|
1509
|
+
var toolCallSchema = z7.object({
|
|
1510
|
+
name: z7.string().optional(),
|
|
1511
|
+
arguments: z7.string().optional(),
|
|
1512
|
+
input: z7.string().optional(),
|
|
1513
|
+
call_id: z7.string().optional(),
|
|
1514
|
+
id: z7.string(),
|
|
1515
|
+
status: z7.string(),
|
|
1516
|
+
action: z7.any().optional()
|
|
1477
1517
|
});
|
|
1478
|
-
var mcpCallSchema =
|
|
1479
|
-
name:
|
|
1480
|
-
arguments:
|
|
1481
|
-
output:
|
|
1482
|
-
error:
|
|
1483
|
-
id:
|
|
1484
|
-
status:
|
|
1485
|
-
server_label:
|
|
1518
|
+
var mcpCallSchema = z7.object({
|
|
1519
|
+
name: z7.string().optional(),
|
|
1520
|
+
arguments: z7.string().optional(),
|
|
1521
|
+
output: z7.string().optional(),
|
|
1522
|
+
error: z7.string().optional(),
|
|
1523
|
+
id: z7.string(),
|
|
1524
|
+
status: z7.string(),
|
|
1525
|
+
server_label: z7.string().optional()
|
|
1486
1526
|
});
|
|
1487
|
-
var outputItemSchema =
|
|
1488
|
-
|
|
1489
|
-
type:
|
|
1527
|
+
var outputItemSchema = z7.discriminatedUnion("type", [
|
|
1528
|
+
z7.object({
|
|
1529
|
+
type: z7.literal("web_search_call"),
|
|
1490
1530
|
...toolCallSchema.shape
|
|
1491
1531
|
}),
|
|
1492
|
-
|
|
1493
|
-
type:
|
|
1532
|
+
z7.object({
|
|
1533
|
+
type: z7.literal("x_search_call"),
|
|
1494
1534
|
...toolCallSchema.shape
|
|
1495
1535
|
}),
|
|
1496
|
-
|
|
1497
|
-
type:
|
|
1536
|
+
z7.object({
|
|
1537
|
+
type: z7.literal("code_interpreter_call"),
|
|
1498
1538
|
...toolCallSchema.shape
|
|
1499
1539
|
}),
|
|
1500
|
-
|
|
1501
|
-
type:
|
|
1540
|
+
z7.object({
|
|
1541
|
+
type: z7.literal("code_execution_call"),
|
|
1502
1542
|
...toolCallSchema.shape
|
|
1503
1543
|
}),
|
|
1504
|
-
|
|
1505
|
-
type:
|
|
1544
|
+
z7.object({
|
|
1545
|
+
type: z7.literal("view_image_call"),
|
|
1506
1546
|
...toolCallSchema.shape
|
|
1507
1547
|
}),
|
|
1508
|
-
|
|
1509
|
-
type:
|
|
1548
|
+
z7.object({
|
|
1549
|
+
type: z7.literal("view_x_video_call"),
|
|
1510
1550
|
...toolCallSchema.shape
|
|
1511
1551
|
}),
|
|
1512
|
-
|
|
1513
|
-
type:
|
|
1514
|
-
id:
|
|
1515
|
-
status:
|
|
1516
|
-
queries:
|
|
1517
|
-
results:
|
|
1518
|
-
|
|
1519
|
-
file_id:
|
|
1520
|
-
filename:
|
|
1521
|
-
score:
|
|
1522
|
-
text:
|
|
1552
|
+
z7.object({
|
|
1553
|
+
type: z7.literal("file_search_call"),
|
|
1554
|
+
id: z7.string(),
|
|
1555
|
+
status: z7.string(),
|
|
1556
|
+
queries: z7.array(z7.string()).optional(),
|
|
1557
|
+
results: z7.array(
|
|
1558
|
+
z7.object({
|
|
1559
|
+
file_id: z7.string(),
|
|
1560
|
+
filename: z7.string(),
|
|
1561
|
+
score: z7.number(),
|
|
1562
|
+
text: z7.string()
|
|
1523
1563
|
})
|
|
1524
1564
|
).nullish()
|
|
1525
1565
|
}),
|
|
1526
|
-
|
|
1527
|
-
type:
|
|
1566
|
+
z7.object({
|
|
1567
|
+
type: z7.literal("custom_tool_call"),
|
|
1528
1568
|
...toolCallSchema.shape
|
|
1529
1569
|
}),
|
|
1530
|
-
|
|
1531
|
-
type:
|
|
1570
|
+
z7.object({
|
|
1571
|
+
type: z7.literal("mcp_call"),
|
|
1532
1572
|
...mcpCallSchema.shape
|
|
1533
1573
|
}),
|
|
1534
|
-
|
|
1535
|
-
type:
|
|
1536
|
-
role:
|
|
1537
|
-
content:
|
|
1538
|
-
id:
|
|
1539
|
-
status:
|
|
1574
|
+
z7.object({
|
|
1575
|
+
type: z7.literal("message"),
|
|
1576
|
+
role: z7.string(),
|
|
1577
|
+
content: z7.array(messageContentPartSchema),
|
|
1578
|
+
id: z7.string(),
|
|
1579
|
+
status: z7.string()
|
|
1540
1580
|
}),
|
|
1541
|
-
|
|
1542
|
-
type:
|
|
1543
|
-
name:
|
|
1544
|
-
arguments:
|
|
1545
|
-
call_id:
|
|
1546
|
-
id:
|
|
1581
|
+
z7.object({
|
|
1582
|
+
type: z7.literal("function_call"),
|
|
1583
|
+
name: z7.string(),
|
|
1584
|
+
arguments: z7.string(),
|
|
1585
|
+
call_id: z7.string(),
|
|
1586
|
+
id: z7.string()
|
|
1547
1587
|
}),
|
|
1548
|
-
|
|
1549
|
-
type:
|
|
1550
|
-
id:
|
|
1551
|
-
summary:
|
|
1552
|
-
content:
|
|
1553
|
-
status:
|
|
1554
|
-
encrypted_content:
|
|
1588
|
+
z7.object({
|
|
1589
|
+
type: z7.literal("reasoning"),
|
|
1590
|
+
id: z7.string(),
|
|
1591
|
+
summary: z7.array(reasoningSummaryPartSchema),
|
|
1592
|
+
content: z7.array(z7.object({ type: z7.string(), text: z7.string() })).nullish(),
|
|
1593
|
+
status: z7.string(),
|
|
1594
|
+
encrypted_content: z7.string().nullish()
|
|
1555
1595
|
})
|
|
1556
1596
|
]);
|
|
1557
|
-
var xaiResponsesUsageSchema =
|
|
1558
|
-
input_tokens:
|
|
1559
|
-
output_tokens:
|
|
1560
|
-
total_tokens:
|
|
1561
|
-
input_tokens_details:
|
|
1562
|
-
cached_tokens:
|
|
1597
|
+
var xaiResponsesUsageSchema = z7.object({
|
|
1598
|
+
input_tokens: z7.number(),
|
|
1599
|
+
output_tokens: z7.number(),
|
|
1600
|
+
total_tokens: z7.number().optional(),
|
|
1601
|
+
input_tokens_details: z7.object({
|
|
1602
|
+
cached_tokens: z7.number().optional()
|
|
1563
1603
|
}).optional(),
|
|
1564
|
-
output_tokens_details:
|
|
1565
|
-
reasoning_tokens:
|
|
1604
|
+
output_tokens_details: z7.object({
|
|
1605
|
+
reasoning_tokens: z7.number().optional()
|
|
1566
1606
|
}).optional(),
|
|
1567
|
-
num_sources_used:
|
|
1568
|
-
num_server_side_tools_used:
|
|
1569
|
-
cost_in_usd_ticks:
|
|
1607
|
+
num_sources_used: z7.number().optional(),
|
|
1608
|
+
num_server_side_tools_used: z7.number().optional(),
|
|
1609
|
+
cost_in_usd_ticks: z7.number().nullish()
|
|
1570
1610
|
});
|
|
1571
|
-
var xaiResponsesResponseSchema =
|
|
1572
|
-
id:
|
|
1573
|
-
created_at:
|
|
1574
|
-
model:
|
|
1575
|
-
object:
|
|
1576
|
-
output:
|
|
1611
|
+
var xaiResponsesResponseSchema = z7.object({
|
|
1612
|
+
id: z7.string().nullish(),
|
|
1613
|
+
created_at: z7.number().nullish(),
|
|
1614
|
+
model: z7.string().nullish(),
|
|
1615
|
+
object: z7.literal("response"),
|
|
1616
|
+
output: z7.array(outputItemSchema),
|
|
1577
1617
|
usage: xaiResponsesUsageSchema.nullish(),
|
|
1578
|
-
status:
|
|
1618
|
+
status: z7.string()
|
|
1579
1619
|
});
|
|
1580
|
-
var xaiResponsesChunkSchema =
|
|
1581
|
-
|
|
1582
|
-
type:
|
|
1620
|
+
var xaiResponsesChunkSchema = z7.union([
|
|
1621
|
+
z7.object({
|
|
1622
|
+
type: z7.literal("response.created"),
|
|
1583
1623
|
response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
|
|
1584
1624
|
}),
|
|
1585
|
-
|
|
1586
|
-
type:
|
|
1625
|
+
z7.object({
|
|
1626
|
+
type: z7.literal("response.in_progress"),
|
|
1587
1627
|
response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
|
|
1588
1628
|
}),
|
|
1589
|
-
|
|
1590
|
-
type:
|
|
1629
|
+
z7.object({
|
|
1630
|
+
type: z7.literal("response.output_item.added"),
|
|
1591
1631
|
item: outputItemSchema,
|
|
1592
|
-
output_index:
|
|
1632
|
+
output_index: z7.number()
|
|
1593
1633
|
}),
|
|
1594
|
-
|
|
1595
|
-
type:
|
|
1634
|
+
z7.object({
|
|
1635
|
+
type: z7.literal("response.output_item.done"),
|
|
1596
1636
|
item: outputItemSchema,
|
|
1597
|
-
output_index:
|
|
1637
|
+
output_index: z7.number()
|
|
1598
1638
|
}),
|
|
1599
|
-
|
|
1600
|
-
type:
|
|
1601
|
-
item_id:
|
|
1602
|
-
output_index:
|
|
1603
|
-
content_index:
|
|
1639
|
+
z7.object({
|
|
1640
|
+
type: z7.literal("response.content_part.added"),
|
|
1641
|
+
item_id: z7.string(),
|
|
1642
|
+
output_index: z7.number(),
|
|
1643
|
+
content_index: z7.number(),
|
|
1604
1644
|
part: messageContentPartSchema
|
|
1605
1645
|
}),
|
|
1606
|
-
|
|
1607
|
-
type:
|
|
1608
|
-
item_id:
|
|
1609
|
-
output_index:
|
|
1610
|
-
content_index:
|
|
1646
|
+
z7.object({
|
|
1647
|
+
type: z7.literal("response.content_part.done"),
|
|
1648
|
+
item_id: z7.string(),
|
|
1649
|
+
output_index: z7.number(),
|
|
1650
|
+
content_index: z7.number(),
|
|
1611
1651
|
part: messageContentPartSchema
|
|
1612
1652
|
}),
|
|
1613
|
-
|
|
1614
|
-
type:
|
|
1615
|
-
item_id:
|
|
1616
|
-
output_index:
|
|
1617
|
-
content_index:
|
|
1618
|
-
delta:
|
|
1619
|
-
logprobs:
|
|
1653
|
+
z7.object({
|
|
1654
|
+
type: z7.literal("response.output_text.delta"),
|
|
1655
|
+
item_id: z7.string(),
|
|
1656
|
+
output_index: z7.number(),
|
|
1657
|
+
content_index: z7.number(),
|
|
1658
|
+
delta: z7.string(),
|
|
1659
|
+
logprobs: z7.array(z7.any()).optional()
|
|
1620
1660
|
}),
|
|
1621
|
-
|
|
1622
|
-
type:
|
|
1623
|
-
item_id:
|
|
1624
|
-
output_index:
|
|
1625
|
-
content_index:
|
|
1626
|
-
text:
|
|
1627
|
-
logprobs:
|
|
1628
|
-
annotations:
|
|
1661
|
+
z7.object({
|
|
1662
|
+
type: z7.literal("response.output_text.done"),
|
|
1663
|
+
item_id: z7.string(),
|
|
1664
|
+
output_index: z7.number(),
|
|
1665
|
+
content_index: z7.number(),
|
|
1666
|
+
text: z7.string(),
|
|
1667
|
+
logprobs: z7.array(z7.any()).optional(),
|
|
1668
|
+
annotations: z7.array(annotationSchema).optional()
|
|
1629
1669
|
}),
|
|
1630
|
-
|
|
1631
|
-
type:
|
|
1632
|
-
item_id:
|
|
1633
|
-
output_index:
|
|
1634
|
-
content_index:
|
|
1635
|
-
annotation_index:
|
|
1670
|
+
z7.object({
|
|
1671
|
+
type: z7.literal("response.output_text.annotation.added"),
|
|
1672
|
+
item_id: z7.string(),
|
|
1673
|
+
output_index: z7.number(),
|
|
1674
|
+
content_index: z7.number(),
|
|
1675
|
+
annotation_index: z7.number(),
|
|
1636
1676
|
annotation: annotationSchema
|
|
1637
1677
|
}),
|
|
1638
|
-
|
|
1639
|
-
type:
|
|
1640
|
-
item_id:
|
|
1641
|
-
output_index:
|
|
1642
|
-
summary_index:
|
|
1678
|
+
z7.object({
|
|
1679
|
+
type: z7.literal("response.reasoning_summary_part.added"),
|
|
1680
|
+
item_id: z7.string(),
|
|
1681
|
+
output_index: z7.number(),
|
|
1682
|
+
summary_index: z7.number(),
|
|
1643
1683
|
part: reasoningSummaryPartSchema
|
|
1644
1684
|
}),
|
|
1645
|
-
|
|
1646
|
-
type:
|
|
1647
|
-
item_id:
|
|
1648
|
-
output_index:
|
|
1649
|
-
summary_index:
|
|
1685
|
+
z7.object({
|
|
1686
|
+
type: z7.literal("response.reasoning_summary_part.done"),
|
|
1687
|
+
item_id: z7.string(),
|
|
1688
|
+
output_index: z7.number(),
|
|
1689
|
+
summary_index: z7.number(),
|
|
1650
1690
|
part: reasoningSummaryPartSchema
|
|
1651
1691
|
}),
|
|
1652
|
-
|
|
1653
|
-
type:
|
|
1654
|
-
item_id:
|
|
1655
|
-
output_index:
|
|
1656
|
-
summary_index:
|
|
1657
|
-
delta:
|
|
1692
|
+
z7.object({
|
|
1693
|
+
type: z7.literal("response.reasoning_summary_text.delta"),
|
|
1694
|
+
item_id: z7.string(),
|
|
1695
|
+
output_index: z7.number(),
|
|
1696
|
+
summary_index: z7.number(),
|
|
1697
|
+
delta: z7.string()
|
|
1658
1698
|
}),
|
|
1659
|
-
|
|
1660
|
-
type:
|
|
1661
|
-
item_id:
|
|
1662
|
-
output_index:
|
|
1663
|
-
summary_index:
|
|
1664
|
-
text:
|
|
1699
|
+
z7.object({
|
|
1700
|
+
type: z7.literal("response.reasoning_summary_text.done"),
|
|
1701
|
+
item_id: z7.string(),
|
|
1702
|
+
output_index: z7.number(),
|
|
1703
|
+
summary_index: z7.number(),
|
|
1704
|
+
text: z7.string()
|
|
1665
1705
|
}),
|
|
1666
|
-
|
|
1667
|
-
type:
|
|
1668
|
-
item_id:
|
|
1669
|
-
output_index:
|
|
1670
|
-
content_index:
|
|
1671
|
-
delta:
|
|
1706
|
+
z7.object({
|
|
1707
|
+
type: z7.literal("response.reasoning_text.delta"),
|
|
1708
|
+
item_id: z7.string(),
|
|
1709
|
+
output_index: z7.number(),
|
|
1710
|
+
content_index: z7.number(),
|
|
1711
|
+
delta: z7.string()
|
|
1672
1712
|
}),
|
|
1673
|
-
|
|
1674
|
-
type:
|
|
1675
|
-
item_id:
|
|
1676
|
-
output_index:
|
|
1677
|
-
content_index:
|
|
1678
|
-
text:
|
|
1713
|
+
z7.object({
|
|
1714
|
+
type: z7.literal("response.reasoning_text.done"),
|
|
1715
|
+
item_id: z7.string(),
|
|
1716
|
+
output_index: z7.number(),
|
|
1717
|
+
content_index: z7.number(),
|
|
1718
|
+
text: z7.string()
|
|
1679
1719
|
}),
|
|
1680
|
-
|
|
1681
|
-
type:
|
|
1682
|
-
item_id:
|
|
1683
|
-
output_index:
|
|
1720
|
+
z7.object({
|
|
1721
|
+
type: z7.literal("response.web_search_call.in_progress"),
|
|
1722
|
+
item_id: z7.string(),
|
|
1723
|
+
output_index: z7.number()
|
|
1684
1724
|
}),
|
|
1685
|
-
|
|
1686
|
-
type:
|
|
1687
|
-
item_id:
|
|
1688
|
-
output_index:
|
|
1725
|
+
z7.object({
|
|
1726
|
+
type: z7.literal("response.web_search_call.searching"),
|
|
1727
|
+
item_id: z7.string(),
|
|
1728
|
+
output_index: z7.number()
|
|
1689
1729
|
}),
|
|
1690
|
-
|
|
1691
|
-
type:
|
|
1692
|
-
item_id:
|
|
1693
|
-
output_index:
|
|
1730
|
+
z7.object({
|
|
1731
|
+
type: z7.literal("response.web_search_call.completed"),
|
|
1732
|
+
item_id: z7.string(),
|
|
1733
|
+
output_index: z7.number()
|
|
1694
1734
|
}),
|
|
1695
|
-
|
|
1696
|
-
type:
|
|
1697
|
-
item_id:
|
|
1698
|
-
output_index:
|
|
1735
|
+
z7.object({
|
|
1736
|
+
type: z7.literal("response.x_search_call.in_progress"),
|
|
1737
|
+
item_id: z7.string(),
|
|
1738
|
+
output_index: z7.number()
|
|
1699
1739
|
}),
|
|
1700
|
-
|
|
1701
|
-
type:
|
|
1702
|
-
item_id:
|
|
1703
|
-
output_index:
|
|
1740
|
+
z7.object({
|
|
1741
|
+
type: z7.literal("response.x_search_call.searching"),
|
|
1742
|
+
item_id: z7.string(),
|
|
1743
|
+
output_index: z7.number()
|
|
1704
1744
|
}),
|
|
1705
|
-
|
|
1706
|
-
type:
|
|
1707
|
-
item_id:
|
|
1708
|
-
output_index:
|
|
1745
|
+
z7.object({
|
|
1746
|
+
type: z7.literal("response.x_search_call.completed"),
|
|
1747
|
+
item_id: z7.string(),
|
|
1748
|
+
output_index: z7.number()
|
|
1709
1749
|
}),
|
|
1710
|
-
|
|
1711
|
-
type:
|
|
1712
|
-
item_id:
|
|
1713
|
-
output_index:
|
|
1750
|
+
z7.object({
|
|
1751
|
+
type: z7.literal("response.file_search_call.in_progress"),
|
|
1752
|
+
item_id: z7.string(),
|
|
1753
|
+
output_index: z7.number()
|
|
1714
1754
|
}),
|
|
1715
|
-
|
|
1716
|
-
type:
|
|
1717
|
-
item_id:
|
|
1718
|
-
output_index:
|
|
1755
|
+
z7.object({
|
|
1756
|
+
type: z7.literal("response.file_search_call.searching"),
|
|
1757
|
+
item_id: z7.string(),
|
|
1758
|
+
output_index: z7.number()
|
|
1719
1759
|
}),
|
|
1720
|
-
|
|
1721
|
-
type:
|
|
1722
|
-
item_id:
|
|
1723
|
-
output_index:
|
|
1760
|
+
z7.object({
|
|
1761
|
+
type: z7.literal("response.file_search_call.completed"),
|
|
1762
|
+
item_id: z7.string(),
|
|
1763
|
+
output_index: z7.number()
|
|
1724
1764
|
}),
|
|
1725
|
-
|
|
1726
|
-
type:
|
|
1727
|
-
item_id:
|
|
1728
|
-
output_index:
|
|
1765
|
+
z7.object({
|
|
1766
|
+
type: z7.literal("response.code_execution_call.in_progress"),
|
|
1767
|
+
item_id: z7.string(),
|
|
1768
|
+
output_index: z7.number()
|
|
1729
1769
|
}),
|
|
1730
|
-
|
|
1731
|
-
type:
|
|
1732
|
-
item_id:
|
|
1733
|
-
output_index:
|
|
1770
|
+
z7.object({
|
|
1771
|
+
type: z7.literal("response.code_execution_call.executing"),
|
|
1772
|
+
item_id: z7.string(),
|
|
1773
|
+
output_index: z7.number()
|
|
1734
1774
|
}),
|
|
1735
|
-
|
|
1736
|
-
type:
|
|
1737
|
-
item_id:
|
|
1738
|
-
output_index:
|
|
1775
|
+
z7.object({
|
|
1776
|
+
type: z7.literal("response.code_execution_call.completed"),
|
|
1777
|
+
item_id: z7.string(),
|
|
1778
|
+
output_index: z7.number()
|
|
1739
1779
|
}),
|
|
1740
|
-
|
|
1741
|
-
type:
|
|
1742
|
-
item_id:
|
|
1743
|
-
output_index:
|
|
1780
|
+
z7.object({
|
|
1781
|
+
type: z7.literal("response.code_interpreter_call.in_progress"),
|
|
1782
|
+
item_id: z7.string(),
|
|
1783
|
+
output_index: z7.number()
|
|
1744
1784
|
}),
|
|
1745
|
-
|
|
1746
|
-
type:
|
|
1747
|
-
item_id:
|
|
1748
|
-
output_index:
|
|
1785
|
+
z7.object({
|
|
1786
|
+
type: z7.literal("response.code_interpreter_call.executing"),
|
|
1787
|
+
item_id: z7.string(),
|
|
1788
|
+
output_index: z7.number()
|
|
1749
1789
|
}),
|
|
1750
|
-
|
|
1751
|
-
type:
|
|
1752
|
-
item_id:
|
|
1753
|
-
output_index:
|
|
1790
|
+
z7.object({
|
|
1791
|
+
type: z7.literal("response.code_interpreter_call.interpreting"),
|
|
1792
|
+
item_id: z7.string(),
|
|
1793
|
+
output_index: z7.number()
|
|
1754
1794
|
}),
|
|
1755
|
-
|
|
1756
|
-
type:
|
|
1757
|
-
item_id:
|
|
1758
|
-
output_index:
|
|
1795
|
+
z7.object({
|
|
1796
|
+
type: z7.literal("response.code_interpreter_call.completed"),
|
|
1797
|
+
item_id: z7.string(),
|
|
1798
|
+
output_index: z7.number()
|
|
1759
1799
|
}),
|
|
1760
1800
|
// Code interpreter code streaming events
|
|
1761
|
-
|
|
1762
|
-
type:
|
|
1763
|
-
item_id:
|
|
1764
|
-
output_index:
|
|
1765
|
-
delta:
|
|
1801
|
+
z7.object({
|
|
1802
|
+
type: z7.literal("response.code_interpreter_call_code.delta"),
|
|
1803
|
+
item_id: z7.string(),
|
|
1804
|
+
output_index: z7.number(),
|
|
1805
|
+
delta: z7.string()
|
|
1766
1806
|
}),
|
|
1767
|
-
|
|
1768
|
-
type:
|
|
1769
|
-
item_id:
|
|
1770
|
-
output_index:
|
|
1771
|
-
code:
|
|
1807
|
+
z7.object({
|
|
1808
|
+
type: z7.literal("response.code_interpreter_call_code.done"),
|
|
1809
|
+
item_id: z7.string(),
|
|
1810
|
+
output_index: z7.number(),
|
|
1811
|
+
code: z7.string()
|
|
1772
1812
|
}),
|
|
1773
|
-
|
|
1774
|
-
type:
|
|
1775
|
-
item_id:
|
|
1776
|
-
output_index:
|
|
1777
|
-
delta:
|
|
1813
|
+
z7.object({
|
|
1814
|
+
type: z7.literal("response.custom_tool_call_input.delta"),
|
|
1815
|
+
item_id: z7.string(),
|
|
1816
|
+
output_index: z7.number(),
|
|
1817
|
+
delta: z7.string()
|
|
1778
1818
|
}),
|
|
1779
|
-
|
|
1780
|
-
type:
|
|
1781
|
-
item_id:
|
|
1782
|
-
output_index:
|
|
1783
|
-
input:
|
|
1819
|
+
z7.object({
|
|
1820
|
+
type: z7.literal("response.custom_tool_call_input.done"),
|
|
1821
|
+
item_id: z7.string(),
|
|
1822
|
+
output_index: z7.number(),
|
|
1823
|
+
input: z7.string()
|
|
1784
1824
|
}),
|
|
1785
1825
|
// Function call arguments streaming events (standard function tools)
|
|
1786
|
-
|
|
1787
|
-
type:
|
|
1788
|
-
item_id:
|
|
1789
|
-
output_index:
|
|
1790
|
-
delta:
|
|
1826
|
+
z7.object({
|
|
1827
|
+
type: z7.literal("response.function_call_arguments.delta"),
|
|
1828
|
+
item_id: z7.string(),
|
|
1829
|
+
output_index: z7.number(),
|
|
1830
|
+
delta: z7.string()
|
|
1791
1831
|
}),
|
|
1792
|
-
|
|
1793
|
-
type:
|
|
1794
|
-
item_id:
|
|
1795
|
-
output_index:
|
|
1796
|
-
arguments:
|
|
1832
|
+
z7.object({
|
|
1833
|
+
type: z7.literal("response.function_call_arguments.done"),
|
|
1834
|
+
item_id: z7.string(),
|
|
1835
|
+
output_index: z7.number(),
|
|
1836
|
+
arguments: z7.string()
|
|
1797
1837
|
}),
|
|
1798
|
-
|
|
1799
|
-
type:
|
|
1800
|
-
item_id:
|
|
1801
|
-
output_index:
|
|
1838
|
+
z7.object({
|
|
1839
|
+
type: z7.literal("response.mcp_call.in_progress"),
|
|
1840
|
+
item_id: z7.string(),
|
|
1841
|
+
output_index: z7.number()
|
|
1802
1842
|
}),
|
|
1803
|
-
|
|
1804
|
-
type:
|
|
1805
|
-
item_id:
|
|
1806
|
-
output_index:
|
|
1843
|
+
z7.object({
|
|
1844
|
+
type: z7.literal("response.mcp_call.executing"),
|
|
1845
|
+
item_id: z7.string(),
|
|
1846
|
+
output_index: z7.number()
|
|
1807
1847
|
}),
|
|
1808
|
-
|
|
1809
|
-
type:
|
|
1810
|
-
item_id:
|
|
1811
|
-
output_index:
|
|
1848
|
+
z7.object({
|
|
1849
|
+
type: z7.literal("response.mcp_call.completed"),
|
|
1850
|
+
item_id: z7.string(),
|
|
1851
|
+
output_index: z7.number()
|
|
1812
1852
|
}),
|
|
1813
|
-
|
|
1814
|
-
type:
|
|
1815
|
-
item_id:
|
|
1816
|
-
output_index:
|
|
1853
|
+
z7.object({
|
|
1854
|
+
type: z7.literal("response.mcp_call.failed"),
|
|
1855
|
+
item_id: z7.string(),
|
|
1856
|
+
output_index: z7.number()
|
|
1817
1857
|
}),
|
|
1818
|
-
|
|
1819
|
-
type:
|
|
1820
|
-
item_id:
|
|
1821
|
-
output_index:
|
|
1822
|
-
delta:
|
|
1858
|
+
z7.object({
|
|
1859
|
+
type: z7.literal("response.mcp_call_arguments.delta"),
|
|
1860
|
+
item_id: z7.string(),
|
|
1861
|
+
output_index: z7.number(),
|
|
1862
|
+
delta: z7.string()
|
|
1823
1863
|
}),
|
|
1824
|
-
|
|
1825
|
-
type:
|
|
1826
|
-
item_id:
|
|
1827
|
-
output_index:
|
|
1828
|
-
arguments:
|
|
1864
|
+
z7.object({
|
|
1865
|
+
type: z7.literal("response.mcp_call_arguments.done"),
|
|
1866
|
+
item_id: z7.string(),
|
|
1867
|
+
output_index: z7.number(),
|
|
1868
|
+
arguments: z7.string().optional()
|
|
1829
1869
|
}),
|
|
1830
|
-
|
|
1831
|
-
type:
|
|
1832
|
-
item_id:
|
|
1833
|
-
output_index:
|
|
1834
|
-
delta:
|
|
1870
|
+
z7.object({
|
|
1871
|
+
type: z7.literal("response.mcp_call_output.delta"),
|
|
1872
|
+
item_id: z7.string(),
|
|
1873
|
+
output_index: z7.number(),
|
|
1874
|
+
delta: z7.string()
|
|
1835
1875
|
}),
|
|
1836
|
-
|
|
1837
|
-
type:
|
|
1838
|
-
item_id:
|
|
1839
|
-
output_index:
|
|
1840
|
-
output:
|
|
1876
|
+
z7.object({
|
|
1877
|
+
type: z7.literal("response.mcp_call_output.done"),
|
|
1878
|
+
item_id: z7.string(),
|
|
1879
|
+
output_index: z7.number(),
|
|
1880
|
+
output: z7.string().optional()
|
|
1841
1881
|
}),
|
|
1842
|
-
|
|
1843
|
-
type:
|
|
1844
|
-
response:
|
|
1845
|
-
incomplete_details:
|
|
1882
|
+
z7.object({
|
|
1883
|
+
type: z7.literal("response.incomplete"),
|
|
1884
|
+
response: z7.object({
|
|
1885
|
+
incomplete_details: z7.object({ reason: z7.string() }).nullish(),
|
|
1846
1886
|
usage: xaiResponsesUsageSchema.nullish()
|
|
1847
1887
|
})
|
|
1848
1888
|
}),
|
|
1849
|
-
|
|
1850
|
-
type:
|
|
1851
|
-
response:
|
|
1852
|
-
error:
|
|
1853
|
-
code:
|
|
1854
|
-
message:
|
|
1889
|
+
z7.object({
|
|
1890
|
+
type: z7.literal("response.failed"),
|
|
1891
|
+
response: z7.object({
|
|
1892
|
+
error: z7.object({
|
|
1893
|
+
code: z7.string().nullish(),
|
|
1894
|
+
message: z7.string()
|
|
1855
1895
|
}).nullish(),
|
|
1856
|
-
incomplete_details:
|
|
1896
|
+
incomplete_details: z7.object({ reason: z7.string() }).nullish(),
|
|
1857
1897
|
usage: xaiResponsesUsageSchema.nullish()
|
|
1858
1898
|
})
|
|
1859
1899
|
}),
|
|
1860
|
-
|
|
1861
|
-
type:
|
|
1862
|
-
code:
|
|
1863
|
-
message:
|
|
1864
|
-
param:
|
|
1900
|
+
z7.object({
|
|
1901
|
+
type: z7.literal("error"),
|
|
1902
|
+
code: z7.string().nullish(),
|
|
1903
|
+
message: z7.string(),
|
|
1904
|
+
param: z7.string().nullish()
|
|
1865
1905
|
}),
|
|
1866
|
-
|
|
1867
|
-
type:
|
|
1906
|
+
z7.object({
|
|
1907
|
+
type: z7.literal("response.done"),
|
|
1868
1908
|
response: xaiResponsesResponseSchema
|
|
1869
1909
|
}),
|
|
1870
|
-
|
|
1871
|
-
type:
|
|
1910
|
+
z7.object({
|
|
1911
|
+
type: z7.literal("response.completed"),
|
|
1872
1912
|
response: xaiResponsesResponseSchema
|
|
1873
1913
|
})
|
|
1874
1914
|
]);
|
|
1875
1915
|
|
|
1876
1916
|
// src/responses/xai-responses-language-model-options.ts
|
|
1877
|
-
import { z as
|
|
1878
|
-
var xaiLanguageModelResponsesOptions =
|
|
1917
|
+
import { z as z8 } from "zod/v4";
|
|
1918
|
+
var xaiLanguageModelResponsesOptions = z8.object({
|
|
1879
1919
|
/**
|
|
1880
1920
|
* Constrains how hard a reasoning model thinks before responding.
|
|
1881
1921
|
* Possible values are `none` (disables reasoning entirely; supported by
|
|
@@ -1884,26 +1924,26 @@ var xaiLanguageModelResponsesOptions = z7.object({
|
|
|
1884
1924
|
*
|
|
1885
1925
|
* @see https://docs.x.ai/docs/guides/reasoning
|
|
1886
1926
|
*/
|
|
1887
|
-
reasoningEffort:
|
|
1888
|
-
reasoningSummary:
|
|
1889
|
-
logprobs:
|
|
1890
|
-
topLogprobs:
|
|
1927
|
+
reasoningEffort: z8.enum(["none", "low", "medium", "high"]).optional(),
|
|
1928
|
+
reasoningSummary: z8.enum(["auto", "concise", "detailed"]).optional(),
|
|
1929
|
+
logprobs: z8.boolean().optional(),
|
|
1930
|
+
topLogprobs: z8.number().int().min(0).max(8).optional(),
|
|
1891
1931
|
/**
|
|
1892
1932
|
* Whether to store the input message(s) and model response for later retrieval.
|
|
1893
1933
|
* Must be set to `false` for teams with Zero Data Retention (ZDR) enabled,
|
|
1894
1934
|
* otherwise the API will return an error.
|
|
1895
1935
|
* @default true
|
|
1896
1936
|
*/
|
|
1897
|
-
store:
|
|
1937
|
+
store: z8.boolean().optional(),
|
|
1898
1938
|
/**
|
|
1899
1939
|
* The ID of the previous response from the model.
|
|
1900
1940
|
*/
|
|
1901
|
-
previousResponseId:
|
|
1941
|
+
previousResponseId: z8.string().optional(),
|
|
1902
1942
|
/**
|
|
1903
1943
|
* Specify additional output data to include in the model response.
|
|
1904
1944
|
* Example values: 'file_search_call.results'.
|
|
1905
1945
|
*/
|
|
1906
|
-
include:
|
|
1946
|
+
include: z8.array(z8.enum(["file_search_call.results"])).nullish()
|
|
1907
1947
|
});
|
|
1908
1948
|
|
|
1909
1949
|
// src/responses/xai-responses-prepare-tools.ts
|
|
@@ -1918,25 +1958,25 @@ import {
|
|
|
1918
1958
|
lazySchema,
|
|
1919
1959
|
zodSchema
|
|
1920
1960
|
} from "@ai-sdk/provider-utils";
|
|
1921
|
-
import { z as
|
|
1961
|
+
import { z as z9 } from "zod/v4";
|
|
1922
1962
|
var fileSearchArgsSchema = lazySchema(
|
|
1923
1963
|
() => zodSchema(
|
|
1924
|
-
|
|
1925
|
-
vectorStoreIds:
|
|
1926
|
-
maxNumResults:
|
|
1964
|
+
z9.object({
|
|
1965
|
+
vectorStoreIds: z9.array(z9.string()),
|
|
1966
|
+
maxNumResults: z9.number().optional()
|
|
1927
1967
|
})
|
|
1928
1968
|
)
|
|
1929
1969
|
);
|
|
1930
1970
|
var fileSearchOutputSchema = lazySchema(
|
|
1931
1971
|
() => zodSchema(
|
|
1932
|
-
|
|
1933
|
-
queries:
|
|
1934
|
-
results:
|
|
1935
|
-
|
|
1936
|
-
fileId:
|
|
1937
|
-
filename:
|
|
1938
|
-
score:
|
|
1939
|
-
text:
|
|
1972
|
+
z9.object({
|
|
1973
|
+
queries: z9.array(z9.string()),
|
|
1974
|
+
results: z9.array(
|
|
1975
|
+
z9.object({
|
|
1976
|
+
fileId: z9.string(),
|
|
1977
|
+
filename: z9.string(),
|
|
1978
|
+
score: z9.number().min(0).max(1),
|
|
1979
|
+
text: z9.string()
|
|
1940
1980
|
})
|
|
1941
1981
|
).nullable()
|
|
1942
1982
|
})
|
|
@@ -1944,7 +1984,7 @@ var fileSearchOutputSchema = lazySchema(
|
|
|
1944
1984
|
);
|
|
1945
1985
|
var fileSearchToolFactory = createProviderExecutedToolFactory({
|
|
1946
1986
|
id: "xai.file_search",
|
|
1947
|
-
inputSchema: lazySchema(() => zodSchema(
|
|
1987
|
+
inputSchema: lazySchema(() => zodSchema(z9.object({}))),
|
|
1948
1988
|
outputSchema: fileSearchOutputSchema
|
|
1949
1989
|
});
|
|
1950
1990
|
var fileSearch = (args) => fileSearchToolFactory(args);
|
|
@@ -1955,31 +1995,31 @@ import {
|
|
|
1955
1995
|
lazySchema as lazySchema2,
|
|
1956
1996
|
zodSchema as zodSchema2
|
|
1957
1997
|
} from "@ai-sdk/provider-utils";
|
|
1958
|
-
import { z as
|
|
1998
|
+
import { z as z10 } from "zod/v4";
|
|
1959
1999
|
var mcpServerArgsSchema = lazySchema2(
|
|
1960
2000
|
() => zodSchema2(
|
|
1961
|
-
|
|
1962
|
-
serverUrl:
|
|
1963
|
-
serverLabel:
|
|
1964
|
-
serverDescription:
|
|
1965
|
-
allowedTools:
|
|
1966
|
-
headers:
|
|
1967
|
-
authorization:
|
|
2001
|
+
z10.object({
|
|
2002
|
+
serverUrl: z10.string().describe("The URL of the MCP server"),
|
|
2003
|
+
serverLabel: z10.string().optional().describe("A label for the MCP server"),
|
|
2004
|
+
serverDescription: z10.string().optional().describe("Description of the MCP server"),
|
|
2005
|
+
allowedTools: z10.array(z10.string()).optional().describe("List of allowed tool names"),
|
|
2006
|
+
headers: z10.record(z10.string(), z10.string()).optional().describe("Custom headers to send"),
|
|
2007
|
+
authorization: z10.string().optional().describe("Authorization header value")
|
|
1968
2008
|
})
|
|
1969
2009
|
)
|
|
1970
2010
|
);
|
|
1971
2011
|
var mcpServerOutputSchema = lazySchema2(
|
|
1972
2012
|
() => zodSchema2(
|
|
1973
|
-
|
|
1974
|
-
name:
|
|
1975
|
-
arguments:
|
|
1976
|
-
result:
|
|
2013
|
+
z10.object({
|
|
2014
|
+
name: z10.string(),
|
|
2015
|
+
arguments: z10.string(),
|
|
2016
|
+
result: z10.unknown()
|
|
1977
2017
|
})
|
|
1978
2018
|
)
|
|
1979
2019
|
);
|
|
1980
2020
|
var mcpServerToolFactory = createProviderExecutedToolFactory2({
|
|
1981
2021
|
id: "xai.mcp",
|
|
1982
|
-
inputSchema: lazySchema2(() => zodSchema2(
|
|
2022
|
+
inputSchema: lazySchema2(() => zodSchema2(z10.object({}))),
|
|
1983
2023
|
outputSchema: mcpServerOutputSchema
|
|
1984
2024
|
});
|
|
1985
2025
|
var mcpServer = (args) => mcpServerToolFactory(args);
|
|
@@ -1990,26 +2030,26 @@ import {
|
|
|
1990
2030
|
lazySchema as lazySchema3,
|
|
1991
2031
|
zodSchema as zodSchema3
|
|
1992
2032
|
} from "@ai-sdk/provider-utils";
|
|
1993
|
-
import { z as
|
|
2033
|
+
import { z as z11 } from "zod/v4";
|
|
1994
2034
|
var webSearchArgsSchema = lazySchema3(
|
|
1995
2035
|
() => zodSchema3(
|
|
1996
|
-
|
|
1997
|
-
allowedDomains:
|
|
1998
|
-
excludedDomains:
|
|
1999
|
-
enableImageSearch:
|
|
2000
|
-
enableImageUnderstanding:
|
|
2036
|
+
z11.object({
|
|
2037
|
+
allowedDomains: z11.array(z11.string()).max(5).optional(),
|
|
2038
|
+
excludedDomains: z11.array(z11.string()).max(5).optional(),
|
|
2039
|
+
enableImageSearch: z11.boolean().optional(),
|
|
2040
|
+
enableImageUnderstanding: z11.boolean().optional()
|
|
2001
2041
|
})
|
|
2002
2042
|
)
|
|
2003
2043
|
);
|
|
2004
2044
|
var webSearchOutputSchema = lazySchema3(
|
|
2005
2045
|
() => zodSchema3(
|
|
2006
|
-
|
|
2007
|
-
query:
|
|
2008
|
-
sources:
|
|
2009
|
-
|
|
2010
|
-
title:
|
|
2011
|
-
url:
|
|
2012
|
-
snippet:
|
|
2046
|
+
z11.object({
|
|
2047
|
+
query: z11.string(),
|
|
2048
|
+
sources: z11.array(
|
|
2049
|
+
z11.object({
|
|
2050
|
+
title: z11.string(),
|
|
2051
|
+
url: z11.string(),
|
|
2052
|
+
snippet: z11.string()
|
|
2013
2053
|
})
|
|
2014
2054
|
)
|
|
2015
2055
|
})
|
|
@@ -2017,7 +2057,7 @@ var webSearchOutputSchema = lazySchema3(
|
|
|
2017
2057
|
);
|
|
2018
2058
|
var webSearchToolFactory = createProviderExecutedToolFactory3({
|
|
2019
2059
|
id: "xai.web_search",
|
|
2020
|
-
inputSchema: lazySchema3(() => zodSchema3(
|
|
2060
|
+
inputSchema: lazySchema3(() => zodSchema3(z11.object({}))),
|
|
2021
2061
|
outputSchema: webSearchOutputSchema
|
|
2022
2062
|
});
|
|
2023
2063
|
var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
@@ -2028,29 +2068,29 @@ import {
|
|
|
2028
2068
|
lazySchema as lazySchema4,
|
|
2029
2069
|
zodSchema as zodSchema4
|
|
2030
2070
|
} from "@ai-sdk/provider-utils";
|
|
2031
|
-
import { z as
|
|
2071
|
+
import { z as z12 } from "zod/v4";
|
|
2032
2072
|
var xSearchArgsSchema = lazySchema4(
|
|
2033
2073
|
() => zodSchema4(
|
|
2034
|
-
|
|
2035
|
-
allowedXHandles:
|
|
2036
|
-
excludedXHandles:
|
|
2037
|
-
fromDate:
|
|
2038
|
-
toDate:
|
|
2039
|
-
enableImageUnderstanding:
|
|
2040
|
-
enableVideoUnderstanding:
|
|
2074
|
+
z12.object({
|
|
2075
|
+
allowedXHandles: z12.array(z12.string()).max(10).optional(),
|
|
2076
|
+
excludedXHandles: z12.array(z12.string()).max(10).optional(),
|
|
2077
|
+
fromDate: z12.string().optional(),
|
|
2078
|
+
toDate: z12.string().optional(),
|
|
2079
|
+
enableImageUnderstanding: z12.boolean().optional(),
|
|
2080
|
+
enableVideoUnderstanding: z12.boolean().optional()
|
|
2041
2081
|
})
|
|
2042
2082
|
)
|
|
2043
2083
|
);
|
|
2044
2084
|
var xSearchOutputSchema = lazySchema4(
|
|
2045
2085
|
() => zodSchema4(
|
|
2046
|
-
|
|
2047
|
-
query:
|
|
2048
|
-
posts:
|
|
2049
|
-
|
|
2050
|
-
author:
|
|
2051
|
-
text:
|
|
2052
|
-
url:
|
|
2053
|
-
likes:
|
|
2086
|
+
z12.object({
|
|
2087
|
+
query: z12.string(),
|
|
2088
|
+
posts: z12.array(
|
|
2089
|
+
z12.object({
|
|
2090
|
+
author: z12.string(),
|
|
2091
|
+
text: z12.string(),
|
|
2092
|
+
url: z12.string(),
|
|
2093
|
+
likes: z12.number()
|
|
2054
2094
|
})
|
|
2055
2095
|
)
|
|
2056
2096
|
})
|
|
@@ -2058,7 +2098,7 @@ var xSearchOutputSchema = lazySchema4(
|
|
|
2058
2098
|
);
|
|
2059
2099
|
var xSearchToolFactory = createProviderExecutedToolFactory4({
|
|
2060
2100
|
id: "xai.x_search",
|
|
2061
|
-
inputSchema: lazySchema4(() => zodSchema4(
|
|
2101
|
+
inputSchema: lazySchema4(() => zodSchema4(z12.object({}))),
|
|
2062
2102
|
outputSchema: xSearchOutputSchema
|
|
2063
2103
|
});
|
|
2064
2104
|
var xSearch = (args = {}) => xSearchToolFactory(args);
|
|
@@ -2256,7 +2296,7 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
|
|
|
2256
2296
|
}) {
|
|
2257
2297
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2258
2298
|
const warnings = [];
|
|
2259
|
-
const options = (_a = await
|
|
2299
|
+
const options = (_a = await parseProviderOptions5({
|
|
2260
2300
|
provider: "xai",
|
|
2261
2301
|
providerOptions,
|
|
2262
2302
|
schema: xaiLanguageModelResponsesOptions
|
|
@@ -3381,43 +3421,43 @@ var XaiRealtimeModel = class {
|
|
|
3381
3421
|
|
|
3382
3422
|
// src/tool/code-execution.ts
|
|
3383
3423
|
import { createProviderExecutedToolFactory as createProviderExecutedToolFactory5 } from "@ai-sdk/provider-utils";
|
|
3384
|
-
import { z as
|
|
3385
|
-
var codeExecutionOutputSchema =
|
|
3386
|
-
output:
|
|
3387
|
-
error:
|
|
3424
|
+
import { z as z13 } from "zod/v4";
|
|
3425
|
+
var codeExecutionOutputSchema = z13.object({
|
|
3426
|
+
output: z13.string().describe("the output of the code execution"),
|
|
3427
|
+
error: z13.string().optional().describe("any error that occurred")
|
|
3388
3428
|
});
|
|
3389
3429
|
var codeExecutionToolFactory = createProviderExecutedToolFactory5({
|
|
3390
3430
|
id: "xai.code_execution",
|
|
3391
|
-
inputSchema:
|
|
3431
|
+
inputSchema: z13.object({}).describe("no input parameters"),
|
|
3392
3432
|
outputSchema: codeExecutionOutputSchema
|
|
3393
3433
|
});
|
|
3394
3434
|
var codeExecution = (args = {}) => codeExecutionToolFactory(args);
|
|
3395
3435
|
|
|
3396
3436
|
// src/tool/view-image.ts
|
|
3397
3437
|
import { createProviderExecutedToolFactory as createProviderExecutedToolFactory6 } from "@ai-sdk/provider-utils";
|
|
3398
|
-
import { z as
|
|
3399
|
-
var viewImageOutputSchema =
|
|
3400
|
-
description:
|
|
3401
|
-
objects:
|
|
3438
|
+
import { z as z14 } from "zod/v4";
|
|
3439
|
+
var viewImageOutputSchema = z14.object({
|
|
3440
|
+
description: z14.string().describe("description of the image"),
|
|
3441
|
+
objects: z14.array(z14.string()).optional().describe("objects detected in the image")
|
|
3402
3442
|
});
|
|
3403
3443
|
var viewImageToolFactory = createProviderExecutedToolFactory6({
|
|
3404
3444
|
id: "xai.view_image",
|
|
3405
|
-
inputSchema:
|
|
3445
|
+
inputSchema: z14.object({}).describe("no input parameters"),
|
|
3406
3446
|
outputSchema: viewImageOutputSchema
|
|
3407
3447
|
});
|
|
3408
3448
|
var viewImage = (args = {}) => viewImageToolFactory(args);
|
|
3409
3449
|
|
|
3410
3450
|
// src/tool/view-x-video.ts
|
|
3411
3451
|
import { createProviderExecutedToolFactory as createProviderExecutedToolFactory7 } from "@ai-sdk/provider-utils";
|
|
3412
|
-
import { z as
|
|
3413
|
-
var viewXVideoOutputSchema =
|
|
3414
|
-
transcript:
|
|
3415
|
-
description:
|
|
3416
|
-
duration:
|
|
3452
|
+
import { z as z15 } from "zod/v4";
|
|
3453
|
+
var viewXVideoOutputSchema = z15.object({
|
|
3454
|
+
transcript: z15.string().optional().describe("transcript of the video"),
|
|
3455
|
+
description: z15.string().describe("description of the video content"),
|
|
3456
|
+
duration: z15.number().optional().describe("duration in seconds")
|
|
3417
3457
|
});
|
|
3418
3458
|
var viewXVideoToolFactory = createProviderExecutedToolFactory7({
|
|
3419
3459
|
id: "xai.view_x_video",
|
|
3420
|
-
inputSchema:
|
|
3460
|
+
inputSchema: z15.object({}).describe("no input parameters"),
|
|
3421
3461
|
outputSchema: viewXVideoOutputSchema
|
|
3422
3462
|
});
|
|
3423
3463
|
var viewXVideo = (args = {}) => viewXVideoToolFactory(args);
|
|
@@ -3434,30 +3474,30 @@ var xaiTools = {
|
|
|
3434
3474
|
};
|
|
3435
3475
|
|
|
3436
3476
|
// src/version.ts
|
|
3437
|
-
var VERSION = true ? "4.0.
|
|
3477
|
+
var VERSION = true ? "4.0.10" : "0.0.0-test";
|
|
3438
3478
|
|
|
3439
3479
|
// src/files/xai-files.ts
|
|
3440
3480
|
import {
|
|
3441
3481
|
combineHeaders as combineHeaders4,
|
|
3442
3482
|
convertInlineFileDataToUint8Array,
|
|
3443
3483
|
createJsonResponseHandler as createJsonResponseHandler4,
|
|
3444
|
-
parseProviderOptions as
|
|
3484
|
+
parseProviderOptions as parseProviderOptions6,
|
|
3445
3485
|
postFormDataToApi
|
|
3446
3486
|
} from "@ai-sdk/provider-utils";
|
|
3447
3487
|
|
|
3448
3488
|
// src/files/xai-files-api.ts
|
|
3449
3489
|
import { lazySchema as lazySchema5, zodSchema as zodSchema5 } from "@ai-sdk/provider-utils";
|
|
3450
|
-
import { z as
|
|
3490
|
+
import { z as z16 } from "zod/v4";
|
|
3451
3491
|
var xaiFilesResponseSchema = lazySchema5(
|
|
3452
3492
|
() => zodSchema5(
|
|
3453
|
-
|
|
3454
|
-
id:
|
|
3455
|
-
object:
|
|
3456
|
-
bytes:
|
|
3457
|
-
created_at:
|
|
3458
|
-
filename:
|
|
3459
|
-
purpose:
|
|
3460
|
-
status:
|
|
3493
|
+
z16.object({
|
|
3494
|
+
id: z16.string(),
|
|
3495
|
+
object: z16.string().nullish(),
|
|
3496
|
+
bytes: z16.number().nullish(),
|
|
3497
|
+
created_at: z16.number().nullish(),
|
|
3498
|
+
filename: z16.string().nullish(),
|
|
3499
|
+
purpose: z16.string().nullish(),
|
|
3500
|
+
status: z16.string().nullish()
|
|
3461
3501
|
})
|
|
3462
3502
|
)
|
|
3463
3503
|
);
|
|
@@ -3467,12 +3507,12 @@ import {
|
|
|
3467
3507
|
lazySchema as lazySchema6,
|
|
3468
3508
|
zodSchema as zodSchema6
|
|
3469
3509
|
} from "@ai-sdk/provider-utils";
|
|
3470
|
-
import { z as
|
|
3510
|
+
import { z as z17 } from "zod/v4";
|
|
3471
3511
|
var xaiFilesOptionsSchema = lazySchema6(
|
|
3472
3512
|
() => zodSchema6(
|
|
3473
|
-
|
|
3474
|
-
teamId:
|
|
3475
|
-
filePath:
|
|
3513
|
+
z17.looseObject({
|
|
3514
|
+
teamId: z17.string().optional(),
|
|
3515
|
+
filePath: z17.string().optional()
|
|
3476
3516
|
})
|
|
3477
3517
|
)
|
|
3478
3518
|
);
|
|
@@ -3493,7 +3533,7 @@ var XaiFiles = class {
|
|
|
3493
3533
|
providerOptions
|
|
3494
3534
|
}) {
|
|
3495
3535
|
var _a, _b;
|
|
3496
|
-
const xaiOptions = await
|
|
3536
|
+
const xaiOptions = await parseProviderOptions6({
|
|
3497
3537
|
provider: "xai",
|
|
3498
3538
|
providerOptions,
|
|
3499
3539
|
schema: xaiFilesOptionsSchema
|
|
@@ -3547,56 +3587,57 @@ import {
|
|
|
3547
3587
|
createJsonResponseHandler as createJsonResponseHandler5,
|
|
3548
3588
|
delay,
|
|
3549
3589
|
getFromApi as getFromApi2,
|
|
3550
|
-
|
|
3590
|
+
getTopLevelMediaType as getTopLevelMediaType3,
|
|
3591
|
+
parseProviderOptions as parseProviderOptions7,
|
|
3551
3592
|
postJsonToApi as postJsonToApi4
|
|
3552
3593
|
} from "@ai-sdk/provider-utils";
|
|
3553
|
-
import { z as
|
|
3594
|
+
import { z as z19 } from "zod/v4";
|
|
3554
3595
|
|
|
3555
3596
|
// src/xai-video-model-options.ts
|
|
3556
3597
|
import { lazySchema as lazySchema7, zodSchema as zodSchema7 } from "@ai-sdk/provider-utils";
|
|
3557
|
-
import { z as
|
|
3558
|
-
var nonEmptyStringSchema =
|
|
3559
|
-
var resolutionSchema =
|
|
3560
|
-
var modeSchema =
|
|
3598
|
+
import { z as z18 } from "zod/v4";
|
|
3599
|
+
var nonEmptyStringSchema = z18.string().min(1);
|
|
3600
|
+
var resolutionSchema = z18.enum(["480p", "720p"]);
|
|
3601
|
+
var modeSchema = z18.enum(["edit-video", "extend-video", "reference-to-video"]);
|
|
3561
3602
|
var baseFields = {
|
|
3562
|
-
pollIntervalMs:
|
|
3563
|
-
pollTimeoutMs:
|
|
3603
|
+
pollIntervalMs: z18.number().positive().nullish(),
|
|
3604
|
+
pollTimeoutMs: z18.number().positive().nullish(),
|
|
3564
3605
|
resolution: resolutionSchema.nullish()
|
|
3565
3606
|
};
|
|
3566
|
-
var editVideoSchema =
|
|
3607
|
+
var editVideoSchema = z18.object({
|
|
3567
3608
|
...baseFields,
|
|
3568
|
-
mode:
|
|
3609
|
+
mode: z18.literal("edit-video"),
|
|
3569
3610
|
videoUrl: nonEmptyStringSchema,
|
|
3570
|
-
referenceImageUrls:
|
|
3611
|
+
referenceImageUrls: z18.undefined().optional()
|
|
3571
3612
|
});
|
|
3572
|
-
var extendVideoSchema =
|
|
3613
|
+
var extendVideoSchema = z18.object({
|
|
3573
3614
|
...baseFields,
|
|
3574
|
-
mode:
|
|
3615
|
+
mode: z18.literal("extend-video"),
|
|
3575
3616
|
videoUrl: nonEmptyStringSchema,
|
|
3576
|
-
referenceImageUrls:
|
|
3617
|
+
referenceImageUrls: z18.undefined().optional()
|
|
3577
3618
|
});
|
|
3578
|
-
var referenceToVideoSchema =
|
|
3619
|
+
var referenceToVideoSchema = z18.object({
|
|
3579
3620
|
...baseFields,
|
|
3580
|
-
mode:
|
|
3581
|
-
referenceImageUrls:
|
|
3582
|
-
videoUrl:
|
|
3621
|
+
mode: z18.literal("reference-to-video"),
|
|
3622
|
+
referenceImageUrls: z18.array(nonEmptyStringSchema).min(1).max(7),
|
|
3623
|
+
videoUrl: z18.undefined().optional()
|
|
3583
3624
|
});
|
|
3584
|
-
var autoDetectSchema =
|
|
3625
|
+
var autoDetectSchema = z18.object({
|
|
3585
3626
|
...baseFields,
|
|
3586
|
-
mode:
|
|
3627
|
+
mode: z18.undefined().optional(),
|
|
3587
3628
|
videoUrl: nonEmptyStringSchema.optional(),
|
|
3588
|
-
referenceImageUrls:
|
|
3629
|
+
referenceImageUrls: z18.array(nonEmptyStringSchema).min(1).max(7).optional()
|
|
3589
3630
|
});
|
|
3590
|
-
var xaiVideoModelOptions =
|
|
3631
|
+
var xaiVideoModelOptions = z18.union([
|
|
3591
3632
|
editVideoSchema,
|
|
3592
3633
|
extendVideoSchema,
|
|
3593
3634
|
referenceToVideoSchema,
|
|
3594
3635
|
autoDetectSchema
|
|
3595
3636
|
]);
|
|
3596
|
-
var runtimeSchema =
|
|
3637
|
+
var runtimeSchema = z18.looseObject({
|
|
3597
3638
|
mode: modeSchema.optional(),
|
|
3598
3639
|
videoUrl: nonEmptyStringSchema.optional(),
|
|
3599
|
-
referenceImageUrls:
|
|
3640
|
+
referenceImageUrls: z18.array(nonEmptyStringSchema).min(1).max(7).optional(),
|
|
3600
3641
|
...baseFields
|
|
3601
3642
|
});
|
|
3602
3643
|
var xaiVideoModelOptionsSchema = lazySchema7(
|
|
@@ -3621,17 +3662,28 @@ function resolveStartImage(options) {
|
|
|
3621
3662
|
var _a;
|
|
3622
3663
|
return (_a = getFirstFrameImage(options)) != null ? _a : options.image;
|
|
3623
3664
|
}
|
|
3665
|
+
var isVideoFile = (file) => file.mediaType != null && getTopLevelMediaType3(file.mediaType) === "video";
|
|
3624
3666
|
function fileToXaiImageUrl(file) {
|
|
3625
|
-
var _a;
|
|
3626
3667
|
if (file.type === "url") {
|
|
3627
3668
|
return file.url;
|
|
3628
3669
|
}
|
|
3629
3670
|
const base64Data = typeof file.data === "string" ? file.data : convertUint8ArrayToBase64(file.data);
|
|
3630
|
-
return `data:${
|
|
3671
|
+
return `data:${file.mediaType};base64,${base64Data}`;
|
|
3631
3672
|
}
|
|
3632
|
-
function resolveReferenceImages(options, xaiOptions) {
|
|
3673
|
+
function resolveReferenceImages(options, xaiOptions, warnings) {
|
|
3633
3674
|
if (options.inputReferences != null && options.inputReferences.length > 0) {
|
|
3634
|
-
|
|
3675
|
+
const imageReferences = options.inputReferences.filter((reference) => {
|
|
3676
|
+
if (isVideoFile(reference)) {
|
|
3677
|
+
warnings.push({
|
|
3678
|
+
type: "unsupported",
|
|
3679
|
+
feature: "inputReferences",
|
|
3680
|
+
details: 'xAI reference-to-video accepts image references only. The video reference was ignored. Use providerOptions.xai.mode "extend-video" to continue from a video.'
|
|
3681
|
+
});
|
|
3682
|
+
return false;
|
|
3683
|
+
}
|
|
3684
|
+
return true;
|
|
3685
|
+
});
|
|
3686
|
+
return imageReferences.map((reference) => ({
|
|
3635
3687
|
url: fileToXaiImageUrl(reference)
|
|
3636
3688
|
}));
|
|
3637
3689
|
}
|
|
@@ -3669,7 +3721,7 @@ var XaiVideoModel = class {
|
|
|
3669
3721
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
3670
3722
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
3671
3723
|
const warnings = [];
|
|
3672
|
-
const xaiOptions = await
|
|
3724
|
+
const xaiOptions = await parseProviderOptions7({
|
|
3673
3725
|
provider: "xai",
|
|
3674
3726
|
providerOptions: options.providerOptions,
|
|
3675
3727
|
schema: xaiVideoModelOptionsSchema
|
|
@@ -3769,17 +3821,31 @@ var XaiVideoModel = class {
|
|
|
3769
3821
|
}
|
|
3770
3822
|
const startImage = resolveStartImage(options);
|
|
3771
3823
|
if (startImage != null) {
|
|
3772
|
-
|
|
3824
|
+
if (isVideoFile(startImage)) {
|
|
3825
|
+
const fromFrameImages = getFirstFrameImage(options) != null;
|
|
3826
|
+
warnings.push({
|
|
3827
|
+
type: "unsupported",
|
|
3828
|
+
feature: fromFrameImages ? "frameImages" : "image",
|
|
3829
|
+
details: 'xAI does not accept a video as a start/frame image. The video was ignored. Use providerOptions.xai.mode "extend-video" to continue from a video instead.'
|
|
3830
|
+
});
|
|
3831
|
+
} else {
|
|
3832
|
+
body.image = { url: fileToXaiImageUrl(startImage) };
|
|
3833
|
+
}
|
|
3773
3834
|
}
|
|
3774
|
-
|
|
3835
|
+
const lastFrameImage = getLastFrameImage(options);
|
|
3836
|
+
if (lastFrameImage != null) {
|
|
3775
3837
|
warnings.push({
|
|
3776
3838
|
type: "unsupported",
|
|
3777
3839
|
feature: "frameImages",
|
|
3778
|
-
details: `xAI video models do not support last_frame. Use providerOptions.xai.mode "extend-video" to continue from a video's last frame. The last frame image was ignored.`
|
|
3840
|
+
details: isVideoFile(lastFrameImage) ? 'xAI does not accept a video as a start/frame image. The video last frame was ignored. Use providerOptions.xai.mode "extend-video" to continue from a video instead.' : `xAI video models do not support last_frame. Use providerOptions.xai.mode "extend-video" to continue from a video's last frame. The last frame image was ignored.`
|
|
3779
3841
|
});
|
|
3780
3842
|
}
|
|
3781
3843
|
if (hasReferenceImages) {
|
|
3782
|
-
const referenceImages = resolveReferenceImages(
|
|
3844
|
+
const referenceImages = resolveReferenceImages(
|
|
3845
|
+
options,
|
|
3846
|
+
xaiOptions,
|
|
3847
|
+
warnings
|
|
3848
|
+
);
|
|
3783
3849
|
if (referenceImages != null) {
|
|
3784
3850
|
body.reference_images = referenceImages;
|
|
3785
3851
|
}
|
|
@@ -3908,24 +3974,24 @@ var XaiVideoModel = class {
|
|
|
3908
3974
|
}
|
|
3909
3975
|
}
|
|
3910
3976
|
};
|
|
3911
|
-
var xaiCreateVideoResponseSchema =
|
|
3912
|
-
request_id:
|
|
3977
|
+
var xaiCreateVideoResponseSchema = z19.object({
|
|
3978
|
+
request_id: z19.string().nullish()
|
|
3913
3979
|
});
|
|
3914
|
-
var xaiVideoStatusResponseSchema =
|
|
3915
|
-
status:
|
|
3916
|
-
video:
|
|
3917
|
-
url:
|
|
3918
|
-
duration:
|
|
3919
|
-
respect_moderation:
|
|
3980
|
+
var xaiVideoStatusResponseSchema = z19.object({
|
|
3981
|
+
status: z19.string().nullish(),
|
|
3982
|
+
video: z19.object({
|
|
3983
|
+
url: z19.string(),
|
|
3984
|
+
duration: z19.number().nullish(),
|
|
3985
|
+
respect_moderation: z19.boolean().nullish()
|
|
3920
3986
|
}).nullish(),
|
|
3921
|
-
model:
|
|
3922
|
-
usage:
|
|
3923
|
-
cost_in_usd_ticks:
|
|
3987
|
+
model: z19.string().nullish(),
|
|
3988
|
+
usage: z19.object({
|
|
3989
|
+
cost_in_usd_ticks: z19.number().nullish()
|
|
3924
3990
|
}).nullish(),
|
|
3925
|
-
progress:
|
|
3926
|
-
error:
|
|
3927
|
-
code:
|
|
3928
|
-
message:
|
|
3991
|
+
progress: z19.number().nullish(),
|
|
3992
|
+
error: z19.object({
|
|
3993
|
+
code: z19.string().nullish(),
|
|
3994
|
+
message: z19.string().nullish()
|
|
3929
3995
|
}).nullish()
|
|
3930
3996
|
});
|
|
3931
3997
|
|
|
@@ -3933,7 +3999,7 @@ var xaiVideoStatusResponseSchema = z18.object({
|
|
|
3933
3999
|
import {
|
|
3934
4000
|
combineHeaders as combineHeaders6,
|
|
3935
4001
|
createBinaryResponseHandler as createBinaryResponseHandler2,
|
|
3936
|
-
parseProviderOptions as
|
|
4002
|
+
parseProviderOptions as parseProviderOptions8,
|
|
3937
4003
|
postJsonToApi as postJsonToApi5,
|
|
3938
4004
|
resolve,
|
|
3939
4005
|
serializeModelOptions as serializeModelOptions4,
|
|
@@ -3946,39 +4012,39 @@ import {
|
|
|
3946
4012
|
lazySchema as lazySchema8,
|
|
3947
4013
|
zodSchema as zodSchema8
|
|
3948
4014
|
} from "@ai-sdk/provider-utils";
|
|
3949
|
-
import { z as
|
|
4015
|
+
import { z as z20 } from "zod/v4";
|
|
3950
4016
|
var xaiSpeechModelOptionsSchema = lazySchema8(
|
|
3951
4017
|
() => zodSchema8(
|
|
3952
|
-
|
|
4018
|
+
z20.object({
|
|
3953
4019
|
/**
|
|
3954
4020
|
* Sample rate of the generated audio in Hz.
|
|
3955
4021
|
*/
|
|
3956
|
-
sampleRate:
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
4022
|
+
sampleRate: z20.union([
|
|
4023
|
+
z20.literal(8e3),
|
|
4024
|
+
z20.literal(16e3),
|
|
4025
|
+
z20.literal(22050),
|
|
4026
|
+
z20.literal(24e3),
|
|
4027
|
+
z20.literal(44100),
|
|
4028
|
+
z20.literal(48e3)
|
|
3963
4029
|
]).nullish(),
|
|
3964
4030
|
/**
|
|
3965
4031
|
* MP3 bit rate in bits per second. Only applies when outputFormat is mp3.
|
|
3966
4032
|
*/
|
|
3967
|
-
bitRate:
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
4033
|
+
bitRate: z20.union([
|
|
4034
|
+
z20.literal(32e3),
|
|
4035
|
+
z20.literal(64e3),
|
|
4036
|
+
z20.literal(96e3),
|
|
4037
|
+
z20.literal(128e3),
|
|
4038
|
+
z20.literal(192e3)
|
|
3973
4039
|
]).nullish(),
|
|
3974
4040
|
/**
|
|
3975
4041
|
* Reduce time to first audio chunk, trading some quality for latency.
|
|
3976
4042
|
*/
|
|
3977
|
-
optimizeStreamingLatency:
|
|
4043
|
+
optimizeStreamingLatency: z20.union([z20.literal(0), z20.literal(1), z20.literal(2)]).nullish(),
|
|
3978
4044
|
/**
|
|
3979
4045
|
* Normalize written-form text into spoken-form text before synthesis.
|
|
3980
4046
|
*/
|
|
3981
|
-
textNormalization:
|
|
4047
|
+
textNormalization: z20.boolean().nullish()
|
|
3982
4048
|
})
|
|
3983
4049
|
)
|
|
3984
4050
|
);
|
|
@@ -4012,7 +4078,7 @@ var XaiSpeechModel = class _XaiSpeechModel {
|
|
|
4012
4078
|
providerOptions
|
|
4013
4079
|
}) {
|
|
4014
4080
|
const warnings = [];
|
|
4015
|
-
const xaiOptions = await
|
|
4081
|
+
const xaiOptions = await parseProviderOptions8({
|
|
4016
4082
|
provider: "xai",
|
|
4017
4083
|
providerOptions,
|
|
4018
4084
|
schema: xaiSpeechModelOptionsSchema
|
|
@@ -4108,7 +4174,7 @@ import {
|
|
|
4108
4174
|
createJsonResponseHandler as createJsonResponseHandler6,
|
|
4109
4175
|
getWebSocketConstructor,
|
|
4110
4176
|
mediaTypeToExtension,
|
|
4111
|
-
parseProviderOptions as
|
|
4177
|
+
parseProviderOptions as parseProviderOptions9,
|
|
4112
4178
|
postFormDataToApi as postFormDataToApi2,
|
|
4113
4179
|
readWebSocketMessageText,
|
|
4114
4180
|
safeParseJSON as safeParseJSON2,
|
|
@@ -4117,80 +4183,80 @@ import {
|
|
|
4117
4183
|
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE5,
|
|
4118
4184
|
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE5
|
|
4119
4185
|
} from "@ai-sdk/provider-utils";
|
|
4120
|
-
import { z as
|
|
4186
|
+
import { z as z22 } from "zod/v4";
|
|
4121
4187
|
|
|
4122
4188
|
// src/xai-transcription-model-options.ts
|
|
4123
4189
|
import {
|
|
4124
4190
|
lazySchema as lazySchema9,
|
|
4125
4191
|
zodSchema as zodSchema9
|
|
4126
4192
|
} from "@ai-sdk/provider-utils";
|
|
4127
|
-
import { z as
|
|
4193
|
+
import { z as z21 } from "zod/v4";
|
|
4128
4194
|
var xaiTranscriptionModelOptionsSchema = lazySchema9(
|
|
4129
4195
|
() => zodSchema9(
|
|
4130
|
-
|
|
4196
|
+
z21.object({
|
|
4131
4197
|
/**
|
|
4132
4198
|
* Audio encoding for raw, headerless input audio.
|
|
4133
4199
|
*/
|
|
4134
|
-
audioFormat:
|
|
4200
|
+
audioFormat: z21.enum(["pcm", "mulaw", "alaw"]).nullish(),
|
|
4135
4201
|
/**
|
|
4136
4202
|
* Sample rate of the input audio in Hz.
|
|
4137
4203
|
*/
|
|
4138
|
-
sampleRate:
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4204
|
+
sampleRate: z21.union([
|
|
4205
|
+
z21.literal(8e3),
|
|
4206
|
+
z21.literal(16e3),
|
|
4207
|
+
z21.literal(22050),
|
|
4208
|
+
z21.literal(24e3),
|
|
4209
|
+
z21.literal(44100),
|
|
4210
|
+
z21.literal(48e3)
|
|
4145
4211
|
]).nullish(),
|
|
4146
4212
|
/**
|
|
4147
4213
|
* Language code used for inverse text normalization.
|
|
4148
4214
|
*/
|
|
4149
|
-
language:
|
|
4215
|
+
language: z21.string().nullish(),
|
|
4150
4216
|
/**
|
|
4151
4217
|
* Enable inverse text normalization. Requires `language`.
|
|
4152
4218
|
*/
|
|
4153
|
-
format:
|
|
4219
|
+
format: z21.boolean().nullish(),
|
|
4154
4220
|
/**
|
|
4155
4221
|
* Enable per-channel transcription for multichannel audio.
|
|
4156
4222
|
*/
|
|
4157
|
-
multichannel:
|
|
4223
|
+
multichannel: z21.boolean().nullish(),
|
|
4158
4224
|
/**
|
|
4159
4225
|
* Number of interleaved audio channels.
|
|
4160
4226
|
*/
|
|
4161
|
-
channels:
|
|
4227
|
+
channels: z21.number().int().min(2).max(8).nullish(),
|
|
4162
4228
|
/**
|
|
4163
4229
|
* Enable speaker diarization.
|
|
4164
4230
|
*/
|
|
4165
|
-
diarize:
|
|
4231
|
+
diarize: z21.boolean().nullish(),
|
|
4166
4232
|
/**
|
|
4167
4233
|
* Terms to bias transcription toward.
|
|
4168
4234
|
*/
|
|
4169
|
-
keyterm:
|
|
4235
|
+
keyterm: z21.union([z21.string(), z21.array(z21.string())]).nullish(),
|
|
4170
4236
|
/**
|
|
4171
4237
|
* Include filler words such as "uh" and "um" in the transcript.
|
|
4172
4238
|
*/
|
|
4173
|
-
fillerWords:
|
|
4239
|
+
fillerWords: z21.boolean().nullish(),
|
|
4174
4240
|
/**
|
|
4175
4241
|
* Options for streaming speech-to-text over WebSocket.
|
|
4176
4242
|
*/
|
|
4177
|
-
streaming:
|
|
4243
|
+
streaming: z21.object({
|
|
4178
4244
|
/**
|
|
4179
4245
|
* Emit interim transcript results while speech is being processed.
|
|
4180
4246
|
*/
|
|
4181
|
-
interimResults:
|
|
4247
|
+
interimResults: z21.boolean().optional(),
|
|
4182
4248
|
/**
|
|
4183
4249
|
* Silence duration in milliseconds before an utterance-final event.
|
|
4184
4250
|
*/
|
|
4185
|
-
endpointing:
|
|
4251
|
+
endpointing: z21.number().int().min(0).max(5e3).optional(),
|
|
4186
4252
|
/**
|
|
4187
4253
|
* End-of-turn detection threshold. When set, enables Smart Turn.
|
|
4188
4254
|
*/
|
|
4189
|
-
smartTurn:
|
|
4255
|
+
smartTurn: z21.number().min(0).max(1).optional(),
|
|
4190
4256
|
/**
|
|
4191
4257
|
* Maximum silence duration in milliseconds before forcing speech_final.
|
|
4192
4258
|
*/
|
|
4193
|
-
smartTurnTimeout:
|
|
4259
|
+
smartTurnTimeout: z21.number().int().min(1).max(5e3).optional()
|
|
4194
4260
|
}).optional()
|
|
4195
4261
|
})
|
|
4196
4262
|
)
|
|
@@ -4221,7 +4287,7 @@ var XaiTranscriptionModel = class _XaiTranscriptionModel {
|
|
|
4221
4287
|
providerOptions
|
|
4222
4288
|
}) {
|
|
4223
4289
|
const warnings = [];
|
|
4224
|
-
const xaiOptions = await
|
|
4290
|
+
const xaiOptions = await parseProviderOptions9({
|
|
4225
4291
|
provider: "xai",
|
|
4226
4292
|
providerOptions,
|
|
4227
4293
|
schema: xaiTranscriptionModelOptionsSchema
|
|
@@ -4298,7 +4364,7 @@ var XaiTranscriptionModel = class _XaiTranscriptionModel {
|
|
|
4298
4364
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
4299
4365
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
4300
4366
|
const warnings = [];
|
|
4301
|
-
const xaiOptions = await
|
|
4367
|
+
const xaiOptions = await parseProviderOptions9({
|
|
4302
4368
|
provider: "xai",
|
|
4303
4369
|
providerOptions: options.providerOptions,
|
|
4304
4370
|
schema: xaiTranscriptionModelOptionsSchema
|
|
@@ -4570,15 +4636,15 @@ function timingFromXaiEvent(event) {
|
|
|
4570
4636
|
...event.start != null && event.duration != null ? { endSecond: event.start + event.duration } : {}
|
|
4571
4637
|
};
|
|
4572
4638
|
}
|
|
4573
|
-
var xaiTranscriptionResponseSchema =
|
|
4574
|
-
text:
|
|
4575
|
-
language:
|
|
4576
|
-
duration:
|
|
4577
|
-
words:
|
|
4578
|
-
|
|
4579
|
-
text:
|
|
4580
|
-
start:
|
|
4581
|
-
end:
|
|
4639
|
+
var xaiTranscriptionResponseSchema = z22.object({
|
|
4640
|
+
text: z22.string(),
|
|
4641
|
+
language: z22.string().nullish(),
|
|
4642
|
+
duration: z22.number().nullish(),
|
|
4643
|
+
words: z22.array(
|
|
4644
|
+
z22.object({
|
|
4645
|
+
text: z22.string(),
|
|
4646
|
+
start: z22.number(),
|
|
4647
|
+
end: z22.number()
|
|
4582
4648
|
})
|
|
4583
4649
|
).nullish()
|
|
4584
4650
|
});
|