@ai-sdk/xai 4.0.8 → 4.0.10

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