@ai-sdk/xai 3.0.104 → 3.0.105
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +630 -591
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +640 -601
- package/dist/index.mjs.map +1 -1
- package/docs/01-xai.mdx +36 -0
- package/package.json +3 -3
- package/src/convert-to-xai-chat-messages.ts +47 -34
- package/src/index.ts +1 -0
- package/src/responses/convert-to-xai-responses-input.ts +15 -2
- package/src/responses/xai-responses-api.ts +5 -1
- package/src/xai-chat-language-model.ts +1 -1
- package/src/xai-chat-prompt.ts +4 -1
- package/src/xai-file-part-options.ts +21 -0
package/dist/index.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": {
|
|
@@ -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,461 +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
|
-
content:
|
|
1422
|
-
status:
|
|
1423
|
-
encrypted_content:
|
|
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()
|
|
1424
1463
|
})
|
|
1425
1464
|
]);
|
|
1426
|
-
var xaiResponsesUsageSchema =
|
|
1427
|
-
input_tokens:
|
|
1428
|
-
output_tokens:
|
|
1429
|
-
total_tokens:
|
|
1430
|
-
input_tokens_details:
|
|
1431
|
-
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()
|
|
1432
1471
|
}).optional(),
|
|
1433
|
-
output_tokens_details:
|
|
1434
|
-
reasoning_tokens:
|
|
1472
|
+
output_tokens_details: z7.object({
|
|
1473
|
+
reasoning_tokens: z7.number().optional()
|
|
1435
1474
|
}).optional(),
|
|
1436
|
-
num_sources_used:
|
|
1437
|
-
num_server_side_tools_used:
|
|
1475
|
+
num_sources_used: z7.number().optional(),
|
|
1476
|
+
num_server_side_tools_used: z7.number().optional()
|
|
1438
1477
|
});
|
|
1439
|
-
var xaiResponsesResponseSchema =
|
|
1440
|
-
id:
|
|
1441
|
-
created_at:
|
|
1442
|
-
model:
|
|
1443
|
-
object:
|
|
1444
|
-
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),
|
|
1445
1484
|
usage: xaiResponsesUsageSchema.nullish(),
|
|
1446
|
-
status:
|
|
1485
|
+
status: z7.string()
|
|
1447
1486
|
});
|
|
1448
|
-
var xaiResponsesChunkSchema =
|
|
1449
|
-
|
|
1450
|
-
type:
|
|
1487
|
+
var xaiResponsesChunkSchema = z7.union([
|
|
1488
|
+
z7.object({
|
|
1489
|
+
type: z7.literal("response.created"),
|
|
1451
1490
|
response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
|
|
1452
1491
|
}),
|
|
1453
|
-
|
|
1454
|
-
type:
|
|
1492
|
+
z7.object({
|
|
1493
|
+
type: z7.literal("response.in_progress"),
|
|
1455
1494
|
response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
|
|
1456
1495
|
}),
|
|
1457
|
-
|
|
1458
|
-
type:
|
|
1496
|
+
z7.object({
|
|
1497
|
+
type: z7.literal("response.output_item.added"),
|
|
1459
1498
|
item: outputItemSchema,
|
|
1460
|
-
output_index:
|
|
1499
|
+
output_index: z7.number()
|
|
1461
1500
|
}),
|
|
1462
|
-
|
|
1463
|
-
type:
|
|
1501
|
+
z7.object({
|
|
1502
|
+
type: z7.literal("response.output_item.done"),
|
|
1464
1503
|
item: outputItemSchema,
|
|
1465
|
-
output_index:
|
|
1504
|
+
output_index: z7.number()
|
|
1466
1505
|
}),
|
|
1467
|
-
|
|
1468
|
-
type:
|
|
1469
|
-
item_id:
|
|
1470
|
-
output_index:
|
|
1471
|
-
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(),
|
|
1472
1511
|
part: messageContentPartSchema
|
|
1473
1512
|
}),
|
|
1474
|
-
|
|
1475
|
-
type:
|
|
1476
|
-
item_id:
|
|
1477
|
-
output_index:
|
|
1478
|
-
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(),
|
|
1479
1518
|
part: messageContentPartSchema
|
|
1480
1519
|
}),
|
|
1481
|
-
|
|
1482
|
-
type:
|
|
1483
|
-
item_id:
|
|
1484
|
-
output_index:
|
|
1485
|
-
content_index:
|
|
1486
|
-
delta:
|
|
1487
|
-
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()
|
|
1488
1527
|
}),
|
|
1489
|
-
|
|
1490
|
-
type:
|
|
1491
|
-
item_id:
|
|
1492
|
-
output_index:
|
|
1493
|
-
content_index:
|
|
1494
|
-
text:
|
|
1495
|
-
logprobs:
|
|
1496
|
-
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()
|
|
1497
1536
|
}),
|
|
1498
|
-
|
|
1499
|
-
type:
|
|
1500
|
-
item_id:
|
|
1501
|
-
output_index:
|
|
1502
|
-
content_index:
|
|
1503
|
-
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(),
|
|
1504
1543
|
annotation: annotationSchema
|
|
1505
1544
|
}),
|
|
1506
|
-
|
|
1507
|
-
type:
|
|
1508
|
-
item_id:
|
|
1509
|
-
output_index:
|
|
1510
|
-
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(),
|
|
1511
1550
|
part: reasoningSummaryPartSchema
|
|
1512
1551
|
}),
|
|
1513
|
-
|
|
1514
|
-
type:
|
|
1515
|
-
item_id:
|
|
1516
|
-
output_index:
|
|
1517
|
-
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(),
|
|
1518
1557
|
part: reasoningSummaryPartSchema
|
|
1519
1558
|
}),
|
|
1520
|
-
|
|
1521
|
-
type:
|
|
1522
|
-
item_id:
|
|
1523
|
-
output_index:
|
|
1524
|
-
summary_index:
|
|
1525
|
-
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()
|
|
1526
1565
|
}),
|
|
1527
|
-
|
|
1528
|
-
type:
|
|
1529
|
-
item_id:
|
|
1530
|
-
output_index:
|
|
1531
|
-
summary_index:
|
|
1532
|
-
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()
|
|
1533
1572
|
}),
|
|
1534
|
-
|
|
1535
|
-
type:
|
|
1536
|
-
item_id:
|
|
1537
|
-
output_index:
|
|
1538
|
-
content_index:
|
|
1539
|
-
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()
|
|
1540
1579
|
}),
|
|
1541
|
-
|
|
1542
|
-
type:
|
|
1543
|
-
item_id:
|
|
1544
|
-
output_index:
|
|
1545
|
-
content_index:
|
|
1546
|
-
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()
|
|
1547
1586
|
}),
|
|
1548
|
-
|
|
1549
|
-
type:
|
|
1550
|
-
item_id:
|
|
1551
|
-
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()
|
|
1552
1591
|
}),
|
|
1553
|
-
|
|
1554
|
-
type:
|
|
1555
|
-
item_id:
|
|
1556
|
-
output_index:
|
|
1592
|
+
z7.object({
|
|
1593
|
+
type: z7.literal("response.web_search_call.searching"),
|
|
1594
|
+
item_id: z7.string(),
|
|
1595
|
+
output_index: z7.number()
|
|
1557
1596
|
}),
|
|
1558
|
-
|
|
1559
|
-
type:
|
|
1560
|
-
item_id:
|
|
1561
|
-
output_index:
|
|
1597
|
+
z7.object({
|
|
1598
|
+
type: z7.literal("response.web_search_call.completed"),
|
|
1599
|
+
item_id: z7.string(),
|
|
1600
|
+
output_index: z7.number()
|
|
1562
1601
|
}),
|
|
1563
|
-
|
|
1564
|
-
type:
|
|
1565
|
-
item_id:
|
|
1566
|
-
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()
|
|
1567
1606
|
}),
|
|
1568
|
-
|
|
1569
|
-
type:
|
|
1570
|
-
item_id:
|
|
1571
|
-
output_index:
|
|
1607
|
+
z7.object({
|
|
1608
|
+
type: z7.literal("response.x_search_call.searching"),
|
|
1609
|
+
item_id: z7.string(),
|
|
1610
|
+
output_index: z7.number()
|
|
1572
1611
|
}),
|
|
1573
|
-
|
|
1574
|
-
type:
|
|
1575
|
-
item_id:
|
|
1576
|
-
output_index:
|
|
1612
|
+
z7.object({
|
|
1613
|
+
type: z7.literal("response.x_search_call.completed"),
|
|
1614
|
+
item_id: z7.string(),
|
|
1615
|
+
output_index: z7.number()
|
|
1577
1616
|
}),
|
|
1578
|
-
|
|
1579
|
-
type:
|
|
1580
|
-
item_id:
|
|
1581
|
-
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()
|
|
1582
1621
|
}),
|
|
1583
|
-
|
|
1584
|
-
type:
|
|
1585
|
-
item_id:
|
|
1586
|
-
output_index:
|
|
1622
|
+
z7.object({
|
|
1623
|
+
type: z7.literal("response.file_search_call.searching"),
|
|
1624
|
+
item_id: z7.string(),
|
|
1625
|
+
output_index: z7.number()
|
|
1587
1626
|
}),
|
|
1588
|
-
|
|
1589
|
-
type:
|
|
1590
|
-
item_id:
|
|
1591
|
-
output_index:
|
|
1627
|
+
z7.object({
|
|
1628
|
+
type: z7.literal("response.file_search_call.completed"),
|
|
1629
|
+
item_id: z7.string(),
|
|
1630
|
+
output_index: z7.number()
|
|
1592
1631
|
}),
|
|
1593
|
-
|
|
1594
|
-
type:
|
|
1595
|
-
item_id:
|
|
1596
|
-
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()
|
|
1597
1636
|
}),
|
|
1598
|
-
|
|
1599
|
-
type:
|
|
1600
|
-
item_id:
|
|
1601
|
-
output_index:
|
|
1637
|
+
z7.object({
|
|
1638
|
+
type: z7.literal("response.code_execution_call.executing"),
|
|
1639
|
+
item_id: z7.string(),
|
|
1640
|
+
output_index: z7.number()
|
|
1602
1641
|
}),
|
|
1603
|
-
|
|
1604
|
-
type:
|
|
1605
|
-
item_id:
|
|
1606
|
-
output_index:
|
|
1642
|
+
z7.object({
|
|
1643
|
+
type: z7.literal("response.code_execution_call.completed"),
|
|
1644
|
+
item_id: z7.string(),
|
|
1645
|
+
output_index: z7.number()
|
|
1607
1646
|
}),
|
|
1608
|
-
|
|
1609
|
-
type:
|
|
1610
|
-
item_id:
|
|
1611
|
-
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()
|
|
1612
1651
|
}),
|
|
1613
|
-
|
|
1614
|
-
type:
|
|
1615
|
-
item_id:
|
|
1616
|
-
output_index:
|
|
1652
|
+
z7.object({
|
|
1653
|
+
type: z7.literal("response.code_interpreter_call.executing"),
|
|
1654
|
+
item_id: z7.string(),
|
|
1655
|
+
output_index: z7.number()
|
|
1617
1656
|
}),
|
|
1618
|
-
|
|
1619
|
-
type:
|
|
1620
|
-
item_id:
|
|
1621
|
-
output_index:
|
|
1657
|
+
z7.object({
|
|
1658
|
+
type: z7.literal("response.code_interpreter_call.interpreting"),
|
|
1659
|
+
item_id: z7.string(),
|
|
1660
|
+
output_index: z7.number()
|
|
1622
1661
|
}),
|
|
1623
|
-
|
|
1624
|
-
type:
|
|
1625
|
-
item_id:
|
|
1626
|
-
output_index:
|
|
1662
|
+
z7.object({
|
|
1663
|
+
type: z7.literal("response.code_interpreter_call.completed"),
|
|
1664
|
+
item_id: z7.string(),
|
|
1665
|
+
output_index: z7.number()
|
|
1627
1666
|
}),
|
|
1628
1667
|
// Code interpreter code streaming events
|
|
1629
|
-
|
|
1630
|
-
type:
|
|
1631
|
-
item_id:
|
|
1632
|
-
output_index:
|
|
1633
|
-
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()
|
|
1634
1673
|
}),
|
|
1635
|
-
|
|
1636
|
-
type:
|
|
1637
|
-
item_id:
|
|
1638
|
-
output_index:
|
|
1639
|
-
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()
|
|
1640
1679
|
}),
|
|
1641
|
-
|
|
1642
|
-
type:
|
|
1643
|
-
item_id:
|
|
1644
|
-
output_index:
|
|
1645
|
-
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()
|
|
1646
1685
|
}),
|
|
1647
|
-
|
|
1648
|
-
type:
|
|
1649
|
-
item_id:
|
|
1650
|
-
output_index:
|
|
1651
|
-
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()
|
|
1652
1691
|
}),
|
|
1653
1692
|
// Function call arguments streaming events (standard function tools)
|
|
1654
|
-
|
|
1655
|
-
type:
|
|
1656
|
-
item_id:
|
|
1657
|
-
output_index:
|
|
1658
|
-
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()
|
|
1659
1698
|
}),
|
|
1660
|
-
|
|
1661
|
-
type:
|
|
1662
|
-
item_id:
|
|
1663
|
-
output_index:
|
|
1664
|
-
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()
|
|
1665
1704
|
}),
|
|
1666
|
-
|
|
1667
|
-
type:
|
|
1668
|
-
item_id:
|
|
1669
|
-
output_index:
|
|
1705
|
+
z7.object({
|
|
1706
|
+
type: z7.literal("response.mcp_call.in_progress"),
|
|
1707
|
+
item_id: z7.string(),
|
|
1708
|
+
output_index: z7.number()
|
|
1670
1709
|
}),
|
|
1671
|
-
|
|
1672
|
-
type:
|
|
1673
|
-
item_id:
|
|
1674
|
-
output_index:
|
|
1710
|
+
z7.object({
|
|
1711
|
+
type: z7.literal("response.mcp_call.executing"),
|
|
1712
|
+
item_id: z7.string(),
|
|
1713
|
+
output_index: z7.number()
|
|
1675
1714
|
}),
|
|
1676
|
-
|
|
1677
|
-
type:
|
|
1678
|
-
item_id:
|
|
1679
|
-
output_index:
|
|
1715
|
+
z7.object({
|
|
1716
|
+
type: z7.literal("response.mcp_call.completed"),
|
|
1717
|
+
item_id: z7.string(),
|
|
1718
|
+
output_index: z7.number()
|
|
1680
1719
|
}),
|
|
1681
|
-
|
|
1682
|
-
type:
|
|
1683
|
-
item_id:
|
|
1684
|
-
output_index:
|
|
1720
|
+
z7.object({
|
|
1721
|
+
type: z7.literal("response.mcp_call.failed"),
|
|
1722
|
+
item_id: z7.string(),
|
|
1723
|
+
output_index: z7.number()
|
|
1685
1724
|
}),
|
|
1686
|
-
|
|
1687
|
-
type:
|
|
1688
|
-
item_id:
|
|
1689
|
-
output_index:
|
|
1690
|
-
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()
|
|
1691
1730
|
}),
|
|
1692
|
-
|
|
1693
|
-
type:
|
|
1694
|
-
item_id:
|
|
1695
|
-
output_index:
|
|
1696
|
-
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()
|
|
1697
1736
|
}),
|
|
1698
|
-
|
|
1699
|
-
type:
|
|
1700
|
-
item_id:
|
|
1701
|
-
output_index:
|
|
1702
|
-
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()
|
|
1703
1742
|
}),
|
|
1704
|
-
|
|
1705
|
-
type:
|
|
1706
|
-
item_id:
|
|
1707
|
-
output_index:
|
|
1708
|
-
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()
|
|
1709
1748
|
}),
|
|
1710
|
-
|
|
1711
|
-
type:
|
|
1712
|
-
response:
|
|
1713
|
-
incomplete_details:
|
|
1749
|
+
z7.object({
|
|
1750
|
+
type: z7.literal("response.incomplete"),
|
|
1751
|
+
response: z7.object({
|
|
1752
|
+
incomplete_details: z7.object({ reason: z7.string() }).nullish(),
|
|
1714
1753
|
usage: xaiResponsesUsageSchema.nullish()
|
|
1715
1754
|
})
|
|
1716
1755
|
}),
|
|
1717
|
-
|
|
1718
|
-
type:
|
|
1719
|
-
response:
|
|
1720
|
-
error:
|
|
1721
|
-
code:
|
|
1722
|
-
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()
|
|
1723
1762
|
}).nullish(),
|
|
1724
|
-
incomplete_details:
|
|
1763
|
+
incomplete_details: z7.object({ reason: z7.string() }).nullish(),
|
|
1725
1764
|
usage: xaiResponsesUsageSchema.nullish()
|
|
1726
1765
|
})
|
|
1727
1766
|
}),
|
|
1728
|
-
|
|
1729
|
-
type:
|
|
1730
|
-
code:
|
|
1731
|
-
message:
|
|
1732
|
-
param:
|
|
1767
|
+
z7.object({
|
|
1768
|
+
type: z7.literal("error"),
|
|
1769
|
+
code: z7.string().nullish(),
|
|
1770
|
+
message: z7.string(),
|
|
1771
|
+
param: z7.string().nullish()
|
|
1733
1772
|
}),
|
|
1734
|
-
|
|
1735
|
-
type:
|
|
1773
|
+
z7.object({
|
|
1774
|
+
type: z7.literal("response.done"),
|
|
1736
1775
|
response: xaiResponsesResponseSchema
|
|
1737
1776
|
}),
|
|
1738
|
-
|
|
1739
|
-
type:
|
|
1777
|
+
z7.object({
|
|
1778
|
+
type: z7.literal("response.completed"),
|
|
1740
1779
|
response: xaiResponsesResponseSchema
|
|
1741
1780
|
})
|
|
1742
1781
|
]);
|
|
1743
1782
|
|
|
1744
1783
|
// src/responses/xai-responses-options.ts
|
|
1745
|
-
import { z as
|
|
1746
|
-
var xaiLanguageModelResponsesOptions =
|
|
1784
|
+
import { z as z8 } from "zod/v4";
|
|
1785
|
+
var xaiLanguageModelResponsesOptions = z8.object({
|
|
1747
1786
|
/**
|
|
1748
1787
|
* Constrains how hard a reasoning model thinks before responding.
|
|
1749
1788
|
* Possible values are `none` (disables reasoning), `low` (uses fewer reasoning
|
|
1750
1789
|
* tokens), `medium` and `high` (uses more reasoning tokens). Not all models
|
|
1751
1790
|
* support reasoning effort; see xAI's docs for the values each model accepts.
|
|
1752
1791
|
*/
|
|
1753
|
-
reasoningEffort:
|
|
1754
|
-
logprobs:
|
|
1755
|
-
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(),
|
|
1756
1795
|
/**
|
|
1757
1796
|
* Whether to store the input message(s) and model response for later retrieval.
|
|
1758
1797
|
* Must be set to `false` for teams with Zero Data Retention (ZDR) enabled,
|
|
1759
1798
|
* otherwise the API will return an error.
|
|
1760
1799
|
* @default true
|
|
1761
1800
|
*/
|
|
1762
|
-
store:
|
|
1801
|
+
store: z8.boolean().optional(),
|
|
1763
1802
|
/**
|
|
1764
1803
|
* The ID of the previous response from the model.
|
|
1765
1804
|
*/
|
|
1766
|
-
previousResponseId:
|
|
1805
|
+
previousResponseId: z8.string().optional(),
|
|
1767
1806
|
/**
|
|
1768
1807
|
* Specify additional output data to include in the model response.
|
|
1769
1808
|
* Example values: 'file_search_call.results'.
|
|
1770
1809
|
*/
|
|
1771
|
-
include:
|
|
1810
|
+
include: z8.array(z8.enum(["file_search_call.results"])).nullish()
|
|
1772
1811
|
});
|
|
1773
1812
|
|
|
1774
1813
|
// src/responses/xai-responses-prepare-tools.ts
|
|
@@ -1783,25 +1822,25 @@ import {
|
|
|
1783
1822
|
lazySchema,
|
|
1784
1823
|
zodSchema
|
|
1785
1824
|
} from "@ai-sdk/provider-utils";
|
|
1786
|
-
import { z as
|
|
1825
|
+
import { z as z9 } from "zod/v4";
|
|
1787
1826
|
var fileSearchArgsSchema = lazySchema(
|
|
1788
1827
|
() => zodSchema(
|
|
1789
|
-
|
|
1790
|
-
vectorStoreIds:
|
|
1791
|
-
maxNumResults:
|
|
1828
|
+
z9.object({
|
|
1829
|
+
vectorStoreIds: z9.array(z9.string()),
|
|
1830
|
+
maxNumResults: z9.number().optional()
|
|
1792
1831
|
})
|
|
1793
1832
|
)
|
|
1794
1833
|
);
|
|
1795
1834
|
var fileSearchOutputSchema = lazySchema(
|
|
1796
1835
|
() => zodSchema(
|
|
1797
|
-
|
|
1798
|
-
queries:
|
|
1799
|
-
results:
|
|
1800
|
-
|
|
1801
|
-
fileId:
|
|
1802
|
-
filename:
|
|
1803
|
-
score:
|
|
1804
|
-
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()
|
|
1805
1844
|
})
|
|
1806
1845
|
).nullable()
|
|
1807
1846
|
})
|
|
@@ -1809,7 +1848,7 @@ var fileSearchOutputSchema = lazySchema(
|
|
|
1809
1848
|
);
|
|
1810
1849
|
var fileSearchToolFactory = createProviderToolFactoryWithOutputSchema({
|
|
1811
1850
|
id: "xai.file_search",
|
|
1812
|
-
inputSchema: lazySchema(() => zodSchema(
|
|
1851
|
+
inputSchema: lazySchema(() => zodSchema(z9.object({}))),
|
|
1813
1852
|
outputSchema: fileSearchOutputSchema
|
|
1814
1853
|
});
|
|
1815
1854
|
var fileSearch = (args) => fileSearchToolFactory(args);
|
|
@@ -1820,31 +1859,31 @@ import {
|
|
|
1820
1859
|
lazySchema as lazySchema2,
|
|
1821
1860
|
zodSchema as zodSchema2
|
|
1822
1861
|
} from "@ai-sdk/provider-utils";
|
|
1823
|
-
import { z as
|
|
1862
|
+
import { z as z10 } from "zod/v4";
|
|
1824
1863
|
var mcpServerArgsSchema = lazySchema2(
|
|
1825
1864
|
() => zodSchema2(
|
|
1826
|
-
|
|
1827
|
-
serverUrl:
|
|
1828
|
-
serverLabel:
|
|
1829
|
-
serverDescription:
|
|
1830
|
-
allowedTools:
|
|
1831
|
-
headers:
|
|
1832
|
-
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")
|
|
1833
1872
|
})
|
|
1834
1873
|
)
|
|
1835
1874
|
);
|
|
1836
1875
|
var mcpServerOutputSchema = lazySchema2(
|
|
1837
1876
|
() => zodSchema2(
|
|
1838
|
-
|
|
1839
|
-
name:
|
|
1840
|
-
arguments:
|
|
1841
|
-
result:
|
|
1877
|
+
z10.object({
|
|
1878
|
+
name: z10.string(),
|
|
1879
|
+
arguments: z10.string(),
|
|
1880
|
+
result: z10.unknown()
|
|
1842
1881
|
})
|
|
1843
1882
|
)
|
|
1844
1883
|
);
|
|
1845
1884
|
var mcpServerToolFactory = createProviderToolFactoryWithOutputSchema2({
|
|
1846
1885
|
id: "xai.mcp",
|
|
1847
|
-
inputSchema: lazySchema2(() => zodSchema2(
|
|
1886
|
+
inputSchema: lazySchema2(() => zodSchema2(z10.object({}))),
|
|
1848
1887
|
outputSchema: mcpServerOutputSchema
|
|
1849
1888
|
});
|
|
1850
1889
|
var mcpServer = (args) => mcpServerToolFactory(args);
|
|
@@ -1855,26 +1894,26 @@ import {
|
|
|
1855
1894
|
lazySchema as lazySchema3,
|
|
1856
1895
|
zodSchema as zodSchema3
|
|
1857
1896
|
} from "@ai-sdk/provider-utils";
|
|
1858
|
-
import { z as
|
|
1897
|
+
import { z as z11 } from "zod/v4";
|
|
1859
1898
|
var webSearchArgsSchema = lazySchema3(
|
|
1860
1899
|
() => zodSchema3(
|
|
1861
|
-
|
|
1862
|
-
allowedDomains:
|
|
1863
|
-
excludedDomains:
|
|
1864
|
-
enableImageSearch:
|
|
1865
|
-
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()
|
|
1866
1905
|
})
|
|
1867
1906
|
)
|
|
1868
1907
|
);
|
|
1869
1908
|
var webSearchOutputSchema = lazySchema3(
|
|
1870
1909
|
() => zodSchema3(
|
|
1871
|
-
|
|
1872
|
-
query:
|
|
1873
|
-
sources:
|
|
1874
|
-
|
|
1875
|
-
title:
|
|
1876
|
-
url:
|
|
1877
|
-
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()
|
|
1878
1917
|
})
|
|
1879
1918
|
)
|
|
1880
1919
|
})
|
|
@@ -1882,7 +1921,7 @@ var webSearchOutputSchema = lazySchema3(
|
|
|
1882
1921
|
);
|
|
1883
1922
|
var webSearchToolFactory = createProviderToolFactoryWithOutputSchema3({
|
|
1884
1923
|
id: "xai.web_search",
|
|
1885
|
-
inputSchema: lazySchema3(() => zodSchema3(
|
|
1924
|
+
inputSchema: lazySchema3(() => zodSchema3(z11.object({}))),
|
|
1886
1925
|
outputSchema: webSearchOutputSchema
|
|
1887
1926
|
});
|
|
1888
1927
|
var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
@@ -1893,29 +1932,29 @@ import {
|
|
|
1893
1932
|
lazySchema as lazySchema4,
|
|
1894
1933
|
zodSchema as zodSchema4
|
|
1895
1934
|
} from "@ai-sdk/provider-utils";
|
|
1896
|
-
import { z as
|
|
1935
|
+
import { z as z12 } from "zod/v4";
|
|
1897
1936
|
var xSearchArgsSchema = lazySchema4(
|
|
1898
1937
|
() => zodSchema4(
|
|
1899
|
-
|
|
1900
|
-
allowedXHandles:
|
|
1901
|
-
excludedXHandles:
|
|
1902
|
-
fromDate:
|
|
1903
|
-
toDate:
|
|
1904
|
-
enableImageUnderstanding:
|
|
1905
|
-
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()
|
|
1906
1945
|
})
|
|
1907
1946
|
)
|
|
1908
1947
|
);
|
|
1909
1948
|
var xSearchOutputSchema = lazySchema4(
|
|
1910
1949
|
() => zodSchema4(
|
|
1911
|
-
|
|
1912
|
-
query:
|
|
1913
|
-
posts:
|
|
1914
|
-
|
|
1915
|
-
author:
|
|
1916
|
-
text:
|
|
1917
|
-
url:
|
|
1918
|
-
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()
|
|
1919
1958
|
})
|
|
1920
1959
|
)
|
|
1921
1960
|
})
|
|
@@ -1923,7 +1962,7 @@ var xSearchOutputSchema = lazySchema4(
|
|
|
1923
1962
|
);
|
|
1924
1963
|
var xSearchToolFactory = createProviderToolFactoryWithOutputSchema4({
|
|
1925
1964
|
id: "xai.x_search",
|
|
1926
|
-
inputSchema: lazySchema4(() => zodSchema4(
|
|
1965
|
+
inputSchema: lazySchema4(() => zodSchema4(z12.object({}))),
|
|
1927
1966
|
outputSchema: xSearchOutputSchema
|
|
1928
1967
|
});
|
|
1929
1968
|
var xSearch = (args = {}) => xSearchToolFactory(args);
|
|
@@ -2111,7 +2150,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2111
2150
|
}) {
|
|
2112
2151
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2113
2152
|
const warnings = [];
|
|
2114
|
-
const options = (_a = await
|
|
2153
|
+
const options = (_a = await parseProviderOptions5({
|
|
2115
2154
|
provider: "xai",
|
|
2116
2155
|
providerOptions,
|
|
2117
2156
|
schema: xaiLanguageModelResponsesOptions
|
|
@@ -2820,43 +2859,43 @@ var XaiResponsesLanguageModel = class {
|
|
|
2820
2859
|
|
|
2821
2860
|
// src/tool/code-execution.ts
|
|
2822
2861
|
import { createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5 } from "@ai-sdk/provider-utils";
|
|
2823
|
-
import { z as
|
|
2824
|
-
var codeExecutionOutputSchema =
|
|
2825
|
-
output:
|
|
2826
|
-
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")
|
|
2827
2866
|
});
|
|
2828
2867
|
var codeExecutionToolFactory = createProviderToolFactoryWithOutputSchema5({
|
|
2829
2868
|
id: "xai.code_execution",
|
|
2830
|
-
inputSchema:
|
|
2869
|
+
inputSchema: z13.object({}).describe("no input parameters"),
|
|
2831
2870
|
outputSchema: codeExecutionOutputSchema
|
|
2832
2871
|
});
|
|
2833
2872
|
var codeExecution = (args = {}) => codeExecutionToolFactory(args);
|
|
2834
2873
|
|
|
2835
2874
|
// src/tool/view-image.ts
|
|
2836
2875
|
import { createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6 } from "@ai-sdk/provider-utils";
|
|
2837
|
-
import { z as
|
|
2838
|
-
var viewImageOutputSchema =
|
|
2839
|
-
description:
|
|
2840
|
-
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")
|
|
2841
2880
|
});
|
|
2842
2881
|
var viewImageToolFactory = createProviderToolFactoryWithOutputSchema6({
|
|
2843
2882
|
id: "xai.view_image",
|
|
2844
|
-
inputSchema:
|
|
2883
|
+
inputSchema: z14.object({}).describe("no input parameters"),
|
|
2845
2884
|
outputSchema: viewImageOutputSchema
|
|
2846
2885
|
});
|
|
2847
2886
|
var viewImage = (args = {}) => viewImageToolFactory(args);
|
|
2848
2887
|
|
|
2849
2888
|
// src/tool/view-x-video.ts
|
|
2850
2889
|
import { createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema7 } from "@ai-sdk/provider-utils";
|
|
2851
|
-
import { z as
|
|
2852
|
-
var viewXVideoOutputSchema =
|
|
2853
|
-
transcript:
|
|
2854
|
-
description:
|
|
2855
|
-
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")
|
|
2856
2895
|
});
|
|
2857
2896
|
var viewXVideoToolFactory = createProviderToolFactoryWithOutputSchema7({
|
|
2858
2897
|
id: "xai.view_x_video",
|
|
2859
|
-
inputSchema:
|
|
2898
|
+
inputSchema: z15.object({}).describe("no input parameters"),
|
|
2860
2899
|
outputSchema: viewXVideoOutputSchema
|
|
2861
2900
|
});
|
|
2862
2901
|
var viewXVideo = (args = {}) => viewXVideoToolFactory(args);
|
|
@@ -2873,7 +2912,7 @@ var xaiTools = {
|
|
|
2873
2912
|
};
|
|
2874
2913
|
|
|
2875
2914
|
// src/version.ts
|
|
2876
|
-
var VERSION = true ? "3.0.
|
|
2915
|
+
var VERSION = true ? "3.0.105" : "0.0.0-test";
|
|
2877
2916
|
|
|
2878
2917
|
// src/xai-video-model.ts
|
|
2879
2918
|
import {
|
|
@@ -2885,56 +2924,56 @@ import {
|
|
|
2885
2924
|
createJsonResponseHandler as createJsonResponseHandler4,
|
|
2886
2925
|
delay,
|
|
2887
2926
|
getFromApi as getFromApi2,
|
|
2888
|
-
parseProviderOptions as
|
|
2927
|
+
parseProviderOptions as parseProviderOptions6,
|
|
2889
2928
|
postJsonToApi as postJsonToApi4
|
|
2890
2929
|
} from "@ai-sdk/provider-utils";
|
|
2891
|
-
import { z as
|
|
2930
|
+
import { z as z17 } from "zod/v4";
|
|
2892
2931
|
|
|
2893
2932
|
// src/xai-video-options.ts
|
|
2894
2933
|
import { lazySchema as lazySchema5, zodSchema as zodSchema5 } from "@ai-sdk/provider-utils";
|
|
2895
|
-
import { z as
|
|
2896
|
-
var nonEmptyStringSchema =
|
|
2897
|
-
var resolutionSchema =
|
|
2898
|
-
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"]);
|
|
2899
2938
|
var baseFields = {
|
|
2900
|
-
pollIntervalMs:
|
|
2901
|
-
pollTimeoutMs:
|
|
2939
|
+
pollIntervalMs: z16.number().positive().nullish(),
|
|
2940
|
+
pollTimeoutMs: z16.number().positive().nullish(),
|
|
2902
2941
|
resolution: resolutionSchema.nullish()
|
|
2903
2942
|
};
|
|
2904
|
-
var editVideoSchema =
|
|
2943
|
+
var editVideoSchema = z16.object({
|
|
2905
2944
|
...baseFields,
|
|
2906
|
-
mode:
|
|
2945
|
+
mode: z16.literal("edit-video"),
|
|
2907
2946
|
videoUrl: nonEmptyStringSchema,
|
|
2908
|
-
referenceImageUrls:
|
|
2947
|
+
referenceImageUrls: z16.undefined().optional()
|
|
2909
2948
|
});
|
|
2910
|
-
var extendVideoSchema =
|
|
2949
|
+
var extendVideoSchema = z16.object({
|
|
2911
2950
|
...baseFields,
|
|
2912
|
-
mode:
|
|
2951
|
+
mode: z16.literal("extend-video"),
|
|
2913
2952
|
videoUrl: nonEmptyStringSchema,
|
|
2914
|
-
referenceImageUrls:
|
|
2953
|
+
referenceImageUrls: z16.undefined().optional()
|
|
2915
2954
|
});
|
|
2916
|
-
var referenceToVideoSchema =
|
|
2955
|
+
var referenceToVideoSchema = z16.object({
|
|
2917
2956
|
...baseFields,
|
|
2918
|
-
mode:
|
|
2919
|
-
referenceImageUrls:
|
|
2920
|
-
videoUrl:
|
|
2957
|
+
mode: z16.literal("reference-to-video"),
|
|
2958
|
+
referenceImageUrls: z16.array(nonEmptyStringSchema).min(1).max(7),
|
|
2959
|
+
videoUrl: z16.undefined().optional()
|
|
2921
2960
|
});
|
|
2922
|
-
var autoDetectSchema =
|
|
2961
|
+
var autoDetectSchema = z16.object({
|
|
2923
2962
|
...baseFields,
|
|
2924
|
-
mode:
|
|
2963
|
+
mode: z16.undefined().optional(),
|
|
2925
2964
|
videoUrl: nonEmptyStringSchema.optional(),
|
|
2926
|
-
referenceImageUrls:
|
|
2965
|
+
referenceImageUrls: z16.array(nonEmptyStringSchema).min(1).max(7).optional()
|
|
2927
2966
|
});
|
|
2928
|
-
var xaiVideoModelOptions =
|
|
2967
|
+
var xaiVideoModelOptions = z16.union([
|
|
2929
2968
|
editVideoSchema,
|
|
2930
2969
|
extendVideoSchema,
|
|
2931
2970
|
referenceToVideoSchema,
|
|
2932
2971
|
autoDetectSchema
|
|
2933
2972
|
]);
|
|
2934
|
-
var runtimeSchema =
|
|
2973
|
+
var runtimeSchema = z16.object({
|
|
2935
2974
|
mode: modeSchema.optional(),
|
|
2936
2975
|
videoUrl: nonEmptyStringSchema.optional(),
|
|
2937
|
-
referenceImageUrls:
|
|
2976
|
+
referenceImageUrls: z16.array(nonEmptyStringSchema).min(1).max(7).optional(),
|
|
2938
2977
|
...baseFields
|
|
2939
2978
|
}).passthrough();
|
|
2940
2979
|
var xaiVideoModelOptionsSchema = lazySchema5(
|
|
@@ -3007,7 +3046,7 @@ var XaiVideoModel = class {
|
|
|
3007
3046
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
3008
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();
|
|
3009
3048
|
const warnings = [];
|
|
3010
|
-
const xaiOptions = await
|
|
3049
|
+
const xaiOptions = await parseProviderOptions6({
|
|
3011
3050
|
provider: "xai",
|
|
3012
3051
|
providerOptions: options.providerOptions,
|
|
3013
3052
|
schema: xaiVideoModelOptionsSchema
|
|
@@ -3246,24 +3285,24 @@ var XaiVideoModel = class {
|
|
|
3246
3285
|
}
|
|
3247
3286
|
}
|
|
3248
3287
|
};
|
|
3249
|
-
var xaiCreateVideoResponseSchema =
|
|
3250
|
-
request_id:
|
|
3288
|
+
var xaiCreateVideoResponseSchema = z17.object({
|
|
3289
|
+
request_id: z17.string().nullish()
|
|
3251
3290
|
});
|
|
3252
|
-
var xaiVideoStatusResponseSchema =
|
|
3253
|
-
status:
|
|
3254
|
-
video:
|
|
3255
|
-
url:
|
|
3256
|
-
duration:
|
|
3257
|
-
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()
|
|
3258
3297
|
}).nullish(),
|
|
3259
|
-
model:
|
|
3260
|
-
usage:
|
|
3261
|
-
cost_in_usd_ticks:
|
|
3298
|
+
model: z17.string().nullish(),
|
|
3299
|
+
usage: z17.object({
|
|
3300
|
+
cost_in_usd_ticks: z17.number().nullish()
|
|
3262
3301
|
}).nullish(),
|
|
3263
|
-
progress:
|
|
3264
|
-
error:
|
|
3265
|
-
code:
|
|
3266
|
-
message:
|
|
3302
|
+
progress: z17.number().nullish(),
|
|
3303
|
+
error: z17.object({
|
|
3304
|
+
code: z17.string().nullish(),
|
|
3305
|
+
message: z17.string().nullish()
|
|
3267
3306
|
}).nullish()
|
|
3268
3307
|
});
|
|
3269
3308
|
|