@ai-sdk/xai 3.0.119 → 3.0.121

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @ai-sdk/xai
2
2
 
3
+ ## 3.0.121
4
+
5
+ ### Patch Changes
6
+
7
+ - 70a6c3b: feat (provider/xai): support Grok Imagine Video 1.5. Adds the `grok-imagine-video-1.5` model id and native `1080p` for text-to-video and image-to-video (the standard `resolution: '1920x1080'` now maps to `1080p`). Reference-to-video remains capped at `720p`, so a `1080p` request in that mode is downgraded with a warning. Also fixes reference routing: previously any non-empty `inputReferences` array selected reference-to-video, so an array holding only a non-image reference sent `reference_images: []` with no usable references.
8
+ - 70a6c3b: feat (provider/xai): add `referenceVoiceIds` for reference-to-video reference audio. Pass up to 3 xAI preset voice ids (e.g. `['eve']`) and reference them from the prompt with `<AUDIO_0>`–`<AUDIO_2>`; they are sent as `reference_audios: [{ voice_id }]` on `POST /v1/videos/generations`.
9
+
10
+ ## 3.0.120
11
+
12
+ ### Patch Changes
13
+
14
+ - 3283e3e: feat(xai): support the priority service tier on chat and responses
15
+
3
16
  ## 3.0.119
4
17
 
5
18
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -14,6 +14,10 @@ declare const xaiLanguageModelChatOptions: z.ZodObject<{
14
14
  }>>;
15
15
  logprobs: z.ZodOptional<z.ZodBoolean>;
16
16
  topLogprobs: z.ZodOptional<z.ZodNumber>;
17
+ serviceTier: z.ZodOptional<z.ZodEnum<{
18
+ default: "default";
19
+ priority: "priority";
20
+ }>>;
17
21
  parallel_function_calling: z.ZodOptional<z.ZodBoolean>;
18
22
  searchParameters: z.ZodOptional<z.ZodObject<{
19
23
  mode: z.ZodEnum<{
@@ -87,6 +91,10 @@ declare const xaiLanguageModelResponsesOptions: z.ZodObject<{
87
91
  }>>;
88
92
  logprobs: z.ZodOptional<z.ZodBoolean>;
89
93
  topLogprobs: z.ZodOptional<z.ZodNumber>;
94
+ serviceTier: z.ZodOptional<z.ZodEnum<{
95
+ default: "default";
96
+ priority: "priority";
97
+ }>>;
90
98
  store: z.ZodOptional<z.ZodBoolean>;
91
99
  previousResponseId: z.ZodOptional<z.ZodString>;
92
100
  include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
@@ -112,11 +120,12 @@ declare const xaiImageModelOptions: z.ZodObject<{
112
120
  }, z.core.$strip>;
113
121
  type XaiImageModelOptions = z.infer<typeof xaiImageModelOptions>;
114
122
 
115
- type XaiVideoModelId = 'grok-imagine-video' | (string & {});
123
+ type XaiVideoModelId = 'grok-imagine-video' | 'grok-imagine-video-1.5' | (string & {});
116
124
 
117
125
  declare const resolutionSchema: z.ZodEnum<{
118
126
  "480p": "480p";
119
127
  "720p": "720p";
128
+ "1080p": "1080p";
120
129
  }>;
121
130
  type XaiVideoResolution = z.infer<typeof resolutionSchema>;
122
131
  interface XaiVideoSharedOptions {
@@ -153,6 +162,10 @@ interface XaiVideoReferenceToVideoOptions extends XaiVideoSharedOptions, XaiVide
153
162
  mode: 'reference-to-video';
154
163
  /** Reference image URLs (1-7) for R2V generation. */
155
164
  referenceImageUrls: string[];
165
+ /**
166
+ * Preset voice ids (up to 3) that give the subject a voice.
167
+ */
168
+ referenceVoiceIds?: string[];
156
169
  }
157
170
  interface XaiVideoGenerationOptions extends XaiVideoSharedOptions, XaiVideoUserOptions {
158
171
  mode?: undefined;
@@ -174,6 +187,10 @@ interface XaiLegacyReferenceToVideoOptions extends XaiVideoSharedOptions, XaiVid
174
187
  */
175
188
  mode?: undefined;
176
189
  referenceImageUrls: string[];
190
+ /**
191
+ * Preset voice ids (up to 3) that give the subject a voice.
192
+ */
193
+ referenceVoiceIds?: string[];
177
194
  }
178
195
  /**
179
196
  * Provider options for xAI video generation.
@@ -185,6 +202,9 @@ interface XaiLegacyReferenceToVideoOptions extends XaiVideoSharedOptions, XaiVid
185
202
  * - `'reference-to-video'` + `referenceImageUrls` -- R2V generation (`POST /v1/videos/generations`)
186
203
  * - no `mode` -- standard generation from text prompts or image input
187
204
  *
205
+ * Reference images may also come from the top-level `inputReferences` option
206
+ * instead of `referenceImageUrls`.
207
+ *
188
208
  * Runtime remains backward compatible with legacy auto-detected provider
189
209
  * options, but the public TypeScript type is intentionally explicit so editors
190
210
  * can suggest valid modes and flag invalid field combinations.
package/dist/index.d.ts CHANGED
@@ -14,6 +14,10 @@ declare const xaiLanguageModelChatOptions: z.ZodObject<{
14
14
  }>>;
15
15
  logprobs: z.ZodOptional<z.ZodBoolean>;
16
16
  topLogprobs: z.ZodOptional<z.ZodNumber>;
17
+ serviceTier: z.ZodOptional<z.ZodEnum<{
18
+ default: "default";
19
+ priority: "priority";
20
+ }>>;
17
21
  parallel_function_calling: z.ZodOptional<z.ZodBoolean>;
18
22
  searchParameters: z.ZodOptional<z.ZodObject<{
19
23
  mode: z.ZodEnum<{
@@ -87,6 +91,10 @@ declare const xaiLanguageModelResponsesOptions: z.ZodObject<{
87
91
  }>>;
88
92
  logprobs: z.ZodOptional<z.ZodBoolean>;
89
93
  topLogprobs: z.ZodOptional<z.ZodNumber>;
94
+ serviceTier: z.ZodOptional<z.ZodEnum<{
95
+ default: "default";
96
+ priority: "priority";
97
+ }>>;
90
98
  store: z.ZodOptional<z.ZodBoolean>;
91
99
  previousResponseId: z.ZodOptional<z.ZodString>;
92
100
  include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
@@ -112,11 +120,12 @@ declare const xaiImageModelOptions: z.ZodObject<{
112
120
  }, z.core.$strip>;
113
121
  type XaiImageModelOptions = z.infer<typeof xaiImageModelOptions>;
114
122
 
115
- type XaiVideoModelId = 'grok-imagine-video' | (string & {});
123
+ type XaiVideoModelId = 'grok-imagine-video' | 'grok-imagine-video-1.5' | (string & {});
116
124
 
117
125
  declare const resolutionSchema: z.ZodEnum<{
118
126
  "480p": "480p";
119
127
  "720p": "720p";
128
+ "1080p": "1080p";
120
129
  }>;
121
130
  type XaiVideoResolution = z.infer<typeof resolutionSchema>;
122
131
  interface XaiVideoSharedOptions {
@@ -153,6 +162,10 @@ interface XaiVideoReferenceToVideoOptions extends XaiVideoSharedOptions, XaiVide
153
162
  mode: 'reference-to-video';
154
163
  /** Reference image URLs (1-7) for R2V generation. */
155
164
  referenceImageUrls: string[];
165
+ /**
166
+ * Preset voice ids (up to 3) that give the subject a voice.
167
+ */
168
+ referenceVoiceIds?: string[];
156
169
  }
157
170
  interface XaiVideoGenerationOptions extends XaiVideoSharedOptions, XaiVideoUserOptions {
158
171
  mode?: undefined;
@@ -174,6 +187,10 @@ interface XaiLegacyReferenceToVideoOptions extends XaiVideoSharedOptions, XaiVid
174
187
  */
175
188
  mode?: undefined;
176
189
  referenceImageUrls: string[];
190
+ /**
191
+ * Preset voice ids (up to 3) that give the subject a voice.
192
+ */
193
+ referenceVoiceIds?: string[];
177
194
  }
178
195
  /**
179
196
  * Provider options for xAI video generation.
@@ -185,6 +202,9 @@ interface XaiLegacyReferenceToVideoOptions extends XaiVideoSharedOptions, XaiVid
185
202
  * - `'reference-to-video'` + `referenceImageUrls` -- R2V generation (`POST /v1/videos/generations`)
186
203
  * - no `mode` -- standard generation from text prompts or image input
187
204
  *
205
+ * Reference images may also come from the top-level `inputReferences` option
206
+ * instead of `referenceImageUrls`.
207
+ *
188
208
  * Runtime remains backward compatible with legacy auto-detected provider
189
209
  * options, but the public TypeScript type is intentionally explicit so editors
190
210
  * can suggest valid modes and flag invalid field combinations.
package/dist/index.js CHANGED
@@ -277,6 +277,7 @@ var xaiLanguageModelChatOptions = import_v42.z.object({
277
277
  reasoningEffort: import_v42.z.enum(["none", "low", "medium", "high", "xhigh"]).optional(),
278
278
  logprobs: import_v42.z.boolean().optional(),
279
279
  topLogprobs: import_v42.z.number().int().min(0).max(8).optional(),
280
+ serviceTier: import_v42.z.enum(["default", "priority"]).optional(),
280
281
  /**
281
282
  * Whether to enable parallel function calling during tool use.
282
283
  * When true, the model can call multiple functions in parallel.
@@ -501,6 +502,8 @@ var XaiChatLanguageModel = class {
501
502
  top_p: topP,
502
503
  seed,
503
504
  reasoning_effort: options.reasoningEffort,
505
+ // scheduling priority
506
+ service_tier: options.serviceTier,
504
507
  // parallel function calling
505
508
  parallel_function_calling: options.parallel_function_calling,
506
509
  // response format
@@ -635,6 +638,11 @@ var XaiChatLanguageModel = class {
635
638
  inputTokens: { total: 0, noCache: 0, cacheRead: 0, cacheWrite: 0 },
636
639
  outputTokens: { total: 0, text: 0, reasoning: 0 }
637
640
  },
641
+ ...response.service_tier != null && {
642
+ providerMetadata: {
643
+ xai: { serviceTier: response.service_tier }
644
+ }
645
+ },
638
646
  request: { body },
639
647
  response: {
640
648
  ...getResponseMetadata(response),
@@ -703,6 +711,7 @@ var XaiChatLanguageModel = class {
703
711
  raw: void 0
704
712
  };
705
713
  let usage = void 0;
714
+ let serviceTier = void 0;
706
715
  let isFirstChunk = true;
707
716
  const contentBlocks = {};
708
717
  const lastReasoningDeltas = {};
@@ -743,6 +752,9 @@ var XaiChatLanguageModel = class {
743
752
  if (value.usage != null) {
744
753
  usage = convertXaiChatUsage(value.usage);
745
754
  }
755
+ if (value.service_tier != null) {
756
+ serviceTier = value.service_tier;
757
+ }
746
758
  const choice = value.choices[0];
747
759
  if ((choice == null ? void 0 : choice.finish_reason) != null) {
748
760
  finishReason = {
@@ -857,6 +869,9 @@ var XaiChatLanguageModel = class {
857
869
  cacheWrite: 0
858
870
  },
859
871
  outputTokens: { total: 0, text: 0, reasoning: 0 }
872
+ },
873
+ ...serviceTier != null && {
874
+ providerMetadata: { xai: { serviceTier } }
860
875
  }
861
876
  });
862
877
  }
@@ -912,6 +927,7 @@ var xaiChatResponseSchema = import_v44.z.object({
912
927
  object: import_v44.z.literal("chat.completion").nullish(),
913
928
  usage: xaiUsageSchema.nullish(),
914
929
  citations: import_v44.z.array(import_v44.z.string().url()).nullish(),
930
+ service_tier: import_v44.z.string().nullish(),
915
931
  code: import_v44.z.string().nullish(),
916
932
  error: import_v44.z.string().nullish()
917
933
  });
@@ -941,7 +957,8 @@ var xaiChatChunkSchema = import_v44.z.object({
941
957
  })
942
958
  ),
943
959
  usage: xaiUsageSchema.nullish(),
944
- citations: import_v44.z.array(import_v44.z.string().url()).nullish()
960
+ citations: import_v44.z.array(import_v44.z.string().url()).nullish(),
961
+ service_tier: import_v44.z.string().nullish()
945
962
  });
946
963
  var xaiStreamErrorSchema = import_v44.z.object({
947
964
  code: import_v44.z.string(),
@@ -1509,7 +1526,8 @@ var xaiResponsesResponseSchema = import_v47.z.object({
1509
1526
  object: import_v47.z.literal("response"),
1510
1527
  output: import_v47.z.array(outputItemSchema),
1511
1528
  usage: xaiResponsesUsageSchema.nullish(),
1512
- status: import_v47.z.string()
1529
+ status: import_v47.z.string(),
1530
+ service_tier: import_v47.z.string().nullish()
1513
1531
  });
1514
1532
  var xaiResponsesChunkSchema = import_v47.z.union([
1515
1533
  import_v47.z.object({
@@ -1777,7 +1795,8 @@ var xaiResponsesChunkSchema = import_v47.z.union([
1777
1795
  type: import_v47.z.literal("response.incomplete"),
1778
1796
  response: import_v47.z.object({
1779
1797
  incomplete_details: import_v47.z.object({ reason: import_v47.z.string() }).nullish(),
1780
- usage: xaiResponsesUsageSchema.nullish()
1798
+ usage: xaiResponsesUsageSchema.nullish(),
1799
+ service_tier: import_v47.z.string().nullish()
1781
1800
  })
1782
1801
  }),
1783
1802
  import_v47.z.object({
@@ -1820,6 +1839,7 @@ var xaiLanguageModelResponsesOptions = import_v48.z.object({
1820
1839
  reasoningEffort: import_v48.z.enum(["none", "low", "medium", "high", "xhigh"]).optional(),
1821
1840
  logprobs: import_v48.z.boolean().optional(),
1822
1841
  topLogprobs: import_v48.z.number().int().min(0).max(8).optional(),
1842
+ serviceTier: import_v48.z.enum(["default", "priority"]).optional(),
1823
1843
  /**
1824
1844
  * Whether to store the input message(s) and model response for later retrieval.
1825
1845
  * Must be set to `false` for teams with Zero Data Retention (ZDR) enabled,
@@ -2248,6 +2268,9 @@ var XaiResponsesLanguageModel = class {
2248
2268
  },
2249
2269
  ...options.previousResponseId != null && {
2250
2270
  previous_response_id: options.previousResponseId
2271
+ },
2272
+ ...options.serviceTier != null && {
2273
+ service_tier: options.serviceTier
2251
2274
  }
2252
2275
  };
2253
2276
  if (xaiTools2 && xaiTools2.length > 0) {
@@ -2424,6 +2447,11 @@ var XaiResponsesLanguageModel = class {
2424
2447
  inputTokens: { total: 0, noCache: 0, cacheRead: 0, cacheWrite: 0 },
2425
2448
  outputTokens: { total: 0, text: 0, reasoning: 0 }
2426
2449
  },
2450
+ ...response.service_tier != null && {
2451
+ providerMetadata: {
2452
+ xai: { serviceTier: response.service_tier }
2453
+ }
2454
+ },
2427
2455
  request: { body },
2428
2456
  response: {
2429
2457
  ...getResponseMetadata(response),
@@ -2465,6 +2493,7 @@ var XaiResponsesLanguageModel = class {
2465
2493
  };
2466
2494
  let hasFunctionCall = false;
2467
2495
  let usage = void 0;
2496
+ let serviceTier = void 0;
2468
2497
  let isFirstChunk = true;
2469
2498
  const contentBlocks = {};
2470
2499
  const seenToolCalls = /* @__PURE__ */ new Set();
@@ -2478,7 +2507,7 @@ var XaiResponsesLanguageModel = class {
2478
2507
  controller.enqueue({ type: "stream-start", warnings });
2479
2508
  },
2480
2509
  transform(chunk, controller) {
2481
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
2510
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
2482
2511
  if (options.includeRawChunks) {
2483
2512
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
2484
2513
  }
@@ -2608,8 +2637,9 @@ var XaiResponsesLanguageModel = class {
2608
2637
  if (response2.usage) {
2609
2638
  usage = convertXaiResponsesUsage(response2.usage);
2610
2639
  }
2640
+ serviceTier = (_c = response2.service_tier) != null ? _c : void 0;
2611
2641
  if (event.type === "response.incomplete") {
2612
- const reason = "incomplete_details" in response2 ? (_c = response2.incomplete_details) == null ? void 0 : _c.reason : void 0;
2642
+ const reason = "incomplete_details" in response2 ? (_d = response2.incomplete_details) == null ? void 0 : _d.reason : void 0;
2613
2643
  finishReason = {
2614
2644
  unified: reason ? mapXaiResponsesFinishReason(reason) : "other",
2615
2645
  raw: reason != null ? reason : "incomplete"
@@ -2623,7 +2653,7 @@ var XaiResponsesLanguageModel = class {
2623
2653
  return;
2624
2654
  }
2625
2655
  if (event.type === "response.failed") {
2626
- const reason = (_d = event.response.incomplete_details) == null ? void 0 : _d.reason;
2656
+ const reason = (_e = event.response.incomplete_details) == null ? void 0 : _e.reason;
2627
2657
  finishReason = {
2628
2658
  unified: reason ? mapXaiResponsesFinishReason(reason) : "error",
2629
2659
  raw: reason != null ? reason : "error"
@@ -2719,13 +2749,13 @@ var XaiResponsesLanguageModel = class {
2719
2749
  toolCallId: part.id,
2720
2750
  toolName,
2721
2751
  result: {
2722
- queries: (_e = part.queries) != null ? _e : [],
2723
- results: (_g = (_f = part.results) == null ? void 0 : _f.map((result) => ({
2752
+ queries: (_f = part.queries) != null ? _f : [],
2753
+ results: (_h = (_g = part.results) == null ? void 0 : _g.map((result) => ({
2724
2754
  fileId: result.file_id,
2725
2755
  filename: result.filename,
2726
2756
  score: result.score,
2727
2757
  text: result.text
2728
- }))) != null ? _g : null
2758
+ }))) != null ? _h : null
2729
2759
  }
2730
2760
  });
2731
2761
  }
@@ -2743,17 +2773,17 @@ var XaiResponsesLanguageModel = class {
2743
2773
  "x_semantic_search",
2744
2774
  "x_thread_fetch"
2745
2775
  ];
2746
- let toolName = (_h = part.name) != null ? _h : "";
2747
- if (webSearchSubTools.includes((_i = part.name) != null ? _i : "") || part.type === "web_search_call") {
2776
+ let toolName = (_i = part.name) != null ? _i : "";
2777
+ if (webSearchSubTools.includes((_j = part.name) != null ? _j : "") || part.type === "web_search_call") {
2748
2778
  toolName = webSearchToolName != null ? webSearchToolName : "web_search";
2749
- } else if (xSearchSubTools.includes((_j = part.name) != null ? _j : "") || part.type === "x_search_call") {
2779
+ } else if (xSearchSubTools.includes((_k = part.name) != null ? _k : "") || part.type === "x_search_call") {
2750
2780
  toolName = xSearchToolName != null ? xSearchToolName : "x_search";
2751
2781
  } else if (part.name === "code_execution" || part.type === "code_interpreter_call" || part.type === "code_execution_call") {
2752
2782
  toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
2753
2783
  } else if (part.type === "mcp_call") {
2754
- toolName = (_k = mcpToolName != null ? mcpToolName : part.name) != null ? _k : "mcp";
2784
+ toolName = (_l = mcpToolName != null ? mcpToolName : part.name) != null ? _l : "mcp";
2755
2785
  }
2756
- const toolInput = part.type === "custom_tool_call" ? (_l = part.input) != null ? _l : "" : part.type === "mcp_call" ? (_m = part.arguments) != null ? _m : "" : (_n = part.arguments) != null ? _n : "";
2786
+ const toolInput = part.type === "custom_tool_call" ? (_m = part.input) != null ? _m : "" : part.type === "mcp_call" ? (_n = part.arguments) != null ? _n : "" : (_o = part.arguments) != null ? _o : "";
2757
2787
  const shouldEmit = part.type === "custom_tool_call" ? event.type === "response.output_item.done" : !seenToolCalls.has(part.id);
2758
2788
  if (shouldEmit && !seenToolCalls.has(part.id)) {
2759
2789
  seenToolCalls.add(part.id);
@@ -2814,7 +2844,7 @@ var XaiResponsesLanguageModel = class {
2814
2844
  sourceType: "url",
2815
2845
  id: self.config.generateId(),
2816
2846
  url: annotation.url,
2817
- title: (_o = annotation.title) != null ? _o : annotation.url
2847
+ title: (_p = annotation.title) != null ? _p : annotation.url
2818
2848
  });
2819
2849
  }
2820
2850
  }
@@ -2868,6 +2898,9 @@ var XaiResponsesLanguageModel = class {
2868
2898
  cacheWrite: 0
2869
2899
  },
2870
2900
  outputTokens: { total: 0, text: 0, reasoning: 0 }
2901
+ },
2902
+ ...serviceTier != null && {
2903
+ providerMetadata: { xai: { serviceTier } }
2871
2904
  }
2872
2905
  });
2873
2906
  }
@@ -2934,7 +2967,7 @@ var xaiTools = {
2934
2967
  };
2935
2968
 
2936
2969
  // src/version.ts
2937
- var VERSION = true ? "3.0.119" : "0.0.0-test";
2970
+ var VERSION = true ? "3.0.121" : "0.0.0-test";
2938
2971
 
2939
2972
  // src/xai-video-model.ts
2940
2973
  var import_provider6 = require("@ai-sdk/provider");
@@ -2945,7 +2978,7 @@ var import_v417 = require("zod/v4");
2945
2978
  var import_provider_utils15 = require("@ai-sdk/provider-utils");
2946
2979
  var import_v416 = require("zod/v4");
2947
2980
  var nonEmptyStringSchema = import_v416.z.string().min(1);
2948
- var resolutionSchema = import_v416.z.enum(["480p", "720p"]);
2981
+ var resolutionSchema = import_v416.z.enum(["480p", "720p", "1080p"]);
2949
2982
  var modeSchema = import_v416.z.enum(["edit-video", "extend-video", "reference-to-video"]);
2950
2983
  var baseFields = {
2951
2984
  pollIntervalMs: import_v416.z.number().positive().nullish(),
@@ -2955,22 +2988,28 @@ var baseFields = {
2955
2988
  var userField = {
2956
2989
  user: import_v416.z.string().optional()
2957
2990
  };
2991
+ var referenceVoiceIdsField = {
2992
+ referenceVoiceIds: import_v416.z.array(nonEmptyStringSchema).max(3).optional()
2993
+ };
2958
2994
  var editVideoSchema = import_v416.z.object({
2959
2995
  ...baseFields,
2960
2996
  ...userField,
2961
2997
  mode: import_v416.z.literal("edit-video"),
2962
2998
  videoUrl: nonEmptyStringSchema,
2963
- referenceImageUrls: import_v416.z.undefined().optional()
2999
+ referenceImageUrls: import_v416.z.undefined().optional(),
3000
+ referenceVoiceIds: import_v416.z.undefined().optional()
2964
3001
  });
2965
3002
  var extendVideoSchema = import_v416.z.object({
2966
3003
  ...baseFields,
2967
3004
  mode: import_v416.z.literal("extend-video"),
2968
3005
  videoUrl: nonEmptyStringSchema,
2969
- referenceImageUrls: import_v416.z.undefined().optional()
3006
+ referenceImageUrls: import_v416.z.undefined().optional(),
3007
+ referenceVoiceIds: import_v416.z.undefined().optional()
2970
3008
  });
2971
3009
  var referenceToVideoSchema = import_v416.z.object({
2972
3010
  ...baseFields,
2973
3011
  ...userField,
3012
+ ...referenceVoiceIdsField,
2974
3013
  mode: import_v416.z.literal("reference-to-video"),
2975
3014
  referenceImageUrls: import_v416.z.array(nonEmptyStringSchema).min(1).max(7),
2976
3015
  videoUrl: import_v416.z.undefined().optional()
@@ -2978,6 +3017,7 @@ var referenceToVideoSchema = import_v416.z.object({
2978
3017
  var autoDetectSchema = import_v416.z.object({
2979
3018
  ...baseFields,
2980
3019
  ...userField,
3020
+ ...referenceVoiceIdsField,
2981
3021
  mode: import_v416.z.undefined().optional(),
2982
3022
  videoUrl: nonEmptyStringSchema.optional(),
2983
3023
  referenceImageUrls: import_v416.z.array(nonEmptyStringSchema).min(1).max(7).optional()
@@ -2992,6 +3032,7 @@ var runtimeSchema = import_v416.z.object({
2992
3032
  mode: modeSchema.optional(),
2993
3033
  videoUrl: nonEmptyStringSchema.optional(),
2994
3034
  referenceImageUrls: import_v416.z.array(nonEmptyStringSchema).min(1).max(7).optional(),
3035
+ referenceVoiceIds: import_v416.z.array(nonEmptyStringSchema).max(3).optional(),
2995
3036
  user: import_v416.z.string().optional(),
2996
3037
  ...baseFields
2997
3038
  }).passthrough();
@@ -3001,6 +3042,7 @@ var xaiVideoModelOptionsSchema = (0, import_provider_utils15.lazySchema)(
3001
3042
 
3002
3043
  // src/xai-video-model.ts
3003
3044
  var RESOLUTION_MAP = {
3045
+ "1920x1080": "1080p",
3004
3046
  "1280x720": "720p",
3005
3047
  "854x480": "480p",
3006
3048
  "640x480": "480p"
@@ -3022,6 +3064,7 @@ function getTopLevelMediaType(mediaType) {
3022
3064
  return slashIndex === -1 ? mediaType : mediaType.substring(0, slashIndex);
3023
3065
  }
3024
3066
  var isVideoFile = (file) => file.mediaType != null && getTopLevelMediaType(file.mediaType) === "video";
3067
+ var isImageReference = (file) => file.mediaType == null || getTopLevelMediaType(file.mediaType) === "image";
3025
3068
  function fileToXaiImageUrl(file) {
3026
3069
  if (file.type === "url") {
3027
3070
  return file.url;
@@ -3031,26 +3074,29 @@ function fileToXaiImageUrl(file) {
3031
3074
  }
3032
3075
  function resolveReferenceImages(options, xaiOptions, warnings) {
3033
3076
  if (options.inputReferences != null && options.inputReferences.length > 0) {
3034
- const imageReferences = options.inputReferences.filter((reference) => {
3035
- if (isVideoFile(reference)) {
3077
+ const imageFiles = [];
3078
+ for (const reference of options.inputReferences) {
3079
+ if (!isImageReference(reference)) {
3036
3080
  warnings.push({
3037
3081
  type: "unsupported",
3038
3082
  feature: "inputReferences",
3039
- details: 'xAI reference-to-video accepts image references only. The video reference was ignored. Use providerOptions.xai.mode "extend-video" to continue from a video.'
3083
+ details: isVideoFile(reference) ? 'xAI reference-to-video accepts image references only. The video reference was ignored. Use providerOptions.xai.mode "extend-video" to continue from a video.' : "xAI reference-to-video accepts image references only. The non-image reference was ignored."
3040
3084
  });
3041
- return false;
3085
+ continue;
3042
3086
  }
3043
- return true;
3044
- });
3045
- return imageReferences.map((reference) => ({
3046
- url: fileToXaiImageUrl(reference)
3047
- }));
3087
+ imageFiles.push(reference);
3088
+ }
3089
+ return imageFiles.length > 0 ? imageFiles.map((reference) => ({ url: fileToXaiImageUrl(reference) })) : void 0;
3048
3090
  }
3049
3091
  if ((xaiOptions == null ? void 0 : xaiOptions.referenceImageUrls) != null && xaiOptions.referenceImageUrls.length > 0) {
3050
3092
  return xaiOptions.referenceImageUrls.map((url) => ({ url }));
3051
3093
  }
3052
3094
  return void 0;
3053
3095
  }
3096
+ function hasImageInputReference(options) {
3097
+ var _a, _b;
3098
+ return (_b = (_a = options.inputReferences) == null ? void 0 : _a.some(isImageReference)) != null ? _b : false;
3099
+ }
3054
3100
  function resolveVideoMode(options, xaiOptions) {
3055
3101
  if ((xaiOptions == null ? void 0 : xaiOptions.mode) != null) {
3056
3102
  return xaiOptions.mode;
@@ -3059,9 +3105,8 @@ function resolveVideoMode(options, xaiOptions) {
3059
3105
  return "edit-video";
3060
3106
  }
3061
3107
  const hasFrameImages = options.frameImages != null && options.frameImages.length > 0;
3062
- const hasInputReferences = options.inputReferences != null && options.inputReferences.length > 0;
3063
3108
  const hasLegacyReferenceUrls = (xaiOptions == null ? void 0 : xaiOptions.referenceImageUrls) != null && xaiOptions.referenceImageUrls.length > 0;
3064
- if (!hasFrameImages && (hasInputReferences || hasLegacyReferenceUrls)) {
3109
+ if (!hasFrameImages && (hasImageInputReference(options) || hasLegacyReferenceUrls)) {
3065
3110
  return "reference-to-video";
3066
3111
  }
3067
3112
  return void 0;
@@ -3168,7 +3213,7 @@ var XaiVideoModel = class {
3168
3213
  warnings.push({
3169
3214
  type: "unsupported",
3170
3215
  feature: "resolution",
3171
- details: `Unrecognized resolution "${options.resolution}". Use providerOptions.xai.resolution with "480p" or "720p" instead.`
3216
+ details: `Unrecognized resolution "${options.resolution}". Use providerOptions.xai.resolution with "480p", "720p", or "1080p" instead.`
3172
3217
  });
3173
3218
  }
3174
3219
  }
@@ -3207,13 +3252,47 @@ var XaiVideoModel = class {
3207
3252
  );
3208
3253
  if (referenceImages != null) {
3209
3254
  body.reference_images = referenceImages;
3255
+ } else {
3256
+ warnings.push({
3257
+ type: "unsupported",
3258
+ feature: "referenceImages",
3259
+ details: "xAI reference-to-video requires at least one image reference. The video will be generated without reference images."
3260
+ });
3261
+ }
3262
+ const referenceVoiceIds = xaiOptions == null ? void 0 : xaiOptions.referenceVoiceIds;
3263
+ if (referenceVoiceIds != null && referenceVoiceIds.length > 0) {
3264
+ body.reference_audios = referenceVoiceIds.map((voiceId) => ({
3265
+ voice_id: voiceId
3266
+ }));
3267
+ }
3268
+ if (body.resolution === "1080p") {
3269
+ warnings.push({
3270
+ type: "unsupported",
3271
+ feature: "resolution",
3272
+ details: "xAI reference-to-video is limited to 720p. The request was downgraded from 1080p to 720p."
3273
+ });
3274
+ body.resolution = "720p";
3210
3275
  }
3211
3276
  }
3277
+ if (body.resolution === "1080p" && this.modelId === "grok-imagine-video") {
3278
+ warnings.push({
3279
+ type: "unsupported",
3280
+ feature: "resolution",
3281
+ details: 'xAI model "grok-imagine-video" does not support 1080p. Use "grok-imagine-video-1.5" for 1080p, or a lower resolution. The request was sent with 1080p.'
3282
+ });
3283
+ }
3212
3284
  if (options.inputReferences != null && options.inputReferences.length > 0 && !hasReferenceImages) {
3213
3285
  warnings.push({
3214
3286
  type: "unsupported",
3215
3287
  feature: "inputReferences",
3216
- details: "xAI only supports inputReferences for reference-to-video generation. The reference images were ignored."
3288
+ details: hasImageInputReference(options) ? "xAI only supports inputReferences for reference-to-video generation. The reference images were ignored." : "xAI reference-to-video requires at least one image reference. The references were ignored."
3289
+ });
3290
+ }
3291
+ if ((xaiOptions == null ? void 0 : xaiOptions.referenceVoiceIds) != null && xaiOptions.referenceVoiceIds.length > 0 && !hasReferenceImages) {
3292
+ warnings.push({
3293
+ type: "unsupported",
3294
+ feature: "referenceVoiceIds",
3295
+ details: "xAI only supports reference voices for reference-to-video generation. The reference voices were ignored."
3217
3296
  });
3218
3297
  }
3219
3298
  if (!isExtension && (xaiOptions == null ? void 0 : xaiOptions.user) !== void 0) {
@@ -3228,6 +3307,7 @@ var XaiVideoModel = class {
3228
3307
  "resolution",
3229
3308
  "videoUrl",
3230
3309
  "referenceImageUrls",
3310
+ "referenceVoiceIds",
3231
3311
  "user"
3232
3312
  ].includes(key)) {
3233
3313
  body[key] = value;