@ai-sdk/xai 4.0.7 → 4.0.9
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 +16 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +786 -713
- package/dist/index.js.map +1 -1
- package/docs/01-xai.mdx +36 -0
- package/package.json +5 -5
- 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.ts +25 -17
- package/src/supports-reasoning-effort.ts +12 -0
- package/src/xai-chat-language-model.ts +28 -18
- package/src/xai-chat-prompt.ts +4 -1
- package/src/xai-file-part-options.ts +21 -0
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": {
|
|
@@ -222,44 +253,50 @@ function mapXaiFinishReason(finishReason) {
|
|
|
222
253
|
}
|
|
223
254
|
}
|
|
224
255
|
|
|
256
|
+
// src/supports-reasoning-effort.ts
|
|
257
|
+
var modelsWithoutReasoningEffort = /^grok-4\.20(-\d{4})?-(non-)?reasoning$/;
|
|
258
|
+
function supportsReasoningEffort(modelId) {
|
|
259
|
+
return !modelsWithoutReasoningEffort.test(modelId);
|
|
260
|
+
}
|
|
261
|
+
|
|
225
262
|
// src/xai-chat-language-model-options.ts
|
|
226
|
-
import { z } from "zod/v4";
|
|
227
|
-
var webSourceSchema =
|
|
228
|
-
type:
|
|
229
|
-
country:
|
|
230
|
-
excludedWebsites:
|
|
231
|
-
allowedWebsites:
|
|
232
|
-
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()
|
|
233
270
|
});
|
|
234
|
-
var xSourceSchema =
|
|
235
|
-
type:
|
|
236
|
-
excludedXHandles:
|
|
237
|
-
includedXHandles:
|
|
238
|
-
postFavoriteCount:
|
|
239
|
-
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(),
|
|
240
277
|
/**
|
|
241
278
|
* @deprecated use `includedXHandles` instead
|
|
242
279
|
*/
|
|
243
|
-
xHandles:
|
|
280
|
+
xHandles: z2.array(z2.string()).optional()
|
|
244
281
|
});
|
|
245
|
-
var newsSourceSchema =
|
|
246
|
-
type:
|
|
247
|
-
country:
|
|
248
|
-
excludedWebsites:
|
|
249
|
-
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()
|
|
250
287
|
});
|
|
251
|
-
var rssSourceSchema =
|
|
252
|
-
type:
|
|
253
|
-
links:
|
|
288
|
+
var rssSourceSchema = z2.object({
|
|
289
|
+
type: z2.literal("rss"),
|
|
290
|
+
links: z2.array(z2.string().url()).max(1)
|
|
254
291
|
// currently only supports one RSS link
|
|
255
292
|
});
|
|
256
|
-
var searchSourceSchema =
|
|
293
|
+
var searchSourceSchema = z2.discriminatedUnion("type", [
|
|
257
294
|
webSourceSchema,
|
|
258
295
|
xSourceSchema,
|
|
259
296
|
newsSourceSchema,
|
|
260
297
|
rssSourceSchema
|
|
261
298
|
]);
|
|
262
|
-
var xaiLanguageModelChatOptions =
|
|
299
|
+
var xaiLanguageModelChatOptions = z2.object({
|
|
263
300
|
/**
|
|
264
301
|
* Constrains how hard a reasoning model thinks before responding.
|
|
265
302
|
*
|
|
@@ -274,16 +311,16 @@ var xaiLanguageModelChatOptions = z.object({
|
|
|
274
311
|
*
|
|
275
312
|
* @see https://docs.x.ai/docs/guides/reasoning
|
|
276
313
|
*/
|
|
277
|
-
reasoningEffort:
|
|
278
|
-
logprobs:
|
|
279
|
-
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(),
|
|
280
317
|
/**
|
|
281
318
|
* Whether to enable parallel function calling during tool use.
|
|
282
319
|
* When true, the model can call multiple functions in parallel.
|
|
283
320
|
* When false, the model will call functions sequentially.
|
|
284
321
|
* Defaults to true.
|
|
285
322
|
*/
|
|
286
|
-
parallel_function_calling:
|
|
323
|
+
parallel_function_calling: z2.boolean().optional(),
|
|
287
324
|
/**
|
|
288
325
|
* @deprecated xAI has deprecated Live Search (`search_parameters`) in favor
|
|
289
326
|
* of the Agent Tools API. Requests using this option now return a "Live
|
|
@@ -293,32 +330,32 @@ var xaiLanguageModelChatOptions = z.object({
|
|
|
293
330
|
*
|
|
294
331
|
* @see https://docs.x.ai/docs/guides/tools/overview
|
|
295
332
|
*/
|
|
296
|
-
searchParameters:
|
|
333
|
+
searchParameters: z2.object({
|
|
297
334
|
/**
|
|
298
335
|
* search mode preference
|
|
299
336
|
* - "off": disables search completely
|
|
300
337
|
* - "auto": model decides whether to search (default)
|
|
301
338
|
* - "on": always enables search
|
|
302
339
|
*/
|
|
303
|
-
mode:
|
|
340
|
+
mode: z2.enum(["off", "auto", "on"]),
|
|
304
341
|
/**
|
|
305
342
|
* whether to return citations in the response
|
|
306
343
|
* defaults to true
|
|
307
344
|
*/
|
|
308
|
-
returnCitations:
|
|
345
|
+
returnCitations: z2.boolean().optional(),
|
|
309
346
|
/**
|
|
310
347
|
* start date for search data (ISO8601 format: YYYY-MM-DD)
|
|
311
348
|
*/
|
|
312
|
-
fromDate:
|
|
349
|
+
fromDate: z2.string().optional(),
|
|
313
350
|
/**
|
|
314
351
|
* end date for search data (ISO8601 format: YYYY-MM-DD)
|
|
315
352
|
*/
|
|
316
|
-
toDate:
|
|
353
|
+
toDate: z2.string().optional(),
|
|
317
354
|
/**
|
|
318
355
|
* maximum number of search results to consider
|
|
319
356
|
* defaults to 20
|
|
320
357
|
*/
|
|
321
|
-
maxSearchResults:
|
|
358
|
+
maxSearchResults: z2.number().min(1).max(50).optional(),
|
|
322
359
|
/**
|
|
323
360
|
* data sources to search from.
|
|
324
361
|
* defaults to [{ type: 'web' }, { type: 'x' }] if not specified.
|
|
@@ -326,26 +363,26 @@ var xaiLanguageModelChatOptions = z.object({
|
|
|
326
363
|
* @example
|
|
327
364
|
* sources: [{ type: 'web', country: 'US' }, { type: 'x' }]
|
|
328
365
|
*/
|
|
329
|
-
sources:
|
|
366
|
+
sources: z2.array(searchSourceSchema).optional()
|
|
330
367
|
}).optional()
|
|
331
368
|
});
|
|
332
369
|
|
|
333
370
|
// src/xai-error.ts
|
|
334
371
|
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
335
|
-
import { z as
|
|
336
|
-
var chatCompletionsErrorSchema =
|
|
337
|
-
error:
|
|
338
|
-
message:
|
|
339
|
-
type:
|
|
340
|
-
param:
|
|
341
|
-
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()
|
|
342
379
|
})
|
|
343
380
|
});
|
|
344
|
-
var responsesErrorSchema =
|
|
345
|
-
code:
|
|
346
|
-
error:
|
|
381
|
+
var responsesErrorSchema = z3.object({
|
|
382
|
+
code: z3.string(),
|
|
383
|
+
error: z3.string()
|
|
347
384
|
});
|
|
348
|
-
var xaiErrorDataSchema =
|
|
385
|
+
var xaiErrorDataSchema = z3.union([
|
|
349
386
|
chatCompletionsErrorSchema,
|
|
350
387
|
responsesErrorSchema
|
|
351
388
|
]);
|
|
@@ -472,9 +509,9 @@ var XaiChatLanguageModel = class _XaiChatLanguageModel {
|
|
|
472
509
|
tools,
|
|
473
510
|
toolChoice
|
|
474
511
|
}) {
|
|
475
|
-
var _a, _b, _c
|
|
512
|
+
var _a, _b, _c;
|
|
476
513
|
const warnings = [];
|
|
477
|
-
const options = (_a = await
|
|
514
|
+
const options = (_a = await parseProviderOptions2({
|
|
478
515
|
provider: "xai",
|
|
479
516
|
providerOptions,
|
|
480
517
|
schema: xaiLanguageModelChatOptions
|
|
@@ -491,7 +528,7 @@ var XaiChatLanguageModel = class _XaiChatLanguageModel {
|
|
|
491
528
|
if (stopSequences != null) {
|
|
492
529
|
warnings.push({ type: "unsupported", feature: "stopSequences" });
|
|
493
530
|
}
|
|
494
|
-
const { messages, warnings: messageWarnings } = convertToXaiChatMessages(prompt);
|
|
531
|
+
const { messages, warnings: messageWarnings } = await convertToXaiChatMessages(prompt);
|
|
495
532
|
warnings.push(...messageWarnings);
|
|
496
533
|
const {
|
|
497
534
|
tools: xaiTools2,
|
|
@@ -502,6 +539,30 @@ var XaiChatLanguageModel = class _XaiChatLanguageModel {
|
|
|
502
539
|
toolChoice
|
|
503
540
|
});
|
|
504
541
|
warnings.push(...toolWarnings);
|
|
542
|
+
let reasoningEffort = options.reasoningEffort;
|
|
543
|
+
if (reasoningEffort == null && isCustomReasoning(reasoning)) {
|
|
544
|
+
if (!supportsReasoningEffort(this.modelId)) {
|
|
545
|
+
warnings.push({
|
|
546
|
+
type: "unsupported",
|
|
547
|
+
feature: "reasoning",
|
|
548
|
+
details: `reasoning "${reasoning}" is not supported by this model.`
|
|
549
|
+
});
|
|
550
|
+
} else if (reasoning === "none") {
|
|
551
|
+
reasoningEffort = "none";
|
|
552
|
+
} else {
|
|
553
|
+
reasoningEffort = mapReasoningToProviderEffort({
|
|
554
|
+
reasoning,
|
|
555
|
+
effortMap: {
|
|
556
|
+
minimal: "low",
|
|
557
|
+
low: "low",
|
|
558
|
+
medium: "medium",
|
|
559
|
+
high: "high",
|
|
560
|
+
xhigh: "high"
|
|
561
|
+
},
|
|
562
|
+
warnings
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
}
|
|
505
566
|
const baseArgs = {
|
|
506
567
|
// model id
|
|
507
568
|
model: this.modelId,
|
|
@@ -512,24 +573,14 @@ var XaiChatLanguageModel = class _XaiChatLanguageModel {
|
|
|
512
573
|
temperature,
|
|
513
574
|
top_p: topP,
|
|
514
575
|
seed,
|
|
515
|
-
reasoning_effort:
|
|
516
|
-
reasoning,
|
|
517
|
-
effortMap: {
|
|
518
|
-
minimal: "low",
|
|
519
|
-
low: "low",
|
|
520
|
-
medium: "medium",
|
|
521
|
-
high: "high",
|
|
522
|
-
xhigh: "high"
|
|
523
|
-
},
|
|
524
|
-
warnings
|
|
525
|
-
}) : void 0,
|
|
576
|
+
reasoning_effort: reasoningEffort,
|
|
526
577
|
// parallel function calling
|
|
527
578
|
parallel_function_calling: options.parallel_function_calling,
|
|
528
579
|
// response format
|
|
529
580
|
response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? responseFormat.schema != null ? {
|
|
530
581
|
type: "json_schema",
|
|
531
582
|
json_schema: {
|
|
532
|
-
name: (
|
|
583
|
+
name: (_b = responseFormat.name) != null ? _b : "response",
|
|
533
584
|
schema: responseFormat.schema,
|
|
534
585
|
strict: true
|
|
535
586
|
}
|
|
@@ -541,7 +592,7 @@ var XaiChatLanguageModel = class _XaiChatLanguageModel {
|
|
|
541
592
|
from_date: options.searchParameters.fromDate,
|
|
542
593
|
to_date: options.searchParameters.toDate,
|
|
543
594
|
max_search_results: options.searchParameters.maxSearchResults,
|
|
544
|
-
sources: (
|
|
595
|
+
sources: (_c = options.searchParameters.sources) == null ? void 0 : _c.map((source) => {
|
|
545
596
|
var _a2;
|
|
546
597
|
return {
|
|
547
598
|
type: source.type,
|
|
@@ -889,85 +940,85 @@ var XaiChatLanguageModel = class _XaiChatLanguageModel {
|
|
|
889
940
|
};
|
|
890
941
|
}
|
|
891
942
|
};
|
|
892
|
-
var xaiUsageSchema =
|
|
893
|
-
prompt_tokens:
|
|
894
|
-
completion_tokens:
|
|
895
|
-
total_tokens:
|
|
896
|
-
prompt_tokens_details:
|
|
897
|
-
text_tokens:
|
|
898
|
-
audio_tokens:
|
|
899
|
-
image_tokens:
|
|
900
|
-
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()
|
|
901
952
|
}).nullish(),
|
|
902
|
-
completion_tokens_details:
|
|
903
|
-
reasoning_tokens:
|
|
904
|
-
audio_tokens:
|
|
905
|
-
accepted_prediction_tokens:
|
|
906
|
-
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()
|
|
907
958
|
}).nullish()
|
|
908
959
|
});
|
|
909
|
-
var xaiChatResponseSchema =
|
|
910
|
-
id:
|
|
911
|
-
created:
|
|
912
|
-
model:
|
|
913
|
-
choices:
|
|
914
|
-
|
|
915
|
-
message:
|
|
916
|
-
role:
|
|
917
|
-
content:
|
|
918
|
-
reasoning_content:
|
|
919
|
-
tool_calls:
|
|
920
|
-
|
|
921
|
-
id:
|
|
922
|
-
type:
|
|
923
|
-
function:
|
|
924
|
-
name:
|
|
925
|
-
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()
|
|
926
977
|
})
|
|
927
978
|
})
|
|
928
979
|
).nullish()
|
|
929
980
|
}),
|
|
930
|
-
index:
|
|
931
|
-
finish_reason:
|
|
981
|
+
index: z4.number(),
|
|
982
|
+
finish_reason: z4.string().nullish()
|
|
932
983
|
})
|
|
933
984
|
).nullish(),
|
|
934
|
-
object:
|
|
985
|
+
object: z4.literal("chat.completion").nullish(),
|
|
935
986
|
usage: xaiUsageSchema.nullish(),
|
|
936
|
-
citations:
|
|
937
|
-
code:
|
|
938
|
-
error:
|
|
987
|
+
citations: z4.array(z4.string().url()).nullish(),
|
|
988
|
+
code: z4.string().nullish(),
|
|
989
|
+
error: z4.string().nullish()
|
|
939
990
|
});
|
|
940
|
-
var xaiChatChunkSchema =
|
|
941
|
-
id:
|
|
942
|
-
created:
|
|
943
|
-
model:
|
|
944
|
-
choices:
|
|
945
|
-
|
|
946
|
-
delta:
|
|
947
|
-
role:
|
|
948
|
-
content:
|
|
949
|
-
reasoning_content:
|
|
950
|
-
tool_calls:
|
|
951
|
-
|
|
952
|
-
id:
|
|
953
|
-
type:
|
|
954
|
-
function:
|
|
955
|
-
name:
|
|
956
|
-
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()
|
|
957
1008
|
})
|
|
958
1009
|
})
|
|
959
1010
|
).nullish()
|
|
960
1011
|
}),
|
|
961
|
-
finish_reason:
|
|
962
|
-
index:
|
|
1012
|
+
finish_reason: z4.string().nullish(),
|
|
1013
|
+
index: z4.number()
|
|
963
1014
|
})
|
|
964
1015
|
),
|
|
965
1016
|
usage: xaiUsageSchema.nullish(),
|
|
966
|
-
citations:
|
|
1017
|
+
citations: z4.array(z4.string().url()).nullish()
|
|
967
1018
|
});
|
|
968
|
-
var xaiStreamErrorSchema =
|
|
969
|
-
code:
|
|
970
|
-
error:
|
|
1019
|
+
var xaiStreamErrorSchema = z4.object({
|
|
1020
|
+
code: z4.string(),
|
|
1021
|
+
error: z4.string()
|
|
971
1022
|
});
|
|
972
1023
|
|
|
973
1024
|
// src/xai-image-model.ts
|
|
@@ -978,23 +1029,23 @@ import {
|
|
|
978
1029
|
createJsonResponseHandler as createJsonResponseHandler2,
|
|
979
1030
|
createStatusCodeErrorResponseHandler,
|
|
980
1031
|
getFromApi,
|
|
981
|
-
parseProviderOptions as
|
|
1032
|
+
parseProviderOptions as parseProviderOptions3,
|
|
982
1033
|
postJsonToApi as postJsonToApi2,
|
|
983
1034
|
serializeModelOptions as serializeModelOptions2,
|
|
984
1035
|
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
|
|
985
1036
|
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2
|
|
986
1037
|
} from "@ai-sdk/provider-utils";
|
|
987
|
-
import { z as
|
|
1038
|
+
import { z as z6 } from "zod/v4";
|
|
988
1039
|
|
|
989
1040
|
// src/xai-image-model-options.ts
|
|
990
|
-
import { z as
|
|
991
|
-
var xaiImageModelOptions =
|
|
992
|
-
aspect_ratio:
|
|
993
|
-
output_format:
|
|
994
|
-
sync_mode:
|
|
995
|
-
resolution:
|
|
996
|
-
quality:
|
|
997
|
-
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()
|
|
998
1049
|
});
|
|
999
1050
|
|
|
1000
1051
|
// src/xai-image-model.ts
|
|
@@ -1050,7 +1101,7 @@ var XaiImageModel = class _XaiImageModel {
|
|
|
1050
1101
|
feature: "mask"
|
|
1051
1102
|
});
|
|
1052
1103
|
}
|
|
1053
|
-
const xaiOptions = await
|
|
1104
|
+
const xaiOptions = await parseProviderOptions3({
|
|
1054
1105
|
provider: "xai",
|
|
1055
1106
|
providerOptions,
|
|
1056
1107
|
schema: xaiImageModelOptions
|
|
@@ -1138,16 +1189,16 @@ var XaiImageModel = class _XaiImageModel {
|
|
|
1138
1189
|
return value;
|
|
1139
1190
|
}
|
|
1140
1191
|
};
|
|
1141
|
-
var xaiImageResponseSchema =
|
|
1142
|
-
data:
|
|
1143
|
-
|
|
1144
|
-
url:
|
|
1145
|
-
b64_json:
|
|
1146
|
-
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()
|
|
1147
1198
|
})
|
|
1148
1199
|
),
|
|
1149
|
-
usage:
|
|
1150
|
-
cost_in_usd_ticks:
|
|
1200
|
+
usage: z6.object({
|
|
1201
|
+
cost_in_usd_ticks: z6.number().nullish()
|
|
1151
1202
|
}).nullish()
|
|
1152
1203
|
});
|
|
1153
1204
|
|
|
@@ -1158,7 +1209,7 @@ import {
|
|
|
1158
1209
|
createJsonResponseHandler as createJsonResponseHandler3,
|
|
1159
1210
|
isCustomReasoning as isCustomReasoning2,
|
|
1160
1211
|
mapReasoningToProviderEffort as mapReasoningToProviderEffort2,
|
|
1161
|
-
parseProviderOptions as
|
|
1212
|
+
parseProviderOptions as parseProviderOptions5,
|
|
1162
1213
|
postJsonToApi as postJsonToApi3,
|
|
1163
1214
|
serializeModelOptions as serializeModelOptions3,
|
|
1164
1215
|
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE3,
|
|
@@ -1172,6 +1223,7 @@ import {
|
|
|
1172
1223
|
import {
|
|
1173
1224
|
convertToBase64 as convertToBase642,
|
|
1174
1225
|
getTopLevelMediaType as getTopLevelMediaType2,
|
|
1226
|
+
parseProviderOptions as parseProviderOptions4,
|
|
1175
1227
|
resolveFullMediaType as resolveFullMediaType2,
|
|
1176
1228
|
resolveProviderReference as resolveProviderReference2
|
|
1177
1229
|
} from "@ai-sdk/provider-utils";
|
|
@@ -1219,9 +1271,17 @@ async function convertToXaiResponsesInput({
|
|
|
1219
1271
|
case "data": {
|
|
1220
1272
|
if (getTopLevelMediaType2(block.mediaType) === "image") {
|
|
1221
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
|
+
});
|
|
1222
1279
|
contentParts.push({
|
|
1223
1280
|
type: "input_image",
|
|
1224
|
-
image_url: imageUrl
|
|
1281
|
+
image_url: imageUrl,
|
|
1282
|
+
...(filePartOptions == null ? void 0 : filePartOptions.imageDetail) != null && {
|
|
1283
|
+
detail: filePartOptions.imageDetail
|
|
1284
|
+
}
|
|
1225
1285
|
});
|
|
1226
1286
|
} else if (block.data.type === "url") {
|
|
1227
1287
|
contentParts.push({
|
|
@@ -1425,437 +1485,437 @@ function mapXaiResponsesFinishReason(finishReason) {
|
|
|
1425
1485
|
}
|
|
1426
1486
|
|
|
1427
1487
|
// src/responses/xai-responses-api.ts
|
|
1428
|
-
import { z as
|
|
1429
|
-
var annotationSchema =
|
|
1430
|
-
|
|
1431
|
-
type:
|
|
1432
|
-
url:
|
|
1433
|
-
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()
|
|
1434
1494
|
}),
|
|
1435
|
-
|
|
1436
|
-
type:
|
|
1495
|
+
z7.object({
|
|
1496
|
+
type: z7.string()
|
|
1437
1497
|
})
|
|
1438
1498
|
]);
|
|
1439
|
-
var messageContentPartSchema =
|
|
1440
|
-
type:
|
|
1441
|
-
text:
|
|
1442
|
-
logprobs:
|
|
1443
|
-
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()
|
|
1444
1504
|
});
|
|
1445
|
-
var reasoningSummaryPartSchema =
|
|
1446
|
-
type:
|
|
1447
|
-
text:
|
|
1505
|
+
var reasoningSummaryPartSchema = z7.object({
|
|
1506
|
+
type: z7.string(),
|
|
1507
|
+
text: z7.string()
|
|
1448
1508
|
});
|
|
1449
|
-
var toolCallSchema =
|
|
1450
|
-
name:
|
|
1451
|
-
arguments:
|
|
1452
|
-
input:
|
|
1453
|
-
call_id:
|
|
1454
|
-
id:
|
|
1455
|
-
status:
|
|
1456
|
-
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()
|
|
1457
1517
|
});
|
|
1458
|
-
var mcpCallSchema =
|
|
1459
|
-
name:
|
|
1460
|
-
arguments:
|
|
1461
|
-
output:
|
|
1462
|
-
error:
|
|
1463
|
-
id:
|
|
1464
|
-
status:
|
|
1465
|
-
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()
|
|
1466
1526
|
});
|
|
1467
|
-
var outputItemSchema =
|
|
1468
|
-
|
|
1469
|
-
type:
|
|
1527
|
+
var outputItemSchema = z7.discriminatedUnion("type", [
|
|
1528
|
+
z7.object({
|
|
1529
|
+
type: z7.literal("web_search_call"),
|
|
1470
1530
|
...toolCallSchema.shape
|
|
1471
1531
|
}),
|
|
1472
|
-
|
|
1473
|
-
type:
|
|
1532
|
+
z7.object({
|
|
1533
|
+
type: z7.literal("x_search_call"),
|
|
1474
1534
|
...toolCallSchema.shape
|
|
1475
1535
|
}),
|
|
1476
|
-
|
|
1477
|
-
type:
|
|
1536
|
+
z7.object({
|
|
1537
|
+
type: z7.literal("code_interpreter_call"),
|
|
1478
1538
|
...toolCallSchema.shape
|
|
1479
1539
|
}),
|
|
1480
|
-
|
|
1481
|
-
type:
|
|
1540
|
+
z7.object({
|
|
1541
|
+
type: z7.literal("code_execution_call"),
|
|
1482
1542
|
...toolCallSchema.shape
|
|
1483
1543
|
}),
|
|
1484
|
-
|
|
1485
|
-
type:
|
|
1544
|
+
z7.object({
|
|
1545
|
+
type: z7.literal("view_image_call"),
|
|
1486
1546
|
...toolCallSchema.shape
|
|
1487
1547
|
}),
|
|
1488
|
-
|
|
1489
|
-
type:
|
|
1548
|
+
z7.object({
|
|
1549
|
+
type: z7.literal("view_x_video_call"),
|
|
1490
1550
|
...toolCallSchema.shape
|
|
1491
1551
|
}),
|
|
1492
|
-
|
|
1493
|
-
type:
|
|
1494
|
-
id:
|
|
1495
|
-
status:
|
|
1496
|
-
queries:
|
|
1497
|
-
results:
|
|
1498
|
-
|
|
1499
|
-
file_id:
|
|
1500
|
-
filename:
|
|
1501
|
-
score:
|
|
1502
|
-
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()
|
|
1503
1563
|
})
|
|
1504
1564
|
).nullish()
|
|
1505
1565
|
}),
|
|
1506
|
-
|
|
1507
|
-
type:
|
|
1566
|
+
z7.object({
|
|
1567
|
+
type: z7.literal("custom_tool_call"),
|
|
1508
1568
|
...toolCallSchema.shape
|
|
1509
1569
|
}),
|
|
1510
|
-
|
|
1511
|
-
type:
|
|
1570
|
+
z7.object({
|
|
1571
|
+
type: z7.literal("mcp_call"),
|
|
1512
1572
|
...mcpCallSchema.shape
|
|
1513
1573
|
}),
|
|
1514
|
-
|
|
1515
|
-
type:
|
|
1516
|
-
role:
|
|
1517
|
-
content:
|
|
1518
|
-
id:
|
|
1519
|
-
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()
|
|
1520
1580
|
}),
|
|
1521
|
-
|
|
1522
|
-
type:
|
|
1523
|
-
name:
|
|
1524
|
-
arguments:
|
|
1525
|
-
call_id:
|
|
1526
|
-
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()
|
|
1527
1587
|
}),
|
|
1528
|
-
|
|
1529
|
-
type:
|
|
1530
|
-
id:
|
|
1531
|
-
summary:
|
|
1532
|
-
content:
|
|
1533
|
-
status:
|
|
1534
|
-
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()
|
|
1535
1595
|
})
|
|
1536
1596
|
]);
|
|
1537
|
-
var xaiResponsesUsageSchema =
|
|
1538
|
-
input_tokens:
|
|
1539
|
-
output_tokens:
|
|
1540
|
-
total_tokens:
|
|
1541
|
-
input_tokens_details:
|
|
1542
|
-
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()
|
|
1543
1603
|
}).optional(),
|
|
1544
|
-
output_tokens_details:
|
|
1545
|
-
reasoning_tokens:
|
|
1604
|
+
output_tokens_details: z7.object({
|
|
1605
|
+
reasoning_tokens: z7.number().optional()
|
|
1546
1606
|
}).optional(),
|
|
1547
|
-
num_sources_used:
|
|
1548
|
-
num_server_side_tools_used:
|
|
1549
|
-
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()
|
|
1550
1610
|
});
|
|
1551
|
-
var xaiResponsesResponseSchema =
|
|
1552
|
-
id:
|
|
1553
|
-
created_at:
|
|
1554
|
-
model:
|
|
1555
|
-
object:
|
|
1556
|
-
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),
|
|
1557
1617
|
usage: xaiResponsesUsageSchema.nullish(),
|
|
1558
|
-
status:
|
|
1618
|
+
status: z7.string()
|
|
1559
1619
|
});
|
|
1560
|
-
var xaiResponsesChunkSchema =
|
|
1561
|
-
|
|
1562
|
-
type:
|
|
1620
|
+
var xaiResponsesChunkSchema = z7.union([
|
|
1621
|
+
z7.object({
|
|
1622
|
+
type: z7.literal("response.created"),
|
|
1563
1623
|
response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
|
|
1564
1624
|
}),
|
|
1565
|
-
|
|
1566
|
-
type:
|
|
1625
|
+
z7.object({
|
|
1626
|
+
type: z7.literal("response.in_progress"),
|
|
1567
1627
|
response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
|
|
1568
1628
|
}),
|
|
1569
|
-
|
|
1570
|
-
type:
|
|
1629
|
+
z7.object({
|
|
1630
|
+
type: z7.literal("response.output_item.added"),
|
|
1571
1631
|
item: outputItemSchema,
|
|
1572
|
-
output_index:
|
|
1632
|
+
output_index: z7.number()
|
|
1573
1633
|
}),
|
|
1574
|
-
|
|
1575
|
-
type:
|
|
1634
|
+
z7.object({
|
|
1635
|
+
type: z7.literal("response.output_item.done"),
|
|
1576
1636
|
item: outputItemSchema,
|
|
1577
|
-
output_index:
|
|
1637
|
+
output_index: z7.number()
|
|
1578
1638
|
}),
|
|
1579
|
-
|
|
1580
|
-
type:
|
|
1581
|
-
item_id:
|
|
1582
|
-
output_index:
|
|
1583
|
-
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(),
|
|
1584
1644
|
part: messageContentPartSchema
|
|
1585
1645
|
}),
|
|
1586
|
-
|
|
1587
|
-
type:
|
|
1588
|
-
item_id:
|
|
1589
|
-
output_index:
|
|
1590
|
-
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(),
|
|
1591
1651
|
part: messageContentPartSchema
|
|
1592
1652
|
}),
|
|
1593
|
-
|
|
1594
|
-
type:
|
|
1595
|
-
item_id:
|
|
1596
|
-
output_index:
|
|
1597
|
-
content_index:
|
|
1598
|
-
delta:
|
|
1599
|
-
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()
|
|
1600
1660
|
}),
|
|
1601
|
-
|
|
1602
|
-
type:
|
|
1603
|
-
item_id:
|
|
1604
|
-
output_index:
|
|
1605
|
-
content_index:
|
|
1606
|
-
text:
|
|
1607
|
-
logprobs:
|
|
1608
|
-
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()
|
|
1609
1669
|
}),
|
|
1610
|
-
|
|
1611
|
-
type:
|
|
1612
|
-
item_id:
|
|
1613
|
-
output_index:
|
|
1614
|
-
content_index:
|
|
1615
|
-
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(),
|
|
1616
1676
|
annotation: annotationSchema
|
|
1617
1677
|
}),
|
|
1618
|
-
|
|
1619
|
-
type:
|
|
1620
|
-
item_id:
|
|
1621
|
-
output_index:
|
|
1622
|
-
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(),
|
|
1623
1683
|
part: reasoningSummaryPartSchema
|
|
1624
1684
|
}),
|
|
1625
|
-
|
|
1626
|
-
type:
|
|
1627
|
-
item_id:
|
|
1628
|
-
output_index:
|
|
1629
|
-
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(),
|
|
1630
1690
|
part: reasoningSummaryPartSchema
|
|
1631
1691
|
}),
|
|
1632
|
-
|
|
1633
|
-
type:
|
|
1634
|
-
item_id:
|
|
1635
|
-
output_index:
|
|
1636
|
-
summary_index:
|
|
1637
|
-
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()
|
|
1638
1698
|
}),
|
|
1639
|
-
|
|
1640
|
-
type:
|
|
1641
|
-
item_id:
|
|
1642
|
-
output_index:
|
|
1643
|
-
summary_index:
|
|
1644
|
-
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()
|
|
1645
1705
|
}),
|
|
1646
|
-
|
|
1647
|
-
type:
|
|
1648
|
-
item_id:
|
|
1649
|
-
output_index:
|
|
1650
|
-
content_index:
|
|
1651
|
-
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()
|
|
1652
1712
|
}),
|
|
1653
|
-
|
|
1654
|
-
type:
|
|
1655
|
-
item_id:
|
|
1656
|
-
output_index:
|
|
1657
|
-
content_index:
|
|
1658
|
-
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()
|
|
1659
1719
|
}),
|
|
1660
|
-
|
|
1661
|
-
type:
|
|
1662
|
-
item_id:
|
|
1663
|
-
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()
|
|
1664
1724
|
}),
|
|
1665
|
-
|
|
1666
|
-
type:
|
|
1667
|
-
item_id:
|
|
1668
|
-
output_index:
|
|
1725
|
+
z7.object({
|
|
1726
|
+
type: z7.literal("response.web_search_call.searching"),
|
|
1727
|
+
item_id: z7.string(),
|
|
1728
|
+
output_index: z7.number()
|
|
1669
1729
|
}),
|
|
1670
|
-
|
|
1671
|
-
type:
|
|
1672
|
-
item_id:
|
|
1673
|
-
output_index:
|
|
1730
|
+
z7.object({
|
|
1731
|
+
type: z7.literal("response.web_search_call.completed"),
|
|
1732
|
+
item_id: z7.string(),
|
|
1733
|
+
output_index: z7.number()
|
|
1674
1734
|
}),
|
|
1675
|
-
|
|
1676
|
-
type:
|
|
1677
|
-
item_id:
|
|
1678
|
-
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()
|
|
1679
1739
|
}),
|
|
1680
|
-
|
|
1681
|
-
type:
|
|
1682
|
-
item_id:
|
|
1683
|
-
output_index:
|
|
1740
|
+
z7.object({
|
|
1741
|
+
type: z7.literal("response.x_search_call.searching"),
|
|
1742
|
+
item_id: z7.string(),
|
|
1743
|
+
output_index: z7.number()
|
|
1684
1744
|
}),
|
|
1685
|
-
|
|
1686
|
-
type:
|
|
1687
|
-
item_id:
|
|
1688
|
-
output_index:
|
|
1745
|
+
z7.object({
|
|
1746
|
+
type: z7.literal("response.x_search_call.completed"),
|
|
1747
|
+
item_id: z7.string(),
|
|
1748
|
+
output_index: z7.number()
|
|
1689
1749
|
}),
|
|
1690
|
-
|
|
1691
|
-
type:
|
|
1692
|
-
item_id:
|
|
1693
|
-
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()
|
|
1694
1754
|
}),
|
|
1695
|
-
|
|
1696
|
-
type:
|
|
1697
|
-
item_id:
|
|
1698
|
-
output_index:
|
|
1755
|
+
z7.object({
|
|
1756
|
+
type: z7.literal("response.file_search_call.searching"),
|
|
1757
|
+
item_id: z7.string(),
|
|
1758
|
+
output_index: z7.number()
|
|
1699
1759
|
}),
|
|
1700
|
-
|
|
1701
|
-
type:
|
|
1702
|
-
item_id:
|
|
1703
|
-
output_index:
|
|
1760
|
+
z7.object({
|
|
1761
|
+
type: z7.literal("response.file_search_call.completed"),
|
|
1762
|
+
item_id: z7.string(),
|
|
1763
|
+
output_index: z7.number()
|
|
1704
1764
|
}),
|
|
1705
|
-
|
|
1706
|
-
type:
|
|
1707
|
-
item_id:
|
|
1708
|
-
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()
|
|
1709
1769
|
}),
|
|
1710
|
-
|
|
1711
|
-
type:
|
|
1712
|
-
item_id:
|
|
1713
|
-
output_index:
|
|
1770
|
+
z7.object({
|
|
1771
|
+
type: z7.literal("response.code_execution_call.executing"),
|
|
1772
|
+
item_id: z7.string(),
|
|
1773
|
+
output_index: z7.number()
|
|
1714
1774
|
}),
|
|
1715
|
-
|
|
1716
|
-
type:
|
|
1717
|
-
item_id:
|
|
1718
|
-
output_index:
|
|
1775
|
+
z7.object({
|
|
1776
|
+
type: z7.literal("response.code_execution_call.completed"),
|
|
1777
|
+
item_id: z7.string(),
|
|
1778
|
+
output_index: z7.number()
|
|
1719
1779
|
}),
|
|
1720
|
-
|
|
1721
|
-
type:
|
|
1722
|
-
item_id:
|
|
1723
|
-
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()
|
|
1724
1784
|
}),
|
|
1725
|
-
|
|
1726
|
-
type:
|
|
1727
|
-
item_id:
|
|
1728
|
-
output_index:
|
|
1785
|
+
z7.object({
|
|
1786
|
+
type: z7.literal("response.code_interpreter_call.executing"),
|
|
1787
|
+
item_id: z7.string(),
|
|
1788
|
+
output_index: z7.number()
|
|
1729
1789
|
}),
|
|
1730
|
-
|
|
1731
|
-
type:
|
|
1732
|
-
item_id:
|
|
1733
|
-
output_index:
|
|
1790
|
+
z7.object({
|
|
1791
|
+
type: z7.literal("response.code_interpreter_call.interpreting"),
|
|
1792
|
+
item_id: z7.string(),
|
|
1793
|
+
output_index: z7.number()
|
|
1734
1794
|
}),
|
|
1735
|
-
|
|
1736
|
-
type:
|
|
1737
|
-
item_id:
|
|
1738
|
-
output_index:
|
|
1795
|
+
z7.object({
|
|
1796
|
+
type: z7.literal("response.code_interpreter_call.completed"),
|
|
1797
|
+
item_id: z7.string(),
|
|
1798
|
+
output_index: z7.number()
|
|
1739
1799
|
}),
|
|
1740
1800
|
// Code interpreter code streaming events
|
|
1741
|
-
|
|
1742
|
-
type:
|
|
1743
|
-
item_id:
|
|
1744
|
-
output_index:
|
|
1745
|
-
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()
|
|
1746
1806
|
}),
|
|
1747
|
-
|
|
1748
|
-
type:
|
|
1749
|
-
item_id:
|
|
1750
|
-
output_index:
|
|
1751
|
-
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()
|
|
1752
1812
|
}),
|
|
1753
|
-
|
|
1754
|
-
type:
|
|
1755
|
-
item_id:
|
|
1756
|
-
output_index:
|
|
1757
|
-
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()
|
|
1758
1818
|
}),
|
|
1759
|
-
|
|
1760
|
-
type:
|
|
1761
|
-
item_id:
|
|
1762
|
-
output_index:
|
|
1763
|
-
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()
|
|
1764
1824
|
}),
|
|
1765
1825
|
// Function call arguments streaming events (standard function tools)
|
|
1766
|
-
|
|
1767
|
-
type:
|
|
1768
|
-
item_id:
|
|
1769
|
-
output_index:
|
|
1770
|
-
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()
|
|
1771
1831
|
}),
|
|
1772
|
-
|
|
1773
|
-
type:
|
|
1774
|
-
item_id:
|
|
1775
|
-
output_index:
|
|
1776
|
-
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()
|
|
1777
1837
|
}),
|
|
1778
|
-
|
|
1779
|
-
type:
|
|
1780
|
-
item_id:
|
|
1781
|
-
output_index:
|
|
1838
|
+
z7.object({
|
|
1839
|
+
type: z7.literal("response.mcp_call.in_progress"),
|
|
1840
|
+
item_id: z7.string(),
|
|
1841
|
+
output_index: z7.number()
|
|
1782
1842
|
}),
|
|
1783
|
-
|
|
1784
|
-
type:
|
|
1785
|
-
item_id:
|
|
1786
|
-
output_index:
|
|
1843
|
+
z7.object({
|
|
1844
|
+
type: z7.literal("response.mcp_call.executing"),
|
|
1845
|
+
item_id: z7.string(),
|
|
1846
|
+
output_index: z7.number()
|
|
1787
1847
|
}),
|
|
1788
|
-
|
|
1789
|
-
type:
|
|
1790
|
-
item_id:
|
|
1791
|
-
output_index:
|
|
1848
|
+
z7.object({
|
|
1849
|
+
type: z7.literal("response.mcp_call.completed"),
|
|
1850
|
+
item_id: z7.string(),
|
|
1851
|
+
output_index: z7.number()
|
|
1792
1852
|
}),
|
|
1793
|
-
|
|
1794
|
-
type:
|
|
1795
|
-
item_id:
|
|
1796
|
-
output_index:
|
|
1853
|
+
z7.object({
|
|
1854
|
+
type: z7.literal("response.mcp_call.failed"),
|
|
1855
|
+
item_id: z7.string(),
|
|
1856
|
+
output_index: z7.number()
|
|
1797
1857
|
}),
|
|
1798
|
-
|
|
1799
|
-
type:
|
|
1800
|
-
item_id:
|
|
1801
|
-
output_index:
|
|
1802
|
-
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()
|
|
1803
1863
|
}),
|
|
1804
|
-
|
|
1805
|
-
type:
|
|
1806
|
-
item_id:
|
|
1807
|
-
output_index:
|
|
1808
|
-
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()
|
|
1809
1869
|
}),
|
|
1810
|
-
|
|
1811
|
-
type:
|
|
1812
|
-
item_id:
|
|
1813
|
-
output_index:
|
|
1814
|
-
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()
|
|
1815
1875
|
}),
|
|
1816
|
-
|
|
1817
|
-
type:
|
|
1818
|
-
item_id:
|
|
1819
|
-
output_index:
|
|
1820
|
-
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()
|
|
1821
1881
|
}),
|
|
1822
|
-
|
|
1823
|
-
type:
|
|
1824
|
-
response:
|
|
1825
|
-
incomplete_details:
|
|
1882
|
+
z7.object({
|
|
1883
|
+
type: z7.literal("response.incomplete"),
|
|
1884
|
+
response: z7.object({
|
|
1885
|
+
incomplete_details: z7.object({ reason: z7.string() }).nullish(),
|
|
1826
1886
|
usage: xaiResponsesUsageSchema.nullish()
|
|
1827
1887
|
})
|
|
1828
1888
|
}),
|
|
1829
|
-
|
|
1830
|
-
type:
|
|
1831
|
-
response:
|
|
1832
|
-
error:
|
|
1833
|
-
code:
|
|
1834
|
-
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()
|
|
1835
1895
|
}).nullish(),
|
|
1836
|
-
incomplete_details:
|
|
1896
|
+
incomplete_details: z7.object({ reason: z7.string() }).nullish(),
|
|
1837
1897
|
usage: xaiResponsesUsageSchema.nullish()
|
|
1838
1898
|
})
|
|
1839
1899
|
}),
|
|
1840
|
-
|
|
1841
|
-
type:
|
|
1842
|
-
code:
|
|
1843
|
-
message:
|
|
1844
|
-
param:
|
|
1900
|
+
z7.object({
|
|
1901
|
+
type: z7.literal("error"),
|
|
1902
|
+
code: z7.string().nullish(),
|
|
1903
|
+
message: z7.string(),
|
|
1904
|
+
param: z7.string().nullish()
|
|
1845
1905
|
}),
|
|
1846
|
-
|
|
1847
|
-
type:
|
|
1906
|
+
z7.object({
|
|
1907
|
+
type: z7.literal("response.done"),
|
|
1848
1908
|
response: xaiResponsesResponseSchema
|
|
1849
1909
|
}),
|
|
1850
|
-
|
|
1851
|
-
type:
|
|
1910
|
+
z7.object({
|
|
1911
|
+
type: z7.literal("response.completed"),
|
|
1852
1912
|
response: xaiResponsesResponseSchema
|
|
1853
1913
|
})
|
|
1854
1914
|
]);
|
|
1855
1915
|
|
|
1856
1916
|
// src/responses/xai-responses-language-model-options.ts
|
|
1857
|
-
import { z as
|
|
1858
|
-
var xaiLanguageModelResponsesOptions =
|
|
1917
|
+
import { z as z8 } from "zod/v4";
|
|
1918
|
+
var xaiLanguageModelResponsesOptions = z8.object({
|
|
1859
1919
|
/**
|
|
1860
1920
|
* Constrains how hard a reasoning model thinks before responding.
|
|
1861
1921
|
* Possible values are `none` (disables reasoning entirely; supported by
|
|
@@ -1864,26 +1924,26 @@ var xaiLanguageModelResponsesOptions = z7.object({
|
|
|
1864
1924
|
*
|
|
1865
1925
|
* @see https://docs.x.ai/docs/guides/reasoning
|
|
1866
1926
|
*/
|
|
1867
|
-
reasoningEffort:
|
|
1868
|
-
reasoningSummary:
|
|
1869
|
-
logprobs:
|
|
1870
|
-
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(),
|
|
1871
1931
|
/**
|
|
1872
1932
|
* Whether to store the input message(s) and model response for later retrieval.
|
|
1873
1933
|
* Must be set to `false` for teams with Zero Data Retention (ZDR) enabled,
|
|
1874
1934
|
* otherwise the API will return an error.
|
|
1875
1935
|
* @default true
|
|
1876
1936
|
*/
|
|
1877
|
-
store:
|
|
1937
|
+
store: z8.boolean().optional(),
|
|
1878
1938
|
/**
|
|
1879
1939
|
* The ID of the previous response from the model.
|
|
1880
1940
|
*/
|
|
1881
|
-
previousResponseId:
|
|
1941
|
+
previousResponseId: z8.string().optional(),
|
|
1882
1942
|
/**
|
|
1883
1943
|
* Specify additional output data to include in the model response.
|
|
1884
1944
|
* Example values: 'file_search_call.results'.
|
|
1885
1945
|
*/
|
|
1886
|
-
include:
|
|
1946
|
+
include: z8.array(z8.enum(["file_search_call.results"])).nullish()
|
|
1887
1947
|
});
|
|
1888
1948
|
|
|
1889
1949
|
// src/responses/xai-responses-prepare-tools.ts
|
|
@@ -1898,25 +1958,25 @@ import {
|
|
|
1898
1958
|
lazySchema,
|
|
1899
1959
|
zodSchema
|
|
1900
1960
|
} from "@ai-sdk/provider-utils";
|
|
1901
|
-
import { z as
|
|
1961
|
+
import { z as z9 } from "zod/v4";
|
|
1902
1962
|
var fileSearchArgsSchema = lazySchema(
|
|
1903
1963
|
() => zodSchema(
|
|
1904
|
-
|
|
1905
|
-
vectorStoreIds:
|
|
1906
|
-
maxNumResults:
|
|
1964
|
+
z9.object({
|
|
1965
|
+
vectorStoreIds: z9.array(z9.string()),
|
|
1966
|
+
maxNumResults: z9.number().optional()
|
|
1907
1967
|
})
|
|
1908
1968
|
)
|
|
1909
1969
|
);
|
|
1910
1970
|
var fileSearchOutputSchema = lazySchema(
|
|
1911
1971
|
() => zodSchema(
|
|
1912
|
-
|
|
1913
|
-
queries:
|
|
1914
|
-
results:
|
|
1915
|
-
|
|
1916
|
-
fileId:
|
|
1917
|
-
filename:
|
|
1918
|
-
score:
|
|
1919
|
-
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()
|
|
1920
1980
|
})
|
|
1921
1981
|
).nullable()
|
|
1922
1982
|
})
|
|
@@ -1924,7 +1984,7 @@ var fileSearchOutputSchema = lazySchema(
|
|
|
1924
1984
|
);
|
|
1925
1985
|
var fileSearchToolFactory = createProviderExecutedToolFactory({
|
|
1926
1986
|
id: "xai.file_search",
|
|
1927
|
-
inputSchema: lazySchema(() => zodSchema(
|
|
1987
|
+
inputSchema: lazySchema(() => zodSchema(z9.object({}))),
|
|
1928
1988
|
outputSchema: fileSearchOutputSchema
|
|
1929
1989
|
});
|
|
1930
1990
|
var fileSearch = (args) => fileSearchToolFactory(args);
|
|
@@ -1935,31 +1995,31 @@ import {
|
|
|
1935
1995
|
lazySchema as lazySchema2,
|
|
1936
1996
|
zodSchema as zodSchema2
|
|
1937
1997
|
} from "@ai-sdk/provider-utils";
|
|
1938
|
-
import { z as
|
|
1998
|
+
import { z as z10 } from "zod/v4";
|
|
1939
1999
|
var mcpServerArgsSchema = lazySchema2(
|
|
1940
2000
|
() => zodSchema2(
|
|
1941
|
-
|
|
1942
|
-
serverUrl:
|
|
1943
|
-
serverLabel:
|
|
1944
|
-
serverDescription:
|
|
1945
|
-
allowedTools:
|
|
1946
|
-
headers:
|
|
1947
|
-
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")
|
|
1948
2008
|
})
|
|
1949
2009
|
)
|
|
1950
2010
|
);
|
|
1951
2011
|
var mcpServerOutputSchema = lazySchema2(
|
|
1952
2012
|
() => zodSchema2(
|
|
1953
|
-
|
|
1954
|
-
name:
|
|
1955
|
-
arguments:
|
|
1956
|
-
result:
|
|
2013
|
+
z10.object({
|
|
2014
|
+
name: z10.string(),
|
|
2015
|
+
arguments: z10.string(),
|
|
2016
|
+
result: z10.unknown()
|
|
1957
2017
|
})
|
|
1958
2018
|
)
|
|
1959
2019
|
);
|
|
1960
2020
|
var mcpServerToolFactory = createProviderExecutedToolFactory2({
|
|
1961
2021
|
id: "xai.mcp",
|
|
1962
|
-
inputSchema: lazySchema2(() => zodSchema2(
|
|
2022
|
+
inputSchema: lazySchema2(() => zodSchema2(z10.object({}))),
|
|
1963
2023
|
outputSchema: mcpServerOutputSchema
|
|
1964
2024
|
});
|
|
1965
2025
|
var mcpServer = (args) => mcpServerToolFactory(args);
|
|
@@ -1970,26 +2030,26 @@ import {
|
|
|
1970
2030
|
lazySchema as lazySchema3,
|
|
1971
2031
|
zodSchema as zodSchema3
|
|
1972
2032
|
} from "@ai-sdk/provider-utils";
|
|
1973
|
-
import { z as
|
|
2033
|
+
import { z as z11 } from "zod/v4";
|
|
1974
2034
|
var webSearchArgsSchema = lazySchema3(
|
|
1975
2035
|
() => zodSchema3(
|
|
1976
|
-
|
|
1977
|
-
allowedDomains:
|
|
1978
|
-
excludedDomains:
|
|
1979
|
-
enableImageSearch:
|
|
1980
|
-
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()
|
|
1981
2041
|
})
|
|
1982
2042
|
)
|
|
1983
2043
|
);
|
|
1984
2044
|
var webSearchOutputSchema = lazySchema3(
|
|
1985
2045
|
() => zodSchema3(
|
|
1986
|
-
|
|
1987
|
-
query:
|
|
1988
|
-
sources:
|
|
1989
|
-
|
|
1990
|
-
title:
|
|
1991
|
-
url:
|
|
1992
|
-
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()
|
|
1993
2053
|
})
|
|
1994
2054
|
)
|
|
1995
2055
|
})
|
|
@@ -1997,7 +2057,7 @@ var webSearchOutputSchema = lazySchema3(
|
|
|
1997
2057
|
);
|
|
1998
2058
|
var webSearchToolFactory = createProviderExecutedToolFactory3({
|
|
1999
2059
|
id: "xai.web_search",
|
|
2000
|
-
inputSchema: lazySchema3(() => zodSchema3(
|
|
2060
|
+
inputSchema: lazySchema3(() => zodSchema3(z11.object({}))),
|
|
2001
2061
|
outputSchema: webSearchOutputSchema
|
|
2002
2062
|
});
|
|
2003
2063
|
var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
@@ -2008,29 +2068,29 @@ import {
|
|
|
2008
2068
|
lazySchema as lazySchema4,
|
|
2009
2069
|
zodSchema as zodSchema4
|
|
2010
2070
|
} from "@ai-sdk/provider-utils";
|
|
2011
|
-
import { z as
|
|
2071
|
+
import { z as z12 } from "zod/v4";
|
|
2012
2072
|
var xSearchArgsSchema = lazySchema4(
|
|
2013
2073
|
() => zodSchema4(
|
|
2014
|
-
|
|
2015
|
-
allowedXHandles:
|
|
2016
|
-
excludedXHandles:
|
|
2017
|
-
fromDate:
|
|
2018
|
-
toDate:
|
|
2019
|
-
enableImageUnderstanding:
|
|
2020
|
-
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()
|
|
2021
2081
|
})
|
|
2022
2082
|
)
|
|
2023
2083
|
);
|
|
2024
2084
|
var xSearchOutputSchema = lazySchema4(
|
|
2025
2085
|
() => zodSchema4(
|
|
2026
|
-
|
|
2027
|
-
query:
|
|
2028
|
-
posts:
|
|
2029
|
-
|
|
2030
|
-
author:
|
|
2031
|
-
text:
|
|
2032
|
-
url:
|
|
2033
|
-
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()
|
|
2034
2094
|
})
|
|
2035
2095
|
)
|
|
2036
2096
|
})
|
|
@@ -2038,7 +2098,7 @@ var xSearchOutputSchema = lazySchema4(
|
|
|
2038
2098
|
);
|
|
2039
2099
|
var xSearchToolFactory = createProviderExecutedToolFactory4({
|
|
2040
2100
|
id: "xai.x_search",
|
|
2041
|
-
inputSchema: lazySchema4(() => zodSchema4(
|
|
2101
|
+
inputSchema: lazySchema4(() => zodSchema4(z12.object({}))),
|
|
2042
2102
|
outputSchema: xSearchOutputSchema
|
|
2043
2103
|
});
|
|
2044
2104
|
var xSearch = (args = {}) => xSearchToolFactory(args);
|
|
@@ -2234,9 +2294,9 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
|
|
|
2234
2294
|
toolChoice,
|
|
2235
2295
|
reasoning
|
|
2236
2296
|
}) {
|
|
2237
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
2297
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2238
2298
|
const warnings = [];
|
|
2239
|
-
const options = (_a = await
|
|
2299
|
+
const options = (_a = await parseProviderOptions5({
|
|
2240
2300
|
provider: "xai",
|
|
2241
2301
|
providerOptions,
|
|
2242
2302
|
schema: xaiLanguageModelResponsesOptions
|
|
@@ -2281,17 +2341,30 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
|
|
|
2281
2341
|
include = [...include, "reasoning.encrypted_content"];
|
|
2282
2342
|
}
|
|
2283
2343
|
}
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
}
|
|
2293
|
-
|
|
2294
|
-
|
|
2344
|
+
let resolvedReasoningEffort = options.reasoningEffort;
|
|
2345
|
+
if (resolvedReasoningEffort == null && isCustomReasoning2(reasoning)) {
|
|
2346
|
+
if (!supportsReasoningEffort(this.modelId)) {
|
|
2347
|
+
warnings.push({
|
|
2348
|
+
type: "unsupported",
|
|
2349
|
+
feature: "reasoning",
|
|
2350
|
+
details: `reasoning "${reasoning}" is not supported by this model.`
|
|
2351
|
+
});
|
|
2352
|
+
} else if (reasoning === "none") {
|
|
2353
|
+
resolvedReasoningEffort = "none";
|
|
2354
|
+
} else {
|
|
2355
|
+
resolvedReasoningEffort = mapReasoningToProviderEffort2({
|
|
2356
|
+
reasoning,
|
|
2357
|
+
effortMap: {
|
|
2358
|
+
minimal: "low",
|
|
2359
|
+
low: "low",
|
|
2360
|
+
medium: "medium",
|
|
2361
|
+
high: "high",
|
|
2362
|
+
xhigh: "high"
|
|
2363
|
+
},
|
|
2364
|
+
warnings
|
|
2365
|
+
});
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2295
2368
|
const baseArgs = {
|
|
2296
2369
|
model: this.modelId,
|
|
2297
2370
|
input,
|
|
@@ -2306,7 +2379,7 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
|
|
|
2306
2379
|
format: responseFormat.schema != null ? {
|
|
2307
2380
|
type: "json_schema",
|
|
2308
2381
|
strict: true,
|
|
2309
|
-
name: (
|
|
2382
|
+
name: (_h = responseFormat.name) != null ? _h : "response",
|
|
2310
2383
|
description: responseFormat.description,
|
|
2311
2384
|
schema: responseFormat.schema
|
|
2312
2385
|
} : { type: "json_object" }
|
|
@@ -3348,43 +3421,43 @@ var XaiRealtimeModel = class {
|
|
|
3348
3421
|
|
|
3349
3422
|
// src/tool/code-execution.ts
|
|
3350
3423
|
import { createProviderExecutedToolFactory as createProviderExecutedToolFactory5 } from "@ai-sdk/provider-utils";
|
|
3351
|
-
import { z as
|
|
3352
|
-
var codeExecutionOutputSchema =
|
|
3353
|
-
output:
|
|
3354
|
-
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")
|
|
3355
3428
|
});
|
|
3356
3429
|
var codeExecutionToolFactory = createProviderExecutedToolFactory5({
|
|
3357
3430
|
id: "xai.code_execution",
|
|
3358
|
-
inputSchema:
|
|
3431
|
+
inputSchema: z13.object({}).describe("no input parameters"),
|
|
3359
3432
|
outputSchema: codeExecutionOutputSchema
|
|
3360
3433
|
});
|
|
3361
3434
|
var codeExecution = (args = {}) => codeExecutionToolFactory(args);
|
|
3362
3435
|
|
|
3363
3436
|
// src/tool/view-image.ts
|
|
3364
3437
|
import { createProviderExecutedToolFactory as createProviderExecutedToolFactory6 } from "@ai-sdk/provider-utils";
|
|
3365
|
-
import { z as
|
|
3366
|
-
var viewImageOutputSchema =
|
|
3367
|
-
description:
|
|
3368
|
-
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")
|
|
3369
3442
|
});
|
|
3370
3443
|
var viewImageToolFactory = createProviderExecutedToolFactory6({
|
|
3371
3444
|
id: "xai.view_image",
|
|
3372
|
-
inputSchema:
|
|
3445
|
+
inputSchema: z14.object({}).describe("no input parameters"),
|
|
3373
3446
|
outputSchema: viewImageOutputSchema
|
|
3374
3447
|
});
|
|
3375
3448
|
var viewImage = (args = {}) => viewImageToolFactory(args);
|
|
3376
3449
|
|
|
3377
3450
|
// src/tool/view-x-video.ts
|
|
3378
3451
|
import { createProviderExecutedToolFactory as createProviderExecutedToolFactory7 } from "@ai-sdk/provider-utils";
|
|
3379
|
-
import { z as
|
|
3380
|
-
var viewXVideoOutputSchema =
|
|
3381
|
-
transcript:
|
|
3382
|
-
description:
|
|
3383
|
-
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")
|
|
3384
3457
|
});
|
|
3385
3458
|
var viewXVideoToolFactory = createProviderExecutedToolFactory7({
|
|
3386
3459
|
id: "xai.view_x_video",
|
|
3387
|
-
inputSchema:
|
|
3460
|
+
inputSchema: z15.object({}).describe("no input parameters"),
|
|
3388
3461
|
outputSchema: viewXVideoOutputSchema
|
|
3389
3462
|
});
|
|
3390
3463
|
var viewXVideo = (args = {}) => viewXVideoToolFactory(args);
|
|
@@ -3401,30 +3474,30 @@ var xaiTools = {
|
|
|
3401
3474
|
};
|
|
3402
3475
|
|
|
3403
3476
|
// src/version.ts
|
|
3404
|
-
var VERSION = true ? "4.0.
|
|
3477
|
+
var VERSION = true ? "4.0.9" : "0.0.0-test";
|
|
3405
3478
|
|
|
3406
3479
|
// src/files/xai-files.ts
|
|
3407
3480
|
import {
|
|
3408
3481
|
combineHeaders as combineHeaders4,
|
|
3409
3482
|
convertInlineFileDataToUint8Array,
|
|
3410
3483
|
createJsonResponseHandler as createJsonResponseHandler4,
|
|
3411
|
-
parseProviderOptions as
|
|
3484
|
+
parseProviderOptions as parseProviderOptions6,
|
|
3412
3485
|
postFormDataToApi
|
|
3413
3486
|
} from "@ai-sdk/provider-utils";
|
|
3414
3487
|
|
|
3415
3488
|
// src/files/xai-files-api.ts
|
|
3416
3489
|
import { lazySchema as lazySchema5, zodSchema as zodSchema5 } from "@ai-sdk/provider-utils";
|
|
3417
|
-
import { z as
|
|
3490
|
+
import { z as z16 } from "zod/v4";
|
|
3418
3491
|
var xaiFilesResponseSchema = lazySchema5(
|
|
3419
3492
|
() => zodSchema5(
|
|
3420
|
-
|
|
3421
|
-
id:
|
|
3422
|
-
object:
|
|
3423
|
-
bytes:
|
|
3424
|
-
created_at:
|
|
3425
|
-
filename:
|
|
3426
|
-
purpose:
|
|
3427
|
-
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()
|
|
3428
3501
|
})
|
|
3429
3502
|
)
|
|
3430
3503
|
);
|
|
@@ -3434,12 +3507,12 @@ import {
|
|
|
3434
3507
|
lazySchema as lazySchema6,
|
|
3435
3508
|
zodSchema as zodSchema6
|
|
3436
3509
|
} from "@ai-sdk/provider-utils";
|
|
3437
|
-
import { z as
|
|
3510
|
+
import { z as z17 } from "zod/v4";
|
|
3438
3511
|
var xaiFilesOptionsSchema = lazySchema6(
|
|
3439
3512
|
() => zodSchema6(
|
|
3440
|
-
|
|
3441
|
-
teamId:
|
|
3442
|
-
filePath:
|
|
3513
|
+
z17.looseObject({
|
|
3514
|
+
teamId: z17.string().optional(),
|
|
3515
|
+
filePath: z17.string().optional()
|
|
3443
3516
|
})
|
|
3444
3517
|
)
|
|
3445
3518
|
);
|
|
@@ -3460,7 +3533,7 @@ var XaiFiles = class {
|
|
|
3460
3533
|
providerOptions
|
|
3461
3534
|
}) {
|
|
3462
3535
|
var _a, _b;
|
|
3463
|
-
const xaiOptions = await
|
|
3536
|
+
const xaiOptions = await parseProviderOptions6({
|
|
3464
3537
|
provider: "xai",
|
|
3465
3538
|
providerOptions,
|
|
3466
3539
|
schema: xaiFilesOptionsSchema
|
|
@@ -3514,56 +3587,56 @@ import {
|
|
|
3514
3587
|
createJsonResponseHandler as createJsonResponseHandler5,
|
|
3515
3588
|
delay,
|
|
3516
3589
|
getFromApi as getFromApi2,
|
|
3517
|
-
parseProviderOptions as
|
|
3590
|
+
parseProviderOptions as parseProviderOptions7,
|
|
3518
3591
|
postJsonToApi as postJsonToApi4
|
|
3519
3592
|
} from "@ai-sdk/provider-utils";
|
|
3520
|
-
import { z as
|
|
3593
|
+
import { z as z19 } from "zod/v4";
|
|
3521
3594
|
|
|
3522
3595
|
// src/xai-video-model-options.ts
|
|
3523
3596
|
import { lazySchema as lazySchema7, zodSchema as zodSchema7 } from "@ai-sdk/provider-utils";
|
|
3524
|
-
import { z as
|
|
3525
|
-
var nonEmptyStringSchema =
|
|
3526
|
-
var resolutionSchema =
|
|
3527
|
-
var modeSchema =
|
|
3597
|
+
import { z as z18 } from "zod/v4";
|
|
3598
|
+
var nonEmptyStringSchema = z18.string().min(1);
|
|
3599
|
+
var resolutionSchema = z18.enum(["480p", "720p"]);
|
|
3600
|
+
var modeSchema = z18.enum(["edit-video", "extend-video", "reference-to-video"]);
|
|
3528
3601
|
var baseFields = {
|
|
3529
|
-
pollIntervalMs:
|
|
3530
|
-
pollTimeoutMs:
|
|
3602
|
+
pollIntervalMs: z18.number().positive().nullish(),
|
|
3603
|
+
pollTimeoutMs: z18.number().positive().nullish(),
|
|
3531
3604
|
resolution: resolutionSchema.nullish()
|
|
3532
3605
|
};
|
|
3533
|
-
var editVideoSchema =
|
|
3606
|
+
var editVideoSchema = z18.object({
|
|
3534
3607
|
...baseFields,
|
|
3535
|
-
mode:
|
|
3608
|
+
mode: z18.literal("edit-video"),
|
|
3536
3609
|
videoUrl: nonEmptyStringSchema,
|
|
3537
|
-
referenceImageUrls:
|
|
3610
|
+
referenceImageUrls: z18.undefined().optional()
|
|
3538
3611
|
});
|
|
3539
|
-
var extendVideoSchema =
|
|
3612
|
+
var extendVideoSchema = z18.object({
|
|
3540
3613
|
...baseFields,
|
|
3541
|
-
mode:
|
|
3614
|
+
mode: z18.literal("extend-video"),
|
|
3542
3615
|
videoUrl: nonEmptyStringSchema,
|
|
3543
|
-
referenceImageUrls:
|
|
3616
|
+
referenceImageUrls: z18.undefined().optional()
|
|
3544
3617
|
});
|
|
3545
|
-
var referenceToVideoSchema =
|
|
3618
|
+
var referenceToVideoSchema = z18.object({
|
|
3546
3619
|
...baseFields,
|
|
3547
|
-
mode:
|
|
3548
|
-
referenceImageUrls:
|
|
3549
|
-
videoUrl:
|
|
3620
|
+
mode: z18.literal("reference-to-video"),
|
|
3621
|
+
referenceImageUrls: z18.array(nonEmptyStringSchema).min(1).max(7),
|
|
3622
|
+
videoUrl: z18.undefined().optional()
|
|
3550
3623
|
});
|
|
3551
|
-
var autoDetectSchema =
|
|
3624
|
+
var autoDetectSchema = z18.object({
|
|
3552
3625
|
...baseFields,
|
|
3553
|
-
mode:
|
|
3626
|
+
mode: z18.undefined().optional(),
|
|
3554
3627
|
videoUrl: nonEmptyStringSchema.optional(),
|
|
3555
|
-
referenceImageUrls:
|
|
3628
|
+
referenceImageUrls: z18.array(nonEmptyStringSchema).min(1).max(7).optional()
|
|
3556
3629
|
});
|
|
3557
|
-
var xaiVideoModelOptions =
|
|
3630
|
+
var xaiVideoModelOptions = z18.union([
|
|
3558
3631
|
editVideoSchema,
|
|
3559
3632
|
extendVideoSchema,
|
|
3560
3633
|
referenceToVideoSchema,
|
|
3561
3634
|
autoDetectSchema
|
|
3562
3635
|
]);
|
|
3563
|
-
var runtimeSchema =
|
|
3636
|
+
var runtimeSchema = z18.looseObject({
|
|
3564
3637
|
mode: modeSchema.optional(),
|
|
3565
3638
|
videoUrl: nonEmptyStringSchema.optional(),
|
|
3566
|
-
referenceImageUrls:
|
|
3639
|
+
referenceImageUrls: z18.array(nonEmptyStringSchema).min(1).max(7).optional(),
|
|
3567
3640
|
...baseFields
|
|
3568
3641
|
});
|
|
3569
3642
|
var xaiVideoModelOptionsSchema = lazySchema7(
|
|
@@ -3636,7 +3709,7 @@ var XaiVideoModel = class {
|
|
|
3636
3709
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
3637
3710
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
3638
3711
|
const warnings = [];
|
|
3639
|
-
const xaiOptions = await
|
|
3712
|
+
const xaiOptions = await parseProviderOptions7({
|
|
3640
3713
|
provider: "xai",
|
|
3641
3714
|
providerOptions: options.providerOptions,
|
|
3642
3715
|
schema: xaiVideoModelOptionsSchema
|
|
@@ -3875,24 +3948,24 @@ var XaiVideoModel = class {
|
|
|
3875
3948
|
}
|
|
3876
3949
|
}
|
|
3877
3950
|
};
|
|
3878
|
-
var xaiCreateVideoResponseSchema =
|
|
3879
|
-
request_id:
|
|
3951
|
+
var xaiCreateVideoResponseSchema = z19.object({
|
|
3952
|
+
request_id: z19.string().nullish()
|
|
3880
3953
|
});
|
|
3881
|
-
var xaiVideoStatusResponseSchema =
|
|
3882
|
-
status:
|
|
3883
|
-
video:
|
|
3884
|
-
url:
|
|
3885
|
-
duration:
|
|
3886
|
-
respect_moderation:
|
|
3954
|
+
var xaiVideoStatusResponseSchema = z19.object({
|
|
3955
|
+
status: z19.string().nullish(),
|
|
3956
|
+
video: z19.object({
|
|
3957
|
+
url: z19.string(),
|
|
3958
|
+
duration: z19.number().nullish(),
|
|
3959
|
+
respect_moderation: z19.boolean().nullish()
|
|
3887
3960
|
}).nullish(),
|
|
3888
|
-
model:
|
|
3889
|
-
usage:
|
|
3890
|
-
cost_in_usd_ticks:
|
|
3961
|
+
model: z19.string().nullish(),
|
|
3962
|
+
usage: z19.object({
|
|
3963
|
+
cost_in_usd_ticks: z19.number().nullish()
|
|
3891
3964
|
}).nullish(),
|
|
3892
|
-
progress:
|
|
3893
|
-
error:
|
|
3894
|
-
code:
|
|
3895
|
-
message:
|
|
3965
|
+
progress: z19.number().nullish(),
|
|
3966
|
+
error: z19.object({
|
|
3967
|
+
code: z19.string().nullish(),
|
|
3968
|
+
message: z19.string().nullish()
|
|
3896
3969
|
}).nullish()
|
|
3897
3970
|
});
|
|
3898
3971
|
|
|
@@ -3900,7 +3973,7 @@ var xaiVideoStatusResponseSchema = z18.object({
|
|
|
3900
3973
|
import {
|
|
3901
3974
|
combineHeaders as combineHeaders6,
|
|
3902
3975
|
createBinaryResponseHandler as createBinaryResponseHandler2,
|
|
3903
|
-
parseProviderOptions as
|
|
3976
|
+
parseProviderOptions as parseProviderOptions8,
|
|
3904
3977
|
postJsonToApi as postJsonToApi5,
|
|
3905
3978
|
resolve,
|
|
3906
3979
|
serializeModelOptions as serializeModelOptions4,
|
|
@@ -3913,39 +3986,39 @@ import {
|
|
|
3913
3986
|
lazySchema as lazySchema8,
|
|
3914
3987
|
zodSchema as zodSchema8
|
|
3915
3988
|
} from "@ai-sdk/provider-utils";
|
|
3916
|
-
import { z as
|
|
3989
|
+
import { z as z20 } from "zod/v4";
|
|
3917
3990
|
var xaiSpeechModelOptionsSchema = lazySchema8(
|
|
3918
3991
|
() => zodSchema8(
|
|
3919
|
-
|
|
3992
|
+
z20.object({
|
|
3920
3993
|
/**
|
|
3921
3994
|
* Sample rate of the generated audio in Hz.
|
|
3922
3995
|
*/
|
|
3923
|
-
sampleRate:
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3996
|
+
sampleRate: z20.union([
|
|
3997
|
+
z20.literal(8e3),
|
|
3998
|
+
z20.literal(16e3),
|
|
3999
|
+
z20.literal(22050),
|
|
4000
|
+
z20.literal(24e3),
|
|
4001
|
+
z20.literal(44100),
|
|
4002
|
+
z20.literal(48e3)
|
|
3930
4003
|
]).nullish(),
|
|
3931
4004
|
/**
|
|
3932
4005
|
* MP3 bit rate in bits per second. Only applies when outputFormat is mp3.
|
|
3933
4006
|
*/
|
|
3934
|
-
bitRate:
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
4007
|
+
bitRate: z20.union([
|
|
4008
|
+
z20.literal(32e3),
|
|
4009
|
+
z20.literal(64e3),
|
|
4010
|
+
z20.literal(96e3),
|
|
4011
|
+
z20.literal(128e3),
|
|
4012
|
+
z20.literal(192e3)
|
|
3940
4013
|
]).nullish(),
|
|
3941
4014
|
/**
|
|
3942
4015
|
* Reduce time to first audio chunk, trading some quality for latency.
|
|
3943
4016
|
*/
|
|
3944
|
-
optimizeStreamingLatency:
|
|
4017
|
+
optimizeStreamingLatency: z20.union([z20.literal(0), z20.literal(1), z20.literal(2)]).nullish(),
|
|
3945
4018
|
/**
|
|
3946
4019
|
* Normalize written-form text into spoken-form text before synthesis.
|
|
3947
4020
|
*/
|
|
3948
|
-
textNormalization:
|
|
4021
|
+
textNormalization: z20.boolean().nullish()
|
|
3949
4022
|
})
|
|
3950
4023
|
)
|
|
3951
4024
|
);
|
|
@@ -3979,7 +4052,7 @@ var XaiSpeechModel = class _XaiSpeechModel {
|
|
|
3979
4052
|
providerOptions
|
|
3980
4053
|
}) {
|
|
3981
4054
|
const warnings = [];
|
|
3982
|
-
const xaiOptions = await
|
|
4055
|
+
const xaiOptions = await parseProviderOptions8({
|
|
3983
4056
|
provider: "xai",
|
|
3984
4057
|
providerOptions,
|
|
3985
4058
|
schema: xaiSpeechModelOptionsSchema
|
|
@@ -4075,7 +4148,7 @@ import {
|
|
|
4075
4148
|
createJsonResponseHandler as createJsonResponseHandler6,
|
|
4076
4149
|
getWebSocketConstructor,
|
|
4077
4150
|
mediaTypeToExtension,
|
|
4078
|
-
parseProviderOptions as
|
|
4151
|
+
parseProviderOptions as parseProviderOptions9,
|
|
4079
4152
|
postFormDataToApi as postFormDataToApi2,
|
|
4080
4153
|
readWebSocketMessageText,
|
|
4081
4154
|
safeParseJSON as safeParseJSON2,
|
|
@@ -4084,80 +4157,80 @@ import {
|
|
|
4084
4157
|
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE5,
|
|
4085
4158
|
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE5
|
|
4086
4159
|
} from "@ai-sdk/provider-utils";
|
|
4087
|
-
import { z as
|
|
4160
|
+
import { z as z22 } from "zod/v4";
|
|
4088
4161
|
|
|
4089
4162
|
// src/xai-transcription-model-options.ts
|
|
4090
4163
|
import {
|
|
4091
4164
|
lazySchema as lazySchema9,
|
|
4092
4165
|
zodSchema as zodSchema9
|
|
4093
4166
|
} from "@ai-sdk/provider-utils";
|
|
4094
|
-
import { z as
|
|
4167
|
+
import { z as z21 } from "zod/v4";
|
|
4095
4168
|
var xaiTranscriptionModelOptionsSchema = lazySchema9(
|
|
4096
4169
|
() => zodSchema9(
|
|
4097
|
-
|
|
4170
|
+
z21.object({
|
|
4098
4171
|
/**
|
|
4099
4172
|
* Audio encoding for raw, headerless input audio.
|
|
4100
4173
|
*/
|
|
4101
|
-
audioFormat:
|
|
4174
|
+
audioFormat: z21.enum(["pcm", "mulaw", "alaw"]).nullish(),
|
|
4102
4175
|
/**
|
|
4103
4176
|
* Sample rate of the input audio in Hz.
|
|
4104
4177
|
*/
|
|
4105
|
-
sampleRate:
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4178
|
+
sampleRate: z21.union([
|
|
4179
|
+
z21.literal(8e3),
|
|
4180
|
+
z21.literal(16e3),
|
|
4181
|
+
z21.literal(22050),
|
|
4182
|
+
z21.literal(24e3),
|
|
4183
|
+
z21.literal(44100),
|
|
4184
|
+
z21.literal(48e3)
|
|
4112
4185
|
]).nullish(),
|
|
4113
4186
|
/**
|
|
4114
4187
|
* Language code used for inverse text normalization.
|
|
4115
4188
|
*/
|
|
4116
|
-
language:
|
|
4189
|
+
language: z21.string().nullish(),
|
|
4117
4190
|
/**
|
|
4118
4191
|
* Enable inverse text normalization. Requires `language`.
|
|
4119
4192
|
*/
|
|
4120
|
-
format:
|
|
4193
|
+
format: z21.boolean().nullish(),
|
|
4121
4194
|
/**
|
|
4122
4195
|
* Enable per-channel transcription for multichannel audio.
|
|
4123
4196
|
*/
|
|
4124
|
-
multichannel:
|
|
4197
|
+
multichannel: z21.boolean().nullish(),
|
|
4125
4198
|
/**
|
|
4126
4199
|
* Number of interleaved audio channels.
|
|
4127
4200
|
*/
|
|
4128
|
-
channels:
|
|
4201
|
+
channels: z21.number().int().min(2).max(8).nullish(),
|
|
4129
4202
|
/**
|
|
4130
4203
|
* Enable speaker diarization.
|
|
4131
4204
|
*/
|
|
4132
|
-
diarize:
|
|
4205
|
+
diarize: z21.boolean().nullish(),
|
|
4133
4206
|
/**
|
|
4134
4207
|
* Terms to bias transcription toward.
|
|
4135
4208
|
*/
|
|
4136
|
-
keyterm:
|
|
4209
|
+
keyterm: z21.union([z21.string(), z21.array(z21.string())]).nullish(),
|
|
4137
4210
|
/**
|
|
4138
4211
|
* Include filler words such as "uh" and "um" in the transcript.
|
|
4139
4212
|
*/
|
|
4140
|
-
fillerWords:
|
|
4213
|
+
fillerWords: z21.boolean().nullish(),
|
|
4141
4214
|
/**
|
|
4142
4215
|
* Options for streaming speech-to-text over WebSocket.
|
|
4143
4216
|
*/
|
|
4144
|
-
streaming:
|
|
4217
|
+
streaming: z21.object({
|
|
4145
4218
|
/**
|
|
4146
4219
|
* Emit interim transcript results while speech is being processed.
|
|
4147
4220
|
*/
|
|
4148
|
-
interimResults:
|
|
4221
|
+
interimResults: z21.boolean().optional(),
|
|
4149
4222
|
/**
|
|
4150
4223
|
* Silence duration in milliseconds before an utterance-final event.
|
|
4151
4224
|
*/
|
|
4152
|
-
endpointing:
|
|
4225
|
+
endpointing: z21.number().int().min(0).max(5e3).optional(),
|
|
4153
4226
|
/**
|
|
4154
4227
|
* End-of-turn detection threshold. When set, enables Smart Turn.
|
|
4155
4228
|
*/
|
|
4156
|
-
smartTurn:
|
|
4229
|
+
smartTurn: z21.number().min(0).max(1).optional(),
|
|
4157
4230
|
/**
|
|
4158
4231
|
* Maximum silence duration in milliseconds before forcing speech_final.
|
|
4159
4232
|
*/
|
|
4160
|
-
smartTurnTimeout:
|
|
4233
|
+
smartTurnTimeout: z21.number().int().min(1).max(5e3).optional()
|
|
4161
4234
|
}).optional()
|
|
4162
4235
|
})
|
|
4163
4236
|
)
|
|
@@ -4188,7 +4261,7 @@ var XaiTranscriptionModel = class _XaiTranscriptionModel {
|
|
|
4188
4261
|
providerOptions
|
|
4189
4262
|
}) {
|
|
4190
4263
|
const warnings = [];
|
|
4191
|
-
const xaiOptions = await
|
|
4264
|
+
const xaiOptions = await parseProviderOptions9({
|
|
4192
4265
|
provider: "xai",
|
|
4193
4266
|
providerOptions,
|
|
4194
4267
|
schema: xaiTranscriptionModelOptionsSchema
|
|
@@ -4265,7 +4338,7 @@ var XaiTranscriptionModel = class _XaiTranscriptionModel {
|
|
|
4265
4338
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
4266
4339
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
4267
4340
|
const warnings = [];
|
|
4268
|
-
const xaiOptions = await
|
|
4341
|
+
const xaiOptions = await parseProviderOptions9({
|
|
4269
4342
|
provider: "xai",
|
|
4270
4343
|
providerOptions: options.providerOptions,
|
|
4271
4344
|
schema: xaiTranscriptionModelOptionsSchema
|
|
@@ -4537,15 +4610,15 @@ function timingFromXaiEvent(event) {
|
|
|
4537
4610
|
...event.start != null && event.duration != null ? { endSecond: event.start + event.duration } : {}
|
|
4538
4611
|
};
|
|
4539
4612
|
}
|
|
4540
|
-
var xaiTranscriptionResponseSchema =
|
|
4541
|
-
text:
|
|
4542
|
-
language:
|
|
4543
|
-
duration:
|
|
4544
|
-
words:
|
|
4545
|
-
|
|
4546
|
-
text:
|
|
4547
|
-
start:
|
|
4548
|
-
end:
|
|
4613
|
+
var xaiTranscriptionResponseSchema = z22.object({
|
|
4614
|
+
text: z22.string(),
|
|
4615
|
+
language: z22.string().nullish(),
|
|
4616
|
+
duration: z22.number().nullish(),
|
|
4617
|
+
words: z22.array(
|
|
4618
|
+
z22.object({
|
|
4619
|
+
text: z22.string(),
|
|
4620
|
+
start: z22.number(),
|
|
4621
|
+
end: z22.number()
|
|
4549
4622
|
})
|
|
4550
4623
|
).nullish()
|
|
4551
4624
|
});
|