@ai-sdk/xai 4.0.7 → 4.0.9

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