@ai-sdk/xai 3.0.103 → 3.0.105
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/index.d.mts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +635 -595
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +645 -605
- package/dist/index.mjs.map +1 -1
- package/docs/01-xai.mdx +36 -0
- package/package.json +4 -4
- package/src/convert-to-xai-chat-messages.ts +48 -35
- package/src/index.ts +1 -0
- package/src/responses/convert-to-xai-responses-input.ts +15 -2
- package/src/responses/xai-responses-api.ts +8 -1
- package/src/responses/xai-responses-language-model.ts +8 -5
- package/src/xai-chat-language-model.ts +1 -1
- package/src/xai-chat-prompt.ts +4 -1
- package/src/xai-file-part-options.ts +21 -0
package/dist/index.mjs
CHANGED
|
@@ -18,18 +18,37 @@ import {
|
|
|
18
18
|
createEventSourceResponseHandler,
|
|
19
19
|
createJsonResponseHandler,
|
|
20
20
|
extractResponseHeaders,
|
|
21
|
-
parseProviderOptions,
|
|
21
|
+
parseProviderOptions as parseProviderOptions2,
|
|
22
22
|
postJsonToApi,
|
|
23
23
|
safeParseJSON
|
|
24
24
|
} from "@ai-sdk/provider-utils";
|
|
25
|
-
import { z as
|
|
25
|
+
import { z as z4 } from "zod/v4";
|
|
26
26
|
|
|
27
27
|
// src/convert-to-xai-chat-messages.ts
|
|
28
28
|
import {
|
|
29
29
|
UnsupportedFunctionalityError
|
|
30
30
|
} from "@ai-sdk/provider";
|
|
31
|
-
import { convertToBase64 } from "@ai-sdk/provider-utils";
|
|
32
|
-
|
|
31
|
+
import { convertToBase64, parseProviderOptions } from "@ai-sdk/provider-utils";
|
|
32
|
+
|
|
33
|
+
// src/xai-file-part-options.ts
|
|
34
|
+
import { z } from "zod/v4";
|
|
35
|
+
var xaiFilePartProviderOptions = z.object({
|
|
36
|
+
/**
|
|
37
|
+
* Controls the resolution at which the model processes the image.
|
|
38
|
+
* `low` processes the image at reduced resolution and consumes fewer
|
|
39
|
+
* input tokens, `high` processes the image at full resolution, and
|
|
40
|
+
* `auto` lets the API decide. Defaults to full resolution when not set.
|
|
41
|
+
*
|
|
42
|
+
* Note: the xAI API silently ignores invalid values, so the value is
|
|
43
|
+
* validated client-side.
|
|
44
|
+
*
|
|
45
|
+
* @see https://docs.x.ai/developers/model-capabilities/images/understanding
|
|
46
|
+
*/
|
|
47
|
+
imageDetail: z.enum(["low", "high", "auto"]).optional()
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// src/convert-to-xai-chat-messages.ts
|
|
51
|
+
async function convertToXaiChatMessages(prompt) {
|
|
33
52
|
var _a;
|
|
34
53
|
const messages = [];
|
|
35
54
|
const warnings = [];
|
|
@@ -44,31 +63,40 @@ function convertToXaiChatMessages(prompt) {
|
|
|
44
63
|
messages.push({ role: "user", content: content[0].text });
|
|
45
64
|
break;
|
|
46
65
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
66
|
+
const userContent = [];
|
|
67
|
+
for (const part of content) {
|
|
68
|
+
switch (part.type) {
|
|
69
|
+
case "text": {
|
|
70
|
+
userContent.push({ type: "text", text: part.text });
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case "file": {
|
|
74
|
+
if (part.mediaType.startsWith("image/")) {
|
|
75
|
+
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
76
|
+
const filePartOptions = await parseProviderOptions({
|
|
77
|
+
provider: "xai",
|
|
78
|
+
providerOptions: part.providerOptions,
|
|
79
|
+
schema: xaiFilePartProviderOptions
|
|
80
|
+
});
|
|
81
|
+
userContent.push({
|
|
82
|
+
type: "image_url",
|
|
83
|
+
image_url: {
|
|
84
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`,
|
|
85
|
+
...(filePartOptions == null ? void 0 : filePartOptions.imageDetail) != null && {
|
|
86
|
+
detail: filePartOptions.imageDetail
|
|
61
87
|
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
throw new UnsupportedFunctionalityError({
|
|
92
|
+
functionality: `file part media type ${part.mediaType}`
|
|
93
|
+
});
|
|
68
94
|
}
|
|
95
|
+
break;
|
|
69
96
|
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
messages.push({ role: "user", content: userContent });
|
|
72
100
|
break;
|
|
73
101
|
}
|
|
74
102
|
case "assistant": {
|
|
@@ -113,7 +141,7 @@ function convertToXaiChatMessages(prompt) {
|
|
|
113
141
|
contentValue = output.value;
|
|
114
142
|
break;
|
|
115
143
|
case "execution-denied":
|
|
116
|
-
contentValue = (_a = output.reason) != null ? _a : "Tool execution denied.";
|
|
144
|
+
contentValue = (_a = output.reason) != null ? _a : "Tool call execution denied.";
|
|
117
145
|
break;
|
|
118
146
|
case "content":
|
|
119
147
|
case "json":
|
|
@@ -193,53 +221,53 @@ function mapXaiFinishReason(finishReason) {
|
|
|
193
221
|
}
|
|
194
222
|
|
|
195
223
|
// src/xai-chat-options.ts
|
|
196
|
-
import { z } from "zod/v4";
|
|
197
|
-
var webSourceSchema =
|
|
198
|
-
type:
|
|
199
|
-
country:
|
|
200
|
-
excludedWebsites:
|
|
201
|
-
allowedWebsites:
|
|
202
|
-
safeSearch:
|
|
224
|
+
import { z as z2 } from "zod/v4";
|
|
225
|
+
var webSourceSchema = z2.object({
|
|
226
|
+
type: z2.literal("web"),
|
|
227
|
+
country: z2.string().length(2).optional(),
|
|
228
|
+
excludedWebsites: z2.array(z2.string()).max(5).optional(),
|
|
229
|
+
allowedWebsites: z2.array(z2.string()).max(5).optional(),
|
|
230
|
+
safeSearch: z2.boolean().optional()
|
|
203
231
|
});
|
|
204
|
-
var xSourceSchema =
|
|
205
|
-
type:
|
|
206
|
-
excludedXHandles:
|
|
207
|
-
includedXHandles:
|
|
208
|
-
postFavoriteCount:
|
|
209
|
-
postViewCount:
|
|
232
|
+
var xSourceSchema = z2.object({
|
|
233
|
+
type: z2.literal("x"),
|
|
234
|
+
excludedXHandles: z2.array(z2.string()).optional(),
|
|
235
|
+
includedXHandles: z2.array(z2.string()).optional(),
|
|
236
|
+
postFavoriteCount: z2.number().int().optional(),
|
|
237
|
+
postViewCount: z2.number().int().optional(),
|
|
210
238
|
/**
|
|
211
239
|
* @deprecated use `includedXHandles` instead
|
|
212
240
|
*/
|
|
213
|
-
xHandles:
|
|
241
|
+
xHandles: z2.array(z2.string()).optional()
|
|
214
242
|
});
|
|
215
|
-
var newsSourceSchema =
|
|
216
|
-
type:
|
|
217
|
-
country:
|
|
218
|
-
excludedWebsites:
|
|
219
|
-
safeSearch:
|
|
243
|
+
var newsSourceSchema = z2.object({
|
|
244
|
+
type: z2.literal("news"),
|
|
245
|
+
country: z2.string().length(2).optional(),
|
|
246
|
+
excludedWebsites: z2.array(z2.string()).max(5).optional(),
|
|
247
|
+
safeSearch: z2.boolean().optional()
|
|
220
248
|
});
|
|
221
|
-
var rssSourceSchema =
|
|
222
|
-
type:
|
|
223
|
-
links:
|
|
249
|
+
var rssSourceSchema = z2.object({
|
|
250
|
+
type: z2.literal("rss"),
|
|
251
|
+
links: z2.array(z2.string().url()).max(1)
|
|
224
252
|
// currently only supports one RSS link
|
|
225
253
|
});
|
|
226
|
-
var searchSourceSchema =
|
|
254
|
+
var searchSourceSchema = z2.discriminatedUnion("type", [
|
|
227
255
|
webSourceSchema,
|
|
228
256
|
xSourceSchema,
|
|
229
257
|
newsSourceSchema,
|
|
230
258
|
rssSourceSchema
|
|
231
259
|
]);
|
|
232
|
-
var xaiLanguageModelChatOptions =
|
|
233
|
-
reasoningEffort:
|
|
234
|
-
logprobs:
|
|
235
|
-
topLogprobs:
|
|
260
|
+
var xaiLanguageModelChatOptions = z2.object({
|
|
261
|
+
reasoningEffort: z2.enum(["none", "low", "medium", "high"]).optional(),
|
|
262
|
+
logprobs: z2.boolean().optional(),
|
|
263
|
+
topLogprobs: z2.number().int().min(0).max(8).optional(),
|
|
236
264
|
/**
|
|
237
265
|
* Whether to enable parallel function calling during tool use.
|
|
238
266
|
* When true, the model can call multiple functions in parallel.
|
|
239
267
|
* When false, the model will call functions sequentially.
|
|
240
268
|
* Defaults to true.
|
|
241
269
|
*/
|
|
242
|
-
parallel_function_calling:
|
|
270
|
+
parallel_function_calling: z2.boolean().optional(),
|
|
243
271
|
/**
|
|
244
272
|
* @deprecated xAI has deprecated Live Search (`search_parameters`) in favor
|
|
245
273
|
* of the Agent Tools API. Requests using this option now return a "Live
|
|
@@ -249,32 +277,32 @@ var xaiLanguageModelChatOptions = z.object({
|
|
|
249
277
|
*
|
|
250
278
|
* @see https://docs.x.ai/docs/guides/tools/overview
|
|
251
279
|
*/
|
|
252
|
-
searchParameters:
|
|
280
|
+
searchParameters: z2.object({
|
|
253
281
|
/**
|
|
254
282
|
* search mode preference
|
|
255
283
|
* - "off": disables search completely
|
|
256
284
|
* - "auto": model decides whether to search (default)
|
|
257
285
|
* - "on": always enables search
|
|
258
286
|
*/
|
|
259
|
-
mode:
|
|
287
|
+
mode: z2.enum(["off", "auto", "on"]),
|
|
260
288
|
/**
|
|
261
289
|
* whether to return citations in the response
|
|
262
290
|
* defaults to true
|
|
263
291
|
*/
|
|
264
|
-
returnCitations:
|
|
292
|
+
returnCitations: z2.boolean().optional(),
|
|
265
293
|
/**
|
|
266
294
|
* start date for search data (ISO8601 format: YYYY-MM-DD)
|
|
267
295
|
*/
|
|
268
|
-
fromDate:
|
|
296
|
+
fromDate: z2.string().optional(),
|
|
269
297
|
/**
|
|
270
298
|
* end date for search data (ISO8601 format: YYYY-MM-DD)
|
|
271
299
|
*/
|
|
272
|
-
toDate:
|
|
300
|
+
toDate: z2.string().optional(),
|
|
273
301
|
/**
|
|
274
302
|
* maximum number of search results to consider
|
|
275
303
|
* defaults to 20
|
|
276
304
|
*/
|
|
277
|
-
maxSearchResults:
|
|
305
|
+
maxSearchResults: z2.number().min(1).max(50).optional(),
|
|
278
306
|
/**
|
|
279
307
|
* data sources to search from.
|
|
280
308
|
* defaults to [{ type: 'web' }, { type: 'x' }] if not specified.
|
|
@@ -282,26 +310,26 @@ var xaiLanguageModelChatOptions = z.object({
|
|
|
282
310
|
* @example
|
|
283
311
|
* sources: [{ type: 'web', country: 'US' }, { type: 'x' }]
|
|
284
312
|
*/
|
|
285
|
-
sources:
|
|
313
|
+
sources: z2.array(searchSourceSchema).optional()
|
|
286
314
|
}).optional()
|
|
287
315
|
});
|
|
288
316
|
|
|
289
317
|
// src/xai-error.ts
|
|
290
318
|
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
291
|
-
import { z as
|
|
292
|
-
var chatCompletionsErrorSchema =
|
|
293
|
-
error:
|
|
294
|
-
message:
|
|
295
|
-
type:
|
|
296
|
-
param:
|
|
297
|
-
code:
|
|
319
|
+
import { z as z3 } from "zod/v4";
|
|
320
|
+
var chatCompletionsErrorSchema = z3.object({
|
|
321
|
+
error: z3.object({
|
|
322
|
+
message: z3.string(),
|
|
323
|
+
type: z3.string().nullish(),
|
|
324
|
+
param: z3.any().nullish(),
|
|
325
|
+
code: z3.union([z3.string(), z3.number()]).nullish()
|
|
298
326
|
})
|
|
299
327
|
});
|
|
300
|
-
var responsesErrorSchema =
|
|
301
|
-
code:
|
|
302
|
-
error:
|
|
328
|
+
var responsesErrorSchema = z3.object({
|
|
329
|
+
code: z3.string(),
|
|
330
|
+
error: z3.string()
|
|
303
331
|
});
|
|
304
|
-
var xaiErrorDataSchema =
|
|
332
|
+
var xaiErrorDataSchema = z3.union([
|
|
305
333
|
chatCompletionsErrorSchema,
|
|
306
334
|
responsesErrorSchema
|
|
307
335
|
]);
|
|
@@ -420,7 +448,7 @@ var XaiChatLanguageModel = class {
|
|
|
420
448
|
}) {
|
|
421
449
|
var _a, _b, _c;
|
|
422
450
|
const warnings = [];
|
|
423
|
-
const options = (_a = await
|
|
451
|
+
const options = (_a = await parseProviderOptions2({
|
|
424
452
|
provider: "xai",
|
|
425
453
|
providerOptions,
|
|
426
454
|
schema: xaiLanguageModelChatOptions
|
|
@@ -437,7 +465,7 @@ var XaiChatLanguageModel = class {
|
|
|
437
465
|
if (stopSequences != null) {
|
|
438
466
|
warnings.push({ type: "unsupported", feature: "stopSequences" });
|
|
439
467
|
}
|
|
440
|
-
const { messages, warnings: messageWarnings } = convertToXaiChatMessages(prompt);
|
|
468
|
+
const { messages, warnings: messageWarnings } = await convertToXaiChatMessages(prompt);
|
|
441
469
|
warnings.push(...messageWarnings);
|
|
442
470
|
const {
|
|
443
471
|
tools: xaiTools2,
|
|
@@ -825,85 +853,85 @@ var XaiChatLanguageModel = class {
|
|
|
825
853
|
};
|
|
826
854
|
}
|
|
827
855
|
};
|
|
828
|
-
var xaiUsageSchema =
|
|
829
|
-
prompt_tokens:
|
|
830
|
-
completion_tokens:
|
|
831
|
-
total_tokens:
|
|
832
|
-
prompt_tokens_details:
|
|
833
|
-
text_tokens:
|
|
834
|
-
audio_tokens:
|
|
835
|
-
image_tokens:
|
|
836
|
-
cached_tokens:
|
|
856
|
+
var xaiUsageSchema = z4.object({
|
|
857
|
+
prompt_tokens: z4.number(),
|
|
858
|
+
completion_tokens: z4.number(),
|
|
859
|
+
total_tokens: z4.number(),
|
|
860
|
+
prompt_tokens_details: z4.object({
|
|
861
|
+
text_tokens: z4.number().nullish(),
|
|
862
|
+
audio_tokens: z4.number().nullish(),
|
|
863
|
+
image_tokens: z4.number().nullish(),
|
|
864
|
+
cached_tokens: z4.number().nullish()
|
|
837
865
|
}).nullish(),
|
|
838
|
-
completion_tokens_details:
|
|
839
|
-
reasoning_tokens:
|
|
840
|
-
audio_tokens:
|
|
841
|
-
accepted_prediction_tokens:
|
|
842
|
-
rejected_prediction_tokens:
|
|
866
|
+
completion_tokens_details: z4.object({
|
|
867
|
+
reasoning_tokens: z4.number().nullish(),
|
|
868
|
+
audio_tokens: z4.number().nullish(),
|
|
869
|
+
accepted_prediction_tokens: z4.number().nullish(),
|
|
870
|
+
rejected_prediction_tokens: z4.number().nullish()
|
|
843
871
|
}).nullish()
|
|
844
872
|
});
|
|
845
|
-
var xaiChatResponseSchema =
|
|
846
|
-
id:
|
|
847
|
-
created:
|
|
848
|
-
model:
|
|
849
|
-
choices:
|
|
850
|
-
|
|
851
|
-
message:
|
|
852
|
-
role:
|
|
853
|
-
content:
|
|
854
|
-
reasoning_content:
|
|
855
|
-
tool_calls:
|
|
856
|
-
|
|
857
|
-
id:
|
|
858
|
-
type:
|
|
859
|
-
function:
|
|
860
|
-
name:
|
|
861
|
-
arguments:
|
|
873
|
+
var xaiChatResponseSchema = z4.object({
|
|
874
|
+
id: z4.string().nullish(),
|
|
875
|
+
created: z4.number().nullish(),
|
|
876
|
+
model: z4.string().nullish(),
|
|
877
|
+
choices: z4.array(
|
|
878
|
+
z4.object({
|
|
879
|
+
message: z4.object({
|
|
880
|
+
role: z4.literal("assistant"),
|
|
881
|
+
content: z4.string().nullish(),
|
|
882
|
+
reasoning_content: z4.string().nullish(),
|
|
883
|
+
tool_calls: z4.array(
|
|
884
|
+
z4.object({
|
|
885
|
+
id: z4.string(),
|
|
886
|
+
type: z4.literal("function"),
|
|
887
|
+
function: z4.object({
|
|
888
|
+
name: z4.string(),
|
|
889
|
+
arguments: z4.string()
|
|
862
890
|
})
|
|
863
891
|
})
|
|
864
892
|
).nullish()
|
|
865
893
|
}),
|
|
866
|
-
index:
|
|
867
|
-
finish_reason:
|
|
894
|
+
index: z4.number(),
|
|
895
|
+
finish_reason: z4.string().nullish()
|
|
868
896
|
})
|
|
869
897
|
).nullish(),
|
|
870
|
-
object:
|
|
898
|
+
object: z4.literal("chat.completion").nullish(),
|
|
871
899
|
usage: xaiUsageSchema.nullish(),
|
|
872
|
-
citations:
|
|
873
|
-
code:
|
|
874
|
-
error:
|
|
900
|
+
citations: z4.array(z4.string().url()).nullish(),
|
|
901
|
+
code: z4.string().nullish(),
|
|
902
|
+
error: z4.string().nullish()
|
|
875
903
|
});
|
|
876
|
-
var xaiChatChunkSchema =
|
|
877
|
-
id:
|
|
878
|
-
created:
|
|
879
|
-
model:
|
|
880
|
-
choices:
|
|
881
|
-
|
|
882
|
-
delta:
|
|
883
|
-
role:
|
|
884
|
-
content:
|
|
885
|
-
reasoning_content:
|
|
886
|
-
tool_calls:
|
|
887
|
-
|
|
888
|
-
id:
|
|
889
|
-
type:
|
|
890
|
-
function:
|
|
891
|
-
name:
|
|
892
|
-
arguments:
|
|
904
|
+
var xaiChatChunkSchema = z4.object({
|
|
905
|
+
id: z4.string().nullish(),
|
|
906
|
+
created: z4.number().nullish(),
|
|
907
|
+
model: z4.string().nullish(),
|
|
908
|
+
choices: z4.array(
|
|
909
|
+
z4.object({
|
|
910
|
+
delta: z4.object({
|
|
911
|
+
role: z4.enum(["assistant"]).optional(),
|
|
912
|
+
content: z4.string().nullish(),
|
|
913
|
+
reasoning_content: z4.string().nullish(),
|
|
914
|
+
tool_calls: z4.array(
|
|
915
|
+
z4.object({
|
|
916
|
+
id: z4.string(),
|
|
917
|
+
type: z4.literal("function"),
|
|
918
|
+
function: z4.object({
|
|
919
|
+
name: z4.string(),
|
|
920
|
+
arguments: z4.string()
|
|
893
921
|
})
|
|
894
922
|
})
|
|
895
923
|
).nullish()
|
|
896
924
|
}),
|
|
897
|
-
finish_reason:
|
|
898
|
-
index:
|
|
925
|
+
finish_reason: z4.string().nullish(),
|
|
926
|
+
index: z4.number()
|
|
899
927
|
})
|
|
900
928
|
),
|
|
901
929
|
usage: xaiUsageSchema.nullish(),
|
|
902
|
-
citations:
|
|
930
|
+
citations: z4.array(z4.string().url()).nullish()
|
|
903
931
|
});
|
|
904
|
-
var xaiStreamErrorSchema =
|
|
905
|
-
code:
|
|
906
|
-
error:
|
|
932
|
+
var xaiStreamErrorSchema = z4.object({
|
|
933
|
+
code: z4.string(),
|
|
934
|
+
error: z4.string()
|
|
907
935
|
});
|
|
908
936
|
|
|
909
937
|
// src/xai-image-model.ts
|
|
@@ -914,20 +942,20 @@ import {
|
|
|
914
942
|
createJsonResponseHandler as createJsonResponseHandler2,
|
|
915
943
|
createStatusCodeErrorResponseHandler,
|
|
916
944
|
getFromApi,
|
|
917
|
-
parseProviderOptions as
|
|
945
|
+
parseProviderOptions as parseProviderOptions3,
|
|
918
946
|
postJsonToApi as postJsonToApi2
|
|
919
947
|
} from "@ai-sdk/provider-utils";
|
|
920
|
-
import { z as
|
|
948
|
+
import { z as z6 } from "zod/v4";
|
|
921
949
|
|
|
922
950
|
// src/xai-image-options.ts
|
|
923
|
-
import { z as
|
|
924
|
-
var xaiImageModelOptions =
|
|
925
|
-
aspect_ratio:
|
|
926
|
-
output_format:
|
|
927
|
-
sync_mode:
|
|
928
|
-
resolution:
|
|
929
|
-
quality:
|
|
930
|
-
user:
|
|
951
|
+
import { z as z5 } from "zod/v4";
|
|
952
|
+
var xaiImageModelOptions = z5.object({
|
|
953
|
+
aspect_ratio: z5.string().optional(),
|
|
954
|
+
output_format: z5.string().optional(),
|
|
955
|
+
sync_mode: z5.boolean().optional(),
|
|
956
|
+
resolution: z5.enum(["1k", "2k"]).optional(),
|
|
957
|
+
quality: z5.enum(["low", "medium", "high"]).optional(),
|
|
958
|
+
user: z5.string().optional()
|
|
931
959
|
});
|
|
932
960
|
|
|
933
961
|
// src/xai-image-model.ts
|
|
@@ -974,7 +1002,7 @@ var XaiImageModel = class {
|
|
|
974
1002
|
feature: "mask"
|
|
975
1003
|
});
|
|
976
1004
|
}
|
|
977
|
-
const xaiOptions = await
|
|
1005
|
+
const xaiOptions = await parseProviderOptions3({
|
|
978
1006
|
provider: "xai",
|
|
979
1007
|
providerOptions,
|
|
980
1008
|
schema: xaiImageModelOptions
|
|
@@ -1062,16 +1090,16 @@ var XaiImageModel = class {
|
|
|
1062
1090
|
return value;
|
|
1063
1091
|
}
|
|
1064
1092
|
};
|
|
1065
|
-
var xaiImageResponseSchema =
|
|
1066
|
-
data:
|
|
1067
|
-
|
|
1068
|
-
url:
|
|
1069
|
-
b64_json:
|
|
1070
|
-
revised_prompt:
|
|
1093
|
+
var xaiImageResponseSchema = z6.object({
|
|
1094
|
+
data: z6.array(
|
|
1095
|
+
z6.object({
|
|
1096
|
+
url: z6.string().nullish(),
|
|
1097
|
+
b64_json: z6.string().nullish(),
|
|
1098
|
+
revised_prompt: z6.string().nullish()
|
|
1071
1099
|
})
|
|
1072
1100
|
),
|
|
1073
|
-
usage:
|
|
1074
|
-
cost_in_usd_ticks:
|
|
1101
|
+
usage: z6.object({
|
|
1102
|
+
cost_in_usd_ticks: z6.number().nullish()
|
|
1075
1103
|
}).nullish()
|
|
1076
1104
|
});
|
|
1077
1105
|
|
|
@@ -1080,7 +1108,7 @@ import {
|
|
|
1080
1108
|
combineHeaders as combineHeaders3,
|
|
1081
1109
|
createEventSourceResponseHandler as createEventSourceResponseHandler2,
|
|
1082
1110
|
createJsonResponseHandler as createJsonResponseHandler3,
|
|
1083
|
-
parseProviderOptions as
|
|
1111
|
+
parseProviderOptions as parseProviderOptions5,
|
|
1084
1112
|
postJsonToApi as postJsonToApi3
|
|
1085
1113
|
} from "@ai-sdk/provider-utils";
|
|
1086
1114
|
|
|
@@ -1088,7 +1116,7 @@ import {
|
|
|
1088
1116
|
import {
|
|
1089
1117
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError3
|
|
1090
1118
|
} from "@ai-sdk/provider";
|
|
1091
|
-
import { convertToBase64 as convertToBase642 } from "@ai-sdk/provider-utils";
|
|
1119
|
+
import { convertToBase64 as convertToBase642, parseProviderOptions as parseProviderOptions4 } from "@ai-sdk/provider-utils";
|
|
1092
1120
|
async function convertToXaiResponsesInput({
|
|
1093
1121
|
prompt
|
|
1094
1122
|
}) {
|
|
@@ -1116,7 +1144,18 @@ async function convertToXaiResponsesInput({
|
|
|
1116
1144
|
if (block.mediaType.startsWith("image/")) {
|
|
1117
1145
|
const mediaType = block.mediaType === "image/*" ? "image/jpeg" : block.mediaType;
|
|
1118
1146
|
const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${convertToBase642(block.data)}`;
|
|
1119
|
-
|
|
1147
|
+
const filePartOptions = await parseProviderOptions4({
|
|
1148
|
+
provider: "xai",
|
|
1149
|
+
providerOptions: block.providerOptions,
|
|
1150
|
+
schema: xaiFilePartProviderOptions
|
|
1151
|
+
});
|
|
1152
|
+
contentParts.push({
|
|
1153
|
+
type: "input_image",
|
|
1154
|
+
image_url: imageUrl,
|
|
1155
|
+
...(filePartOptions == null ? void 0 : filePartOptions.imageDetail) != null && {
|
|
1156
|
+
detail: filePartOptions.imageDetail
|
|
1157
|
+
}
|
|
1158
|
+
});
|
|
1120
1159
|
} else if (block.data instanceof URL) {
|
|
1121
1160
|
contentParts.push({
|
|
1122
1161
|
type: "input_file",
|
|
@@ -1314,460 +1353,461 @@ function mapXaiResponsesFinishReason(finishReason) {
|
|
|
1314
1353
|
}
|
|
1315
1354
|
|
|
1316
1355
|
// src/responses/xai-responses-api.ts
|
|
1317
|
-
import { z as
|
|
1318
|
-
var annotationSchema =
|
|
1319
|
-
|
|
1320
|
-
type:
|
|
1321
|
-
url:
|
|
1322
|
-
title:
|
|
1356
|
+
import { z as z7 } from "zod/v4";
|
|
1357
|
+
var annotationSchema = z7.union([
|
|
1358
|
+
z7.object({
|
|
1359
|
+
type: z7.literal("url_citation"),
|
|
1360
|
+
url: z7.string(),
|
|
1361
|
+
title: z7.string().optional()
|
|
1323
1362
|
}),
|
|
1324
|
-
|
|
1325
|
-
type:
|
|
1363
|
+
z7.object({
|
|
1364
|
+
type: z7.string()
|
|
1326
1365
|
})
|
|
1327
1366
|
]);
|
|
1328
|
-
var messageContentPartSchema =
|
|
1329
|
-
type:
|
|
1330
|
-
text:
|
|
1331
|
-
logprobs:
|
|
1332
|
-
annotations:
|
|
1367
|
+
var messageContentPartSchema = z7.object({
|
|
1368
|
+
type: z7.string(),
|
|
1369
|
+
text: z7.string().optional(),
|
|
1370
|
+
logprobs: z7.array(z7.any()).optional(),
|
|
1371
|
+
annotations: z7.array(annotationSchema).optional()
|
|
1333
1372
|
});
|
|
1334
|
-
var reasoningSummaryPartSchema =
|
|
1335
|
-
type:
|
|
1336
|
-
text:
|
|
1373
|
+
var reasoningSummaryPartSchema = z7.object({
|
|
1374
|
+
type: z7.string(),
|
|
1375
|
+
text: z7.string()
|
|
1337
1376
|
});
|
|
1338
|
-
var toolCallSchema =
|
|
1339
|
-
name:
|
|
1340
|
-
arguments:
|
|
1341
|
-
input:
|
|
1342
|
-
call_id:
|
|
1343
|
-
id:
|
|
1344
|
-
status:
|
|
1345
|
-
action:
|
|
1377
|
+
var toolCallSchema = z7.object({
|
|
1378
|
+
name: z7.string().optional(),
|
|
1379
|
+
arguments: z7.string().optional(),
|
|
1380
|
+
input: z7.string().optional(),
|
|
1381
|
+
call_id: z7.string().optional(),
|
|
1382
|
+
id: z7.string(),
|
|
1383
|
+
status: z7.string(),
|
|
1384
|
+
action: z7.any().optional()
|
|
1346
1385
|
});
|
|
1347
|
-
var mcpCallSchema =
|
|
1348
|
-
name:
|
|
1349
|
-
arguments:
|
|
1350
|
-
output:
|
|
1351
|
-
error:
|
|
1352
|
-
id:
|
|
1353
|
-
status:
|
|
1354
|
-
server_label:
|
|
1386
|
+
var mcpCallSchema = z7.object({
|
|
1387
|
+
name: z7.string().optional(),
|
|
1388
|
+
arguments: z7.string().optional(),
|
|
1389
|
+
output: z7.string().optional(),
|
|
1390
|
+
error: z7.string().optional(),
|
|
1391
|
+
id: z7.string(),
|
|
1392
|
+
status: z7.string(),
|
|
1393
|
+
server_label: z7.string().optional()
|
|
1355
1394
|
});
|
|
1356
|
-
var outputItemSchema =
|
|
1357
|
-
|
|
1358
|
-
type:
|
|
1395
|
+
var outputItemSchema = z7.discriminatedUnion("type", [
|
|
1396
|
+
z7.object({
|
|
1397
|
+
type: z7.literal("web_search_call"),
|
|
1359
1398
|
...toolCallSchema.shape
|
|
1360
1399
|
}),
|
|
1361
|
-
|
|
1362
|
-
type:
|
|
1400
|
+
z7.object({
|
|
1401
|
+
type: z7.literal("x_search_call"),
|
|
1363
1402
|
...toolCallSchema.shape
|
|
1364
1403
|
}),
|
|
1365
|
-
|
|
1366
|
-
type:
|
|
1404
|
+
z7.object({
|
|
1405
|
+
type: z7.literal("code_interpreter_call"),
|
|
1367
1406
|
...toolCallSchema.shape
|
|
1368
1407
|
}),
|
|
1369
|
-
|
|
1370
|
-
type:
|
|
1408
|
+
z7.object({
|
|
1409
|
+
type: z7.literal("code_execution_call"),
|
|
1371
1410
|
...toolCallSchema.shape
|
|
1372
1411
|
}),
|
|
1373
|
-
|
|
1374
|
-
type:
|
|
1412
|
+
z7.object({
|
|
1413
|
+
type: z7.literal("view_image_call"),
|
|
1375
1414
|
...toolCallSchema.shape
|
|
1376
1415
|
}),
|
|
1377
|
-
|
|
1378
|
-
type:
|
|
1416
|
+
z7.object({
|
|
1417
|
+
type: z7.literal("view_x_video_call"),
|
|
1379
1418
|
...toolCallSchema.shape
|
|
1380
1419
|
}),
|
|
1381
|
-
|
|
1382
|
-
type:
|
|
1383
|
-
id:
|
|
1384
|
-
status:
|
|
1385
|
-
queries:
|
|
1386
|
-
results:
|
|
1387
|
-
|
|
1388
|
-
file_id:
|
|
1389
|
-
filename:
|
|
1390
|
-
score:
|
|
1391
|
-
text:
|
|
1420
|
+
z7.object({
|
|
1421
|
+
type: z7.literal("file_search_call"),
|
|
1422
|
+
id: z7.string(),
|
|
1423
|
+
status: z7.string(),
|
|
1424
|
+
queries: z7.array(z7.string()).optional(),
|
|
1425
|
+
results: z7.array(
|
|
1426
|
+
z7.object({
|
|
1427
|
+
file_id: z7.string(),
|
|
1428
|
+
filename: z7.string(),
|
|
1429
|
+
score: z7.number(),
|
|
1430
|
+
text: z7.string()
|
|
1392
1431
|
})
|
|
1393
1432
|
).nullish()
|
|
1394
1433
|
}),
|
|
1395
|
-
|
|
1396
|
-
type:
|
|
1434
|
+
z7.object({
|
|
1435
|
+
type: z7.literal("custom_tool_call"),
|
|
1397
1436
|
...toolCallSchema.shape
|
|
1398
1437
|
}),
|
|
1399
|
-
|
|
1400
|
-
type:
|
|
1438
|
+
z7.object({
|
|
1439
|
+
type: z7.literal("mcp_call"),
|
|
1401
1440
|
...mcpCallSchema.shape
|
|
1402
1441
|
}),
|
|
1403
|
-
|
|
1404
|
-
type:
|
|
1405
|
-
role:
|
|
1406
|
-
content:
|
|
1407
|
-
id:
|
|
1408
|
-
status:
|
|
1442
|
+
z7.object({
|
|
1443
|
+
type: z7.literal("message"),
|
|
1444
|
+
role: z7.string(),
|
|
1445
|
+
content: z7.array(messageContentPartSchema),
|
|
1446
|
+
id: z7.string(),
|
|
1447
|
+
status: z7.string()
|
|
1409
1448
|
}),
|
|
1410
|
-
|
|
1411
|
-
type:
|
|
1412
|
-
name:
|
|
1413
|
-
arguments:
|
|
1414
|
-
call_id:
|
|
1415
|
-
id:
|
|
1449
|
+
z7.object({
|
|
1450
|
+
type: z7.literal("function_call"),
|
|
1451
|
+
name: z7.string(),
|
|
1452
|
+
arguments: z7.string(),
|
|
1453
|
+
call_id: z7.string(),
|
|
1454
|
+
id: z7.string()
|
|
1416
1455
|
}),
|
|
1417
|
-
|
|
1418
|
-
type:
|
|
1419
|
-
id:
|
|
1420
|
-
summary:
|
|
1421
|
-
|
|
1422
|
-
|
|
1456
|
+
z7.object({
|
|
1457
|
+
type: z7.literal("reasoning"),
|
|
1458
|
+
id: z7.string(),
|
|
1459
|
+
summary: z7.array(reasoningSummaryPartSchema),
|
|
1460
|
+
content: z7.array(z7.object({ type: z7.string(), text: z7.string() })).nullish(),
|
|
1461
|
+
status: z7.string(),
|
|
1462
|
+
encrypted_content: z7.string().nullish()
|
|
1423
1463
|
})
|
|
1424
1464
|
]);
|
|
1425
|
-
var xaiResponsesUsageSchema =
|
|
1426
|
-
input_tokens:
|
|
1427
|
-
output_tokens:
|
|
1428
|
-
total_tokens:
|
|
1429
|
-
input_tokens_details:
|
|
1430
|
-
cached_tokens:
|
|
1465
|
+
var xaiResponsesUsageSchema = z7.object({
|
|
1466
|
+
input_tokens: z7.number(),
|
|
1467
|
+
output_tokens: z7.number(),
|
|
1468
|
+
total_tokens: z7.number().optional(),
|
|
1469
|
+
input_tokens_details: z7.object({
|
|
1470
|
+
cached_tokens: z7.number().optional()
|
|
1431
1471
|
}).optional(),
|
|
1432
|
-
output_tokens_details:
|
|
1433
|
-
reasoning_tokens:
|
|
1472
|
+
output_tokens_details: z7.object({
|
|
1473
|
+
reasoning_tokens: z7.number().optional()
|
|
1434
1474
|
}).optional(),
|
|
1435
|
-
num_sources_used:
|
|
1436
|
-
num_server_side_tools_used:
|
|
1475
|
+
num_sources_used: z7.number().optional(),
|
|
1476
|
+
num_server_side_tools_used: z7.number().optional()
|
|
1437
1477
|
});
|
|
1438
|
-
var xaiResponsesResponseSchema =
|
|
1439
|
-
id:
|
|
1440
|
-
created_at:
|
|
1441
|
-
model:
|
|
1442
|
-
object:
|
|
1443
|
-
output:
|
|
1478
|
+
var xaiResponsesResponseSchema = z7.object({
|
|
1479
|
+
id: z7.string().nullish(),
|
|
1480
|
+
created_at: z7.number().nullish(),
|
|
1481
|
+
model: z7.string().nullish(),
|
|
1482
|
+
object: z7.literal("response"),
|
|
1483
|
+
output: z7.array(outputItemSchema),
|
|
1444
1484
|
usage: xaiResponsesUsageSchema.nullish(),
|
|
1445
|
-
status:
|
|
1485
|
+
status: z7.string()
|
|
1446
1486
|
});
|
|
1447
|
-
var xaiResponsesChunkSchema =
|
|
1448
|
-
|
|
1449
|
-
type:
|
|
1487
|
+
var xaiResponsesChunkSchema = z7.union([
|
|
1488
|
+
z7.object({
|
|
1489
|
+
type: z7.literal("response.created"),
|
|
1450
1490
|
response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
|
|
1451
1491
|
}),
|
|
1452
|
-
|
|
1453
|
-
type:
|
|
1492
|
+
z7.object({
|
|
1493
|
+
type: z7.literal("response.in_progress"),
|
|
1454
1494
|
response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
|
|
1455
1495
|
}),
|
|
1456
|
-
|
|
1457
|
-
type:
|
|
1496
|
+
z7.object({
|
|
1497
|
+
type: z7.literal("response.output_item.added"),
|
|
1458
1498
|
item: outputItemSchema,
|
|
1459
|
-
output_index:
|
|
1499
|
+
output_index: z7.number()
|
|
1460
1500
|
}),
|
|
1461
|
-
|
|
1462
|
-
type:
|
|
1501
|
+
z7.object({
|
|
1502
|
+
type: z7.literal("response.output_item.done"),
|
|
1463
1503
|
item: outputItemSchema,
|
|
1464
|
-
output_index:
|
|
1504
|
+
output_index: z7.number()
|
|
1465
1505
|
}),
|
|
1466
|
-
|
|
1467
|
-
type:
|
|
1468
|
-
item_id:
|
|
1469
|
-
output_index:
|
|
1470
|
-
content_index:
|
|
1506
|
+
z7.object({
|
|
1507
|
+
type: z7.literal("response.content_part.added"),
|
|
1508
|
+
item_id: z7.string(),
|
|
1509
|
+
output_index: z7.number(),
|
|
1510
|
+
content_index: z7.number(),
|
|
1471
1511
|
part: messageContentPartSchema
|
|
1472
1512
|
}),
|
|
1473
|
-
|
|
1474
|
-
type:
|
|
1475
|
-
item_id:
|
|
1476
|
-
output_index:
|
|
1477
|
-
content_index:
|
|
1513
|
+
z7.object({
|
|
1514
|
+
type: z7.literal("response.content_part.done"),
|
|
1515
|
+
item_id: z7.string(),
|
|
1516
|
+
output_index: z7.number(),
|
|
1517
|
+
content_index: z7.number(),
|
|
1478
1518
|
part: messageContentPartSchema
|
|
1479
1519
|
}),
|
|
1480
|
-
|
|
1481
|
-
type:
|
|
1482
|
-
item_id:
|
|
1483
|
-
output_index:
|
|
1484
|
-
content_index:
|
|
1485
|
-
delta:
|
|
1486
|
-
logprobs:
|
|
1520
|
+
z7.object({
|
|
1521
|
+
type: z7.literal("response.output_text.delta"),
|
|
1522
|
+
item_id: z7.string(),
|
|
1523
|
+
output_index: z7.number(),
|
|
1524
|
+
content_index: z7.number(),
|
|
1525
|
+
delta: z7.string(),
|
|
1526
|
+
logprobs: z7.array(z7.any()).optional()
|
|
1487
1527
|
}),
|
|
1488
|
-
|
|
1489
|
-
type:
|
|
1490
|
-
item_id:
|
|
1491
|
-
output_index:
|
|
1492
|
-
content_index:
|
|
1493
|
-
text:
|
|
1494
|
-
logprobs:
|
|
1495
|
-
annotations:
|
|
1528
|
+
z7.object({
|
|
1529
|
+
type: z7.literal("response.output_text.done"),
|
|
1530
|
+
item_id: z7.string(),
|
|
1531
|
+
output_index: z7.number(),
|
|
1532
|
+
content_index: z7.number(),
|
|
1533
|
+
text: z7.string(),
|
|
1534
|
+
logprobs: z7.array(z7.any()).optional(),
|
|
1535
|
+
annotations: z7.array(annotationSchema).optional()
|
|
1496
1536
|
}),
|
|
1497
|
-
|
|
1498
|
-
type:
|
|
1499
|
-
item_id:
|
|
1500
|
-
output_index:
|
|
1501
|
-
content_index:
|
|
1502
|
-
annotation_index:
|
|
1537
|
+
z7.object({
|
|
1538
|
+
type: z7.literal("response.output_text.annotation.added"),
|
|
1539
|
+
item_id: z7.string(),
|
|
1540
|
+
output_index: z7.number(),
|
|
1541
|
+
content_index: z7.number(),
|
|
1542
|
+
annotation_index: z7.number(),
|
|
1503
1543
|
annotation: annotationSchema
|
|
1504
1544
|
}),
|
|
1505
|
-
|
|
1506
|
-
type:
|
|
1507
|
-
item_id:
|
|
1508
|
-
output_index:
|
|
1509
|
-
summary_index:
|
|
1545
|
+
z7.object({
|
|
1546
|
+
type: z7.literal("response.reasoning_summary_part.added"),
|
|
1547
|
+
item_id: z7.string(),
|
|
1548
|
+
output_index: z7.number(),
|
|
1549
|
+
summary_index: z7.number(),
|
|
1510
1550
|
part: reasoningSummaryPartSchema
|
|
1511
1551
|
}),
|
|
1512
|
-
|
|
1513
|
-
type:
|
|
1514
|
-
item_id:
|
|
1515
|
-
output_index:
|
|
1516
|
-
summary_index:
|
|
1552
|
+
z7.object({
|
|
1553
|
+
type: z7.literal("response.reasoning_summary_part.done"),
|
|
1554
|
+
item_id: z7.string(),
|
|
1555
|
+
output_index: z7.number(),
|
|
1556
|
+
summary_index: z7.number(),
|
|
1517
1557
|
part: reasoningSummaryPartSchema
|
|
1518
1558
|
}),
|
|
1519
|
-
|
|
1520
|
-
type:
|
|
1521
|
-
item_id:
|
|
1522
|
-
output_index:
|
|
1523
|
-
summary_index:
|
|
1524
|
-
delta:
|
|
1559
|
+
z7.object({
|
|
1560
|
+
type: z7.literal("response.reasoning_summary_text.delta"),
|
|
1561
|
+
item_id: z7.string(),
|
|
1562
|
+
output_index: z7.number(),
|
|
1563
|
+
summary_index: z7.number(),
|
|
1564
|
+
delta: z7.string()
|
|
1525
1565
|
}),
|
|
1526
|
-
|
|
1527
|
-
type:
|
|
1528
|
-
item_id:
|
|
1529
|
-
output_index:
|
|
1530
|
-
summary_index:
|
|
1531
|
-
text:
|
|
1566
|
+
z7.object({
|
|
1567
|
+
type: z7.literal("response.reasoning_summary_text.done"),
|
|
1568
|
+
item_id: z7.string(),
|
|
1569
|
+
output_index: z7.number(),
|
|
1570
|
+
summary_index: z7.number(),
|
|
1571
|
+
text: z7.string()
|
|
1532
1572
|
}),
|
|
1533
|
-
|
|
1534
|
-
type:
|
|
1535
|
-
item_id:
|
|
1536
|
-
output_index:
|
|
1537
|
-
content_index:
|
|
1538
|
-
delta:
|
|
1573
|
+
z7.object({
|
|
1574
|
+
type: z7.literal("response.reasoning_text.delta"),
|
|
1575
|
+
item_id: z7.string(),
|
|
1576
|
+
output_index: z7.number(),
|
|
1577
|
+
content_index: z7.number(),
|
|
1578
|
+
delta: z7.string()
|
|
1539
1579
|
}),
|
|
1540
|
-
|
|
1541
|
-
type:
|
|
1542
|
-
item_id:
|
|
1543
|
-
output_index:
|
|
1544
|
-
content_index:
|
|
1545
|
-
text:
|
|
1580
|
+
z7.object({
|
|
1581
|
+
type: z7.literal("response.reasoning_text.done"),
|
|
1582
|
+
item_id: z7.string(),
|
|
1583
|
+
output_index: z7.number(),
|
|
1584
|
+
content_index: z7.number(),
|
|
1585
|
+
text: z7.string()
|
|
1546
1586
|
}),
|
|
1547
|
-
|
|
1548
|
-
type:
|
|
1549
|
-
item_id:
|
|
1550
|
-
output_index:
|
|
1587
|
+
z7.object({
|
|
1588
|
+
type: z7.literal("response.web_search_call.in_progress"),
|
|
1589
|
+
item_id: z7.string(),
|
|
1590
|
+
output_index: z7.number()
|
|
1551
1591
|
}),
|
|
1552
|
-
|
|
1553
|
-
type:
|
|
1554
|
-
item_id:
|
|
1555
|
-
output_index:
|
|
1592
|
+
z7.object({
|
|
1593
|
+
type: z7.literal("response.web_search_call.searching"),
|
|
1594
|
+
item_id: z7.string(),
|
|
1595
|
+
output_index: z7.number()
|
|
1556
1596
|
}),
|
|
1557
|
-
|
|
1558
|
-
type:
|
|
1559
|
-
item_id:
|
|
1560
|
-
output_index:
|
|
1597
|
+
z7.object({
|
|
1598
|
+
type: z7.literal("response.web_search_call.completed"),
|
|
1599
|
+
item_id: z7.string(),
|
|
1600
|
+
output_index: z7.number()
|
|
1561
1601
|
}),
|
|
1562
|
-
|
|
1563
|
-
type:
|
|
1564
|
-
item_id:
|
|
1565
|
-
output_index:
|
|
1602
|
+
z7.object({
|
|
1603
|
+
type: z7.literal("response.x_search_call.in_progress"),
|
|
1604
|
+
item_id: z7.string(),
|
|
1605
|
+
output_index: z7.number()
|
|
1566
1606
|
}),
|
|
1567
|
-
|
|
1568
|
-
type:
|
|
1569
|
-
item_id:
|
|
1570
|
-
output_index:
|
|
1607
|
+
z7.object({
|
|
1608
|
+
type: z7.literal("response.x_search_call.searching"),
|
|
1609
|
+
item_id: z7.string(),
|
|
1610
|
+
output_index: z7.number()
|
|
1571
1611
|
}),
|
|
1572
|
-
|
|
1573
|
-
type:
|
|
1574
|
-
item_id:
|
|
1575
|
-
output_index:
|
|
1612
|
+
z7.object({
|
|
1613
|
+
type: z7.literal("response.x_search_call.completed"),
|
|
1614
|
+
item_id: z7.string(),
|
|
1615
|
+
output_index: z7.number()
|
|
1576
1616
|
}),
|
|
1577
|
-
|
|
1578
|
-
type:
|
|
1579
|
-
item_id:
|
|
1580
|
-
output_index:
|
|
1617
|
+
z7.object({
|
|
1618
|
+
type: z7.literal("response.file_search_call.in_progress"),
|
|
1619
|
+
item_id: z7.string(),
|
|
1620
|
+
output_index: z7.number()
|
|
1581
1621
|
}),
|
|
1582
|
-
|
|
1583
|
-
type:
|
|
1584
|
-
item_id:
|
|
1585
|
-
output_index:
|
|
1622
|
+
z7.object({
|
|
1623
|
+
type: z7.literal("response.file_search_call.searching"),
|
|
1624
|
+
item_id: z7.string(),
|
|
1625
|
+
output_index: z7.number()
|
|
1586
1626
|
}),
|
|
1587
|
-
|
|
1588
|
-
type:
|
|
1589
|
-
item_id:
|
|
1590
|
-
output_index:
|
|
1627
|
+
z7.object({
|
|
1628
|
+
type: z7.literal("response.file_search_call.completed"),
|
|
1629
|
+
item_id: z7.string(),
|
|
1630
|
+
output_index: z7.number()
|
|
1591
1631
|
}),
|
|
1592
|
-
|
|
1593
|
-
type:
|
|
1594
|
-
item_id:
|
|
1595
|
-
output_index:
|
|
1632
|
+
z7.object({
|
|
1633
|
+
type: z7.literal("response.code_execution_call.in_progress"),
|
|
1634
|
+
item_id: z7.string(),
|
|
1635
|
+
output_index: z7.number()
|
|
1596
1636
|
}),
|
|
1597
|
-
|
|
1598
|
-
type:
|
|
1599
|
-
item_id:
|
|
1600
|
-
output_index:
|
|
1637
|
+
z7.object({
|
|
1638
|
+
type: z7.literal("response.code_execution_call.executing"),
|
|
1639
|
+
item_id: z7.string(),
|
|
1640
|
+
output_index: z7.number()
|
|
1601
1641
|
}),
|
|
1602
|
-
|
|
1603
|
-
type:
|
|
1604
|
-
item_id:
|
|
1605
|
-
output_index:
|
|
1642
|
+
z7.object({
|
|
1643
|
+
type: z7.literal("response.code_execution_call.completed"),
|
|
1644
|
+
item_id: z7.string(),
|
|
1645
|
+
output_index: z7.number()
|
|
1606
1646
|
}),
|
|
1607
|
-
|
|
1608
|
-
type:
|
|
1609
|
-
item_id:
|
|
1610
|
-
output_index:
|
|
1647
|
+
z7.object({
|
|
1648
|
+
type: z7.literal("response.code_interpreter_call.in_progress"),
|
|
1649
|
+
item_id: z7.string(),
|
|
1650
|
+
output_index: z7.number()
|
|
1611
1651
|
}),
|
|
1612
|
-
|
|
1613
|
-
type:
|
|
1614
|
-
item_id:
|
|
1615
|
-
output_index:
|
|
1652
|
+
z7.object({
|
|
1653
|
+
type: z7.literal("response.code_interpreter_call.executing"),
|
|
1654
|
+
item_id: z7.string(),
|
|
1655
|
+
output_index: z7.number()
|
|
1616
1656
|
}),
|
|
1617
|
-
|
|
1618
|
-
type:
|
|
1619
|
-
item_id:
|
|
1620
|
-
output_index:
|
|
1657
|
+
z7.object({
|
|
1658
|
+
type: z7.literal("response.code_interpreter_call.interpreting"),
|
|
1659
|
+
item_id: z7.string(),
|
|
1660
|
+
output_index: z7.number()
|
|
1621
1661
|
}),
|
|
1622
|
-
|
|
1623
|
-
type:
|
|
1624
|
-
item_id:
|
|
1625
|
-
output_index:
|
|
1662
|
+
z7.object({
|
|
1663
|
+
type: z7.literal("response.code_interpreter_call.completed"),
|
|
1664
|
+
item_id: z7.string(),
|
|
1665
|
+
output_index: z7.number()
|
|
1626
1666
|
}),
|
|
1627
1667
|
// Code interpreter code streaming events
|
|
1628
|
-
|
|
1629
|
-
type:
|
|
1630
|
-
item_id:
|
|
1631
|
-
output_index:
|
|
1632
|
-
delta:
|
|
1668
|
+
z7.object({
|
|
1669
|
+
type: z7.literal("response.code_interpreter_call_code.delta"),
|
|
1670
|
+
item_id: z7.string(),
|
|
1671
|
+
output_index: z7.number(),
|
|
1672
|
+
delta: z7.string()
|
|
1633
1673
|
}),
|
|
1634
|
-
|
|
1635
|
-
type:
|
|
1636
|
-
item_id:
|
|
1637
|
-
output_index:
|
|
1638
|
-
code:
|
|
1674
|
+
z7.object({
|
|
1675
|
+
type: z7.literal("response.code_interpreter_call_code.done"),
|
|
1676
|
+
item_id: z7.string(),
|
|
1677
|
+
output_index: z7.number(),
|
|
1678
|
+
code: z7.string()
|
|
1639
1679
|
}),
|
|
1640
|
-
|
|
1641
|
-
type:
|
|
1642
|
-
item_id:
|
|
1643
|
-
output_index:
|
|
1644
|
-
delta:
|
|
1680
|
+
z7.object({
|
|
1681
|
+
type: z7.literal("response.custom_tool_call_input.delta"),
|
|
1682
|
+
item_id: z7.string(),
|
|
1683
|
+
output_index: z7.number(),
|
|
1684
|
+
delta: z7.string()
|
|
1645
1685
|
}),
|
|
1646
|
-
|
|
1647
|
-
type:
|
|
1648
|
-
item_id:
|
|
1649
|
-
output_index:
|
|
1650
|
-
input:
|
|
1686
|
+
z7.object({
|
|
1687
|
+
type: z7.literal("response.custom_tool_call_input.done"),
|
|
1688
|
+
item_id: z7.string(),
|
|
1689
|
+
output_index: z7.number(),
|
|
1690
|
+
input: z7.string()
|
|
1651
1691
|
}),
|
|
1652
1692
|
// Function call arguments streaming events (standard function tools)
|
|
1653
|
-
|
|
1654
|
-
type:
|
|
1655
|
-
item_id:
|
|
1656
|
-
output_index:
|
|
1657
|
-
delta:
|
|
1693
|
+
z7.object({
|
|
1694
|
+
type: z7.literal("response.function_call_arguments.delta"),
|
|
1695
|
+
item_id: z7.string(),
|
|
1696
|
+
output_index: z7.number(),
|
|
1697
|
+
delta: z7.string()
|
|
1658
1698
|
}),
|
|
1659
|
-
|
|
1660
|
-
type:
|
|
1661
|
-
item_id:
|
|
1662
|
-
output_index:
|
|
1663
|
-
arguments:
|
|
1699
|
+
z7.object({
|
|
1700
|
+
type: z7.literal("response.function_call_arguments.done"),
|
|
1701
|
+
item_id: z7.string(),
|
|
1702
|
+
output_index: z7.number(),
|
|
1703
|
+
arguments: z7.string()
|
|
1664
1704
|
}),
|
|
1665
|
-
|
|
1666
|
-
type:
|
|
1667
|
-
item_id:
|
|
1668
|
-
output_index:
|
|
1705
|
+
z7.object({
|
|
1706
|
+
type: z7.literal("response.mcp_call.in_progress"),
|
|
1707
|
+
item_id: z7.string(),
|
|
1708
|
+
output_index: z7.number()
|
|
1669
1709
|
}),
|
|
1670
|
-
|
|
1671
|
-
type:
|
|
1672
|
-
item_id:
|
|
1673
|
-
output_index:
|
|
1710
|
+
z7.object({
|
|
1711
|
+
type: z7.literal("response.mcp_call.executing"),
|
|
1712
|
+
item_id: z7.string(),
|
|
1713
|
+
output_index: z7.number()
|
|
1674
1714
|
}),
|
|
1675
|
-
|
|
1676
|
-
type:
|
|
1677
|
-
item_id:
|
|
1678
|
-
output_index:
|
|
1715
|
+
z7.object({
|
|
1716
|
+
type: z7.literal("response.mcp_call.completed"),
|
|
1717
|
+
item_id: z7.string(),
|
|
1718
|
+
output_index: z7.number()
|
|
1679
1719
|
}),
|
|
1680
|
-
|
|
1681
|
-
type:
|
|
1682
|
-
item_id:
|
|
1683
|
-
output_index:
|
|
1720
|
+
z7.object({
|
|
1721
|
+
type: z7.literal("response.mcp_call.failed"),
|
|
1722
|
+
item_id: z7.string(),
|
|
1723
|
+
output_index: z7.number()
|
|
1684
1724
|
}),
|
|
1685
|
-
|
|
1686
|
-
type:
|
|
1687
|
-
item_id:
|
|
1688
|
-
output_index:
|
|
1689
|
-
delta:
|
|
1725
|
+
z7.object({
|
|
1726
|
+
type: z7.literal("response.mcp_call_arguments.delta"),
|
|
1727
|
+
item_id: z7.string(),
|
|
1728
|
+
output_index: z7.number(),
|
|
1729
|
+
delta: z7.string()
|
|
1690
1730
|
}),
|
|
1691
|
-
|
|
1692
|
-
type:
|
|
1693
|
-
item_id:
|
|
1694
|
-
output_index:
|
|
1695
|
-
arguments:
|
|
1731
|
+
z7.object({
|
|
1732
|
+
type: z7.literal("response.mcp_call_arguments.done"),
|
|
1733
|
+
item_id: z7.string(),
|
|
1734
|
+
output_index: z7.number(),
|
|
1735
|
+
arguments: z7.string().optional()
|
|
1696
1736
|
}),
|
|
1697
|
-
|
|
1698
|
-
type:
|
|
1699
|
-
item_id:
|
|
1700
|
-
output_index:
|
|
1701
|
-
delta:
|
|
1737
|
+
z7.object({
|
|
1738
|
+
type: z7.literal("response.mcp_call_output.delta"),
|
|
1739
|
+
item_id: z7.string(),
|
|
1740
|
+
output_index: z7.number(),
|
|
1741
|
+
delta: z7.string()
|
|
1702
1742
|
}),
|
|
1703
|
-
|
|
1704
|
-
type:
|
|
1705
|
-
item_id:
|
|
1706
|
-
output_index:
|
|
1707
|
-
output:
|
|
1743
|
+
z7.object({
|
|
1744
|
+
type: z7.literal("response.mcp_call_output.done"),
|
|
1745
|
+
item_id: z7.string(),
|
|
1746
|
+
output_index: z7.number(),
|
|
1747
|
+
output: z7.string().optional()
|
|
1708
1748
|
}),
|
|
1709
|
-
|
|
1710
|
-
type:
|
|
1711
|
-
response:
|
|
1712
|
-
incomplete_details:
|
|
1749
|
+
z7.object({
|
|
1750
|
+
type: z7.literal("response.incomplete"),
|
|
1751
|
+
response: z7.object({
|
|
1752
|
+
incomplete_details: z7.object({ reason: z7.string() }).nullish(),
|
|
1713
1753
|
usage: xaiResponsesUsageSchema.nullish()
|
|
1714
1754
|
})
|
|
1715
1755
|
}),
|
|
1716
|
-
|
|
1717
|
-
type:
|
|
1718
|
-
response:
|
|
1719
|
-
error:
|
|
1720
|
-
code:
|
|
1721
|
-
message:
|
|
1756
|
+
z7.object({
|
|
1757
|
+
type: z7.literal("response.failed"),
|
|
1758
|
+
response: z7.object({
|
|
1759
|
+
error: z7.object({
|
|
1760
|
+
code: z7.string().nullish(),
|
|
1761
|
+
message: z7.string()
|
|
1722
1762
|
}).nullish(),
|
|
1723
|
-
incomplete_details:
|
|
1763
|
+
incomplete_details: z7.object({ reason: z7.string() }).nullish(),
|
|
1724
1764
|
usage: xaiResponsesUsageSchema.nullish()
|
|
1725
1765
|
})
|
|
1726
1766
|
}),
|
|
1727
|
-
|
|
1728
|
-
type:
|
|
1729
|
-
code:
|
|
1730
|
-
message:
|
|
1731
|
-
param:
|
|
1767
|
+
z7.object({
|
|
1768
|
+
type: z7.literal("error"),
|
|
1769
|
+
code: z7.string().nullish(),
|
|
1770
|
+
message: z7.string(),
|
|
1771
|
+
param: z7.string().nullish()
|
|
1732
1772
|
}),
|
|
1733
|
-
|
|
1734
|
-
type:
|
|
1773
|
+
z7.object({
|
|
1774
|
+
type: z7.literal("response.done"),
|
|
1735
1775
|
response: xaiResponsesResponseSchema
|
|
1736
1776
|
}),
|
|
1737
|
-
|
|
1738
|
-
type:
|
|
1777
|
+
z7.object({
|
|
1778
|
+
type: z7.literal("response.completed"),
|
|
1739
1779
|
response: xaiResponsesResponseSchema
|
|
1740
1780
|
})
|
|
1741
1781
|
]);
|
|
1742
1782
|
|
|
1743
1783
|
// src/responses/xai-responses-options.ts
|
|
1744
|
-
import { z as
|
|
1745
|
-
var xaiLanguageModelResponsesOptions =
|
|
1784
|
+
import { z as z8 } from "zod/v4";
|
|
1785
|
+
var xaiLanguageModelResponsesOptions = z8.object({
|
|
1746
1786
|
/**
|
|
1747
1787
|
* Constrains how hard a reasoning model thinks before responding.
|
|
1748
1788
|
* Possible values are `none` (disables reasoning), `low` (uses fewer reasoning
|
|
1749
1789
|
* tokens), `medium` and `high` (uses more reasoning tokens). Not all models
|
|
1750
1790
|
* support reasoning effort; see xAI's docs for the values each model accepts.
|
|
1751
1791
|
*/
|
|
1752
|
-
reasoningEffort:
|
|
1753
|
-
logprobs:
|
|
1754
|
-
topLogprobs:
|
|
1792
|
+
reasoningEffort: z8.enum(["none", "low", "medium", "high"]).optional(),
|
|
1793
|
+
logprobs: z8.boolean().optional(),
|
|
1794
|
+
topLogprobs: z8.number().int().min(0).max(8).optional(),
|
|
1755
1795
|
/**
|
|
1756
1796
|
* Whether to store the input message(s) and model response for later retrieval.
|
|
1757
1797
|
* Must be set to `false` for teams with Zero Data Retention (ZDR) enabled,
|
|
1758
1798
|
* otherwise the API will return an error.
|
|
1759
1799
|
* @default true
|
|
1760
1800
|
*/
|
|
1761
|
-
store:
|
|
1801
|
+
store: z8.boolean().optional(),
|
|
1762
1802
|
/**
|
|
1763
1803
|
* The ID of the previous response from the model.
|
|
1764
1804
|
*/
|
|
1765
|
-
previousResponseId:
|
|
1805
|
+
previousResponseId: z8.string().optional(),
|
|
1766
1806
|
/**
|
|
1767
1807
|
* Specify additional output data to include in the model response.
|
|
1768
1808
|
* Example values: 'file_search_call.results'.
|
|
1769
1809
|
*/
|
|
1770
|
-
include:
|
|
1810
|
+
include: z8.array(z8.enum(["file_search_call.results"])).nullish()
|
|
1771
1811
|
});
|
|
1772
1812
|
|
|
1773
1813
|
// src/responses/xai-responses-prepare-tools.ts
|
|
@@ -1782,25 +1822,25 @@ import {
|
|
|
1782
1822
|
lazySchema,
|
|
1783
1823
|
zodSchema
|
|
1784
1824
|
} from "@ai-sdk/provider-utils";
|
|
1785
|
-
import { z as
|
|
1825
|
+
import { z as z9 } from "zod/v4";
|
|
1786
1826
|
var fileSearchArgsSchema = lazySchema(
|
|
1787
1827
|
() => zodSchema(
|
|
1788
|
-
|
|
1789
|
-
vectorStoreIds:
|
|
1790
|
-
maxNumResults:
|
|
1828
|
+
z9.object({
|
|
1829
|
+
vectorStoreIds: z9.array(z9.string()),
|
|
1830
|
+
maxNumResults: z9.number().optional()
|
|
1791
1831
|
})
|
|
1792
1832
|
)
|
|
1793
1833
|
);
|
|
1794
1834
|
var fileSearchOutputSchema = lazySchema(
|
|
1795
1835
|
() => zodSchema(
|
|
1796
|
-
|
|
1797
|
-
queries:
|
|
1798
|
-
results:
|
|
1799
|
-
|
|
1800
|
-
fileId:
|
|
1801
|
-
filename:
|
|
1802
|
-
score:
|
|
1803
|
-
text:
|
|
1836
|
+
z9.object({
|
|
1837
|
+
queries: z9.array(z9.string()),
|
|
1838
|
+
results: z9.array(
|
|
1839
|
+
z9.object({
|
|
1840
|
+
fileId: z9.string(),
|
|
1841
|
+
filename: z9.string(),
|
|
1842
|
+
score: z9.number().min(0).max(1),
|
|
1843
|
+
text: z9.string()
|
|
1804
1844
|
})
|
|
1805
1845
|
).nullable()
|
|
1806
1846
|
})
|
|
@@ -1808,7 +1848,7 @@ var fileSearchOutputSchema = lazySchema(
|
|
|
1808
1848
|
);
|
|
1809
1849
|
var fileSearchToolFactory = createProviderToolFactoryWithOutputSchema({
|
|
1810
1850
|
id: "xai.file_search",
|
|
1811
|
-
inputSchema: lazySchema(() => zodSchema(
|
|
1851
|
+
inputSchema: lazySchema(() => zodSchema(z9.object({}))),
|
|
1812
1852
|
outputSchema: fileSearchOutputSchema
|
|
1813
1853
|
});
|
|
1814
1854
|
var fileSearch = (args) => fileSearchToolFactory(args);
|
|
@@ -1819,31 +1859,31 @@ import {
|
|
|
1819
1859
|
lazySchema as lazySchema2,
|
|
1820
1860
|
zodSchema as zodSchema2
|
|
1821
1861
|
} from "@ai-sdk/provider-utils";
|
|
1822
|
-
import { z as
|
|
1862
|
+
import { z as z10 } from "zod/v4";
|
|
1823
1863
|
var mcpServerArgsSchema = lazySchema2(
|
|
1824
1864
|
() => zodSchema2(
|
|
1825
|
-
|
|
1826
|
-
serverUrl:
|
|
1827
|
-
serverLabel:
|
|
1828
|
-
serverDescription:
|
|
1829
|
-
allowedTools:
|
|
1830
|
-
headers:
|
|
1831
|
-
authorization:
|
|
1865
|
+
z10.object({
|
|
1866
|
+
serverUrl: z10.string().describe("The URL of the MCP server"),
|
|
1867
|
+
serverLabel: z10.string().optional().describe("A label for the MCP server"),
|
|
1868
|
+
serverDescription: z10.string().optional().describe("Description of the MCP server"),
|
|
1869
|
+
allowedTools: z10.array(z10.string()).optional().describe("List of allowed tool names"),
|
|
1870
|
+
headers: z10.record(z10.string(), z10.string()).optional().describe("Custom headers to send"),
|
|
1871
|
+
authorization: z10.string().optional().describe("Authorization header value")
|
|
1832
1872
|
})
|
|
1833
1873
|
)
|
|
1834
1874
|
);
|
|
1835
1875
|
var mcpServerOutputSchema = lazySchema2(
|
|
1836
1876
|
() => zodSchema2(
|
|
1837
|
-
|
|
1838
|
-
name:
|
|
1839
|
-
arguments:
|
|
1840
|
-
result:
|
|
1877
|
+
z10.object({
|
|
1878
|
+
name: z10.string(),
|
|
1879
|
+
arguments: z10.string(),
|
|
1880
|
+
result: z10.unknown()
|
|
1841
1881
|
})
|
|
1842
1882
|
)
|
|
1843
1883
|
);
|
|
1844
1884
|
var mcpServerToolFactory = createProviderToolFactoryWithOutputSchema2({
|
|
1845
1885
|
id: "xai.mcp",
|
|
1846
|
-
inputSchema: lazySchema2(() => zodSchema2(
|
|
1886
|
+
inputSchema: lazySchema2(() => zodSchema2(z10.object({}))),
|
|
1847
1887
|
outputSchema: mcpServerOutputSchema
|
|
1848
1888
|
});
|
|
1849
1889
|
var mcpServer = (args) => mcpServerToolFactory(args);
|
|
@@ -1854,26 +1894,26 @@ import {
|
|
|
1854
1894
|
lazySchema as lazySchema3,
|
|
1855
1895
|
zodSchema as zodSchema3
|
|
1856
1896
|
} from "@ai-sdk/provider-utils";
|
|
1857
|
-
import { z as
|
|
1897
|
+
import { z as z11 } from "zod/v4";
|
|
1858
1898
|
var webSearchArgsSchema = lazySchema3(
|
|
1859
1899
|
() => zodSchema3(
|
|
1860
|
-
|
|
1861
|
-
allowedDomains:
|
|
1862
|
-
excludedDomains:
|
|
1863
|
-
enableImageSearch:
|
|
1864
|
-
enableImageUnderstanding:
|
|
1900
|
+
z11.object({
|
|
1901
|
+
allowedDomains: z11.array(z11.string()).max(5).optional(),
|
|
1902
|
+
excludedDomains: z11.array(z11.string()).max(5).optional(),
|
|
1903
|
+
enableImageSearch: z11.boolean().optional(),
|
|
1904
|
+
enableImageUnderstanding: z11.boolean().optional()
|
|
1865
1905
|
})
|
|
1866
1906
|
)
|
|
1867
1907
|
);
|
|
1868
1908
|
var webSearchOutputSchema = lazySchema3(
|
|
1869
1909
|
() => zodSchema3(
|
|
1870
|
-
|
|
1871
|
-
query:
|
|
1872
|
-
sources:
|
|
1873
|
-
|
|
1874
|
-
title:
|
|
1875
|
-
url:
|
|
1876
|
-
snippet:
|
|
1910
|
+
z11.object({
|
|
1911
|
+
query: z11.string(),
|
|
1912
|
+
sources: z11.array(
|
|
1913
|
+
z11.object({
|
|
1914
|
+
title: z11.string(),
|
|
1915
|
+
url: z11.string(),
|
|
1916
|
+
snippet: z11.string()
|
|
1877
1917
|
})
|
|
1878
1918
|
)
|
|
1879
1919
|
})
|
|
@@ -1881,7 +1921,7 @@ var webSearchOutputSchema = lazySchema3(
|
|
|
1881
1921
|
);
|
|
1882
1922
|
var webSearchToolFactory = createProviderToolFactoryWithOutputSchema3({
|
|
1883
1923
|
id: "xai.web_search",
|
|
1884
|
-
inputSchema: lazySchema3(() => zodSchema3(
|
|
1924
|
+
inputSchema: lazySchema3(() => zodSchema3(z11.object({}))),
|
|
1885
1925
|
outputSchema: webSearchOutputSchema
|
|
1886
1926
|
});
|
|
1887
1927
|
var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
@@ -1892,29 +1932,29 @@ import {
|
|
|
1892
1932
|
lazySchema as lazySchema4,
|
|
1893
1933
|
zodSchema as zodSchema4
|
|
1894
1934
|
} from "@ai-sdk/provider-utils";
|
|
1895
|
-
import { z as
|
|
1935
|
+
import { z as z12 } from "zod/v4";
|
|
1896
1936
|
var xSearchArgsSchema = lazySchema4(
|
|
1897
1937
|
() => zodSchema4(
|
|
1898
|
-
|
|
1899
|
-
allowedXHandles:
|
|
1900
|
-
excludedXHandles:
|
|
1901
|
-
fromDate:
|
|
1902
|
-
toDate:
|
|
1903
|
-
enableImageUnderstanding:
|
|
1904
|
-
enableVideoUnderstanding:
|
|
1938
|
+
z12.object({
|
|
1939
|
+
allowedXHandles: z12.array(z12.string()).max(10).optional(),
|
|
1940
|
+
excludedXHandles: z12.array(z12.string()).max(10).optional(),
|
|
1941
|
+
fromDate: z12.string().optional(),
|
|
1942
|
+
toDate: z12.string().optional(),
|
|
1943
|
+
enableImageUnderstanding: z12.boolean().optional(),
|
|
1944
|
+
enableVideoUnderstanding: z12.boolean().optional()
|
|
1905
1945
|
})
|
|
1906
1946
|
)
|
|
1907
1947
|
);
|
|
1908
1948
|
var xSearchOutputSchema = lazySchema4(
|
|
1909
1949
|
() => zodSchema4(
|
|
1910
|
-
|
|
1911
|
-
query:
|
|
1912
|
-
posts:
|
|
1913
|
-
|
|
1914
|
-
author:
|
|
1915
|
-
text:
|
|
1916
|
-
url:
|
|
1917
|
-
likes:
|
|
1950
|
+
z12.object({
|
|
1951
|
+
query: z12.string(),
|
|
1952
|
+
posts: z12.array(
|
|
1953
|
+
z12.object({
|
|
1954
|
+
author: z12.string(),
|
|
1955
|
+
text: z12.string(),
|
|
1956
|
+
url: z12.string(),
|
|
1957
|
+
likes: z12.number()
|
|
1918
1958
|
})
|
|
1919
1959
|
)
|
|
1920
1960
|
})
|
|
@@ -1922,7 +1962,7 @@ var xSearchOutputSchema = lazySchema4(
|
|
|
1922
1962
|
);
|
|
1923
1963
|
var xSearchToolFactory = createProviderToolFactoryWithOutputSchema4({
|
|
1924
1964
|
id: "xai.x_search",
|
|
1925
|
-
inputSchema: lazySchema4(() => zodSchema4(
|
|
1965
|
+
inputSchema: lazySchema4(() => zodSchema4(z12.object({}))),
|
|
1926
1966
|
outputSchema: xSearchOutputSchema
|
|
1927
1967
|
});
|
|
1928
1968
|
var xSearch = (args = {}) => xSearchToolFactory(args);
|
|
@@ -2110,7 +2150,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2110
2150
|
}) {
|
|
2111
2151
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2112
2152
|
const warnings = [];
|
|
2113
|
-
const options = (_a = await
|
|
2153
|
+
const options = (_a = await parseProviderOptions5({
|
|
2114
2154
|
provider: "xai",
|
|
2115
2155
|
providerOptions,
|
|
2116
2156
|
schema: xaiLanguageModelResponsesOptions
|
|
@@ -2205,7 +2245,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2205
2245
|
};
|
|
2206
2246
|
}
|
|
2207
2247
|
async doGenerate(options) {
|
|
2208
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
2248
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
2209
2249
|
const {
|
|
2210
2250
|
args: body,
|
|
2211
2251
|
warnings,
|
|
@@ -2326,8 +2366,8 @@ var XaiResponsesLanguageModel = class {
|
|
|
2326
2366
|
break;
|
|
2327
2367
|
}
|
|
2328
2368
|
case "reasoning": {
|
|
2329
|
-
const
|
|
2330
|
-
const reasoningText =
|
|
2369
|
+
const texts = part.summary.length > 0 ? part.summary.map((s) => s.text) : ((_m = part.content) != null ? _m : []).map((c) => c.text);
|
|
2370
|
+
const reasoningText = texts.filter((text) => text && text.length > 0).join("");
|
|
2331
2371
|
if (reasoningText || part.encrypted_content) {
|
|
2332
2372
|
const hasMetadata = part.encrypted_content || part.id;
|
|
2333
2373
|
content.push({
|
|
@@ -2356,7 +2396,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2356
2396
|
content,
|
|
2357
2397
|
finishReason: {
|
|
2358
2398
|
unified: hasFunctionCall ? "tool-calls" : mapXaiResponsesFinishReason(response.status),
|
|
2359
|
-
raw: (
|
|
2399
|
+
raw: (_n = response.status) != null ? _n : void 0
|
|
2360
2400
|
},
|
|
2361
2401
|
usage: response.usage ? convertXaiResponsesUsage(response.usage) : {
|
|
2362
2402
|
inputTokens: { total: 0, noCache: 0, cacheRead: 0, cacheWrite: 0 },
|
|
@@ -2819,43 +2859,43 @@ var XaiResponsesLanguageModel = class {
|
|
|
2819
2859
|
|
|
2820
2860
|
// src/tool/code-execution.ts
|
|
2821
2861
|
import { createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5 } from "@ai-sdk/provider-utils";
|
|
2822
|
-
import { z as
|
|
2823
|
-
var codeExecutionOutputSchema =
|
|
2824
|
-
output:
|
|
2825
|
-
error:
|
|
2862
|
+
import { z as z13 } from "zod/v4";
|
|
2863
|
+
var codeExecutionOutputSchema = z13.object({
|
|
2864
|
+
output: z13.string().describe("the output of the code execution"),
|
|
2865
|
+
error: z13.string().optional().describe("any error that occurred")
|
|
2826
2866
|
});
|
|
2827
2867
|
var codeExecutionToolFactory = createProviderToolFactoryWithOutputSchema5({
|
|
2828
2868
|
id: "xai.code_execution",
|
|
2829
|
-
inputSchema:
|
|
2869
|
+
inputSchema: z13.object({}).describe("no input parameters"),
|
|
2830
2870
|
outputSchema: codeExecutionOutputSchema
|
|
2831
2871
|
});
|
|
2832
2872
|
var codeExecution = (args = {}) => codeExecutionToolFactory(args);
|
|
2833
2873
|
|
|
2834
2874
|
// src/tool/view-image.ts
|
|
2835
2875
|
import { createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6 } from "@ai-sdk/provider-utils";
|
|
2836
|
-
import { z as
|
|
2837
|
-
var viewImageOutputSchema =
|
|
2838
|
-
description:
|
|
2839
|
-
objects:
|
|
2876
|
+
import { z as z14 } from "zod/v4";
|
|
2877
|
+
var viewImageOutputSchema = z14.object({
|
|
2878
|
+
description: z14.string().describe("description of the image"),
|
|
2879
|
+
objects: z14.array(z14.string()).optional().describe("objects detected in the image")
|
|
2840
2880
|
});
|
|
2841
2881
|
var viewImageToolFactory = createProviderToolFactoryWithOutputSchema6({
|
|
2842
2882
|
id: "xai.view_image",
|
|
2843
|
-
inputSchema:
|
|
2883
|
+
inputSchema: z14.object({}).describe("no input parameters"),
|
|
2844
2884
|
outputSchema: viewImageOutputSchema
|
|
2845
2885
|
});
|
|
2846
2886
|
var viewImage = (args = {}) => viewImageToolFactory(args);
|
|
2847
2887
|
|
|
2848
2888
|
// src/tool/view-x-video.ts
|
|
2849
2889
|
import { createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema7 } from "@ai-sdk/provider-utils";
|
|
2850
|
-
import { z as
|
|
2851
|
-
var viewXVideoOutputSchema =
|
|
2852
|
-
transcript:
|
|
2853
|
-
description:
|
|
2854
|
-
duration:
|
|
2890
|
+
import { z as z15 } from "zod/v4";
|
|
2891
|
+
var viewXVideoOutputSchema = z15.object({
|
|
2892
|
+
transcript: z15.string().optional().describe("transcript of the video"),
|
|
2893
|
+
description: z15.string().describe("description of the video content"),
|
|
2894
|
+
duration: z15.number().optional().describe("duration in seconds")
|
|
2855
2895
|
});
|
|
2856
2896
|
var viewXVideoToolFactory = createProviderToolFactoryWithOutputSchema7({
|
|
2857
2897
|
id: "xai.view_x_video",
|
|
2858
|
-
inputSchema:
|
|
2898
|
+
inputSchema: z15.object({}).describe("no input parameters"),
|
|
2859
2899
|
outputSchema: viewXVideoOutputSchema
|
|
2860
2900
|
});
|
|
2861
2901
|
var viewXVideo = (args = {}) => viewXVideoToolFactory(args);
|
|
@@ -2872,7 +2912,7 @@ var xaiTools = {
|
|
|
2872
2912
|
};
|
|
2873
2913
|
|
|
2874
2914
|
// src/version.ts
|
|
2875
|
-
var VERSION = true ? "3.0.
|
|
2915
|
+
var VERSION = true ? "3.0.105" : "0.0.0-test";
|
|
2876
2916
|
|
|
2877
2917
|
// src/xai-video-model.ts
|
|
2878
2918
|
import {
|
|
@@ -2884,56 +2924,56 @@ import {
|
|
|
2884
2924
|
createJsonResponseHandler as createJsonResponseHandler4,
|
|
2885
2925
|
delay,
|
|
2886
2926
|
getFromApi as getFromApi2,
|
|
2887
|
-
parseProviderOptions as
|
|
2927
|
+
parseProviderOptions as parseProviderOptions6,
|
|
2888
2928
|
postJsonToApi as postJsonToApi4
|
|
2889
2929
|
} from "@ai-sdk/provider-utils";
|
|
2890
|
-
import { z as
|
|
2930
|
+
import { z as z17 } from "zod/v4";
|
|
2891
2931
|
|
|
2892
2932
|
// src/xai-video-options.ts
|
|
2893
2933
|
import { lazySchema as lazySchema5, zodSchema as zodSchema5 } from "@ai-sdk/provider-utils";
|
|
2894
|
-
import { z as
|
|
2895
|
-
var nonEmptyStringSchema =
|
|
2896
|
-
var resolutionSchema =
|
|
2897
|
-
var modeSchema =
|
|
2934
|
+
import { z as z16 } from "zod/v4";
|
|
2935
|
+
var nonEmptyStringSchema = z16.string().min(1);
|
|
2936
|
+
var resolutionSchema = z16.enum(["480p", "720p"]);
|
|
2937
|
+
var modeSchema = z16.enum(["edit-video", "extend-video", "reference-to-video"]);
|
|
2898
2938
|
var baseFields = {
|
|
2899
|
-
pollIntervalMs:
|
|
2900
|
-
pollTimeoutMs:
|
|
2939
|
+
pollIntervalMs: z16.number().positive().nullish(),
|
|
2940
|
+
pollTimeoutMs: z16.number().positive().nullish(),
|
|
2901
2941
|
resolution: resolutionSchema.nullish()
|
|
2902
2942
|
};
|
|
2903
|
-
var editVideoSchema =
|
|
2943
|
+
var editVideoSchema = z16.object({
|
|
2904
2944
|
...baseFields,
|
|
2905
|
-
mode:
|
|
2945
|
+
mode: z16.literal("edit-video"),
|
|
2906
2946
|
videoUrl: nonEmptyStringSchema,
|
|
2907
|
-
referenceImageUrls:
|
|
2947
|
+
referenceImageUrls: z16.undefined().optional()
|
|
2908
2948
|
});
|
|
2909
|
-
var extendVideoSchema =
|
|
2949
|
+
var extendVideoSchema = z16.object({
|
|
2910
2950
|
...baseFields,
|
|
2911
|
-
mode:
|
|
2951
|
+
mode: z16.literal("extend-video"),
|
|
2912
2952
|
videoUrl: nonEmptyStringSchema,
|
|
2913
|
-
referenceImageUrls:
|
|
2953
|
+
referenceImageUrls: z16.undefined().optional()
|
|
2914
2954
|
});
|
|
2915
|
-
var referenceToVideoSchema =
|
|
2955
|
+
var referenceToVideoSchema = z16.object({
|
|
2916
2956
|
...baseFields,
|
|
2917
|
-
mode:
|
|
2918
|
-
referenceImageUrls:
|
|
2919
|
-
videoUrl:
|
|
2957
|
+
mode: z16.literal("reference-to-video"),
|
|
2958
|
+
referenceImageUrls: z16.array(nonEmptyStringSchema).min(1).max(7),
|
|
2959
|
+
videoUrl: z16.undefined().optional()
|
|
2920
2960
|
});
|
|
2921
|
-
var autoDetectSchema =
|
|
2961
|
+
var autoDetectSchema = z16.object({
|
|
2922
2962
|
...baseFields,
|
|
2923
|
-
mode:
|
|
2963
|
+
mode: z16.undefined().optional(),
|
|
2924
2964
|
videoUrl: nonEmptyStringSchema.optional(),
|
|
2925
|
-
referenceImageUrls:
|
|
2965
|
+
referenceImageUrls: z16.array(nonEmptyStringSchema).min(1).max(7).optional()
|
|
2926
2966
|
});
|
|
2927
|
-
var xaiVideoModelOptions =
|
|
2967
|
+
var xaiVideoModelOptions = z16.union([
|
|
2928
2968
|
editVideoSchema,
|
|
2929
2969
|
extendVideoSchema,
|
|
2930
2970
|
referenceToVideoSchema,
|
|
2931
2971
|
autoDetectSchema
|
|
2932
2972
|
]);
|
|
2933
|
-
var runtimeSchema =
|
|
2973
|
+
var runtimeSchema = z16.object({
|
|
2934
2974
|
mode: modeSchema.optional(),
|
|
2935
2975
|
videoUrl: nonEmptyStringSchema.optional(),
|
|
2936
|
-
referenceImageUrls:
|
|
2976
|
+
referenceImageUrls: z16.array(nonEmptyStringSchema).min(1).max(7).optional(),
|
|
2937
2977
|
...baseFields
|
|
2938
2978
|
}).passthrough();
|
|
2939
2979
|
var xaiVideoModelOptionsSchema = lazySchema5(
|
|
@@ -3006,7 +3046,7 @@ var XaiVideoModel = class {
|
|
|
3006
3046
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
3007
3047
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
3008
3048
|
const warnings = [];
|
|
3009
|
-
const xaiOptions = await
|
|
3049
|
+
const xaiOptions = await parseProviderOptions6({
|
|
3010
3050
|
provider: "xai",
|
|
3011
3051
|
providerOptions: options.providerOptions,
|
|
3012
3052
|
schema: xaiVideoModelOptionsSchema
|
|
@@ -3245,24 +3285,24 @@ var XaiVideoModel = class {
|
|
|
3245
3285
|
}
|
|
3246
3286
|
}
|
|
3247
3287
|
};
|
|
3248
|
-
var xaiCreateVideoResponseSchema =
|
|
3249
|
-
request_id:
|
|
3288
|
+
var xaiCreateVideoResponseSchema = z17.object({
|
|
3289
|
+
request_id: z17.string().nullish()
|
|
3250
3290
|
});
|
|
3251
|
-
var xaiVideoStatusResponseSchema =
|
|
3252
|
-
status:
|
|
3253
|
-
video:
|
|
3254
|
-
url:
|
|
3255
|
-
duration:
|
|
3256
|
-
respect_moderation:
|
|
3291
|
+
var xaiVideoStatusResponseSchema = z17.object({
|
|
3292
|
+
status: z17.string().nullish(),
|
|
3293
|
+
video: z17.object({
|
|
3294
|
+
url: z17.string(),
|
|
3295
|
+
duration: z17.number().nullish(),
|
|
3296
|
+
respect_moderation: z17.boolean().nullish()
|
|
3257
3297
|
}).nullish(),
|
|
3258
|
-
model:
|
|
3259
|
-
usage:
|
|
3260
|
-
cost_in_usd_ticks:
|
|
3298
|
+
model: z17.string().nullish(),
|
|
3299
|
+
usage: z17.object({
|
|
3300
|
+
cost_in_usd_ticks: z17.number().nullish()
|
|
3261
3301
|
}).nullish(),
|
|
3262
|
-
progress:
|
|
3263
|
-
error:
|
|
3264
|
-
code:
|
|
3265
|
-
message:
|
|
3302
|
+
progress: z17.number().nullish(),
|
|
3303
|
+
error: z17.object({
|
|
3304
|
+
code: z17.string().nullish(),
|
|
3305
|
+
message: z17.string().nullish()
|
|
3266
3306
|
}).nullish()
|
|
3267
3307
|
});
|
|
3268
3308
|
|