@ai-sdk/xai 4.0.33 → 4.0.34

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
@@ -1587,6 +1587,13 @@ var outputItemSchema = z7.discriminatedUnion("type", [
1587
1587
  })
1588
1588
  ).nullish()
1589
1589
  }),
1590
+ z7.object({
1591
+ type: z7.literal("image_generation_call"),
1592
+ id: z7.string(),
1593
+ status: z7.string(),
1594
+ prompt: z7.string().nullish(),
1595
+ result: z7.string().nullish()
1596
+ }),
1590
1597
  z7.object({
1591
1598
  type: z7.literal("custom_tool_call"),
1592
1599
  ...toolCallSchema.shape
@@ -1786,6 +1793,21 @@ var xaiResponsesChunkSchema = z7.union([
1786
1793
  item_id: z7.string(),
1787
1794
  output_index: z7.number()
1788
1795
  }),
1796
+ z7.object({
1797
+ type: z7.literal("response.image_generation_call.in_progress"),
1798
+ item_id: z7.string(),
1799
+ output_index: z7.number()
1800
+ }),
1801
+ z7.object({
1802
+ type: z7.literal("response.image_generation_call.generating"),
1803
+ item_id: z7.string(),
1804
+ output_index: z7.number()
1805
+ }),
1806
+ z7.object({
1807
+ type: z7.literal("response.image_generation_call.completed"),
1808
+ item_id: z7.string(),
1809
+ output_index: z7.number()
1810
+ }),
1789
1811
  z7.object({
1790
1812
  type: z7.literal("response.code_execution_call.in_progress"),
1791
1813
  item_id: z7.string(),
@@ -2013,116 +2035,146 @@ var fileSearchToolFactory = createProviderExecutedToolFactory({
2013
2035
  });
2014
2036
  var fileSearch = (args) => fileSearchToolFactory(args);
2015
2037
 
2016
- // src/tool/mcp-server.ts
2038
+ // src/tool/image-generation.ts
2017
2039
  import {
2018
2040
  createProviderExecutedToolFactory as createProviderExecutedToolFactory2,
2019
2041
  lazySchema as lazySchema2,
2020
2042
  zodSchema as zodSchema2
2021
2043
  } from "@ai-sdk/provider-utils";
2022
2044
  import { z as z10 } from "zod/v4";
2023
- var mcpServerArgsSchema = lazySchema2(
2045
+ var imageGenerationArgsSchema = lazySchema2(
2024
2046
  () => zodSchema2(
2025
2047
  z10.object({
2026
- serverUrl: z10.string().describe("The URL of the MCP server"),
2027
- serverLabel: z10.string().optional().describe("A label for the MCP server"),
2028
- serverDescription: z10.string().optional().describe("Description of the MCP server"),
2029
- allowedTools: z10.array(z10.string()).optional().describe("List of allowed tool names"),
2030
- headers: z10.record(z10.string(), z10.string()).optional().describe("Custom headers to send"),
2031
- authorization: z10.string().optional().describe("Authorization header value")
2048
+ action: z10.enum(["auto", "generate", "edit"]).optional()
2032
2049
  })
2033
2050
  )
2034
2051
  );
2035
- var mcpServerOutputSchema = lazySchema2(
2052
+ var imageGenerationInputSchema = lazySchema2(() => zodSchema2(z10.object({})));
2053
+ var imageGenerationOutputSchema = lazySchema2(
2036
2054
  () => zodSchema2(
2037
2055
  z10.object({
2038
- name: z10.string(),
2039
- arguments: z10.string(),
2040
- result: z10.unknown()
2056
+ result: z10.string(),
2057
+ prompt: z10.string().optional()
2041
2058
  })
2042
2059
  )
2043
2060
  );
2044
- var mcpServerToolFactory = createProviderExecutedToolFactory2({
2045
- id: "xai.mcp",
2046
- inputSchema: lazySchema2(() => zodSchema2(z10.object({}))),
2047
- outputSchema: mcpServerOutputSchema
2061
+ var imageGenerationToolFactory = createProviderExecutedToolFactory2({
2062
+ id: "xai.image_generation",
2063
+ inputSchema: imageGenerationInputSchema,
2064
+ outputSchema: imageGenerationOutputSchema
2048
2065
  });
2049
- var mcpServer = (args) => mcpServerToolFactory(args);
2066
+ var imageGeneration = (args = {}) => imageGenerationToolFactory(args);
2050
2067
 
2051
- // src/tool/web-search.ts
2068
+ // src/tool/mcp-server.ts
2052
2069
  import {
2053
2070
  createProviderExecutedToolFactory as createProviderExecutedToolFactory3,
2054
2071
  lazySchema as lazySchema3,
2055
2072
  zodSchema as zodSchema3
2056
2073
  } from "@ai-sdk/provider-utils";
2057
2074
  import { z as z11 } from "zod/v4";
2058
- var webSearchArgsSchema = lazySchema3(
2075
+ var mcpServerArgsSchema = lazySchema3(
2059
2076
  () => zodSchema3(
2060
2077
  z11.object({
2061
- allowedDomains: z11.array(z11.string()).max(5).optional(),
2062
- excludedDomains: z11.array(z11.string()).max(5).optional(),
2063
- enableImageSearch: z11.boolean().optional(),
2064
- enableImageUnderstanding: z11.boolean().optional()
2078
+ serverUrl: z11.string().describe("The URL of the MCP server"),
2079
+ serverLabel: z11.string().optional().describe("A label for the MCP server"),
2080
+ serverDescription: z11.string().optional().describe("Description of the MCP server"),
2081
+ allowedTools: z11.array(z11.string()).optional().describe("List of allowed tool names"),
2082
+ headers: z11.record(z11.string(), z11.string()).optional().describe("Custom headers to send"),
2083
+ authorization: z11.string().optional().describe("Authorization header value")
2065
2084
  })
2066
2085
  )
2067
2086
  );
2068
- var webSearchOutputSchema = lazySchema3(
2087
+ var mcpServerOutputSchema = lazySchema3(
2069
2088
  () => zodSchema3(
2070
2089
  z11.object({
2071
- query: z11.string(),
2072
- sources: z11.array(
2073
- z11.object({
2074
- title: z11.string(),
2075
- url: z11.string(),
2076
- snippet: z11.string()
2077
- })
2078
- )
2090
+ name: z11.string(),
2091
+ arguments: z11.string(),
2092
+ result: z11.unknown()
2079
2093
  })
2080
2094
  )
2081
2095
  );
2082
- var webSearchToolFactory = createProviderExecutedToolFactory3({
2083
- id: "xai.web_search",
2096
+ var mcpServerToolFactory = createProviderExecutedToolFactory3({
2097
+ id: "xai.mcp",
2084
2098
  inputSchema: lazySchema3(() => zodSchema3(z11.object({}))),
2085
- outputSchema: webSearchOutputSchema
2099
+ outputSchema: mcpServerOutputSchema
2086
2100
  });
2087
- var webSearch = (args = {}) => webSearchToolFactory(args);
2101
+ var mcpServer = (args) => mcpServerToolFactory(args);
2088
2102
 
2089
- // src/tool/x-search.ts
2103
+ // src/tool/web-search.ts
2090
2104
  import {
2091
2105
  createProviderExecutedToolFactory as createProviderExecutedToolFactory4,
2092
2106
  lazySchema as lazySchema4,
2093
2107
  zodSchema as zodSchema4
2094
2108
  } from "@ai-sdk/provider-utils";
2095
2109
  import { z as z12 } from "zod/v4";
2096
- var xSearchArgsSchema = lazySchema4(
2110
+ var webSearchArgsSchema = lazySchema4(
2097
2111
  () => zodSchema4(
2098
2112
  z12.object({
2099
- allowedXHandles: z12.array(z12.string()).max(10).optional(),
2100
- excludedXHandles: z12.array(z12.string()).max(10).optional(),
2101
- fromDate: z12.string().optional(),
2102
- toDate: z12.string().optional(),
2103
- enableImageUnderstanding: z12.boolean().optional(),
2104
- enableVideoUnderstanding: z12.boolean().optional()
2113
+ allowedDomains: z12.array(z12.string()).max(5).optional(),
2114
+ excludedDomains: z12.array(z12.string()).max(5).optional(),
2115
+ enableImageSearch: z12.boolean().optional(),
2116
+ enableImageUnderstanding: z12.boolean().optional()
2105
2117
  })
2106
2118
  )
2107
2119
  );
2108
- var xSearchOutputSchema = lazySchema4(
2120
+ var webSearchOutputSchema = lazySchema4(
2109
2121
  () => zodSchema4(
2110
2122
  z12.object({
2111
2123
  query: z12.string(),
2112
- posts: z12.array(
2124
+ sources: z12.array(
2113
2125
  z12.object({
2114
- author: z12.string(),
2115
- text: z12.string(),
2126
+ title: z12.string(),
2116
2127
  url: z12.string(),
2117
- likes: z12.number()
2128
+ snippet: z12.string()
2118
2129
  })
2119
2130
  )
2120
2131
  })
2121
2132
  )
2122
2133
  );
2123
- var xSearchToolFactory = createProviderExecutedToolFactory4({
2124
- id: "xai.x_search",
2134
+ var webSearchToolFactory = createProviderExecutedToolFactory4({
2135
+ id: "xai.web_search",
2125
2136
  inputSchema: lazySchema4(() => zodSchema4(z12.object({}))),
2137
+ outputSchema: webSearchOutputSchema
2138
+ });
2139
+ var webSearch = (args = {}) => webSearchToolFactory(args);
2140
+
2141
+ // src/tool/x-search.ts
2142
+ import {
2143
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory5,
2144
+ lazySchema as lazySchema5,
2145
+ zodSchema as zodSchema5
2146
+ } from "@ai-sdk/provider-utils";
2147
+ import { z as z13 } from "zod/v4";
2148
+ var xSearchArgsSchema = lazySchema5(
2149
+ () => zodSchema5(
2150
+ z13.object({
2151
+ allowedXHandles: z13.array(z13.string()).max(10).optional(),
2152
+ excludedXHandles: z13.array(z13.string()).max(10).optional(),
2153
+ fromDate: z13.string().optional(),
2154
+ toDate: z13.string().optional(),
2155
+ enableImageUnderstanding: z13.boolean().optional(),
2156
+ enableVideoUnderstanding: z13.boolean().optional()
2157
+ })
2158
+ )
2159
+ );
2160
+ var xSearchOutputSchema = lazySchema5(
2161
+ () => zodSchema5(
2162
+ z13.object({
2163
+ query: z13.string(),
2164
+ posts: z13.array(
2165
+ z13.object({
2166
+ author: z13.string(),
2167
+ text: z13.string(),
2168
+ url: z13.string(),
2169
+ likes: z13.number()
2170
+ })
2171
+ )
2172
+ })
2173
+ )
2174
+ );
2175
+ var xSearchToolFactory = createProviderExecutedToolFactory5({
2176
+ id: "xai.x_search",
2177
+ inputSchema: lazySchema5(() => zodSchema5(z13.object({}))),
2126
2178
  outputSchema: xSearchOutputSchema
2127
2179
  });
2128
2180
  var xSearch = (args = {}) => xSearchToolFactory(args);
@@ -2191,6 +2243,17 @@ async function prepareResponsesTools({
2191
2243
  });
2192
2244
  break;
2193
2245
  }
2246
+ case "xai.image_generation": {
2247
+ const args = await validateTypes({
2248
+ value: tool.args,
2249
+ schema: imageGenerationArgsSchema
2250
+ });
2251
+ xaiTools2.push({
2252
+ type: "image_generation",
2253
+ action: args.action
2254
+ });
2255
+ break;
2256
+ }
2194
2257
  case "xai.file_search": {
2195
2258
  const args = await validateTypes({
2196
2259
  value: tool.args,
@@ -2321,7 +2384,7 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
2321
2384
  toolChoice,
2322
2385
  reasoning
2323
2386
  }) {
2324
- var _a, _b, _c, _d, _e, _f, _g, _h;
2387
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2325
2388
  const warnings = [];
2326
2389
  const options = (_a = await parseProviderOptions5({
2327
2390
  provider: "xai",
@@ -2355,9 +2418,12 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
2355
2418
  const fileSearchToolName = (_f = tools == null ? void 0 : tools.find(
2356
2419
  (tool) => tool.type === "provider" && tool.id === "xai.file_search"
2357
2420
  )) == null ? void 0 : _f.name;
2421
+ const imageGenerationToolName = (_g = tools == null ? void 0 : tools.find(
2422
+ (tool) => tool.type === "provider" && tool.id === "xai.image_generation"
2423
+ )) == null ? void 0 : _g.name;
2358
2424
  const { input, inputWarnings } = await convertToXaiResponsesInput({
2359
2425
  prompt,
2360
- store: (_g = options.store) != null ? _g : true
2426
+ store: (_h = options.store) != null ? _h : true
2361
2427
  });
2362
2428
  warnings.push(...inputWarnings);
2363
2429
  const {
@@ -2415,7 +2481,7 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
2415
2481
  format: responseFormat.schema != null ? {
2416
2482
  type: "json_schema",
2417
2483
  strict: true,
2418
- name: (_h = responseFormat.name) != null ? _h : "response",
2484
+ name: (_i = responseFormat.name) != null ? _i : "response",
2419
2485
  description: responseFormat.description,
2420
2486
  schema: responseFormat.schema
2421
2487
  } : { type: "json_object" }
@@ -2454,7 +2520,8 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
2454
2520
  xSearchToolName,
2455
2521
  codeExecutionToolName,
2456
2522
  mcpToolName,
2457
- fileSearchToolName
2523
+ fileSearchToolName,
2524
+ imageGenerationToolName
2458
2525
  };
2459
2526
  }
2460
2527
  async doGenerate(options) {
@@ -2466,7 +2533,8 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
2466
2533
  xSearchToolName,
2467
2534
  codeExecutionToolName,
2468
2535
  mcpToolName,
2469
- fileSearchToolName
2536
+ fileSearchToolName,
2537
+ imageGenerationToolName
2470
2538
  } = await this.getArgs(options);
2471
2539
  const {
2472
2540
  responseHeaders,
@@ -2522,6 +2590,36 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
2522
2590
  });
2523
2591
  continue;
2524
2592
  }
2593
+ if (part.type === "image_generation_call") {
2594
+ const toolName = imageGenerationToolName != null ? imageGenerationToolName : "image_generation";
2595
+ content.push({
2596
+ type: "tool-call",
2597
+ toolCallId: part.id,
2598
+ toolName,
2599
+ input: "{}",
2600
+ providerExecuted: true
2601
+ });
2602
+ if (part.result != null) {
2603
+ content.push({
2604
+ type: "tool-result",
2605
+ toolCallId: part.id,
2606
+ toolName,
2607
+ result: {
2608
+ result: part.result,
2609
+ ...part.prompt != null && { prompt: part.prompt }
2610
+ }
2611
+ });
2612
+ } else {
2613
+ content.push({
2614
+ type: "tool-result",
2615
+ toolCallId: part.id,
2616
+ toolName,
2617
+ isError: true,
2618
+ result: `Image generation failed (status: ${part.status}).`
2619
+ });
2620
+ }
2621
+ continue;
2622
+ }
2525
2623
  if (part.type === "web_search_call" || part.type === "x_search_call" || part.type === "code_interpreter_call" || part.type === "code_execution_call" || part.type === "view_image_call" || part.type === "view_x_video_call" || part.type === "custom_tool_call" || part.type === "mcp_call") {
2526
2624
  let toolName = (_g = part.name) != null ? _g : "";
2527
2625
  if (webSearchSubTools.includes((_h = part.name) != null ? _h : "") || part.type === "web_search_call") {
@@ -2640,7 +2738,8 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
2640
2738
  xSearchToolName,
2641
2739
  codeExecutionToolName,
2642
2740
  mcpToolName,
2643
- fileSearchToolName
2741
+ fileSearchToolName,
2742
+ imageGenerationToolName
2644
2743
  } = await this.getArgs(options);
2645
2744
  const body = {
2646
2745
  ...args,
@@ -2854,6 +2953,34 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
2854
2953
  if (event.type === "response.function_call_arguments.done") {
2855
2954
  return;
2856
2955
  }
2956
+ if (event.type === "response.image_generation_call.in_progress" || event.type === "response.image_generation_call.generating" || event.type === "response.image_generation_call.completed") {
2957
+ if (!seenToolCalls.has(event.item_id)) {
2958
+ seenToolCalls.add(event.item_id);
2959
+ const toolName = imageGenerationToolName != null ? imageGenerationToolName : "image_generation";
2960
+ controller.enqueue({
2961
+ type: "tool-input-start",
2962
+ id: event.item_id,
2963
+ toolName
2964
+ });
2965
+ controller.enqueue({
2966
+ type: "tool-input-delta",
2967
+ id: event.item_id,
2968
+ delta: "{}"
2969
+ });
2970
+ controller.enqueue({
2971
+ type: "tool-input-end",
2972
+ id: event.item_id
2973
+ });
2974
+ controller.enqueue({
2975
+ type: "tool-call",
2976
+ toolCallId: event.item_id,
2977
+ toolName,
2978
+ input: "{}",
2979
+ providerExecuted: true
2980
+ });
2981
+ }
2982
+ return;
2983
+ }
2857
2984
  if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
2858
2985
  const part = event.item;
2859
2986
  if (part.type === "reasoning") {
@@ -2931,6 +3058,55 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
2931
3058
  }
2932
3059
  return;
2933
3060
  }
3061
+ if (part.type === "image_generation_call") {
3062
+ const toolName = imageGenerationToolName != null ? imageGenerationToolName : "image_generation";
3063
+ if (!seenToolCalls.has(part.id)) {
3064
+ seenToolCalls.add(part.id);
3065
+ controller.enqueue({
3066
+ type: "tool-input-start",
3067
+ id: part.id,
3068
+ toolName
3069
+ });
3070
+ controller.enqueue({
3071
+ type: "tool-input-delta",
3072
+ id: part.id,
3073
+ delta: "{}"
3074
+ });
3075
+ controller.enqueue({
3076
+ type: "tool-input-end",
3077
+ id: part.id
3078
+ });
3079
+ controller.enqueue({
3080
+ type: "tool-call",
3081
+ toolCallId: part.id,
3082
+ toolName,
3083
+ input: "{}",
3084
+ providerExecuted: true
3085
+ });
3086
+ }
3087
+ if (event.type === "response.output_item.done") {
3088
+ if (part.result != null) {
3089
+ controller.enqueue({
3090
+ type: "tool-result",
3091
+ toolCallId: part.id,
3092
+ toolName,
3093
+ result: {
3094
+ result: part.result,
3095
+ ...part.prompt != null && { prompt: part.prompt }
3096
+ }
3097
+ });
3098
+ } else {
3099
+ controller.enqueue({
3100
+ type: "tool-result",
3101
+ toolCallId: part.id,
3102
+ toolName,
3103
+ isError: true,
3104
+ result: `Image generation failed (status: ${part.status}).`
3105
+ });
3106
+ }
3107
+ }
3108
+ return;
3109
+ }
2934
3110
  if (part.type === "web_search_call" || part.type === "x_search_call" || part.type === "code_interpreter_call" || part.type === "code_execution_call" || part.type === "view_image_call" || part.type === "view_x_video_call" || part.type === "custom_tool_call" || part.type === "mcp_call") {
2935
3111
  const webSearchSubTools = [
2936
3112
  "web_search",
@@ -3456,44 +3632,44 @@ var XaiRealtimeModel = class {
3456
3632
  };
3457
3633
 
3458
3634
  // src/tool/code-execution.ts
3459
- import { createProviderExecutedToolFactory as createProviderExecutedToolFactory5 } from "@ai-sdk/provider-utils";
3460
- import { z as z13 } from "zod/v4";
3461
- var codeExecutionOutputSchema = z13.object({
3462
- output: z13.string().describe("the output of the code execution"),
3463
- error: z13.string().optional().describe("any error that occurred")
3635
+ import { createProviderExecutedToolFactory as createProviderExecutedToolFactory6 } from "@ai-sdk/provider-utils";
3636
+ import { z as z14 } from "zod/v4";
3637
+ var codeExecutionOutputSchema = z14.object({
3638
+ output: z14.string().describe("the output of the code execution"),
3639
+ error: z14.string().optional().describe("any error that occurred")
3464
3640
  });
3465
- var codeExecutionToolFactory = createProviderExecutedToolFactory5({
3641
+ var codeExecutionToolFactory = createProviderExecutedToolFactory6({
3466
3642
  id: "xai.code_execution",
3467
- inputSchema: z13.object({}).describe("no input parameters"),
3643
+ inputSchema: z14.object({}).describe("no input parameters"),
3468
3644
  outputSchema: codeExecutionOutputSchema
3469
3645
  });
3470
3646
  var codeExecution = (args = {}) => codeExecutionToolFactory(args);
3471
3647
 
3472
3648
  // src/tool/view-image.ts
3473
- import { createProviderExecutedToolFactory as createProviderExecutedToolFactory6 } from "@ai-sdk/provider-utils";
3474
- import { z as z14 } from "zod/v4";
3475
- var viewImageOutputSchema = z14.object({
3476
- description: z14.string().describe("description of the image"),
3477
- objects: z14.array(z14.string()).optional().describe("objects detected in the image")
3649
+ import { createProviderExecutedToolFactory as createProviderExecutedToolFactory7 } from "@ai-sdk/provider-utils";
3650
+ import { z as z15 } from "zod/v4";
3651
+ var viewImageOutputSchema = z15.object({
3652
+ description: z15.string().describe("description of the image"),
3653
+ objects: z15.array(z15.string()).optional().describe("objects detected in the image")
3478
3654
  });
3479
- var viewImageToolFactory = createProviderExecutedToolFactory6({
3655
+ var viewImageToolFactory = createProviderExecutedToolFactory7({
3480
3656
  id: "xai.view_image",
3481
- inputSchema: z14.object({}).describe("no input parameters"),
3657
+ inputSchema: z15.object({}).describe("no input parameters"),
3482
3658
  outputSchema: viewImageOutputSchema
3483
3659
  });
3484
3660
  var viewImage = (args = {}) => viewImageToolFactory(args);
3485
3661
 
3486
3662
  // src/tool/view-x-video.ts
3487
- import { createProviderExecutedToolFactory as createProviderExecutedToolFactory7 } from "@ai-sdk/provider-utils";
3488
- import { z as z15 } from "zod/v4";
3489
- var viewXVideoOutputSchema = z15.object({
3490
- transcript: z15.string().optional().describe("transcript of the video"),
3491
- description: z15.string().describe("description of the video content"),
3492
- duration: z15.number().optional().describe("duration in seconds")
3663
+ import { createProviderExecutedToolFactory as createProviderExecutedToolFactory8 } from "@ai-sdk/provider-utils";
3664
+ import { z as z16 } from "zod/v4";
3665
+ var viewXVideoOutputSchema = z16.object({
3666
+ transcript: z16.string().optional().describe("transcript of the video"),
3667
+ description: z16.string().describe("description of the video content"),
3668
+ duration: z16.number().optional().describe("duration in seconds")
3493
3669
  });
3494
- var viewXVideoToolFactory = createProviderExecutedToolFactory7({
3670
+ var viewXVideoToolFactory = createProviderExecutedToolFactory8({
3495
3671
  id: "xai.view_x_video",
3496
- inputSchema: z15.object({}).describe("no input parameters"),
3672
+ inputSchema: z16.object({}).describe("no input parameters"),
3497
3673
  outputSchema: viewXVideoOutputSchema
3498
3674
  });
3499
3675
  var viewXVideo = (args = {}) => viewXVideoToolFactory(args);
@@ -3502,6 +3678,7 @@ var viewXVideo = (args = {}) => viewXVideoToolFactory(args);
3502
3678
  var xaiTools = {
3503
3679
  codeExecution,
3504
3680
  fileSearch,
3681
+ imageGeneration,
3505
3682
  mcpServer,
3506
3683
  viewImage,
3507
3684
  viewXVideo,
@@ -3510,7 +3687,7 @@ var xaiTools = {
3510
3687
  };
3511
3688
 
3512
3689
  // src/version.ts
3513
- var VERSION = true ? "4.0.33" : "0.0.0-test";
3690
+ var VERSION = true ? "4.0.34" : "0.0.0-test";
3514
3691
 
3515
3692
  // src/files/xai-files.ts
3516
3693
  import {
@@ -3522,33 +3699,33 @@ import {
3522
3699
  } from "@ai-sdk/provider-utils";
3523
3700
 
3524
3701
  // src/files/xai-files-api.ts
3525
- import { lazySchema as lazySchema5, zodSchema as zodSchema5 } from "@ai-sdk/provider-utils";
3526
- import { z as z16 } from "zod/v4";
3527
- var xaiFilesResponseSchema = lazySchema5(
3528
- () => zodSchema5(
3529
- z16.object({
3530
- id: z16.string(),
3531
- object: z16.string().nullish(),
3532
- bytes: z16.number().nullish(),
3533
- created_at: z16.number().nullish(),
3534
- filename: z16.string().nullish(),
3535
- purpose: z16.string().nullish(),
3536
- status: z16.string().nullish()
3702
+ import { lazySchema as lazySchema6, zodSchema as zodSchema6 } from "@ai-sdk/provider-utils";
3703
+ import { z as z17 } from "zod/v4";
3704
+ var xaiFilesResponseSchema = lazySchema6(
3705
+ () => zodSchema6(
3706
+ z17.object({
3707
+ id: z17.string(),
3708
+ object: z17.string().nullish(),
3709
+ bytes: z17.number().nullish(),
3710
+ created_at: z17.number().nullish(),
3711
+ filename: z17.string().nullish(),
3712
+ purpose: z17.string().nullish(),
3713
+ status: z17.string().nullish()
3537
3714
  })
3538
3715
  )
3539
3716
  );
3540
3717
 
3541
3718
  // src/files/xai-files-options.ts
3542
3719
  import {
3543
- lazySchema as lazySchema6,
3544
- zodSchema as zodSchema6
3720
+ lazySchema as lazySchema7,
3721
+ zodSchema as zodSchema7
3545
3722
  } from "@ai-sdk/provider-utils";
3546
- import { z as z17 } from "zod/v4";
3547
- var xaiFilesOptionsSchema = lazySchema6(
3548
- () => zodSchema6(
3549
- z17.looseObject({
3550
- teamId: z17.string().optional(),
3551
- filePath: z17.string().optional()
3723
+ import { z as z18 } from "zod/v4";
3724
+ var xaiFilesOptionsSchema = lazySchema7(
3725
+ () => zodSchema7(
3726
+ z18.looseObject({
3727
+ teamId: z18.string().optional(),
3728
+ filePath: z18.string().optional()
3552
3729
  })
3553
3730
  )
3554
3731
  );
@@ -3629,64 +3806,64 @@ import {
3629
3806
  postJsonToApi as postJsonToApi4,
3630
3807
  safeParseJSON as safeParseJSON2
3631
3808
  } from "@ai-sdk/provider-utils";
3632
- import { z as z19 } from "zod/v4";
3809
+ import { z as z20 } from "zod/v4";
3633
3810
 
3634
3811
  // src/xai-video-model-options.ts
3635
- import { lazySchema as lazySchema7, zodSchema as zodSchema7 } from "@ai-sdk/provider-utils";
3636
- import { z as z18 } from "zod/v4";
3637
- var nonEmptyStringSchema = z18.string().min(1);
3638
- var resolutionSchema = z18.enum(["480p", "720p"]);
3639
- var modeSchema = z18.enum(["edit-video", "extend-video", "reference-to-video"]);
3812
+ import { lazySchema as lazySchema8, zodSchema as zodSchema8 } from "@ai-sdk/provider-utils";
3813
+ import { z as z19 } from "zod/v4";
3814
+ var nonEmptyStringSchema = z19.string().min(1);
3815
+ var resolutionSchema = z19.enum(["480p", "720p"]);
3816
+ var modeSchema = z19.enum(["edit-video", "extend-video", "reference-to-video"]);
3640
3817
  var baseFields = {
3641
- pollIntervalMs: z18.number().positive().nullish(),
3642
- pollTimeoutMs: z18.number().positive().nullish(),
3818
+ pollIntervalMs: z19.number().positive().nullish(),
3819
+ pollTimeoutMs: z19.number().positive().nullish(),
3643
3820
  resolution: resolutionSchema.nullish()
3644
3821
  };
3645
3822
  var userField = {
3646
- user: z18.string().optional()
3823
+ user: z19.string().optional()
3647
3824
  };
3648
- var editVideoSchema = z18.object({
3825
+ var editVideoSchema = z19.object({
3649
3826
  ...baseFields,
3650
3827
  ...userField,
3651
- mode: z18.literal("edit-video"),
3828
+ mode: z19.literal("edit-video"),
3652
3829
  videoUrl: nonEmptyStringSchema,
3653
- referenceImageUrls: z18.undefined().optional()
3830
+ referenceImageUrls: z19.undefined().optional()
3654
3831
  });
3655
- var extendVideoSchema = z18.object({
3832
+ var extendVideoSchema = z19.object({
3656
3833
  ...baseFields,
3657
- mode: z18.literal("extend-video"),
3834
+ mode: z19.literal("extend-video"),
3658
3835
  videoUrl: nonEmptyStringSchema,
3659
- referenceImageUrls: z18.undefined().optional()
3836
+ referenceImageUrls: z19.undefined().optional()
3660
3837
  });
3661
- var referenceToVideoSchema = z18.object({
3838
+ var referenceToVideoSchema = z19.object({
3662
3839
  ...baseFields,
3663
3840
  ...userField,
3664
- mode: z18.literal("reference-to-video"),
3665
- referenceImageUrls: z18.array(nonEmptyStringSchema).min(1).max(7),
3666
- videoUrl: z18.undefined().optional()
3841
+ mode: z19.literal("reference-to-video"),
3842
+ referenceImageUrls: z19.array(nonEmptyStringSchema).min(1).max(7),
3843
+ videoUrl: z19.undefined().optional()
3667
3844
  });
3668
- var autoDetectSchema = z18.object({
3845
+ var autoDetectSchema = z19.object({
3669
3846
  ...baseFields,
3670
3847
  ...userField,
3671
- mode: z18.undefined().optional(),
3848
+ mode: z19.undefined().optional(),
3672
3849
  videoUrl: nonEmptyStringSchema.optional(),
3673
- referenceImageUrls: z18.array(nonEmptyStringSchema).min(1).max(7).optional()
3850
+ referenceImageUrls: z19.array(nonEmptyStringSchema).min(1).max(7).optional()
3674
3851
  });
3675
- var xaiVideoModelOptions = z18.union([
3852
+ var xaiVideoModelOptions = z19.union([
3676
3853
  editVideoSchema,
3677
3854
  extendVideoSchema,
3678
3855
  referenceToVideoSchema,
3679
3856
  autoDetectSchema
3680
3857
  ]);
3681
- var runtimeSchema = z18.looseObject({
3858
+ var runtimeSchema = z19.looseObject({
3682
3859
  mode: modeSchema.optional(),
3683
3860
  videoUrl: nonEmptyStringSchema.optional(),
3684
- referenceImageUrls: z18.array(nonEmptyStringSchema).min(1).max(7).optional(),
3685
- user: z18.string().optional(),
3861
+ referenceImageUrls: z19.array(nonEmptyStringSchema).min(1).max(7).optional(),
3862
+ user: z19.string().optional(),
3686
3863
  ...baseFields
3687
3864
  });
3688
- var xaiVideoModelOptionsSchema = lazySchema7(
3689
- () => zodSchema7(runtimeSchema)
3865
+ var xaiVideoModelOptionsSchema = lazySchema8(
3866
+ () => zodSchema8(runtimeSchema)
3690
3867
  );
3691
3868
 
3692
3869
  // src/xai-video-model.ts
@@ -4055,24 +4232,24 @@ var XaiVideoModel = class {
4055
4232
  };
4056
4233
  }
4057
4234
  };
4058
- var xaiCreateVideoResponseSchema = z19.object({
4059
- request_id: z19.string().nullish()
4235
+ var xaiCreateVideoResponseSchema = z20.object({
4236
+ request_id: z20.string().nullish()
4060
4237
  });
4061
- var xaiVideoStatusResponseSchema = z19.object({
4062
- status: z19.string().nullish(),
4063
- video: z19.object({
4064
- url: z19.string(),
4065
- duration: z19.number().nullish(),
4066
- respect_moderation: z19.boolean().nullish()
4238
+ var xaiVideoStatusResponseSchema = z20.object({
4239
+ status: z20.string().nullish(),
4240
+ video: z20.object({
4241
+ url: z20.string(),
4242
+ duration: z20.number().nullish(),
4243
+ respect_moderation: z20.boolean().nullish()
4067
4244
  }).nullish(),
4068
- model: z19.string().nullish(),
4069
- usage: z19.object({
4070
- cost_in_usd_ticks: z19.number().nullish()
4245
+ model: z20.string().nullish(),
4246
+ usage: z20.object({
4247
+ cost_in_usd_ticks: z20.number().nullish()
4071
4248
  }).nullish(),
4072
- progress: z19.number().nullish(),
4073
- error: z19.object({
4074
- code: z19.string().nullish(),
4075
- message: z19.string().nullish()
4249
+ progress: z20.number().nullish(),
4250
+ error: z20.object({
4251
+ code: z20.string().nullish(),
4252
+ message: z20.string().nullish()
4076
4253
  }).nullish()
4077
4254
  });
4078
4255
  var xaiVideoStatusJsonResponseHandler = createJsonResponseHandler5(
@@ -4151,42 +4328,42 @@ import {
4151
4328
 
4152
4329
  // src/xai-speech-model-options.ts
4153
4330
  import {
4154
- lazySchema as lazySchema8,
4155
- zodSchema as zodSchema8
4331
+ lazySchema as lazySchema9,
4332
+ zodSchema as zodSchema9
4156
4333
  } from "@ai-sdk/provider-utils";
4157
- import { z as z20 } from "zod/v4";
4158
- var xaiSpeechModelOptionsSchema = lazySchema8(
4159
- () => zodSchema8(
4160
- z20.object({
4334
+ import { z as z21 } from "zod/v4";
4335
+ var xaiSpeechModelOptionsSchema = lazySchema9(
4336
+ () => zodSchema9(
4337
+ z21.object({
4161
4338
  /**
4162
4339
  * Sample rate of the generated audio in Hz.
4163
4340
  */
4164
- sampleRate: z20.union([
4165
- z20.literal(8e3),
4166
- z20.literal(16e3),
4167
- z20.literal(22050),
4168
- z20.literal(24e3),
4169
- z20.literal(44100),
4170
- z20.literal(48e3)
4341
+ sampleRate: z21.union([
4342
+ z21.literal(8e3),
4343
+ z21.literal(16e3),
4344
+ z21.literal(22050),
4345
+ z21.literal(24e3),
4346
+ z21.literal(44100),
4347
+ z21.literal(48e3)
4171
4348
  ]).nullish(),
4172
4349
  /**
4173
4350
  * MP3 bit rate in bits per second. Only applies when outputFormat is mp3.
4174
4351
  */
4175
- bitRate: z20.union([
4176
- z20.literal(32e3),
4177
- z20.literal(64e3),
4178
- z20.literal(96e3),
4179
- z20.literal(128e3),
4180
- z20.literal(192e3)
4352
+ bitRate: z21.union([
4353
+ z21.literal(32e3),
4354
+ z21.literal(64e3),
4355
+ z21.literal(96e3),
4356
+ z21.literal(128e3),
4357
+ z21.literal(192e3)
4181
4358
  ]).nullish(),
4182
4359
  /**
4183
4360
  * Reduce time to first audio chunk, trading some quality for latency.
4184
4361
  */
4185
- optimizeStreamingLatency: z20.union([z20.literal(0), z20.literal(1), z20.literal(2)]).nullish(),
4362
+ optimizeStreamingLatency: z21.union([z21.literal(0), z21.literal(1), z21.literal(2)]).nullish(),
4186
4363
  /**
4187
4364
  * Normalize written-form text into spoken-form text before synthesis.
4188
4365
  */
4189
- textNormalization: z20.boolean().nullish()
4366
+ textNormalization: z21.boolean().nullish()
4190
4367
  })
4191
4368
  )
4192
4369
  );
@@ -4325,80 +4502,80 @@ import {
4325
4502
  WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE5,
4326
4503
  WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE5
4327
4504
  } from "@ai-sdk/provider-utils";
4328
- import { z as z22 } from "zod/v4";
4505
+ import { z as z23 } from "zod/v4";
4329
4506
 
4330
4507
  // src/xai-transcription-model-options.ts
4331
4508
  import {
4332
- lazySchema as lazySchema9,
4333
- zodSchema as zodSchema9
4509
+ lazySchema as lazySchema10,
4510
+ zodSchema as zodSchema10
4334
4511
  } from "@ai-sdk/provider-utils";
4335
- import { z as z21 } from "zod/v4";
4336
- var xaiTranscriptionModelOptionsSchema = lazySchema9(
4337
- () => zodSchema9(
4338
- z21.object({
4512
+ import { z as z22 } from "zod/v4";
4513
+ var xaiTranscriptionModelOptionsSchema = lazySchema10(
4514
+ () => zodSchema10(
4515
+ z22.object({
4339
4516
  /**
4340
4517
  * Audio encoding for raw, headerless input audio.
4341
4518
  */
4342
- audioFormat: z21.enum(["pcm", "mulaw", "alaw"]).nullish(),
4519
+ audioFormat: z22.enum(["pcm", "mulaw", "alaw"]).nullish(),
4343
4520
  /**
4344
4521
  * Sample rate of the input audio in Hz.
4345
4522
  */
4346
- sampleRate: z21.union([
4347
- z21.literal(8e3),
4348
- z21.literal(16e3),
4349
- z21.literal(22050),
4350
- z21.literal(24e3),
4351
- z21.literal(44100),
4352
- z21.literal(48e3)
4523
+ sampleRate: z22.union([
4524
+ z22.literal(8e3),
4525
+ z22.literal(16e3),
4526
+ z22.literal(22050),
4527
+ z22.literal(24e3),
4528
+ z22.literal(44100),
4529
+ z22.literal(48e3)
4353
4530
  ]).nullish(),
4354
4531
  /**
4355
4532
  * Language code used for inverse text normalization.
4356
4533
  */
4357
- language: z21.string().nullish(),
4534
+ language: z22.string().nullish(),
4358
4535
  /**
4359
4536
  * Enable inverse text normalization. Requires `language`.
4360
4537
  */
4361
- format: z21.boolean().nullish(),
4538
+ format: z22.boolean().nullish(),
4362
4539
  /**
4363
4540
  * Enable per-channel transcription for multichannel audio.
4364
4541
  */
4365
- multichannel: z21.boolean().nullish(),
4542
+ multichannel: z22.boolean().nullish(),
4366
4543
  /**
4367
4544
  * Number of interleaved audio channels.
4368
4545
  */
4369
- channels: z21.number().int().min(2).max(8).nullish(),
4546
+ channels: z22.number().int().min(2).max(8).nullish(),
4370
4547
  /**
4371
4548
  * Enable speaker diarization.
4372
4549
  */
4373
- diarize: z21.boolean().nullish(),
4550
+ diarize: z22.boolean().nullish(),
4374
4551
  /**
4375
4552
  * Terms to bias transcription toward.
4376
4553
  */
4377
- keyterm: z21.union([z21.string(), z21.array(z21.string())]).nullish(),
4554
+ keyterm: z22.union([z22.string(), z22.array(z22.string())]).nullish(),
4378
4555
  /**
4379
4556
  * Include filler words such as "uh" and "um" in the transcript.
4380
4557
  */
4381
- fillerWords: z21.boolean().nullish(),
4558
+ fillerWords: z22.boolean().nullish(),
4382
4559
  /**
4383
4560
  * Options for streaming speech-to-text over WebSocket.
4384
4561
  */
4385
- streaming: z21.object({
4562
+ streaming: z22.object({
4386
4563
  /**
4387
4564
  * Emit interim transcript results while speech is being processed.
4388
4565
  */
4389
- interimResults: z21.boolean().optional(),
4566
+ interimResults: z22.boolean().optional(),
4390
4567
  /**
4391
4568
  * Silence duration in milliseconds before an utterance-final event.
4392
4569
  */
4393
- endpointing: z21.number().int().min(0).max(5e3).optional(),
4570
+ endpointing: z22.number().int().min(0).max(5e3).optional(),
4394
4571
  /**
4395
4572
  * End-of-turn detection threshold. When set, enables Smart Turn.
4396
4573
  */
4397
- smartTurn: z21.number().min(0).max(1).optional(),
4574
+ smartTurn: z22.number().min(0).max(1).optional(),
4398
4575
  /**
4399
4576
  * Maximum silence duration in milliseconds before forcing speech_final.
4400
4577
  */
4401
- smartTurnTimeout: z21.number().int().min(1).max(5e3).optional()
4578
+ smartTurnTimeout: z22.number().int().min(1).max(5e3).optional()
4402
4579
  }).optional()
4403
4580
  })
4404
4581
  )
@@ -4797,15 +4974,15 @@ function timingFromXaiEvent(event) {
4797
4974
  ...event.start != null && event.duration != null ? { endSecond: event.start + event.duration } : {}
4798
4975
  };
4799
4976
  }
4800
- var xaiTranscriptionResponseSchema = z22.object({
4801
- text: z22.string(),
4802
- language: z22.string().nullish(),
4803
- duration: z22.number().nullish(),
4804
- words: z22.array(
4805
- z22.object({
4806
- text: z22.string(),
4807
- start: z22.number(),
4808
- end: z22.number()
4977
+ var xaiTranscriptionResponseSchema = z23.object({
4978
+ text: z23.string(),
4979
+ language: z23.string().nullish(),
4980
+ duration: z23.number().nullish(),
4981
+ words: z23.array(
4982
+ z23.object({
4983
+ text: z23.string(),
4984
+ start: z23.number(),
4985
+ end: z23.number()
4809
4986
  })
4810
4987
  ).nullish()
4811
4988
  });
@@ -4937,6 +5114,7 @@ export {
4937
5114
  VERSION,
4938
5115
  codeExecution,
4939
5116
  createXai,
5117
+ imageGeneration,
4940
5118
  mcpServer,
4941
5119
  viewImage,
4942
5120
  viewXVideo,