@ai-sdk/xai 4.0.0-beta.34 → 4.0.0-beta.35

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
@@ -1,50 +1,40 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- VERSION: () => VERSION,
24
- codeExecution: () => codeExecution,
25
- createXai: () => createXai,
26
- mcpServer: () => mcpServer,
27
- viewImage: () => viewImage,
28
- viewXVideo: () => viewXVideo,
29
- webSearch: () => webSearch,
30
- xSearch: () => xSearch,
31
- xai: () => xai,
32
- xaiTools: () => xaiTools
33
- });
34
- module.exports = __toCommonJS(index_exports);
35
-
36
1
  // src/xai-provider.ts
37
- var import_provider7 = require("@ai-sdk/provider");
38
- var import_provider_utils20 = require("@ai-sdk/provider-utils");
2
+ import {
3
+ NoSuchModelError
4
+ } from "@ai-sdk/provider";
5
+ import {
6
+ generateId,
7
+ loadApiKey,
8
+ withoutTrailingSlash,
9
+ withUserAgentSuffix
10
+ } from "@ai-sdk/provider-utils";
39
11
 
40
12
  // src/xai-chat-language-model.ts
41
- var import_provider3 = require("@ai-sdk/provider");
42
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
43
- var import_v43 = require("zod/v4");
13
+ import {
14
+ APICallError
15
+ } from "@ai-sdk/provider";
16
+ import {
17
+ combineHeaders,
18
+ createEventSourceResponseHandler,
19
+ createJsonResponseHandler,
20
+ extractResponseHeaders,
21
+ isCustomReasoning,
22
+ mapReasoningToProviderEffort,
23
+ parseProviderOptions,
24
+ postJsonToApi,
25
+ safeParseJSON
26
+ } from "@ai-sdk/provider-utils";
27
+ import { z as z3 } from "zod/v4";
44
28
 
45
29
  // src/convert-to-xai-chat-messages.ts
46
- var import_provider = require("@ai-sdk/provider");
47
- var import_provider_utils = require("@ai-sdk/provider-utils");
30
+ import {
31
+ UnsupportedFunctionalityError
32
+ } from "@ai-sdk/provider";
33
+ import {
34
+ convertToBase64,
35
+ isProviderReference,
36
+ resolveProviderReference
37
+ } from "@ai-sdk/provider-utils";
48
38
  function convertToXaiChatMessages(prompt) {
49
39
  var _a;
50
40
  const messages = [];
@@ -68,11 +58,11 @@ function convertToXaiChatMessages(prompt) {
68
58
  return { type: "text", text: part.text };
69
59
  }
70
60
  case "file": {
71
- if ((0, import_provider_utils.isProviderReference)(part.data)) {
61
+ if (isProviderReference(part.data)) {
72
62
  return {
73
63
  type: "file",
74
64
  file: {
75
- file_id: (0, import_provider_utils.resolveProviderReference)({
65
+ file_id: resolveProviderReference({
76
66
  reference: part.data,
77
67
  provider: "xai"
78
68
  })
@@ -84,11 +74,11 @@ function convertToXaiChatMessages(prompt) {
84
74
  return {
85
75
  type: "image_url",
86
76
  image_url: {
87
- url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils.convertToBase64)(part.data)}`
77
+ url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`
88
78
  }
89
79
  };
90
80
  } else {
91
- throw new import_provider.UnsupportedFunctionalityError({
81
+ throw new UnsupportedFunctionalityError({
92
82
  functionality: `file part media type ${part.mediaType}`
93
83
  });
94
84
  }
@@ -220,79 +210,79 @@ function mapXaiFinishReason(finishReason) {
220
210
  }
221
211
 
222
212
  // src/xai-chat-options.ts
223
- var import_v4 = require("zod/v4");
224
- var webSourceSchema = import_v4.z.object({
225
- type: import_v4.z.literal("web"),
226
- country: import_v4.z.string().length(2).optional(),
227
- excludedWebsites: import_v4.z.array(import_v4.z.string()).max(5).optional(),
228
- allowedWebsites: import_v4.z.array(import_v4.z.string()).max(5).optional(),
229
- safeSearch: import_v4.z.boolean().optional()
213
+ import { z } from "zod/v4";
214
+ var webSourceSchema = z.object({
215
+ type: z.literal("web"),
216
+ country: z.string().length(2).optional(),
217
+ excludedWebsites: z.array(z.string()).max(5).optional(),
218
+ allowedWebsites: z.array(z.string()).max(5).optional(),
219
+ safeSearch: z.boolean().optional()
230
220
  });
231
- var xSourceSchema = import_v4.z.object({
232
- type: import_v4.z.literal("x"),
233
- excludedXHandles: import_v4.z.array(import_v4.z.string()).optional(),
234
- includedXHandles: import_v4.z.array(import_v4.z.string()).optional(),
235
- postFavoriteCount: import_v4.z.number().int().optional(),
236
- postViewCount: import_v4.z.number().int().optional(),
221
+ var xSourceSchema = z.object({
222
+ type: z.literal("x"),
223
+ excludedXHandles: z.array(z.string()).optional(),
224
+ includedXHandles: z.array(z.string()).optional(),
225
+ postFavoriteCount: z.number().int().optional(),
226
+ postViewCount: z.number().int().optional(),
237
227
  /**
238
228
  * @deprecated use `includedXHandles` instead
239
229
  */
240
- xHandles: import_v4.z.array(import_v4.z.string()).optional()
230
+ xHandles: z.array(z.string()).optional()
241
231
  });
242
- var newsSourceSchema = import_v4.z.object({
243
- type: import_v4.z.literal("news"),
244
- country: import_v4.z.string().length(2).optional(),
245
- excludedWebsites: import_v4.z.array(import_v4.z.string()).max(5).optional(),
246
- safeSearch: import_v4.z.boolean().optional()
232
+ var newsSourceSchema = z.object({
233
+ type: z.literal("news"),
234
+ country: z.string().length(2).optional(),
235
+ excludedWebsites: z.array(z.string()).max(5).optional(),
236
+ safeSearch: z.boolean().optional()
247
237
  });
248
- var rssSourceSchema = import_v4.z.object({
249
- type: import_v4.z.literal("rss"),
250
- links: import_v4.z.array(import_v4.z.string().url()).max(1)
238
+ var rssSourceSchema = z.object({
239
+ type: z.literal("rss"),
240
+ links: z.array(z.string().url()).max(1)
251
241
  // currently only supports one RSS link
252
242
  });
253
- var searchSourceSchema = import_v4.z.discriminatedUnion("type", [
243
+ var searchSourceSchema = z.discriminatedUnion("type", [
254
244
  webSourceSchema,
255
245
  xSourceSchema,
256
246
  newsSourceSchema,
257
247
  rssSourceSchema
258
248
  ]);
259
- var xaiLanguageModelChatOptions = import_v4.z.object({
260
- reasoningEffort: import_v4.z.enum(["low", "high"]).optional(),
261
- logprobs: import_v4.z.boolean().optional(),
262
- topLogprobs: import_v4.z.number().int().min(0).max(8).optional(),
249
+ var xaiLanguageModelChatOptions = z.object({
250
+ reasoningEffort: z.enum(["low", "high"]).optional(),
251
+ logprobs: z.boolean().optional(),
252
+ topLogprobs: z.number().int().min(0).max(8).optional(),
263
253
  /**
264
254
  * Whether to enable parallel function calling during tool use.
265
255
  * When true, the model can call multiple functions in parallel.
266
256
  * When false, the model will call functions sequentially.
267
257
  * Defaults to true.
268
258
  */
269
- parallel_function_calling: import_v4.z.boolean().optional(),
270
- searchParameters: import_v4.z.object({
259
+ parallel_function_calling: z.boolean().optional(),
260
+ searchParameters: z.object({
271
261
  /**
272
262
  * search mode preference
273
263
  * - "off": disables search completely
274
264
  * - "auto": model decides whether to search (default)
275
265
  * - "on": always enables search
276
266
  */
277
- mode: import_v4.z.enum(["off", "auto", "on"]),
267
+ mode: z.enum(["off", "auto", "on"]),
278
268
  /**
279
269
  * whether to return citations in the response
280
270
  * defaults to true
281
271
  */
282
- returnCitations: import_v4.z.boolean().optional(),
272
+ returnCitations: z.boolean().optional(),
283
273
  /**
284
274
  * start date for search data (ISO8601 format: YYYY-MM-DD)
285
275
  */
286
- fromDate: import_v4.z.string().optional(),
276
+ fromDate: z.string().optional(),
287
277
  /**
288
278
  * end date for search data (ISO8601 format: YYYY-MM-DD)
289
279
  */
290
- toDate: import_v4.z.string().optional(),
280
+ toDate: z.string().optional(),
291
281
  /**
292
282
  * maximum number of search results to consider
293
283
  * defaults to 20
294
284
  */
295
- maxSearchResults: import_v4.z.number().min(1).max(50).optional(),
285
+ maxSearchResults: z.number().min(1).max(50).optional(),
296
286
  /**
297
287
  * data sources to search from.
298
288
  * defaults to [{ type: 'web' }, { type: 'x' }] if not specified.
@@ -300,28 +290,30 @@ var xaiLanguageModelChatOptions = import_v4.z.object({
300
290
  * @example
301
291
  * sources: [{ type: 'web', country: 'US' }, { type: 'x' }]
302
292
  */
303
- sources: import_v4.z.array(searchSourceSchema).optional()
293
+ sources: z.array(searchSourceSchema).optional()
304
294
  }).optional()
305
295
  });
306
296
 
307
297
  // src/xai-error.ts
308
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
309
- var import_v42 = require("zod/v4");
310
- var xaiErrorDataSchema = import_v42.z.object({
311
- error: import_v42.z.object({
312
- message: import_v42.z.string(),
313
- type: import_v42.z.string().nullish(),
314
- param: import_v42.z.any().nullish(),
315
- code: import_v42.z.union([import_v42.z.string(), import_v42.z.number()]).nullish()
298
+ import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
299
+ import { z as z2 } from "zod/v4";
300
+ var xaiErrorDataSchema = z2.object({
301
+ error: z2.object({
302
+ message: z2.string(),
303
+ type: z2.string().nullish(),
304
+ param: z2.any().nullish(),
305
+ code: z2.union([z2.string(), z2.number()]).nullish()
316
306
  })
317
307
  });
318
- var xaiFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResponseHandler)({
308
+ var xaiFailedResponseHandler = createJsonErrorResponseHandler({
319
309
  errorSchema: xaiErrorDataSchema,
320
310
  errorToMessage: (data) => data.error.message
321
311
  });
322
312
 
323
313
  // src/xai-prepare-tools.ts
324
- var import_provider2 = require("@ai-sdk/provider");
314
+ import {
315
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError2
316
+ } from "@ai-sdk/provider";
325
317
  function prepareTools({
326
318
  tools,
327
319
  toolChoice
@@ -371,7 +363,7 @@ function prepareTools({
371
363
  };
372
364
  default: {
373
365
  const _exhaustiveCheck = type;
374
- throw new import_provider2.UnsupportedFunctionalityError({
366
+ throw new UnsupportedFunctionalityError2({
375
367
  functionality: `tool choice type: ${_exhaustiveCheck}`
376
368
  });
377
369
  }
@@ -409,7 +401,7 @@ var XaiChatLanguageModel = class {
409
401
  }) {
410
402
  var _a, _b, _c, _d;
411
403
  const warnings = [];
412
- const options = (_a = await (0, import_provider_utils3.parseProviderOptions)({
404
+ const options = (_a = await parseProviderOptions({
413
405
  provider: "xai",
414
406
  providerOptions,
415
407
  schema: xaiLanguageModelChatOptions
@@ -447,7 +439,7 @@ var XaiChatLanguageModel = class {
447
439
  temperature,
448
440
  top_p: topP,
449
441
  seed,
450
- reasoning_effort: (_b = options.reasoningEffort) != null ? _b : (0, import_provider_utils3.isCustomReasoning)(reasoning) ? reasoning === "none" ? void 0 : (0, import_provider_utils3.mapReasoningToProviderEffort)({
442
+ reasoning_effort: (_b = options.reasoningEffort) != null ? _b : isCustomReasoning(reasoning) ? reasoning === "none" ? void 0 : mapReasoningToProviderEffort({
451
443
  reasoning,
452
444
  effortMap: {
453
445
  minimal: "low",
@@ -522,19 +514,19 @@ var XaiChatLanguageModel = class {
522
514
  responseHeaders,
523
515
  value: response,
524
516
  rawValue: rawResponse
525
- } = await (0, import_provider_utils3.postJsonToApi)({
517
+ } = await postJsonToApi({
526
518
  url,
527
- headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
519
+ headers: combineHeaders(this.config.headers(), options.headers),
528
520
  body,
529
521
  failedResponseHandler: xaiFailedResponseHandler,
530
- successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
522
+ successfulResponseHandler: createJsonResponseHandler(
531
523
  xaiChatResponseSchema
532
524
  ),
533
525
  abortSignal: options.abortSignal,
534
526
  fetch: this.config.fetch
535
527
  });
536
528
  if (response.error != null) {
537
- throw new import_provider3.APICallError({
529
+ throw new APICallError({
538
530
  message: response.error,
539
531
  url,
540
532
  requestBodyValues: body,
@@ -612,22 +604,22 @@ var XaiChatLanguageModel = class {
612
604
  }
613
605
  };
614
606
  const url = `${(_a = this.config.baseURL) != null ? _a : "https://api.x.ai/v1"}/chat/completions`;
615
- const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({
607
+ const { responseHeaders, value: response } = await postJsonToApi({
616
608
  url,
617
- headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
609
+ headers: combineHeaders(this.config.headers(), options.headers),
618
610
  body,
619
611
  failedResponseHandler: xaiFailedResponseHandler,
620
612
  successfulResponseHandler: async ({ response: response2 }) => {
621
- const responseHeaders2 = (0, import_provider_utils3.extractResponseHeaders)(response2);
613
+ const responseHeaders2 = extractResponseHeaders(response2);
622
614
  const contentType = response2.headers.get("content-type");
623
615
  if (contentType == null ? void 0 : contentType.includes("application/json")) {
624
616
  const responseBody = await response2.text();
625
- const parsedError = await (0, import_provider_utils3.safeParseJSON)({
617
+ const parsedError = await safeParseJSON({
626
618
  text: responseBody,
627
619
  schema: xaiStreamErrorSchema
628
620
  });
629
621
  if (parsedError.success) {
630
- throw new import_provider3.APICallError({
622
+ throw new APICallError({
631
623
  message: parsedError.value.error,
632
624
  url,
633
625
  requestBodyValues: body,
@@ -637,7 +629,7 @@ var XaiChatLanguageModel = class {
637
629
  isRetryable: parsedError.value.code === "The service is currently unavailable"
638
630
  });
639
631
  }
640
- throw new import_provider3.APICallError({
632
+ throw new APICallError({
641
633
  message: "Invalid JSON response",
642
634
  url,
643
635
  requestBodyValues: body,
@@ -646,7 +638,7 @@ var XaiChatLanguageModel = class {
646
638
  responseBody
647
639
  });
648
640
  }
649
- return (0, import_provider_utils3.createEventSourceResponseHandler)(xaiChatChunkSchema)({
641
+ return createEventSourceResponseHandler(xaiChatChunkSchema)({
650
642
  response: response2,
651
643
  url,
652
644
  requestBodyValues: body
@@ -824,100 +816,109 @@ var XaiChatLanguageModel = class {
824
816
  };
825
817
  }
826
818
  };
827
- var xaiUsageSchema = import_v43.z.object({
828
- prompt_tokens: import_v43.z.number(),
829
- completion_tokens: import_v43.z.number(),
830
- total_tokens: import_v43.z.number(),
831
- prompt_tokens_details: import_v43.z.object({
832
- text_tokens: import_v43.z.number().nullish(),
833
- audio_tokens: import_v43.z.number().nullish(),
834
- image_tokens: import_v43.z.number().nullish(),
835
- cached_tokens: import_v43.z.number().nullish()
819
+ var xaiUsageSchema = z3.object({
820
+ prompt_tokens: z3.number(),
821
+ completion_tokens: z3.number(),
822
+ total_tokens: z3.number(),
823
+ prompt_tokens_details: z3.object({
824
+ text_tokens: z3.number().nullish(),
825
+ audio_tokens: z3.number().nullish(),
826
+ image_tokens: z3.number().nullish(),
827
+ cached_tokens: z3.number().nullish()
836
828
  }).nullish(),
837
- completion_tokens_details: import_v43.z.object({
838
- reasoning_tokens: import_v43.z.number().nullish(),
839
- audio_tokens: import_v43.z.number().nullish(),
840
- accepted_prediction_tokens: import_v43.z.number().nullish(),
841
- rejected_prediction_tokens: import_v43.z.number().nullish()
829
+ completion_tokens_details: z3.object({
830
+ reasoning_tokens: z3.number().nullish(),
831
+ audio_tokens: z3.number().nullish(),
832
+ accepted_prediction_tokens: z3.number().nullish(),
833
+ rejected_prediction_tokens: z3.number().nullish()
842
834
  }).nullish()
843
835
  });
844
- var xaiChatResponseSchema = import_v43.z.object({
845
- id: import_v43.z.string().nullish(),
846
- created: import_v43.z.number().nullish(),
847
- model: import_v43.z.string().nullish(),
848
- choices: import_v43.z.array(
849
- import_v43.z.object({
850
- message: import_v43.z.object({
851
- role: import_v43.z.literal("assistant"),
852
- content: import_v43.z.string().nullish(),
853
- reasoning_content: import_v43.z.string().nullish(),
854
- tool_calls: import_v43.z.array(
855
- import_v43.z.object({
856
- id: import_v43.z.string(),
857
- type: import_v43.z.literal("function"),
858
- function: import_v43.z.object({
859
- name: import_v43.z.string(),
860
- arguments: import_v43.z.string()
836
+ var xaiChatResponseSchema = z3.object({
837
+ id: z3.string().nullish(),
838
+ created: z3.number().nullish(),
839
+ model: z3.string().nullish(),
840
+ choices: z3.array(
841
+ z3.object({
842
+ message: z3.object({
843
+ role: z3.literal("assistant"),
844
+ content: z3.string().nullish(),
845
+ reasoning_content: z3.string().nullish(),
846
+ tool_calls: z3.array(
847
+ z3.object({
848
+ id: z3.string(),
849
+ type: z3.literal("function"),
850
+ function: z3.object({
851
+ name: z3.string(),
852
+ arguments: z3.string()
861
853
  })
862
854
  })
863
855
  ).nullish()
864
856
  }),
865
- index: import_v43.z.number(),
866
- finish_reason: import_v43.z.string().nullish()
857
+ index: z3.number(),
858
+ finish_reason: z3.string().nullish()
867
859
  })
868
860
  ).nullish(),
869
- object: import_v43.z.literal("chat.completion").nullish(),
861
+ object: z3.literal("chat.completion").nullish(),
870
862
  usage: xaiUsageSchema.nullish(),
871
- citations: import_v43.z.array(import_v43.z.string().url()).nullish(),
872
- code: import_v43.z.string().nullish(),
873
- error: import_v43.z.string().nullish()
863
+ citations: z3.array(z3.string().url()).nullish(),
864
+ code: z3.string().nullish(),
865
+ error: z3.string().nullish()
874
866
  });
875
- var xaiChatChunkSchema = import_v43.z.object({
876
- id: import_v43.z.string().nullish(),
877
- created: import_v43.z.number().nullish(),
878
- model: import_v43.z.string().nullish(),
879
- choices: import_v43.z.array(
880
- import_v43.z.object({
881
- delta: import_v43.z.object({
882
- role: import_v43.z.enum(["assistant"]).optional(),
883
- content: import_v43.z.string().nullish(),
884
- reasoning_content: import_v43.z.string().nullish(),
885
- tool_calls: import_v43.z.array(
886
- import_v43.z.object({
887
- id: import_v43.z.string(),
888
- type: import_v43.z.literal("function"),
889
- function: import_v43.z.object({
890
- name: import_v43.z.string(),
891
- arguments: import_v43.z.string()
867
+ var xaiChatChunkSchema = z3.object({
868
+ id: z3.string().nullish(),
869
+ created: z3.number().nullish(),
870
+ model: z3.string().nullish(),
871
+ choices: z3.array(
872
+ z3.object({
873
+ delta: z3.object({
874
+ role: z3.enum(["assistant"]).optional(),
875
+ content: z3.string().nullish(),
876
+ reasoning_content: z3.string().nullish(),
877
+ tool_calls: z3.array(
878
+ z3.object({
879
+ id: z3.string(),
880
+ type: z3.literal("function"),
881
+ function: z3.object({
882
+ name: z3.string(),
883
+ arguments: z3.string()
892
884
  })
893
885
  })
894
886
  ).nullish()
895
887
  }),
896
- finish_reason: import_v43.z.string().nullish(),
897
- index: import_v43.z.number()
888
+ finish_reason: z3.string().nullish(),
889
+ index: z3.number()
898
890
  })
899
891
  ),
900
892
  usage: xaiUsageSchema.nullish(),
901
- citations: import_v43.z.array(import_v43.z.string().url()).nullish()
893
+ citations: z3.array(z3.string().url()).nullish()
902
894
  });
903
- var xaiStreamErrorSchema = import_v43.z.object({
904
- code: import_v43.z.string(),
905
- error: import_v43.z.string()
895
+ var xaiStreamErrorSchema = z3.object({
896
+ code: z3.string(),
897
+ error: z3.string()
906
898
  });
907
899
 
908
900
  // src/xai-image-model.ts
909
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
910
- var import_v45 = require("zod/v4");
901
+ import {
902
+ combineHeaders as combineHeaders2,
903
+ convertImageModelFileToDataUri,
904
+ createBinaryResponseHandler,
905
+ createJsonResponseHandler as createJsonResponseHandler2,
906
+ createStatusCodeErrorResponseHandler,
907
+ getFromApi,
908
+ parseProviderOptions as parseProviderOptions2,
909
+ postJsonToApi as postJsonToApi2
910
+ } from "@ai-sdk/provider-utils";
911
+ import { z as z5 } from "zod/v4";
911
912
 
912
913
  // src/xai-image-options.ts
913
- var import_v44 = require("zod/v4");
914
- var xaiImageModelOptions = import_v44.z.object({
915
- aspect_ratio: import_v44.z.string().optional(),
916
- output_format: import_v44.z.string().optional(),
917
- sync_mode: import_v44.z.boolean().optional(),
918
- resolution: import_v44.z.enum(["1k", "2k"]).optional(),
919
- quality: import_v44.z.enum(["low", "medium", "high"]).optional(),
920
- user: import_v44.z.string().optional()
914
+ import { z as z4 } from "zod/v4";
915
+ var xaiImageModelOptions = z4.object({
916
+ aspect_ratio: z4.string().optional(),
917
+ output_format: z4.string().optional(),
918
+ sync_mode: z4.boolean().optional(),
919
+ resolution: z4.enum(["1k", "2k"]).optional(),
920
+ quality: z4.enum(["low", "medium", "high"]).optional(),
921
+ user: z4.string().optional()
921
922
  });
922
923
 
923
924
  // src/xai-image-model.ts
@@ -964,13 +965,13 @@ var XaiImageModel = class {
964
965
  feature: "mask"
965
966
  });
966
967
  }
967
- const xaiOptions = await (0, import_provider_utils4.parseProviderOptions)({
968
+ const xaiOptions = await parseProviderOptions2({
968
969
  provider: "xai",
969
970
  providerOptions,
970
971
  schema: xaiImageModelOptions
971
972
  });
972
973
  const hasFiles = files != null && files.length > 0;
973
- const imageUrls = hasFiles ? files.map((file) => (0, import_provider_utils4.convertImageModelFileToDataUri)(file)) : [];
974
+ const imageUrls = hasFiles ? files.map((file) => convertImageModelFileToDataUri(file)) : [];
974
975
  const endpoint = hasFiles ? "/images/edits" : "/images/generations";
975
976
  const body = {
976
977
  model: this.modelId,
@@ -1006,12 +1007,12 @@ var XaiImageModel = class {
1006
1007
  }
1007
1008
  const baseURL = (_a = this.config.baseURL) != null ? _a : "https://api.x.ai/v1";
1008
1009
  const currentDate = (_d = (_c = (_b = this.config._internal) == null ? void 0 : _b.currentDate) == null ? void 0 : _c.call(_b)) != null ? _d : /* @__PURE__ */ new Date();
1009
- const { value: response, responseHeaders } = await (0, import_provider_utils4.postJsonToApi)({
1010
+ const { value: response, responseHeaders } = await postJsonToApi2({
1010
1011
  url: `${baseURL}${endpoint}`,
1011
- headers: (0, import_provider_utils4.combineHeaders)(this.config.headers(), headers),
1012
+ headers: combineHeaders2(this.config.headers(), headers),
1012
1013
  body,
1013
1014
  failedResponseHandler: xaiFailedResponseHandler,
1014
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
1015
+ successfulResponseHandler: createJsonResponseHandler2(
1015
1016
  xaiImageResponseSchema
1016
1017
  ),
1017
1018
  abortSignal,
@@ -1042,35 +1043,49 @@ var XaiImageModel = class {
1042
1043
  };
1043
1044
  }
1044
1045
  async downloadImage(url, abortSignal) {
1045
- const { value } = await (0, import_provider_utils4.getFromApi)({
1046
+ const { value } = await getFromApi({
1046
1047
  url,
1047
1048
  abortSignal,
1048
- failedResponseHandler: (0, import_provider_utils4.createStatusCodeErrorResponseHandler)(),
1049
- successfulResponseHandler: (0, import_provider_utils4.createBinaryResponseHandler)(),
1049
+ failedResponseHandler: createStatusCodeErrorResponseHandler(),
1050
+ successfulResponseHandler: createBinaryResponseHandler(),
1050
1051
  fetch: this.config.fetch
1051
1052
  });
1052
1053
  return value;
1053
1054
  }
1054
1055
  };
1055
- var xaiImageResponseSchema = import_v45.z.object({
1056
- data: import_v45.z.array(
1057
- import_v45.z.object({
1058
- url: import_v45.z.string().nullish(),
1059
- b64_json: import_v45.z.string().nullish(),
1060
- revised_prompt: import_v45.z.string().nullish()
1056
+ var xaiImageResponseSchema = z5.object({
1057
+ data: z5.array(
1058
+ z5.object({
1059
+ url: z5.string().nullish(),
1060
+ b64_json: z5.string().nullish(),
1061
+ revised_prompt: z5.string().nullish()
1061
1062
  })
1062
1063
  ),
1063
- usage: import_v45.z.object({
1064
- cost_in_usd_ticks: import_v45.z.number().nullish()
1064
+ usage: z5.object({
1065
+ cost_in_usd_ticks: z5.number().nullish()
1065
1066
  }).nullish()
1066
1067
  });
1067
1068
 
1068
1069
  // src/responses/xai-responses-language-model.ts
1069
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
1070
+ import {
1071
+ combineHeaders as combineHeaders3,
1072
+ createEventSourceResponseHandler as createEventSourceResponseHandler2,
1073
+ createJsonResponseHandler as createJsonResponseHandler3,
1074
+ isCustomReasoning as isCustomReasoning2,
1075
+ mapReasoningToProviderEffort as mapReasoningToProviderEffort2,
1076
+ parseProviderOptions as parseProviderOptions3,
1077
+ postJsonToApi as postJsonToApi3
1078
+ } from "@ai-sdk/provider-utils";
1070
1079
 
1071
1080
  // src/responses/convert-to-xai-responses-input.ts
1072
- var import_provider4 = require("@ai-sdk/provider");
1073
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
1081
+ import {
1082
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError3
1083
+ } from "@ai-sdk/provider";
1084
+ import {
1085
+ convertToBase64 as convertToBase642,
1086
+ isProviderReference as isProviderReference2,
1087
+ resolveProviderReference as resolveProviderReference2
1088
+ } from "@ai-sdk/provider-utils";
1074
1089
  async function convertToXaiResponsesInput({
1075
1090
  prompt
1076
1091
  }) {
@@ -1095,20 +1110,20 @@ async function convertToXaiResponsesInput({
1095
1110
  break;
1096
1111
  }
1097
1112
  case "file": {
1098
- if ((0, import_provider_utils5.isProviderReference)(block.data)) {
1113
+ if (isProviderReference2(block.data)) {
1099
1114
  contentParts.push({
1100
1115
  type: "input_file",
1101
- file_id: (0, import_provider_utils5.resolveProviderReference)({
1116
+ file_id: resolveProviderReference2({
1102
1117
  reference: block.data,
1103
1118
  provider: "xai"
1104
1119
  })
1105
1120
  });
1106
1121
  } else if (block.mediaType.startsWith("image/")) {
1107
1122
  const mediaType = block.mediaType === "image/*" ? "image/jpeg" : block.mediaType;
1108
- const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils5.convertToBase64)(block.data)}`;
1123
+ const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${convertToBase642(block.data)}`;
1109
1124
  contentParts.push({ type: "input_image", image_url: imageUrl });
1110
1125
  } else {
1111
- throw new import_provider4.UnsupportedFunctionalityError({
1126
+ throw new UnsupportedFunctionalityError3({
1112
1127
  functionality: `file part media type ${block.mediaType}`
1113
1128
  });
1114
1129
  }
@@ -1274,594 +1289,612 @@ function mapXaiResponsesFinishReason(finishReason) {
1274
1289
  }
1275
1290
 
1276
1291
  // src/responses/xai-responses-api.ts
1277
- var import_v46 = require("zod/v4");
1278
- var annotationSchema = import_v46.z.union([
1279
- import_v46.z.object({
1280
- type: import_v46.z.literal("url_citation"),
1281
- url: import_v46.z.string(),
1282
- title: import_v46.z.string().optional()
1292
+ import { z as z6 } from "zod/v4";
1293
+ var annotationSchema = z6.union([
1294
+ z6.object({
1295
+ type: z6.literal("url_citation"),
1296
+ url: z6.string(),
1297
+ title: z6.string().optional()
1283
1298
  }),
1284
- import_v46.z.object({
1285
- type: import_v46.z.string()
1299
+ z6.object({
1300
+ type: z6.string()
1286
1301
  })
1287
1302
  ]);
1288
- var messageContentPartSchema = import_v46.z.object({
1289
- type: import_v46.z.string(),
1290
- text: import_v46.z.string().optional(),
1291
- logprobs: import_v46.z.array(import_v46.z.any()).optional(),
1292
- annotations: import_v46.z.array(annotationSchema).optional()
1303
+ var messageContentPartSchema = z6.object({
1304
+ type: z6.string(),
1305
+ text: z6.string().optional(),
1306
+ logprobs: z6.array(z6.any()).optional(),
1307
+ annotations: z6.array(annotationSchema).optional()
1293
1308
  });
1294
- var reasoningSummaryPartSchema = import_v46.z.object({
1295
- type: import_v46.z.string(),
1296
- text: import_v46.z.string()
1309
+ var reasoningSummaryPartSchema = z6.object({
1310
+ type: z6.string(),
1311
+ text: z6.string()
1297
1312
  });
1298
- var toolCallSchema = import_v46.z.object({
1299
- name: import_v46.z.string().optional(),
1300
- arguments: import_v46.z.string().optional(),
1301
- input: import_v46.z.string().optional(),
1302
- call_id: import_v46.z.string().optional(),
1303
- id: import_v46.z.string(),
1304
- status: import_v46.z.string(),
1305
- action: import_v46.z.any().optional()
1313
+ var toolCallSchema = z6.object({
1314
+ name: z6.string().optional(),
1315
+ arguments: z6.string().optional(),
1316
+ input: z6.string().optional(),
1317
+ call_id: z6.string().optional(),
1318
+ id: z6.string(),
1319
+ status: z6.string(),
1320
+ action: z6.any().optional()
1306
1321
  });
1307
- var mcpCallSchema = import_v46.z.object({
1308
- name: import_v46.z.string().optional(),
1309
- arguments: import_v46.z.string().optional(),
1310
- output: import_v46.z.string().optional(),
1311
- error: import_v46.z.string().optional(),
1312
- id: import_v46.z.string(),
1313
- status: import_v46.z.string(),
1314
- server_label: import_v46.z.string().optional()
1322
+ var mcpCallSchema = z6.object({
1323
+ name: z6.string().optional(),
1324
+ arguments: z6.string().optional(),
1325
+ output: z6.string().optional(),
1326
+ error: z6.string().optional(),
1327
+ id: z6.string(),
1328
+ status: z6.string(),
1329
+ server_label: z6.string().optional()
1315
1330
  });
1316
- var outputItemSchema = import_v46.z.discriminatedUnion("type", [
1317
- import_v46.z.object({
1318
- type: import_v46.z.literal("web_search_call"),
1331
+ var outputItemSchema = z6.discriminatedUnion("type", [
1332
+ z6.object({
1333
+ type: z6.literal("web_search_call"),
1319
1334
  ...toolCallSchema.shape
1320
1335
  }),
1321
- import_v46.z.object({
1322
- type: import_v46.z.literal("x_search_call"),
1336
+ z6.object({
1337
+ type: z6.literal("x_search_call"),
1323
1338
  ...toolCallSchema.shape
1324
1339
  }),
1325
- import_v46.z.object({
1326
- type: import_v46.z.literal("code_interpreter_call"),
1340
+ z6.object({
1341
+ type: z6.literal("code_interpreter_call"),
1327
1342
  ...toolCallSchema.shape
1328
1343
  }),
1329
- import_v46.z.object({
1330
- type: import_v46.z.literal("code_execution_call"),
1344
+ z6.object({
1345
+ type: z6.literal("code_execution_call"),
1331
1346
  ...toolCallSchema.shape
1332
1347
  }),
1333
- import_v46.z.object({
1334
- type: import_v46.z.literal("view_image_call"),
1348
+ z6.object({
1349
+ type: z6.literal("view_image_call"),
1335
1350
  ...toolCallSchema.shape
1336
1351
  }),
1337
- import_v46.z.object({
1338
- type: import_v46.z.literal("view_x_video_call"),
1352
+ z6.object({
1353
+ type: z6.literal("view_x_video_call"),
1339
1354
  ...toolCallSchema.shape
1340
1355
  }),
1341
- import_v46.z.object({
1342
- type: import_v46.z.literal("file_search_call"),
1343
- id: import_v46.z.string(),
1344
- status: import_v46.z.string(),
1345
- queries: import_v46.z.array(import_v46.z.string()).optional(),
1346
- results: import_v46.z.array(
1347
- import_v46.z.object({
1348
- file_id: import_v46.z.string(),
1349
- filename: import_v46.z.string(),
1350
- score: import_v46.z.number(),
1351
- text: import_v46.z.string()
1356
+ z6.object({
1357
+ type: z6.literal("file_search_call"),
1358
+ id: z6.string(),
1359
+ status: z6.string(),
1360
+ queries: z6.array(z6.string()).optional(),
1361
+ results: z6.array(
1362
+ z6.object({
1363
+ file_id: z6.string(),
1364
+ filename: z6.string(),
1365
+ score: z6.number(),
1366
+ text: z6.string()
1352
1367
  })
1353
1368
  ).nullish()
1354
1369
  }),
1355
- import_v46.z.object({
1356
- type: import_v46.z.literal("custom_tool_call"),
1370
+ z6.object({
1371
+ type: z6.literal("custom_tool_call"),
1357
1372
  ...toolCallSchema.shape
1358
1373
  }),
1359
- import_v46.z.object({
1360
- type: import_v46.z.literal("mcp_call"),
1374
+ z6.object({
1375
+ type: z6.literal("mcp_call"),
1361
1376
  ...mcpCallSchema.shape
1362
1377
  }),
1363
- import_v46.z.object({
1364
- type: import_v46.z.literal("message"),
1365
- role: import_v46.z.string(),
1366
- content: import_v46.z.array(messageContentPartSchema),
1367
- id: import_v46.z.string(),
1368
- status: import_v46.z.string()
1378
+ z6.object({
1379
+ type: z6.literal("message"),
1380
+ role: z6.string(),
1381
+ content: z6.array(messageContentPartSchema),
1382
+ id: z6.string(),
1383
+ status: z6.string()
1369
1384
  }),
1370
- import_v46.z.object({
1371
- type: import_v46.z.literal("function_call"),
1372
- name: import_v46.z.string(),
1373
- arguments: import_v46.z.string(),
1374
- call_id: import_v46.z.string(),
1375
- id: import_v46.z.string()
1385
+ z6.object({
1386
+ type: z6.literal("function_call"),
1387
+ name: z6.string(),
1388
+ arguments: z6.string(),
1389
+ call_id: z6.string(),
1390
+ id: z6.string()
1376
1391
  }),
1377
- import_v46.z.object({
1378
- type: import_v46.z.literal("reasoning"),
1379
- id: import_v46.z.string(),
1380
- summary: import_v46.z.array(reasoningSummaryPartSchema),
1381
- content: import_v46.z.array(import_v46.z.object({ type: import_v46.z.string(), text: import_v46.z.string() })).nullish(),
1382
- status: import_v46.z.string(),
1383
- encrypted_content: import_v46.z.string().nullish()
1392
+ z6.object({
1393
+ type: z6.literal("reasoning"),
1394
+ id: z6.string(),
1395
+ summary: z6.array(reasoningSummaryPartSchema),
1396
+ content: z6.array(z6.object({ type: z6.string(), text: z6.string() })).nullish(),
1397
+ status: z6.string(),
1398
+ encrypted_content: z6.string().nullish()
1384
1399
  })
1385
1400
  ]);
1386
- var xaiResponsesUsageSchema = import_v46.z.object({
1387
- input_tokens: import_v46.z.number(),
1388
- output_tokens: import_v46.z.number(),
1389
- total_tokens: import_v46.z.number().optional(),
1390
- input_tokens_details: import_v46.z.object({
1391
- cached_tokens: import_v46.z.number().optional()
1401
+ var xaiResponsesUsageSchema = z6.object({
1402
+ input_tokens: z6.number(),
1403
+ output_tokens: z6.number(),
1404
+ total_tokens: z6.number().optional(),
1405
+ input_tokens_details: z6.object({
1406
+ cached_tokens: z6.number().optional()
1392
1407
  }).optional(),
1393
- output_tokens_details: import_v46.z.object({
1394
- reasoning_tokens: import_v46.z.number().optional()
1408
+ output_tokens_details: z6.object({
1409
+ reasoning_tokens: z6.number().optional()
1395
1410
  }).optional(),
1396
- num_sources_used: import_v46.z.number().optional(),
1397
- num_server_side_tools_used: import_v46.z.number().optional()
1411
+ num_sources_used: z6.number().optional(),
1412
+ num_server_side_tools_used: z6.number().optional()
1398
1413
  });
1399
- var xaiResponsesResponseSchema = import_v46.z.object({
1400
- id: import_v46.z.string().nullish(),
1401
- created_at: import_v46.z.number().nullish(),
1402
- model: import_v46.z.string().nullish(),
1403
- object: import_v46.z.literal("response"),
1404
- output: import_v46.z.array(outputItemSchema),
1414
+ var xaiResponsesResponseSchema = z6.object({
1415
+ id: z6.string().nullish(),
1416
+ created_at: z6.number().nullish(),
1417
+ model: z6.string().nullish(),
1418
+ object: z6.literal("response"),
1419
+ output: z6.array(outputItemSchema),
1405
1420
  usage: xaiResponsesUsageSchema.nullish(),
1406
- status: import_v46.z.string()
1421
+ status: z6.string()
1407
1422
  });
1408
- var xaiResponsesChunkSchema = import_v46.z.union([
1409
- import_v46.z.object({
1410
- type: import_v46.z.literal("response.created"),
1423
+ var xaiResponsesChunkSchema = z6.union([
1424
+ z6.object({
1425
+ type: z6.literal("response.created"),
1411
1426
  response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
1412
1427
  }),
1413
- import_v46.z.object({
1414
- type: import_v46.z.literal("response.in_progress"),
1428
+ z6.object({
1429
+ type: z6.literal("response.in_progress"),
1415
1430
  response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
1416
1431
  }),
1417
- import_v46.z.object({
1418
- type: import_v46.z.literal("response.output_item.added"),
1432
+ z6.object({
1433
+ type: z6.literal("response.output_item.added"),
1419
1434
  item: outputItemSchema,
1420
- output_index: import_v46.z.number()
1435
+ output_index: z6.number()
1421
1436
  }),
1422
- import_v46.z.object({
1423
- type: import_v46.z.literal("response.output_item.done"),
1437
+ z6.object({
1438
+ type: z6.literal("response.output_item.done"),
1424
1439
  item: outputItemSchema,
1425
- output_index: import_v46.z.number()
1440
+ output_index: z6.number()
1426
1441
  }),
1427
- import_v46.z.object({
1428
- type: import_v46.z.literal("response.content_part.added"),
1429
- item_id: import_v46.z.string(),
1430
- output_index: import_v46.z.number(),
1431
- content_index: import_v46.z.number(),
1442
+ z6.object({
1443
+ type: z6.literal("response.content_part.added"),
1444
+ item_id: z6.string(),
1445
+ output_index: z6.number(),
1446
+ content_index: z6.number(),
1432
1447
  part: messageContentPartSchema
1433
1448
  }),
1434
- import_v46.z.object({
1435
- type: import_v46.z.literal("response.content_part.done"),
1436
- item_id: import_v46.z.string(),
1437
- output_index: import_v46.z.number(),
1438
- content_index: import_v46.z.number(),
1449
+ z6.object({
1450
+ type: z6.literal("response.content_part.done"),
1451
+ item_id: z6.string(),
1452
+ output_index: z6.number(),
1453
+ content_index: z6.number(),
1439
1454
  part: messageContentPartSchema
1440
1455
  }),
1441
- import_v46.z.object({
1442
- type: import_v46.z.literal("response.output_text.delta"),
1443
- item_id: import_v46.z.string(),
1444
- output_index: import_v46.z.number(),
1445
- content_index: import_v46.z.number(),
1446
- delta: import_v46.z.string(),
1447
- logprobs: import_v46.z.array(import_v46.z.any()).optional()
1456
+ z6.object({
1457
+ type: z6.literal("response.output_text.delta"),
1458
+ item_id: z6.string(),
1459
+ output_index: z6.number(),
1460
+ content_index: z6.number(),
1461
+ delta: z6.string(),
1462
+ logprobs: z6.array(z6.any()).optional()
1448
1463
  }),
1449
- import_v46.z.object({
1450
- type: import_v46.z.literal("response.output_text.done"),
1451
- item_id: import_v46.z.string(),
1452
- output_index: import_v46.z.number(),
1453
- content_index: import_v46.z.number(),
1454
- text: import_v46.z.string(),
1455
- logprobs: import_v46.z.array(import_v46.z.any()).optional(),
1456
- annotations: import_v46.z.array(annotationSchema).optional()
1464
+ z6.object({
1465
+ type: z6.literal("response.output_text.done"),
1466
+ item_id: z6.string(),
1467
+ output_index: z6.number(),
1468
+ content_index: z6.number(),
1469
+ text: z6.string(),
1470
+ logprobs: z6.array(z6.any()).optional(),
1471
+ annotations: z6.array(annotationSchema).optional()
1457
1472
  }),
1458
- import_v46.z.object({
1459
- type: import_v46.z.literal("response.output_text.annotation.added"),
1460
- item_id: import_v46.z.string(),
1461
- output_index: import_v46.z.number(),
1462
- content_index: import_v46.z.number(),
1463
- annotation_index: import_v46.z.number(),
1473
+ z6.object({
1474
+ type: z6.literal("response.output_text.annotation.added"),
1475
+ item_id: z6.string(),
1476
+ output_index: z6.number(),
1477
+ content_index: z6.number(),
1478
+ annotation_index: z6.number(),
1464
1479
  annotation: annotationSchema
1465
1480
  }),
1466
- import_v46.z.object({
1467
- type: import_v46.z.literal("response.reasoning_summary_part.added"),
1468
- item_id: import_v46.z.string(),
1469
- output_index: import_v46.z.number(),
1470
- summary_index: import_v46.z.number(),
1481
+ z6.object({
1482
+ type: z6.literal("response.reasoning_summary_part.added"),
1483
+ item_id: z6.string(),
1484
+ output_index: z6.number(),
1485
+ summary_index: z6.number(),
1471
1486
  part: reasoningSummaryPartSchema
1472
1487
  }),
1473
- import_v46.z.object({
1474
- type: import_v46.z.literal("response.reasoning_summary_part.done"),
1475
- item_id: import_v46.z.string(),
1476
- output_index: import_v46.z.number(),
1477
- summary_index: import_v46.z.number(),
1488
+ z6.object({
1489
+ type: z6.literal("response.reasoning_summary_part.done"),
1490
+ item_id: z6.string(),
1491
+ output_index: z6.number(),
1492
+ summary_index: z6.number(),
1478
1493
  part: reasoningSummaryPartSchema
1479
1494
  }),
1480
- import_v46.z.object({
1481
- type: import_v46.z.literal("response.reasoning_summary_text.delta"),
1482
- item_id: import_v46.z.string(),
1483
- output_index: import_v46.z.number(),
1484
- summary_index: import_v46.z.number(),
1485
- delta: import_v46.z.string()
1495
+ z6.object({
1496
+ type: z6.literal("response.reasoning_summary_text.delta"),
1497
+ item_id: z6.string(),
1498
+ output_index: z6.number(),
1499
+ summary_index: z6.number(),
1500
+ delta: z6.string()
1486
1501
  }),
1487
- import_v46.z.object({
1488
- type: import_v46.z.literal("response.reasoning_summary_text.done"),
1489
- item_id: import_v46.z.string(),
1490
- output_index: import_v46.z.number(),
1491
- summary_index: import_v46.z.number(),
1492
- text: import_v46.z.string()
1502
+ z6.object({
1503
+ type: z6.literal("response.reasoning_summary_text.done"),
1504
+ item_id: z6.string(),
1505
+ output_index: z6.number(),
1506
+ summary_index: z6.number(),
1507
+ text: z6.string()
1493
1508
  }),
1494
- import_v46.z.object({
1495
- type: import_v46.z.literal("response.reasoning_text.delta"),
1496
- item_id: import_v46.z.string(),
1497
- output_index: import_v46.z.number(),
1498
- content_index: import_v46.z.number(),
1499
- delta: import_v46.z.string()
1509
+ z6.object({
1510
+ type: z6.literal("response.reasoning_text.delta"),
1511
+ item_id: z6.string(),
1512
+ output_index: z6.number(),
1513
+ content_index: z6.number(),
1514
+ delta: z6.string()
1500
1515
  }),
1501
- import_v46.z.object({
1502
- type: import_v46.z.literal("response.reasoning_text.done"),
1503
- item_id: import_v46.z.string(),
1504
- output_index: import_v46.z.number(),
1505
- content_index: import_v46.z.number(),
1506
- text: import_v46.z.string()
1516
+ z6.object({
1517
+ type: z6.literal("response.reasoning_text.done"),
1518
+ item_id: z6.string(),
1519
+ output_index: z6.number(),
1520
+ content_index: z6.number(),
1521
+ text: z6.string()
1507
1522
  }),
1508
- import_v46.z.object({
1509
- type: import_v46.z.literal("response.web_search_call.in_progress"),
1510
- item_id: import_v46.z.string(),
1511
- output_index: import_v46.z.number()
1523
+ z6.object({
1524
+ type: z6.literal("response.web_search_call.in_progress"),
1525
+ item_id: z6.string(),
1526
+ output_index: z6.number()
1512
1527
  }),
1513
- import_v46.z.object({
1514
- type: import_v46.z.literal("response.web_search_call.searching"),
1515
- item_id: import_v46.z.string(),
1516
- output_index: import_v46.z.number()
1528
+ z6.object({
1529
+ type: z6.literal("response.web_search_call.searching"),
1530
+ item_id: z6.string(),
1531
+ output_index: z6.number()
1517
1532
  }),
1518
- import_v46.z.object({
1519
- type: import_v46.z.literal("response.web_search_call.completed"),
1520
- item_id: import_v46.z.string(),
1521
- output_index: import_v46.z.number()
1533
+ z6.object({
1534
+ type: z6.literal("response.web_search_call.completed"),
1535
+ item_id: z6.string(),
1536
+ output_index: z6.number()
1522
1537
  }),
1523
- import_v46.z.object({
1524
- type: import_v46.z.literal("response.x_search_call.in_progress"),
1525
- item_id: import_v46.z.string(),
1526
- output_index: import_v46.z.number()
1538
+ z6.object({
1539
+ type: z6.literal("response.x_search_call.in_progress"),
1540
+ item_id: z6.string(),
1541
+ output_index: z6.number()
1527
1542
  }),
1528
- import_v46.z.object({
1529
- type: import_v46.z.literal("response.x_search_call.searching"),
1530
- item_id: import_v46.z.string(),
1531
- output_index: import_v46.z.number()
1543
+ z6.object({
1544
+ type: z6.literal("response.x_search_call.searching"),
1545
+ item_id: z6.string(),
1546
+ output_index: z6.number()
1532
1547
  }),
1533
- import_v46.z.object({
1534
- type: import_v46.z.literal("response.x_search_call.completed"),
1535
- item_id: import_v46.z.string(),
1536
- output_index: import_v46.z.number()
1548
+ z6.object({
1549
+ type: z6.literal("response.x_search_call.completed"),
1550
+ item_id: z6.string(),
1551
+ output_index: z6.number()
1537
1552
  }),
1538
- import_v46.z.object({
1539
- type: import_v46.z.literal("response.file_search_call.in_progress"),
1540
- item_id: import_v46.z.string(),
1541
- output_index: import_v46.z.number()
1553
+ z6.object({
1554
+ type: z6.literal("response.file_search_call.in_progress"),
1555
+ item_id: z6.string(),
1556
+ output_index: z6.number()
1542
1557
  }),
1543
- import_v46.z.object({
1544
- type: import_v46.z.literal("response.file_search_call.searching"),
1545
- item_id: import_v46.z.string(),
1546
- output_index: import_v46.z.number()
1558
+ z6.object({
1559
+ type: z6.literal("response.file_search_call.searching"),
1560
+ item_id: z6.string(),
1561
+ output_index: z6.number()
1547
1562
  }),
1548
- import_v46.z.object({
1549
- type: import_v46.z.literal("response.file_search_call.completed"),
1550
- item_id: import_v46.z.string(),
1551
- output_index: import_v46.z.number()
1563
+ z6.object({
1564
+ type: z6.literal("response.file_search_call.completed"),
1565
+ item_id: z6.string(),
1566
+ output_index: z6.number()
1552
1567
  }),
1553
- import_v46.z.object({
1554
- type: import_v46.z.literal("response.code_execution_call.in_progress"),
1555
- item_id: import_v46.z.string(),
1556
- output_index: import_v46.z.number()
1568
+ z6.object({
1569
+ type: z6.literal("response.code_execution_call.in_progress"),
1570
+ item_id: z6.string(),
1571
+ output_index: z6.number()
1557
1572
  }),
1558
- import_v46.z.object({
1559
- type: import_v46.z.literal("response.code_execution_call.executing"),
1560
- item_id: import_v46.z.string(),
1561
- output_index: import_v46.z.number()
1573
+ z6.object({
1574
+ type: z6.literal("response.code_execution_call.executing"),
1575
+ item_id: z6.string(),
1576
+ output_index: z6.number()
1562
1577
  }),
1563
- import_v46.z.object({
1564
- type: import_v46.z.literal("response.code_execution_call.completed"),
1565
- item_id: import_v46.z.string(),
1566
- output_index: import_v46.z.number()
1578
+ z6.object({
1579
+ type: z6.literal("response.code_execution_call.completed"),
1580
+ item_id: z6.string(),
1581
+ output_index: z6.number()
1567
1582
  }),
1568
- import_v46.z.object({
1569
- type: import_v46.z.literal("response.code_interpreter_call.in_progress"),
1570
- item_id: import_v46.z.string(),
1571
- output_index: import_v46.z.number()
1583
+ z6.object({
1584
+ type: z6.literal("response.code_interpreter_call.in_progress"),
1585
+ item_id: z6.string(),
1586
+ output_index: z6.number()
1572
1587
  }),
1573
- import_v46.z.object({
1574
- type: import_v46.z.literal("response.code_interpreter_call.executing"),
1575
- item_id: import_v46.z.string(),
1576
- output_index: import_v46.z.number()
1588
+ z6.object({
1589
+ type: z6.literal("response.code_interpreter_call.executing"),
1590
+ item_id: z6.string(),
1591
+ output_index: z6.number()
1577
1592
  }),
1578
- import_v46.z.object({
1579
- type: import_v46.z.literal("response.code_interpreter_call.interpreting"),
1580
- item_id: import_v46.z.string(),
1581
- output_index: import_v46.z.number()
1593
+ z6.object({
1594
+ type: z6.literal("response.code_interpreter_call.interpreting"),
1595
+ item_id: z6.string(),
1596
+ output_index: z6.number()
1582
1597
  }),
1583
- import_v46.z.object({
1584
- type: import_v46.z.literal("response.code_interpreter_call.completed"),
1585
- item_id: import_v46.z.string(),
1586
- output_index: import_v46.z.number()
1598
+ z6.object({
1599
+ type: z6.literal("response.code_interpreter_call.completed"),
1600
+ item_id: z6.string(),
1601
+ output_index: z6.number()
1587
1602
  }),
1588
1603
  // Code interpreter code streaming events
1589
- import_v46.z.object({
1590
- type: import_v46.z.literal("response.code_interpreter_call_code.delta"),
1591
- item_id: import_v46.z.string(),
1592
- output_index: import_v46.z.number(),
1593
- delta: import_v46.z.string()
1604
+ z6.object({
1605
+ type: z6.literal("response.code_interpreter_call_code.delta"),
1606
+ item_id: z6.string(),
1607
+ output_index: z6.number(),
1608
+ delta: z6.string()
1594
1609
  }),
1595
- import_v46.z.object({
1596
- type: import_v46.z.literal("response.code_interpreter_call_code.done"),
1597
- item_id: import_v46.z.string(),
1598
- output_index: import_v46.z.number(),
1599
- code: import_v46.z.string()
1610
+ z6.object({
1611
+ type: z6.literal("response.code_interpreter_call_code.done"),
1612
+ item_id: z6.string(),
1613
+ output_index: z6.number(),
1614
+ code: z6.string()
1600
1615
  }),
1601
- import_v46.z.object({
1602
- type: import_v46.z.literal("response.custom_tool_call_input.delta"),
1603
- item_id: import_v46.z.string(),
1604
- output_index: import_v46.z.number(),
1605
- delta: import_v46.z.string()
1616
+ z6.object({
1617
+ type: z6.literal("response.custom_tool_call_input.delta"),
1618
+ item_id: z6.string(),
1619
+ output_index: z6.number(),
1620
+ delta: z6.string()
1606
1621
  }),
1607
- import_v46.z.object({
1608
- type: import_v46.z.literal("response.custom_tool_call_input.done"),
1609
- item_id: import_v46.z.string(),
1610
- output_index: import_v46.z.number(),
1611
- input: import_v46.z.string()
1622
+ z6.object({
1623
+ type: z6.literal("response.custom_tool_call_input.done"),
1624
+ item_id: z6.string(),
1625
+ output_index: z6.number(),
1626
+ input: z6.string()
1612
1627
  }),
1613
1628
  // Function call arguments streaming events (standard function tools)
1614
- import_v46.z.object({
1615
- type: import_v46.z.literal("response.function_call_arguments.delta"),
1616
- item_id: import_v46.z.string(),
1617
- output_index: import_v46.z.number(),
1618
- delta: import_v46.z.string()
1629
+ z6.object({
1630
+ type: z6.literal("response.function_call_arguments.delta"),
1631
+ item_id: z6.string(),
1632
+ output_index: z6.number(),
1633
+ delta: z6.string()
1619
1634
  }),
1620
- import_v46.z.object({
1621
- type: import_v46.z.literal("response.function_call_arguments.done"),
1622
- item_id: import_v46.z.string(),
1623
- output_index: import_v46.z.number(),
1624
- arguments: import_v46.z.string()
1635
+ z6.object({
1636
+ type: z6.literal("response.function_call_arguments.done"),
1637
+ item_id: z6.string(),
1638
+ output_index: z6.number(),
1639
+ arguments: z6.string()
1625
1640
  }),
1626
- import_v46.z.object({
1627
- type: import_v46.z.literal("response.mcp_call.in_progress"),
1628
- item_id: import_v46.z.string(),
1629
- output_index: import_v46.z.number()
1641
+ z6.object({
1642
+ type: z6.literal("response.mcp_call.in_progress"),
1643
+ item_id: z6.string(),
1644
+ output_index: z6.number()
1630
1645
  }),
1631
- import_v46.z.object({
1632
- type: import_v46.z.literal("response.mcp_call.executing"),
1633
- item_id: import_v46.z.string(),
1634
- output_index: import_v46.z.number()
1646
+ z6.object({
1647
+ type: z6.literal("response.mcp_call.executing"),
1648
+ item_id: z6.string(),
1649
+ output_index: z6.number()
1635
1650
  }),
1636
- import_v46.z.object({
1637
- type: import_v46.z.literal("response.mcp_call.completed"),
1638
- item_id: import_v46.z.string(),
1639
- output_index: import_v46.z.number()
1651
+ z6.object({
1652
+ type: z6.literal("response.mcp_call.completed"),
1653
+ item_id: z6.string(),
1654
+ output_index: z6.number()
1640
1655
  }),
1641
- import_v46.z.object({
1642
- type: import_v46.z.literal("response.mcp_call.failed"),
1643
- item_id: import_v46.z.string(),
1644
- output_index: import_v46.z.number()
1656
+ z6.object({
1657
+ type: z6.literal("response.mcp_call.failed"),
1658
+ item_id: z6.string(),
1659
+ output_index: z6.number()
1645
1660
  }),
1646
- import_v46.z.object({
1647
- type: import_v46.z.literal("response.mcp_call_arguments.delta"),
1648
- item_id: import_v46.z.string(),
1649
- output_index: import_v46.z.number(),
1650
- delta: import_v46.z.string()
1661
+ z6.object({
1662
+ type: z6.literal("response.mcp_call_arguments.delta"),
1663
+ item_id: z6.string(),
1664
+ output_index: z6.number(),
1665
+ delta: z6.string()
1651
1666
  }),
1652
- import_v46.z.object({
1653
- type: import_v46.z.literal("response.mcp_call_arguments.done"),
1654
- item_id: import_v46.z.string(),
1655
- output_index: import_v46.z.number(),
1656
- arguments: import_v46.z.string().optional()
1667
+ z6.object({
1668
+ type: z6.literal("response.mcp_call_arguments.done"),
1669
+ item_id: z6.string(),
1670
+ output_index: z6.number(),
1671
+ arguments: z6.string().optional()
1657
1672
  }),
1658
- import_v46.z.object({
1659
- type: import_v46.z.literal("response.mcp_call_output.delta"),
1660
- item_id: import_v46.z.string(),
1661
- output_index: import_v46.z.number(),
1662
- delta: import_v46.z.string()
1673
+ z6.object({
1674
+ type: z6.literal("response.mcp_call_output.delta"),
1675
+ item_id: z6.string(),
1676
+ output_index: z6.number(),
1677
+ delta: z6.string()
1663
1678
  }),
1664
- import_v46.z.object({
1665
- type: import_v46.z.literal("response.mcp_call_output.done"),
1666
- item_id: import_v46.z.string(),
1667
- output_index: import_v46.z.number(),
1668
- output: import_v46.z.string().optional()
1679
+ z6.object({
1680
+ type: z6.literal("response.mcp_call_output.done"),
1681
+ item_id: z6.string(),
1682
+ output_index: z6.number(),
1683
+ output: z6.string().optional()
1669
1684
  }),
1670
- import_v46.z.object({
1671
- type: import_v46.z.literal("response.incomplete"),
1672
- response: import_v46.z.object({
1673
- incomplete_details: import_v46.z.object({ reason: import_v46.z.string() }).nullish(),
1685
+ z6.object({
1686
+ type: z6.literal("response.incomplete"),
1687
+ response: z6.object({
1688
+ incomplete_details: z6.object({ reason: z6.string() }).nullish(),
1674
1689
  usage: xaiResponsesUsageSchema.nullish()
1675
1690
  })
1676
1691
  }),
1677
- import_v46.z.object({
1678
- type: import_v46.z.literal("response.failed"),
1679
- response: import_v46.z.object({
1680
- error: import_v46.z.object({
1681
- code: import_v46.z.string().nullish(),
1682
- message: import_v46.z.string()
1692
+ z6.object({
1693
+ type: z6.literal("response.failed"),
1694
+ response: z6.object({
1695
+ error: z6.object({
1696
+ code: z6.string().nullish(),
1697
+ message: z6.string()
1683
1698
  }).nullish(),
1684
- incomplete_details: import_v46.z.object({ reason: import_v46.z.string() }).nullish(),
1699
+ incomplete_details: z6.object({ reason: z6.string() }).nullish(),
1685
1700
  usage: xaiResponsesUsageSchema.nullish()
1686
1701
  })
1687
1702
  }),
1688
- import_v46.z.object({
1689
- type: import_v46.z.literal("error"),
1690
- code: import_v46.z.string().nullish(),
1691
- message: import_v46.z.string(),
1692
- param: import_v46.z.string().nullish()
1703
+ z6.object({
1704
+ type: z6.literal("error"),
1705
+ code: z6.string().nullish(),
1706
+ message: z6.string(),
1707
+ param: z6.string().nullish()
1693
1708
  }),
1694
- import_v46.z.object({
1695
- type: import_v46.z.literal("response.done"),
1709
+ z6.object({
1710
+ type: z6.literal("response.done"),
1696
1711
  response: xaiResponsesResponseSchema
1697
1712
  }),
1698
- import_v46.z.object({
1699
- type: import_v46.z.literal("response.completed"),
1713
+ z6.object({
1714
+ type: z6.literal("response.completed"),
1700
1715
  response: xaiResponsesResponseSchema
1701
1716
  })
1702
1717
  ]);
1703
1718
 
1704
1719
  // src/responses/xai-responses-options.ts
1705
- var import_v47 = require("zod/v4");
1706
- var xaiLanguageModelResponsesOptions = import_v47.z.object({
1720
+ import { z as z7 } from "zod/v4";
1721
+ var xaiLanguageModelResponsesOptions = z7.object({
1707
1722
  /**
1708
1723
  * Constrains how hard a reasoning model thinks before responding.
1709
1724
  * Possible values are `low` (uses fewer reasoning tokens), `medium` and `high` (uses more reasoning tokens).
1710
1725
  */
1711
- reasoningEffort: import_v47.z.enum(["low", "medium", "high"]).optional(),
1712
- reasoningSummary: import_v47.z.enum(["auto", "concise", "detailed"]).optional(),
1713
- logprobs: import_v47.z.boolean().optional(),
1714
- topLogprobs: import_v47.z.number().int().min(0).max(8).optional(),
1726
+ reasoningEffort: z7.enum(["low", "medium", "high"]).optional(),
1727
+ reasoningSummary: z7.enum(["auto", "concise", "detailed"]).optional(),
1728
+ logprobs: z7.boolean().optional(),
1729
+ topLogprobs: z7.number().int().min(0).max(8).optional(),
1715
1730
  /**
1716
1731
  * Whether to store the input message(s) and model response for later retrieval.
1717
1732
  * @default true
1718
1733
  */
1719
- store: import_v47.z.boolean().optional(),
1734
+ store: z7.boolean().optional(),
1720
1735
  /**
1721
1736
  * The ID of the previous response from the model.
1722
1737
  */
1723
- previousResponseId: import_v47.z.string().optional(),
1738
+ previousResponseId: z7.string().optional(),
1724
1739
  /**
1725
1740
  * Specify additional output data to include in the model response.
1726
1741
  * Example values: 'file_search_call.results'.
1727
1742
  */
1728
- include: import_v47.z.array(import_v47.z.enum(["file_search_call.results"])).nullish()
1743
+ include: z7.array(z7.enum(["file_search_call.results"])).nullish()
1729
1744
  });
1730
1745
 
1731
1746
  // src/responses/xai-responses-prepare-tools.ts
1732
- var import_provider5 = require("@ai-sdk/provider");
1733
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
1747
+ import {
1748
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError4
1749
+ } from "@ai-sdk/provider";
1750
+ import { validateTypes } from "@ai-sdk/provider-utils";
1734
1751
 
1735
1752
  // src/tool/file-search.ts
1736
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
1737
- var import_v48 = require("zod/v4");
1738
- var fileSearchArgsSchema = (0, import_provider_utils6.lazySchema)(
1739
- () => (0, import_provider_utils6.zodSchema)(
1740
- import_v48.z.object({
1741
- vectorStoreIds: import_v48.z.array(import_v48.z.string()),
1742
- maxNumResults: import_v48.z.number().optional()
1753
+ import {
1754
+ createProviderToolFactoryWithOutputSchema,
1755
+ lazySchema,
1756
+ zodSchema
1757
+ } from "@ai-sdk/provider-utils";
1758
+ import { z as z8 } from "zod/v4";
1759
+ var fileSearchArgsSchema = lazySchema(
1760
+ () => zodSchema(
1761
+ z8.object({
1762
+ vectorStoreIds: z8.array(z8.string()),
1763
+ maxNumResults: z8.number().optional()
1743
1764
  })
1744
1765
  )
1745
1766
  );
1746
- var fileSearchOutputSchema = (0, import_provider_utils6.lazySchema)(
1747
- () => (0, import_provider_utils6.zodSchema)(
1748
- import_v48.z.object({
1749
- queries: import_v48.z.array(import_v48.z.string()),
1750
- results: import_v48.z.array(
1751
- import_v48.z.object({
1752
- fileId: import_v48.z.string(),
1753
- filename: import_v48.z.string(),
1754
- score: import_v48.z.number().min(0).max(1),
1755
- text: import_v48.z.string()
1767
+ var fileSearchOutputSchema = lazySchema(
1768
+ () => zodSchema(
1769
+ z8.object({
1770
+ queries: z8.array(z8.string()),
1771
+ results: z8.array(
1772
+ z8.object({
1773
+ fileId: z8.string(),
1774
+ filename: z8.string(),
1775
+ score: z8.number().min(0).max(1),
1776
+ text: z8.string()
1756
1777
  })
1757
1778
  ).nullable()
1758
1779
  })
1759
1780
  )
1760
1781
  );
1761
- var fileSearchToolFactory = (0, import_provider_utils6.createProviderToolFactoryWithOutputSchema)({
1782
+ var fileSearchToolFactory = createProviderToolFactoryWithOutputSchema({
1762
1783
  id: "xai.file_search",
1763
- inputSchema: (0, import_provider_utils6.lazySchema)(() => (0, import_provider_utils6.zodSchema)(import_v48.z.object({}))),
1784
+ inputSchema: lazySchema(() => zodSchema(z8.object({}))),
1764
1785
  outputSchema: fileSearchOutputSchema
1765
1786
  });
1766
1787
  var fileSearch = (args) => fileSearchToolFactory(args);
1767
1788
 
1768
1789
  // src/tool/mcp-server.ts
1769
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
1770
- var import_v49 = require("zod/v4");
1771
- var mcpServerArgsSchema = (0, import_provider_utils7.lazySchema)(
1772
- () => (0, import_provider_utils7.zodSchema)(
1773
- import_v49.z.object({
1774
- serverUrl: import_v49.z.string().describe("The URL of the MCP server"),
1775
- serverLabel: import_v49.z.string().optional().describe("A label for the MCP server"),
1776
- serverDescription: import_v49.z.string().optional().describe("Description of the MCP server"),
1777
- allowedTools: import_v49.z.array(import_v49.z.string()).optional().describe("List of allowed tool names"),
1778
- headers: import_v49.z.record(import_v49.z.string(), import_v49.z.string()).optional().describe("Custom headers to send"),
1779
- authorization: import_v49.z.string().optional().describe("Authorization header value")
1790
+ import {
1791
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema2,
1792
+ lazySchema as lazySchema2,
1793
+ zodSchema as zodSchema2
1794
+ } from "@ai-sdk/provider-utils";
1795
+ import { z as z9 } from "zod/v4";
1796
+ var mcpServerArgsSchema = lazySchema2(
1797
+ () => zodSchema2(
1798
+ z9.object({
1799
+ serverUrl: z9.string().describe("The URL of the MCP server"),
1800
+ serverLabel: z9.string().optional().describe("A label for the MCP server"),
1801
+ serverDescription: z9.string().optional().describe("Description of the MCP server"),
1802
+ allowedTools: z9.array(z9.string()).optional().describe("List of allowed tool names"),
1803
+ headers: z9.record(z9.string(), z9.string()).optional().describe("Custom headers to send"),
1804
+ authorization: z9.string().optional().describe("Authorization header value")
1780
1805
  })
1781
1806
  )
1782
1807
  );
1783
- var mcpServerOutputSchema = (0, import_provider_utils7.lazySchema)(
1784
- () => (0, import_provider_utils7.zodSchema)(
1785
- import_v49.z.object({
1786
- name: import_v49.z.string(),
1787
- arguments: import_v49.z.string(),
1788
- result: import_v49.z.unknown()
1808
+ var mcpServerOutputSchema = lazySchema2(
1809
+ () => zodSchema2(
1810
+ z9.object({
1811
+ name: z9.string(),
1812
+ arguments: z9.string(),
1813
+ result: z9.unknown()
1789
1814
  })
1790
1815
  )
1791
1816
  );
1792
- var mcpServerToolFactory = (0, import_provider_utils7.createProviderToolFactoryWithOutputSchema)({
1817
+ var mcpServerToolFactory = createProviderToolFactoryWithOutputSchema2({
1793
1818
  id: "xai.mcp",
1794
- inputSchema: (0, import_provider_utils7.lazySchema)(() => (0, import_provider_utils7.zodSchema)(import_v49.z.object({}))),
1819
+ inputSchema: lazySchema2(() => zodSchema2(z9.object({}))),
1795
1820
  outputSchema: mcpServerOutputSchema
1796
1821
  });
1797
1822
  var mcpServer = (args) => mcpServerToolFactory(args);
1798
1823
 
1799
1824
  // src/tool/web-search.ts
1800
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1801
- var import_v410 = require("zod/v4");
1802
- var webSearchArgsSchema = (0, import_provider_utils8.lazySchema)(
1803
- () => (0, import_provider_utils8.zodSchema)(
1804
- import_v410.z.object({
1805
- allowedDomains: import_v410.z.array(import_v410.z.string()).max(5).optional(),
1806
- excludedDomains: import_v410.z.array(import_v410.z.string()).max(5).optional(),
1807
- enableImageUnderstanding: import_v410.z.boolean().optional()
1825
+ import {
1826
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema3,
1827
+ lazySchema as lazySchema3,
1828
+ zodSchema as zodSchema3
1829
+ } from "@ai-sdk/provider-utils";
1830
+ import { z as z10 } from "zod/v4";
1831
+ var webSearchArgsSchema = lazySchema3(
1832
+ () => zodSchema3(
1833
+ z10.object({
1834
+ allowedDomains: z10.array(z10.string()).max(5).optional(),
1835
+ excludedDomains: z10.array(z10.string()).max(5).optional(),
1836
+ enableImageUnderstanding: z10.boolean().optional()
1808
1837
  })
1809
1838
  )
1810
1839
  );
1811
- var webSearchOutputSchema = (0, import_provider_utils8.lazySchema)(
1812
- () => (0, import_provider_utils8.zodSchema)(
1813
- import_v410.z.object({
1814
- query: import_v410.z.string(),
1815
- sources: import_v410.z.array(
1816
- import_v410.z.object({
1817
- title: import_v410.z.string(),
1818
- url: import_v410.z.string(),
1819
- snippet: import_v410.z.string()
1840
+ var webSearchOutputSchema = lazySchema3(
1841
+ () => zodSchema3(
1842
+ z10.object({
1843
+ query: z10.string(),
1844
+ sources: z10.array(
1845
+ z10.object({
1846
+ title: z10.string(),
1847
+ url: z10.string(),
1848
+ snippet: z10.string()
1820
1849
  })
1821
1850
  )
1822
1851
  })
1823
1852
  )
1824
1853
  );
1825
- var webSearchToolFactory = (0, import_provider_utils8.createProviderToolFactoryWithOutputSchema)({
1854
+ var webSearchToolFactory = createProviderToolFactoryWithOutputSchema3({
1826
1855
  id: "xai.web_search",
1827
- inputSchema: (0, import_provider_utils8.lazySchema)(() => (0, import_provider_utils8.zodSchema)(import_v410.z.object({}))),
1856
+ inputSchema: lazySchema3(() => zodSchema3(z10.object({}))),
1828
1857
  outputSchema: webSearchOutputSchema
1829
1858
  });
1830
1859
  var webSearch = (args = {}) => webSearchToolFactory(args);
1831
1860
 
1832
1861
  // src/tool/x-search.ts
1833
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
1834
- var import_v411 = require("zod/v4");
1835
- var xSearchArgsSchema = (0, import_provider_utils9.lazySchema)(
1836
- () => (0, import_provider_utils9.zodSchema)(
1837
- import_v411.z.object({
1838
- allowedXHandles: import_v411.z.array(import_v411.z.string()).max(10).optional(),
1839
- excludedXHandles: import_v411.z.array(import_v411.z.string()).max(10).optional(),
1840
- fromDate: import_v411.z.string().optional(),
1841
- toDate: import_v411.z.string().optional(),
1842
- enableImageUnderstanding: import_v411.z.boolean().optional(),
1843
- enableVideoUnderstanding: import_v411.z.boolean().optional()
1862
+ import {
1863
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema4,
1864
+ lazySchema as lazySchema4,
1865
+ zodSchema as zodSchema4
1866
+ } from "@ai-sdk/provider-utils";
1867
+ import { z as z11 } from "zod/v4";
1868
+ var xSearchArgsSchema = lazySchema4(
1869
+ () => zodSchema4(
1870
+ z11.object({
1871
+ allowedXHandles: z11.array(z11.string()).max(10).optional(),
1872
+ excludedXHandles: z11.array(z11.string()).max(10).optional(),
1873
+ fromDate: z11.string().optional(),
1874
+ toDate: z11.string().optional(),
1875
+ enableImageUnderstanding: z11.boolean().optional(),
1876
+ enableVideoUnderstanding: z11.boolean().optional()
1844
1877
  })
1845
1878
  )
1846
1879
  );
1847
- var xSearchOutputSchema = (0, import_provider_utils9.lazySchema)(
1848
- () => (0, import_provider_utils9.zodSchema)(
1849
- import_v411.z.object({
1850
- query: import_v411.z.string(),
1851
- posts: import_v411.z.array(
1852
- import_v411.z.object({
1853
- author: import_v411.z.string(),
1854
- text: import_v411.z.string(),
1855
- url: import_v411.z.string(),
1856
- likes: import_v411.z.number()
1880
+ var xSearchOutputSchema = lazySchema4(
1881
+ () => zodSchema4(
1882
+ z11.object({
1883
+ query: z11.string(),
1884
+ posts: z11.array(
1885
+ z11.object({
1886
+ author: z11.string(),
1887
+ text: z11.string(),
1888
+ url: z11.string(),
1889
+ likes: z11.number()
1857
1890
  })
1858
1891
  )
1859
1892
  })
1860
1893
  )
1861
1894
  );
1862
- var xSearchToolFactory = (0, import_provider_utils9.createProviderToolFactoryWithOutputSchema)({
1895
+ var xSearchToolFactory = createProviderToolFactoryWithOutputSchema4({
1863
1896
  id: "xai.x_search",
1864
- inputSchema: (0, import_provider_utils9.lazySchema)(() => (0, import_provider_utils9.zodSchema)(import_v411.z.object({}))),
1897
+ inputSchema: lazySchema4(() => zodSchema4(z11.object({}))),
1865
1898
  outputSchema: xSearchOutputSchema
1866
1899
  });
1867
1900
  var xSearch = (args = {}) => xSearchToolFactory(args);
@@ -1883,7 +1916,7 @@ async function prepareResponsesTools({
1883
1916
  if (tool.type === "provider") {
1884
1917
  switch (tool.id) {
1885
1918
  case "xai.web_search": {
1886
- const args = await (0, import_provider_utils10.validateTypes)({
1919
+ const args = await validateTypes({
1887
1920
  value: tool.args,
1888
1921
  schema: webSearchArgsSchema
1889
1922
  });
@@ -1896,7 +1929,7 @@ async function prepareResponsesTools({
1896
1929
  break;
1897
1930
  }
1898
1931
  case "xai.x_search": {
1899
- const args = await (0, import_provider_utils10.validateTypes)({
1932
+ const args = await validateTypes({
1900
1933
  value: tool.args,
1901
1934
  schema: xSearchArgsSchema
1902
1935
  });
@@ -1930,7 +1963,7 @@ async function prepareResponsesTools({
1930
1963
  break;
1931
1964
  }
1932
1965
  case "xai.file_search": {
1933
- const args = await (0, import_provider_utils10.validateTypes)({
1966
+ const args = await validateTypes({
1934
1967
  value: tool.args,
1935
1968
  schema: fileSearchArgsSchema
1936
1969
  });
@@ -1942,7 +1975,7 @@ async function prepareResponsesTools({
1942
1975
  break;
1943
1976
  }
1944
1977
  case "xai.mcp": {
1945
- const args = await (0, import_provider_utils10.validateTypes)({
1978
+ const args = await validateTypes({
1946
1979
  value: tool.args,
1947
1980
  schema: mcpServerArgsSchema
1948
1981
  });
@@ -2009,7 +2042,7 @@ async function prepareResponsesTools({
2009
2042
  }
2010
2043
  default: {
2011
2044
  const _exhaustiveCheck = type;
2012
- throw new import_provider5.UnsupportedFunctionalityError({
2045
+ throw new UnsupportedFunctionalityError4({
2013
2046
  functionality: `tool choice type: ${_exhaustiveCheck}`
2014
2047
  });
2015
2048
  }
@@ -2044,7 +2077,7 @@ var XaiResponsesLanguageModel = class {
2044
2077
  }) {
2045
2078
  var _a, _b, _c, _d, _e, _f, _g, _h;
2046
2079
  const warnings = [];
2047
- const options = (_a = await (0, import_provider_utils11.parseProviderOptions)({
2080
+ const options = (_a = await parseProviderOptions3({
2048
2081
  provider: "xai",
2049
2082
  providerOptions,
2050
2083
  schema: xaiLanguageModelResponsesOptions
@@ -2089,7 +2122,7 @@ var XaiResponsesLanguageModel = class {
2089
2122
  include = [...include, "reasoning.encrypted_content"];
2090
2123
  }
2091
2124
  }
2092
- const resolvedReasoningEffort = (_g = options.reasoningEffort) != null ? _g : (0, import_provider_utils11.isCustomReasoning)(reasoning) ? reasoning === "none" ? void 0 : (0, import_provider_utils11.mapReasoningToProviderEffort)({
2125
+ const resolvedReasoningEffort = (_g = options.reasoningEffort) != null ? _g : isCustomReasoning2(reasoning) ? reasoning === "none" ? void 0 : mapReasoningToProviderEffort2({
2093
2126
  reasoning,
2094
2127
  effortMap: {
2095
2128
  minimal: "low",
@@ -2171,12 +2204,12 @@ var XaiResponsesLanguageModel = class {
2171
2204
  responseHeaders,
2172
2205
  value: response,
2173
2206
  rawValue: rawResponse
2174
- } = await (0, import_provider_utils11.postJsonToApi)({
2207
+ } = await postJsonToApi3({
2175
2208
  url: `${(_a = this.config.baseURL) != null ? _a : "https://api.x.ai/v1"}/responses`,
2176
- headers: (0, import_provider_utils11.combineHeaders)(this.config.headers(), options.headers),
2209
+ headers: combineHeaders3(this.config.headers(), options.headers),
2177
2210
  body,
2178
2211
  failedResponseHandler: xaiFailedResponseHandler,
2179
- successfulResponseHandler: (0, import_provider_utils11.createJsonResponseHandler)(
2212
+ successfulResponseHandler: createJsonResponseHandler3(
2180
2213
  xaiResponsesResponseSchema
2181
2214
  ),
2182
2215
  abortSignal: options.abortSignal,
@@ -2342,12 +2375,12 @@ var XaiResponsesLanguageModel = class {
2342
2375
  ...args,
2343
2376
  stream: true
2344
2377
  };
2345
- const { responseHeaders, value: response } = await (0, import_provider_utils11.postJsonToApi)({
2378
+ const { responseHeaders, value: response } = await postJsonToApi3({
2346
2379
  url: `${(_a = this.config.baseURL) != null ? _a : "https://api.x.ai/v1"}/responses`,
2347
- headers: (0, import_provider_utils11.combineHeaders)(this.config.headers(), options.headers),
2380
+ headers: combineHeaders3(this.config.headers(), options.headers),
2348
2381
  body,
2349
2382
  failedResponseHandler: xaiFailedResponseHandler,
2350
- successfulResponseHandler: (0, import_provider_utils11.createEventSourceResponseHandler)(
2383
+ successfulResponseHandler: createEventSourceResponseHandler2(
2351
2384
  xaiResponsesChunkSchema
2352
2385
  ),
2353
2386
  abortSignal: options.abortSignal,
@@ -2764,44 +2797,44 @@ var XaiResponsesLanguageModel = class {
2764
2797
  };
2765
2798
 
2766
2799
  // src/tool/code-execution.ts
2767
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
2768
- var import_v412 = require("zod/v4");
2769
- var codeExecutionOutputSchema = import_v412.z.object({
2770
- output: import_v412.z.string().describe("the output of the code execution"),
2771
- error: import_v412.z.string().optional().describe("any error that occurred")
2800
+ import { createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5 } from "@ai-sdk/provider-utils";
2801
+ import { z as z12 } from "zod/v4";
2802
+ var codeExecutionOutputSchema = z12.object({
2803
+ output: z12.string().describe("the output of the code execution"),
2804
+ error: z12.string().optional().describe("any error that occurred")
2772
2805
  });
2773
- var codeExecutionToolFactory = (0, import_provider_utils12.createProviderToolFactoryWithOutputSchema)({
2806
+ var codeExecutionToolFactory = createProviderToolFactoryWithOutputSchema5({
2774
2807
  id: "xai.code_execution",
2775
- inputSchema: import_v412.z.object({}).describe("no input parameters"),
2808
+ inputSchema: z12.object({}).describe("no input parameters"),
2776
2809
  outputSchema: codeExecutionOutputSchema
2777
2810
  });
2778
2811
  var codeExecution = (args = {}) => codeExecutionToolFactory(args);
2779
2812
 
2780
2813
  // src/tool/view-image.ts
2781
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
2782
- var import_v413 = require("zod/v4");
2783
- var viewImageOutputSchema = import_v413.z.object({
2784
- description: import_v413.z.string().describe("description of the image"),
2785
- objects: import_v413.z.array(import_v413.z.string()).optional().describe("objects detected in the image")
2814
+ import { createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6 } from "@ai-sdk/provider-utils";
2815
+ import { z as z13 } from "zod/v4";
2816
+ var viewImageOutputSchema = z13.object({
2817
+ description: z13.string().describe("description of the image"),
2818
+ objects: z13.array(z13.string()).optional().describe("objects detected in the image")
2786
2819
  });
2787
- var viewImageToolFactory = (0, import_provider_utils13.createProviderToolFactoryWithOutputSchema)({
2820
+ var viewImageToolFactory = createProviderToolFactoryWithOutputSchema6({
2788
2821
  id: "xai.view_image",
2789
- inputSchema: import_v413.z.object({}).describe("no input parameters"),
2822
+ inputSchema: z13.object({}).describe("no input parameters"),
2790
2823
  outputSchema: viewImageOutputSchema
2791
2824
  });
2792
2825
  var viewImage = (args = {}) => viewImageToolFactory(args);
2793
2826
 
2794
2827
  // src/tool/view-x-video.ts
2795
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
2796
- var import_v414 = require("zod/v4");
2797
- var viewXVideoOutputSchema = import_v414.z.object({
2798
- transcript: import_v414.z.string().optional().describe("transcript of the video"),
2799
- description: import_v414.z.string().describe("description of the video content"),
2800
- duration: import_v414.z.number().optional().describe("duration in seconds")
2828
+ import { createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema7 } from "@ai-sdk/provider-utils";
2829
+ import { z as z14 } from "zod/v4";
2830
+ var viewXVideoOutputSchema = z14.object({
2831
+ transcript: z14.string().optional().describe("transcript of the video"),
2832
+ description: z14.string().describe("description of the video content"),
2833
+ duration: z14.number().optional().describe("duration in seconds")
2801
2834
  });
2802
- var viewXVideoToolFactory = (0, import_provider_utils14.createProviderToolFactoryWithOutputSchema)({
2835
+ var viewXVideoToolFactory = createProviderToolFactoryWithOutputSchema7({
2803
2836
  id: "xai.view_x_video",
2804
- inputSchema: import_v414.z.object({}).describe("no input parameters"),
2837
+ inputSchema: z14.object({}).describe("no input parameters"),
2805
2838
  outputSchema: viewXVideoOutputSchema
2806
2839
  });
2807
2840
  var viewXVideo = (args = {}) => viewXVideoToolFactory(args);
@@ -2818,36 +2851,42 @@ var xaiTools = {
2818
2851
  };
2819
2852
 
2820
2853
  // src/version.ts
2821
- var VERSION = true ? "4.0.0-beta.34" : "0.0.0-test";
2854
+ var VERSION = true ? "4.0.0-beta.35" : "0.0.0-test";
2822
2855
 
2823
2856
  // src/files/xai-files.ts
2824
- var import_provider_utils17 = require("@ai-sdk/provider-utils");
2857
+ import {
2858
+ combineHeaders as combineHeaders4,
2859
+ convertBase64ToUint8Array,
2860
+ createJsonResponseHandler as createJsonResponseHandler4,
2861
+ parseProviderOptions as parseProviderOptions4,
2862
+ postFormDataToApi
2863
+ } from "@ai-sdk/provider-utils";
2825
2864
 
2826
2865
  // src/files/xai-files-api.ts
2827
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
2828
- var import_v415 = require("zod/v4");
2829
- var xaiFilesResponseSchema = (0, import_provider_utils15.lazySchema)(
2830
- () => (0, import_provider_utils15.zodSchema)(
2831
- import_v415.z.object({
2832
- id: import_v415.z.string(),
2833
- object: import_v415.z.string().nullish(),
2834
- bytes: import_v415.z.number().nullish(),
2835
- created_at: import_v415.z.number().nullish(),
2836
- filename: import_v415.z.string().nullish(),
2837
- purpose: import_v415.z.string().nullish(),
2838
- status: import_v415.z.string().nullish()
2866
+ import { lazySchema as lazySchema5, zodSchema as zodSchema5 } from "@ai-sdk/provider-utils";
2867
+ import { z as z15 } from "zod/v4";
2868
+ var xaiFilesResponseSchema = lazySchema5(
2869
+ () => zodSchema5(
2870
+ z15.object({
2871
+ id: z15.string(),
2872
+ object: z15.string().nullish(),
2873
+ bytes: z15.number().nullish(),
2874
+ created_at: z15.number().nullish(),
2875
+ filename: z15.string().nullish(),
2876
+ purpose: z15.string().nullish(),
2877
+ status: z15.string().nullish()
2839
2878
  })
2840
2879
  )
2841
2880
  );
2842
2881
 
2843
2882
  // src/files/xai-files-options.ts
2844
- var import_provider_utils16 = require("@ai-sdk/provider-utils");
2845
- var import_v416 = require("zod/v4");
2846
- var xaiFilesOptionsSchema = (0, import_provider_utils16.lazySchema)(
2847
- () => (0, import_provider_utils16.zodSchema)(
2848
- import_v416.z.object({
2849
- teamId: import_v416.z.string().optional(),
2850
- filePath: import_v416.z.string().optional()
2883
+ import { lazySchema as lazySchema6, zodSchema as zodSchema6 } from "@ai-sdk/provider-utils";
2884
+ import { z as z16 } from "zod/v4";
2885
+ var xaiFilesOptionsSchema = lazySchema6(
2886
+ () => zodSchema6(
2887
+ z16.object({
2888
+ teamId: z16.string().optional(),
2889
+ filePath: z16.string().optional()
2851
2890
  }).passthrough()
2852
2891
  )
2853
2892
  );
@@ -2868,12 +2907,12 @@ var XaiFiles = class {
2868
2907
  providerOptions
2869
2908
  }) {
2870
2909
  var _a, _b;
2871
- const xaiOptions = await (0, import_provider_utils17.parseProviderOptions)({
2910
+ const xaiOptions = await parseProviderOptions4({
2872
2911
  provider: "xai",
2873
2912
  providerOptions,
2874
2913
  schema: xaiFilesOptionsSchema
2875
2914
  });
2876
- const fileBytes = data instanceof Uint8Array ? data : (0, import_provider_utils17.convertBase64ToUint8Array)(data);
2915
+ const fileBytes = data instanceof Uint8Array ? data : convertBase64ToUint8Array(data);
2877
2916
  const blob = new Blob([fileBytes], {
2878
2917
  type: mediaType
2879
2918
  });
@@ -2886,12 +2925,12 @@ var XaiFiles = class {
2886
2925
  if ((xaiOptions == null ? void 0 : xaiOptions.teamId) != null) {
2887
2926
  formData.append("team_id", xaiOptions.teamId);
2888
2927
  }
2889
- const { value: response } = await (0, import_provider_utils17.postFormDataToApi)({
2928
+ const { value: response } = await postFormDataToApi({
2890
2929
  url: `${this.config.baseURL}/files`,
2891
- headers: (0, import_provider_utils17.combineHeaders)(this.config.headers()),
2930
+ headers: combineHeaders4(this.config.headers()),
2892
2931
  formData,
2893
2932
  failedResponseHandler: xaiFailedResponseHandler,
2894
- successfulResponseHandler: (0, import_provider_utils17.createJsonResponseHandler)(
2933
+ successfulResponseHandler: createJsonResponseHandler4(
2895
2934
  xaiFilesResponseSchema
2896
2935
  ),
2897
2936
  fetch: this.config.fetch
@@ -2913,59 +2952,69 @@ var XaiFiles = class {
2913
2952
  };
2914
2953
 
2915
2954
  // src/xai-video-model.ts
2916
- var import_provider6 = require("@ai-sdk/provider");
2917
- var import_provider_utils19 = require("@ai-sdk/provider-utils");
2918
- var import_v418 = require("zod/v4");
2955
+ import {
2956
+ AISDKError
2957
+ } from "@ai-sdk/provider";
2958
+ import {
2959
+ combineHeaders as combineHeaders5,
2960
+ convertUint8ArrayToBase64,
2961
+ createJsonResponseHandler as createJsonResponseHandler5,
2962
+ delay,
2963
+ getFromApi as getFromApi2,
2964
+ parseProviderOptions as parseProviderOptions5,
2965
+ postJsonToApi as postJsonToApi4
2966
+ } from "@ai-sdk/provider-utils";
2967
+ import { z as z18 } from "zod/v4";
2919
2968
 
2920
2969
  // src/xai-video-options.ts
2921
- var import_provider_utils18 = require("@ai-sdk/provider-utils");
2922
- var import_v417 = require("zod/v4");
2923
- var nonEmptyStringSchema = import_v417.z.string().min(1);
2924
- var resolutionSchema = import_v417.z.enum(["480p", "720p"]);
2925
- var modeSchema = import_v417.z.enum(["edit-video", "extend-video", "reference-to-video"]);
2970
+ import { lazySchema as lazySchema7, zodSchema as zodSchema7 } from "@ai-sdk/provider-utils";
2971
+ import { z as z17 } from "zod/v4";
2972
+ var nonEmptyStringSchema = z17.string().min(1);
2973
+ var resolutionSchema = z17.enum(["480p", "720p"]);
2974
+ var modeSchema = z17.enum(["edit-video", "extend-video", "reference-to-video"]);
2926
2975
  var baseFields = {
2927
- pollIntervalMs: import_v417.z.number().positive().nullish(),
2928
- pollTimeoutMs: import_v417.z.number().positive().nullish(),
2976
+ pollIntervalMs: z17.number().positive().nullish(),
2977
+ pollTimeoutMs: z17.number().positive().nullish(),
2929
2978
  resolution: resolutionSchema.nullish()
2930
2979
  };
2931
- var editVideoSchema = import_v417.z.object({
2980
+ var editVideoSchema = z17.object({
2932
2981
  ...baseFields,
2933
- mode: import_v417.z.literal("edit-video"),
2982
+ mode: z17.literal("edit-video"),
2934
2983
  videoUrl: nonEmptyStringSchema,
2935
- referenceImageUrls: import_v417.z.undefined().optional()
2984
+ referenceImageUrls: z17.undefined().optional()
2936
2985
  });
2937
- var extendVideoSchema = import_v417.z.object({
2986
+ var extendVideoSchema = z17.object({
2938
2987
  ...baseFields,
2939
- mode: import_v417.z.literal("extend-video"),
2988
+ mode: z17.literal("extend-video"),
2940
2989
  videoUrl: nonEmptyStringSchema,
2941
- referenceImageUrls: import_v417.z.undefined().optional()
2990
+ referenceImageUrls: z17.undefined().optional()
2942
2991
  });
2943
- var referenceToVideoSchema = import_v417.z.object({
2992
+ var referenceToVideoSchema = z17.object({
2944
2993
  ...baseFields,
2945
- mode: import_v417.z.literal("reference-to-video"),
2946
- referenceImageUrls: import_v417.z.array(nonEmptyStringSchema).min(1).max(7),
2947
- videoUrl: import_v417.z.undefined().optional()
2994
+ mode: z17.literal("reference-to-video"),
2995
+ referenceImageUrls: z17.array(nonEmptyStringSchema).min(1).max(7),
2996
+ videoUrl: z17.undefined().optional()
2948
2997
  });
2949
- var autoDetectSchema = import_v417.z.object({
2998
+ var autoDetectSchema = z17.object({
2950
2999
  ...baseFields,
2951
- mode: import_v417.z.undefined().optional(),
3000
+ mode: z17.undefined().optional(),
2952
3001
  videoUrl: nonEmptyStringSchema.optional(),
2953
- referenceImageUrls: import_v417.z.array(nonEmptyStringSchema).min(1).max(7).optional()
3002
+ referenceImageUrls: z17.array(nonEmptyStringSchema).min(1).max(7).optional()
2954
3003
  });
2955
- var xaiVideoModelOptions = import_v417.z.union([
3004
+ var xaiVideoModelOptions = z17.union([
2956
3005
  editVideoSchema,
2957
3006
  extendVideoSchema,
2958
3007
  referenceToVideoSchema,
2959
3008
  autoDetectSchema
2960
3009
  ]);
2961
- var runtimeSchema = import_v417.z.object({
3010
+ var runtimeSchema = z17.object({
2962
3011
  mode: modeSchema.optional(),
2963
3012
  videoUrl: nonEmptyStringSchema.optional(),
2964
- referenceImageUrls: import_v417.z.array(nonEmptyStringSchema).min(1).max(7).optional(),
3013
+ referenceImageUrls: z17.array(nonEmptyStringSchema).min(1).max(7).optional(),
2965
3014
  ...baseFields
2966
3015
  }).passthrough();
2967
- var xaiVideoModelOptionsSchema = (0, import_provider_utils18.lazySchema)(
2968
- () => (0, import_provider_utils18.zodSchema)(runtimeSchema)
3016
+ var xaiVideoModelOptionsSchema = lazySchema7(
3017
+ () => zodSchema7(runtimeSchema)
2969
3018
  );
2970
3019
 
2971
3020
  // src/xai-video-model.ts
@@ -3000,7 +3049,7 @@ var XaiVideoModel = class {
3000
3049
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
3001
3050
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
3002
3051
  const warnings = [];
3003
- const xaiOptions = await (0, import_provider_utils19.parseProviderOptions)({
3052
+ const xaiOptions = await parseProviderOptions5({
3004
3053
  provider: "xai",
3005
3054
  providerOptions: options.providerOptions,
3006
3055
  schema: xaiVideoModelOptionsSchema
@@ -3102,7 +3151,7 @@ var XaiVideoModel = class {
3102
3151
  if (options.image.type === "url") {
3103
3152
  body.image = { url: options.image.url };
3104
3153
  } else {
3105
- const base64Data = typeof options.image.data === "string" ? options.image.data : (0, import_provider_utils19.convertUint8ArrayToBase64)(options.image.data);
3154
+ const base64Data = typeof options.image.data === "string" ? options.image.data : convertUint8ArrayToBase64(options.image.data);
3106
3155
  body.image = {
3107
3156
  url: `data:${options.image.mediaType};base64,${base64Data}`
3108
3157
  };
@@ -3136,12 +3185,12 @@ var XaiVideoModel = class {
3136
3185
  } else {
3137
3186
  endpoint = `${baseURL}/videos/generations`;
3138
3187
  }
3139
- const { value: createResponse } = await (0, import_provider_utils19.postJsonToApi)({
3188
+ const { value: createResponse } = await postJsonToApi4({
3140
3189
  url: endpoint,
3141
- headers: (0, import_provider_utils19.combineHeaders)(this.config.headers(), options.headers),
3190
+ headers: combineHeaders5(this.config.headers(), options.headers),
3142
3191
  body,
3143
3192
  failedResponseHandler: xaiFailedResponseHandler,
3144
- successfulResponseHandler: (0, import_provider_utils19.createJsonResponseHandler)(
3193
+ successfulResponseHandler: createJsonResponseHandler5(
3145
3194
  xaiCreateVideoResponseSchema
3146
3195
  ),
3147
3196
  abortSignal: options.abortSignal,
@@ -3149,7 +3198,7 @@ var XaiVideoModel = class {
3149
3198
  });
3150
3199
  const requestId = createResponse.request_id;
3151
3200
  if (!requestId) {
3152
- throw new import_provider6.AISDKError({
3201
+ throw new AISDKError({
3153
3202
  name: "XAI_VIDEO_GENERATION_ERROR",
3154
3203
  message: `No request_id returned from xAI API. Response: ${JSON.stringify(createResponse)}`
3155
3204
  });
@@ -3159,17 +3208,17 @@ var XaiVideoModel = class {
3159
3208
  const startTime = Date.now();
3160
3209
  let responseHeaders;
3161
3210
  while (true) {
3162
- await (0, import_provider_utils19.delay)(pollIntervalMs, { abortSignal: options.abortSignal });
3211
+ await delay(pollIntervalMs, { abortSignal: options.abortSignal });
3163
3212
  if (Date.now() - startTime > pollTimeoutMs) {
3164
- throw new import_provider6.AISDKError({
3213
+ throw new AISDKError({
3165
3214
  name: "XAI_VIDEO_GENERATION_TIMEOUT",
3166
3215
  message: `Video generation timed out after ${pollTimeoutMs}ms`
3167
3216
  });
3168
3217
  }
3169
- const { value: statusResponse, responseHeaders: pollHeaders } = await (0, import_provider_utils19.getFromApi)({
3218
+ const { value: statusResponse, responseHeaders: pollHeaders } = await getFromApi2({
3170
3219
  url: `${baseURL}/videos/${requestId}`,
3171
- headers: (0, import_provider_utils19.combineHeaders)(this.config.headers(), options.headers),
3172
- successfulResponseHandler: (0, import_provider_utils19.createJsonResponseHandler)(
3220
+ headers: combineHeaders5(this.config.headers(), options.headers),
3221
+ successfulResponseHandler: createJsonResponseHandler5(
3173
3222
  xaiVideoStatusResponseSchema
3174
3223
  ),
3175
3224
  failedResponseHandler: xaiFailedResponseHandler,
@@ -3179,13 +3228,13 @@ var XaiVideoModel = class {
3179
3228
  responseHeaders = pollHeaders;
3180
3229
  if (statusResponse.status === "done" || statusResponse.status == null && ((_g = statusResponse.video) == null ? void 0 : _g.url)) {
3181
3230
  if (((_h = statusResponse.video) == null ? void 0 : _h.respect_moderation) === false) {
3182
- throw new import_provider6.AISDKError({
3231
+ throw new AISDKError({
3183
3232
  name: "XAI_VIDEO_MODERATION_ERROR",
3184
3233
  message: "Video generation was blocked due to a content policy violation."
3185
3234
  });
3186
3235
  }
3187
3236
  if (!((_i = statusResponse.video) == null ? void 0 : _i.url)) {
3188
- throw new import_provider6.AISDKError({
3237
+ throw new AISDKError({
3189
3238
  name: "XAI_VIDEO_GENERATION_ERROR",
3190
3239
  message: "Video generation completed but no video URL was returned."
3191
3240
  });
@@ -3216,13 +3265,13 @@ var XaiVideoModel = class {
3216
3265
  };
3217
3266
  }
3218
3267
  if (statusResponse.status === "expired") {
3219
- throw new import_provider6.AISDKError({
3268
+ throw new AISDKError({
3220
3269
  name: "XAI_VIDEO_GENERATION_EXPIRED",
3221
3270
  message: "Video generation request expired."
3222
3271
  });
3223
3272
  }
3224
3273
  if (statusResponse.status === "failed") {
3225
- throw new import_provider6.AISDKError({
3274
+ throw new AISDKError({
3226
3275
  name: "XAI_VIDEO_GENERATION_FAILED",
3227
3276
  message: "Video generation failed."
3228
3277
  });
@@ -3230,36 +3279,36 @@ var XaiVideoModel = class {
3230
3279
  }
3231
3280
  }
3232
3281
  };
3233
- var xaiCreateVideoResponseSchema = import_v418.z.object({
3234
- request_id: import_v418.z.string().nullish()
3282
+ var xaiCreateVideoResponseSchema = z18.object({
3283
+ request_id: z18.string().nullish()
3235
3284
  });
3236
- var xaiVideoStatusResponseSchema = import_v418.z.object({
3237
- status: import_v418.z.string().nullish(),
3238
- video: import_v418.z.object({
3239
- url: import_v418.z.string(),
3240
- duration: import_v418.z.number().nullish(),
3241
- respect_moderation: import_v418.z.boolean().nullish()
3285
+ var xaiVideoStatusResponseSchema = z18.object({
3286
+ status: z18.string().nullish(),
3287
+ video: z18.object({
3288
+ url: z18.string(),
3289
+ duration: z18.number().nullish(),
3290
+ respect_moderation: z18.boolean().nullish()
3242
3291
  }).nullish(),
3243
- model: import_v418.z.string().nullish(),
3244
- usage: import_v418.z.object({
3245
- cost_in_usd_ticks: import_v418.z.number().nullish()
3292
+ model: z18.string().nullish(),
3293
+ usage: z18.object({
3294
+ cost_in_usd_ticks: z18.number().nullish()
3246
3295
  }).nullish(),
3247
- progress: import_v418.z.number().nullish(),
3248
- error: import_v418.z.object({
3249
- code: import_v418.z.string().nullish(),
3250
- message: import_v418.z.string().nullish()
3296
+ progress: z18.number().nullish(),
3297
+ error: z18.object({
3298
+ code: z18.string().nullish(),
3299
+ message: z18.string().nullish()
3251
3300
  }).nullish()
3252
3301
  });
3253
3302
 
3254
3303
  // src/xai-provider.ts
3255
3304
  function createXai(options = {}) {
3256
3305
  var _a;
3257
- const baseURL = (0, import_provider_utils20.withoutTrailingSlash)(
3306
+ const baseURL = withoutTrailingSlash(
3258
3307
  (_a = options.baseURL) != null ? _a : "https://api.x.ai/v1"
3259
3308
  );
3260
- const getHeaders = () => (0, import_provider_utils20.withUserAgentSuffix)(
3309
+ const getHeaders = () => withUserAgentSuffix(
3261
3310
  {
3262
- Authorization: `Bearer ${(0, import_provider_utils20.loadApiKey)({
3311
+ Authorization: `Bearer ${loadApiKey({
3263
3312
  apiKey: options.apiKey,
3264
3313
  environmentVariableName: "XAI_API_KEY",
3265
3314
  description: "xAI API key"
@@ -3273,7 +3322,7 @@ function createXai(options = {}) {
3273
3322
  provider: "xai.chat",
3274
3323
  baseURL,
3275
3324
  headers: getHeaders,
3276
- generateId: import_provider_utils20.generateId,
3325
+ generateId,
3277
3326
  fetch: options.fetch
3278
3327
  });
3279
3328
  };
@@ -3282,7 +3331,7 @@ function createXai(options = {}) {
3282
3331
  provider: "xai.responses",
3283
3332
  baseURL,
3284
3333
  headers: getHeaders,
3285
- generateId: import_provider_utils20.generateId,
3334
+ generateId,
3286
3335
  fetch: options.fetch
3287
3336
  });
3288
3337
  };
@@ -3314,7 +3363,7 @@ function createXai(options = {}) {
3314
3363
  provider.chat = createChatLanguageModel;
3315
3364
  provider.responses = createResponsesLanguageModel;
3316
3365
  provider.embeddingModel = (modelId) => {
3317
- throw new import_provider7.NoSuchModelError({ modelId, modelType: "embeddingModel" });
3366
+ throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
3318
3367
  };
3319
3368
  provider.textEmbeddingModel = provider.embeddingModel;
3320
3369
  provider.imageModel = createImageModel;
@@ -3326,8 +3375,7 @@ function createXai(options = {}) {
3326
3375
  return provider;
3327
3376
  }
3328
3377
  var xai = createXai();
3329
- // Annotate the CommonJS export names for ESM import in node:
3330
- 0 && (module.exports = {
3378
+ export {
3331
3379
  VERSION,
3332
3380
  codeExecution,
3333
3381
  createXai,
@@ -3338,5 +3386,5 @@ var xai = createXai();
3338
3386
  xSearch,
3339
3387
  xai,
3340
3388
  xaiTools
3341
- });
3389
+ };
3342
3390
  //# sourceMappingURL=index.js.map