@shop-os/modelkit 0.18.1 → 0.19.0

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
@@ -158,6 +158,7 @@ function isListed(row2) {
158
158
  var IMAGE_USAGE = { unit: "images" };
159
159
  var EXPOSURE = ["cowork", "space_builder"];
160
160
  var LOBE = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light";
161
+ var MINIMAX_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
161
162
  var SIZED_RATIOS = [
162
163
  "1:1",
163
164
  "16:9",
@@ -183,6 +184,36 @@ var RECRAFT_RATIOS = [
183
184
  "5:4",
184
185
  "4:5"
185
186
  ];
187
+ function minimaxH3ImageRow(row2) {
188
+ return {
189
+ id: row2.id,
190
+ aliases: [],
191
+ label: row2.label,
192
+ type: "image",
193
+ adapter: "fal",
194
+ providerModelId: row2.providerModelId,
195
+ lifecycle: "active",
196
+ exposure: EXPOSURE,
197
+ constraints: {
198
+ aspectRatios: [...SIZED_RATIOS],
199
+ sizes: ["1K", "2K", "4K"],
200
+ references: {
201
+ images: 16,
202
+ imagePixels: { minWidth: 128, minHeight: 128, maxSide: 8192 }
203
+ },
204
+ supports: ["count", "outputFormat"],
205
+ prompt: { referenceSyntax: "numbered", maxChars: 32e3 }
206
+ },
207
+ defaults: { size: "2K", aspectRatio: "1:1", count: 1 },
208
+ usage: { ...IMAGE_USAGE },
209
+ pricingKind: "image_size",
210
+ display: {
211
+ provider: "minimax",
212
+ description: row2.description,
213
+ logo: MINIMAX_LOGO
214
+ }
215
+ };
216
+ }
186
217
  var FAL_IMAGE_MODELS = [
187
218
  {
188
219
  // krea/v3/text-to-image; references switch to krea/v3/edit (1-8 images). Billed per
@@ -266,6 +297,22 @@ var FAL_IMAGE_MODELS = [
266
297
  logo: `${LOBE}/qwen-color.png`
267
298
  }
268
299
  },
300
+ minimaxH3ImageRow({
301
+ // minimax/h3-image/text-to-image; references switch to minimax/h3-image/edit. Billed on
302
+ // tokens: $2.30/M input text, $1.50/M input image, $3.80/M output image.
303
+ id: "minimax-h3-image",
304
+ label: "MiniMax H3 Image",
305
+ providerModelId: "minimax/h3-image/text-to-image",
306
+ description: "MiniMax H3 Image text-to-image and multi-image editing with precise instruction following; takes a prompt and up to 16 reference images and outputs 1K, 2K or 4K."
307
+ }),
308
+ minimaxH3ImageRow({
309
+ // minimax/h3-image/highspeed/text-to-image; references switch to .../highspeed/edit.
310
+ // Billed on tokens: $2.30/M input text, $3.00/M input image, $7.60/M output image.
311
+ id: "minimax-h3-image-highspeed",
312
+ label: "MiniMax H3 Image Highspeed",
313
+ providerModelId: "minimax/h3-image/highspeed/text-to-image",
314
+ description: "MiniMax H3 Image Highspeed, the faster tier of H3 Image for text-to-image and multi-image editing; takes a prompt and up to 16 reference images and outputs 1K, 2K or 4K."
315
+ }),
269
316
  {
270
317
  // fal-ai/kling-image/o3/text-to-image; references switch to .../o3/image-to-image (up to
271
318
  // 10, "@Image1".."@Image10"). $0.028 per image at 1K and 2K, double at 4K.
@@ -3764,7 +3811,7 @@ var MINIMAX_VOICES = [
3764
3811
  // src/catalog/media-nodes.ts
3765
3812
  var ELEVENLABS_LOGO2 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/elevenlabs.png";
3766
3813
  var GOOGLE_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png";
3767
- var MINIMAX_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
3814
+ var MINIMAX_LOGO2 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
3768
3815
  var SYNC_LOGO = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/sync.png";
3769
3816
  var PER_CALL3 = { unit: "images" };
3770
3817
  var EXPOSURE5 = ["cowork", "space_builder"];
@@ -3899,7 +3946,7 @@ var MEDIA_NODE_MODELS = [
3899
3946
  pricingKind: "flat",
3900
3947
  display: {
3901
3948
  provider: "minimax",
3902
- logo: MINIMAX_LOGO,
3949
+ logo: MINIMAX_LOGO2,
3903
3950
  description: "MiniMax Speech 2.8 HD text to speech; studio-quality narration in over 300 voices, with pause and interjection tags."
3904
3951
  },
3905
3952
  capabilities: {}
@@ -4026,7 +4073,7 @@ var MEDIA_NODE_MODELS = [
4026
4073
  pricingKind: "video_per_second",
4027
4074
  display: {
4028
4075
  provider: "minimax",
4029
- logo: MINIMAX_LOGO,
4076
+ logo: MINIMAX_LOGO2,
4030
4077
  description: "MiniMax H3 Max lip sync; animates a portrait image into a talking video as long as the speech, up to 2K."
4031
4078
  },
4032
4079
  capabilities: {}
@@ -4256,7 +4303,7 @@ var MODEL3D_MODELS = [
4256
4303
  // src/catalog/other.ts
4257
4304
  var GOOGLE_LOGO2 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png";
4258
4305
  var ELEVENLABS_LOGO3 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/elevenlabs.png";
4259
- var MINIMAX_LOGO2 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
4306
+ var MINIMAX_LOGO3 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
4260
4307
  var OTHER_MODELS = [
4261
4308
  {
4262
4309
  id: "lyria-3-clip-preview",
@@ -4445,7 +4492,7 @@ var OTHER_MODELS = [
4445
4492
  pricingKind: "flat",
4446
4493
  display: {
4447
4494
  provider: "minimax",
4448
- logo: MINIMAX_LOGO2,
4495
+ logo: MINIMAX_LOGO3,
4449
4496
  description: "MiniMax Music 3 songs from a style prompt and your lyrics (or instrumental), up to 5 minutes."
4450
4497
  },
4451
4498
  capabilities: {}
@@ -4863,6 +4910,7 @@ var TEXT_MODELS = [
4863
4910
  description: "Anthropic Claude Fable 5 (legacy) model for demanding reasoning and long-horizon agentic work; text and image input, 1M-token context."
4864
4911
  },
4865
4912
  capabilities: {
4913
+ reasoning: true,
4866
4914
  vision: true,
4867
4915
  contextWindow: 1e6
4868
4916
  }
@@ -5142,7 +5190,7 @@ var TEXT_MODELS = [
5142
5190
  var VIDEO_USAGE = { unit: "seconds" };
5143
5191
  var MB = 1024 * 1024;
5144
5192
  var KLING_LOGO = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/kling-color.png";
5145
- var MINIMAX_LOGO3 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
5193
+ var MINIMAX_LOGO4 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
5146
5194
  var BYTEDANCE_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/3bba5d81-4e57-4e71-911b-cdfa05acca2c_compressed.png";
5147
5195
  var XAI_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/858b7fcc-9bd5-411d-aea1-a7b35ecfffab_compressed.png";
5148
5196
  var H3_RATIOS = ["21:9", "16:9", "4:3", "1:1", "3:4", "9:16"];
@@ -5294,7 +5342,8 @@ var VIDEO_FAMILY_MODELS = [
5294
5342
  images: 10,
5295
5343
  videos: 5,
5296
5344
  videoSeconds: { min: 3, max: 30.05, total: 30 },
5297
- videoPixels: { minWidth: 700, minHeight: 700 }
5345
+ videoPixels: { minWidth: 700, minHeight: 700 },
5346
+ videoFps: { min: 23.9, max: 60.05 }
5298
5347
  },
5299
5348
  supports: ["lastFrame"],
5300
5349
  prompt: KLING_V4_PROMPT,
@@ -5460,7 +5509,7 @@ var VIDEO_FAMILY_MODELS = [
5460
5509
  pricingKind: "video_per_second",
5461
5510
  display: {
5462
5511
  provider: "minimax",
5463
- logo: MINIMAX_LOGO3,
5512
+ logo: MINIMAX_LOGO4,
5464
5513
  description: "The fast tier of MiniMax H3 Max: text-to-video and start/end-frame image-to-video with native audio and an optional soundtrack clip, up to 15 seconds at 1080p."
5465
5514
  },
5466
5515
  capabilities: {}
@@ -5490,7 +5539,7 @@ var VIDEO_FAMILY_MODELS = [
5490
5539
  pricingKind: "video_per_second",
5491
5540
  display: {
5492
5541
  provider: "minimax",
5493
- logo: MINIMAX_LOGO3,
5542
+ logo: MINIMAX_LOGO4,
5494
5543
  description: "MiniMax H3 Max Insert: generates a new 5-13 second scene inside an existing video from a prompt, reference images or videos, then returns to the original footage."
5495
5544
  },
5496
5545
  capabilities: { acceptsSourceVideo: true, videoEdit: true }
@@ -5519,7 +5568,7 @@ var VIDEO_FAMILY_MODELS = [
5519
5568
  pricingKind: "video_per_second",
5520
5569
  display: {
5521
5570
  provider: "minimax",
5522
- logo: MINIMAX_LOGO3,
5571
+ logo: MINIMAX_LOGO4,
5523
5572
  description: "MiniMax H3 Max Recast: replaces the people in a 5-30 second video with up to 4 reference photos, keeping the motion, camera, cuts and soundtrack."
5524
5573
  },
5525
5574
  capabilities: { acceptsSourceVideo: true, videoEdit: true }
@@ -5550,7 +5599,7 @@ var VIDEO_FAMILY_MODELS = [
5550
5599
  pricingKind: "video_per_second",
5551
5600
  display: {
5552
5601
  provider: "minimax",
5553
- logo: MINIMAX_LOGO3,
5602
+ logo: MINIMAX_LOGO4,
5554
5603
  description: "MiniMax H3 Max Relight: relights a video of up to 15 seconds from a lighting sphere image, keeping the subjects, motion, camera and audio."
5555
5604
  },
5556
5605
  capabilities: { acceptsSourceVideo: true, videoEdit: true }
@@ -5862,6 +5911,11 @@ var SEEDANCE_2_AUDIO = {
5862
5911
  audioFormats: ["wav", "mp3"],
5863
5912
  audioMaxBytes: 15 * 1024 * 1024
5864
5913
  };
5914
+ var SEEDANCE_REFERENCE_MEDIA = {
5915
+ videoPixels: { minPixels: 407696, maxPixels: 8295044 },
5916
+ videoFps: { min: 23.8, max: 60 },
5917
+ imagePixels: { minPixels: 9e4 }
5918
+ };
5865
5919
  var H3_PROMPT2 = { referenceSyntax: "numbered", maxChars: 5e4 };
5866
5920
  var WAN_PROMPT = { referenceSyntax: "numbered", maxChars: 2e4 };
5867
5921
  var OMNI_PROMPT = { referenceSyntax: "caption", maxChars: 5e4 };
@@ -6106,6 +6160,7 @@ var VIDEO_MODELS = [
6106
6160
  audios: 3,
6107
6161
  audioOnly: false,
6108
6162
  videoSeconds: { min: 2, max: 15, total: 15 },
6163
+ ...SEEDANCE_REFERENCE_MEDIA,
6109
6164
  ...SEEDANCE_2_AUDIO
6110
6165
  },
6111
6166
  sourceVideoSeconds: { min: 2, max: 15, inReferenceTotal: true },
@@ -6149,6 +6204,7 @@ var VIDEO_MODELS = [
6149
6204
  audios: 3,
6150
6205
  audioOnly: false,
6151
6206
  videoSeconds: { min: 2, max: 15, total: 15 },
6207
+ ...SEEDANCE_REFERENCE_MEDIA,
6152
6208
  ...SEEDANCE_2_AUDIO
6153
6209
  },
6154
6210
  sourceVideoSeconds: { min: 2, max: 15, inReferenceTotal: true },
@@ -6192,6 +6248,7 @@ var VIDEO_MODELS = [
6192
6248
  videos: 10,
6193
6249
  audios: 10,
6194
6250
  videoSeconds: { min: 2, max: 30, total: 30, editMin: 4 },
6251
+ ...SEEDANCE_REFERENCE_MEDIA,
6195
6252
  // BytePlus: 2-30 s per clip, 30 s in all, wav/mp3, 15 MB each.
6196
6253
  audioSeconds: { min: 2, max: 30, total: 30 },
6197
6254
  audioFormats: ["wav", "mp3"],
@@ -6340,7 +6397,12 @@ var VIDEO_MODELS = [
6340
6397
  prompt: KLING_PROMPT2,
6341
6398
  audio: "optional"
6342
6399
  },
6343
- defaults: { durationSeconds: 5, aspectRatio: "16:9", generateAudio: true, mode: "pro" },
6400
+ defaults: {
6401
+ durationSeconds: 5,
6402
+ aspectRatio: "16:9",
6403
+ generateAudio: true,
6404
+ mode: "standard"
6405
+ },
6344
6406
  usage: { ...VIDEO_USAGE3 },
6345
6407
  pricingKind: "video_per_second",
6346
6408
  display: {
@@ -8005,7 +8067,14 @@ var VideoSecondsLimitsSchema = z3.looseObject({
8005
8067
  });
8006
8068
  var VideoPixelLimitsSchema = z3.looseObject({
8007
8069
  minWidth: z3.number().int().positive().optional(),
8008
- minHeight: z3.number().int().positive().optional()
8070
+ minHeight: z3.number().int().positive().optional(),
8071
+ minPixels: z3.number().int().positive().optional(),
8072
+ maxPixels: z3.number().int().positive().optional(),
8073
+ maxSide: z3.number().int().positive().optional()
8074
+ });
8075
+ var VideoFpsLimitsSchema = z3.looseObject({
8076
+ min: z3.number().positive().optional(),
8077
+ max: z3.number().positive().optional()
8009
8078
  });
8010
8079
  var ReferenceLimitsSchema = z3.looseObject({
8011
8080
  images: z3.number().optional(),
@@ -8016,6 +8085,13 @@ var ReferenceLimitsSchema = z3.looseObject({
8016
8085
  audioOnly: z3.boolean().optional(),
8017
8086
  videoSeconds: VideoSecondsLimitsSchema.optional(),
8018
8087
  videoPixels: VideoPixelLimitsSchema.optional(),
8088
+ videoFps: VideoFpsLimitsSchema.optional(),
8089
+ videoMaxBytes: z3.number().positive().optional(),
8090
+ imagePixels: VideoPixelLimitsSchema.optional(),
8091
+ imageAspect: z3.looseObject({
8092
+ min: z3.number().positive().optional(),
8093
+ max: z3.number().positive().optional()
8094
+ }).optional(),
8019
8095
  audioSeconds: z3.looseObject({
8020
8096
  min: z3.number().optional(),
8021
8097
  max: z3.number().optional(),
@@ -10333,6 +10409,27 @@ var QWEN_EXACT = {
10333
10409
  maxArea: 2048 * 2048,
10334
10410
  multipleOf: 1
10335
10411
  };
10412
+ var MINIMAX_H3_IMAGE_EXACT = {
10413
+ minSide: 1,
10414
+ maxSide: 14142,
10415
+ minArea: 655360,
10416
+ maxArea: 4096 * 4096,
10417
+ multipleOf: 1,
10418
+ maxAspect: 3,
10419
+ topTier: "4K"
10420
+ };
10421
+ function minimaxH3ImageSpec(label) {
10422
+ return {
10423
+ label,
10424
+ maxReferences: 16,
10425
+ maxCount: 10,
10426
+ outputFormats: ALL_FORMATS,
10427
+ promptMax: 32e3,
10428
+ promptRequired: true,
10429
+ aspectRatios: WIDE_RATIOS,
10430
+ exactSize: MINIMAX_H3_IMAGE_EXACT
10431
+ };
10432
+ }
10336
10433
  var FAL_IMAGE_SPECS = /* @__PURE__ */ new Map([
10337
10434
  [
10338
10435
  "krea/v3/text-to-image",
@@ -10374,6 +10471,8 @@ var FAL_IMAGE_SPECS = /* @__PURE__ */ new Map([
10374
10471
  exactSize: QWEN_EXACT
10375
10472
  }
10376
10473
  ],
10474
+ ["minimax/h3-image/text-to-image", minimaxH3ImageSpec("MiniMax H3 Image")],
10475
+ ["minimax/h3-image/highspeed/text-to-image", minimaxH3ImageSpec("MiniMax H3 Image Highspeed")],
10377
10476
  [
10378
10477
  "fal-ai/kling-image/o3/text-to-image",
10379
10478
  {
@@ -10437,6 +10536,7 @@ function falImageSpec(providerModelId) {
10437
10536
  return FAL_IMAGE_SPECS.get(providerModelId.toLowerCase());
10438
10537
  }
10439
10538
  var AREA_1K = 1024 * 1024;
10539
+ var AREA_2K = 2048 * 2048;
10440
10540
  function checkExactSize(exact, b) {
10441
10541
  const match = /^(\d+)x(\d+)$/.exec(exact);
10442
10542
  if (match === null) {
@@ -10448,14 +10548,21 @@ function checkExactSize(exact, b) {
10448
10548
  const sideOk = [width, height].every(
10449
10549
  (side) => side >= b.minSide && side <= b.maxSide && side % b.multipleOf === 0
10450
10550
  );
10451
- if (!sideOk || area < b.minArea || area > b.maxArea) {
10551
+ const aspectOk = b.maxAspect === void 0 || Math.max(width, height) <= b.maxAspect * Math.min(width, height);
10552
+ if (!sideOk || !aspectOk || area < b.minArea || area > b.maxArea) {
10452
10553
  const step = b.multipleOf > 1 ? `, multiples of ${b.multipleOf}` : "";
10554
+ const aspectLimit = b.maxAspect === void 0 ? "" : `, at most ${b.maxAspect}:1,`;
10453
10555
  return {
10454
10556
  ok: false,
10455
- message: `takes an exactSize with sides of ${b.minSide} to ${b.maxSide} px${step} and ${b.minArea} to ${b.maxArea} px in total; got ${exact}`
10557
+ message: `takes an exactSize with sides of ${b.minSide} to ${b.maxSide} px${step}${aspectLimit} and ${b.minArea} to ${b.maxArea} px in total; got ${exact}`
10456
10558
  };
10457
10559
  }
10458
- return { ok: true, size: { width, height, tier: area <= AREA_1K ? "1K" : "2K" } };
10560
+ return { ok: true, size: { width, height, tier: exactTier(area, b) } };
10561
+ }
10562
+ function exactTier(area, b) {
10563
+ if (area <= AREA_1K) return "1K";
10564
+ if (b.topTier === void 0 || area <= AREA_2K) return "2K";
10565
+ return b.topTier;
10459
10566
  }
10460
10567
  function unsupported(message) {
10461
10568
  return { code: "unsupported_option", message };
@@ -10661,17 +10768,17 @@ function pick(model, label, field, value, table) {
10661
10768
  }
10662
10769
  return mapped;
10663
10770
  }
10664
- function familyImageSize(model, call) {
10665
- if (call.exact === void 0) return { dims: sizedDimensions(model, call) };
10771
+ function familyImageSize(model, call, areas = TIER_AREAS) {
10772
+ if (call.exact === void 0) return { dims: sizedDimensions(model, call, areas) };
10666
10773
  const { width, height, tier } = call.exact;
10667
10774
  return { dims: { width, height }, imageSize: tier };
10668
10775
  }
10669
- function sizedDimensions(model, { label, req }) {
10776
+ function sizedDimensions(model, { label, req }, areas) {
10670
10777
  const aspectRatio = req.aspectRatio ?? "1:1";
10671
10778
  const size = req.size ?? "1K";
10672
- pick(model, label, "size", size, TIER_AREAS);
10779
+ pick(model, label, "size", size, areas);
10673
10780
  const dims = dimensionsFor(
10674
- { field: "image_size", areas: { ...TIER_AREAS }, multipleOf: 16 },
10781
+ { field: "image_size", areas: { ...areas }, multipleOf: 16 },
10675
10782
  { prompt: req.prompt, aspectRatio, size }
10676
10783
  );
10677
10784
  if (dims === void 0) throw fail2(model, `${label} has no size for ${aspectRatio}`);
@@ -10684,8 +10791,8 @@ function withCommon(input, req, opts) {
10684
10791
  return input;
10685
10792
  }
10686
10793
  var AREA_1K2 = 1024 * 1024;
10687
- var AREA_2K = 2048 * 2048;
10688
- var TIER_AREAS = { "1K": AREA_1K2, "2K": AREA_2K };
10794
+ var AREA_2K2 = 2048 * 2048;
10795
+ var TIER_AREAS = { "1K": AREA_1K2, "2K": AREA_2K2 };
10689
10796
  var KREA = {
10690
10797
  editEndpoint: "krea/v3/edit",
10691
10798
  build(call, model) {
@@ -10743,6 +10850,24 @@ var QWEN = {
10743
10850
  };
10744
10851
  }
10745
10852
  };
10853
+ function minimaxH3Image(editEndpoint) {
10854
+ return {
10855
+ editEndpoint,
10856
+ build(call, model) {
10857
+ const { req, refs } = call;
10858
+ const size = familyImageSize(model, call, H3_IMAGE_AREAS);
10859
+ const input = { prompt: req.prompt, image_size: { ...size.dims } };
10860
+ if (refs.length > 0) input["image_urls"] = refs;
10861
+ return {
10862
+ input: withCommon(input, req, { count: true, seed: false }),
10863
+ ...size.imageSize !== void 0 && { imageSize: size.imageSize }
10864
+ };
10865
+ }
10866
+ };
10867
+ }
10868
+ var H3_IMAGE_AREAS = { ...TIER_AREAS, "4K": 4096 * 4096 };
10869
+ var MINIMAX_H3_IMAGE = minimaxH3Image("minimax/h3-image/edit");
10870
+ var MINIMAX_H3_IMAGE_HIGHSPEED = minimaxH3Image("minimax/h3-image/highspeed/edit");
10746
10871
  function klingImage(editEndpoint, sizes, field) {
10747
10872
  return {
10748
10873
  editEndpoint,
@@ -10824,6 +10949,8 @@ var FAMILIES = /* @__PURE__ */ new Map([
10824
10949
  ["krea/v3/text-to-image", KREA],
10825
10950
  ["xai/grok-imagine-image/v2.0/text-to-image", GROK],
10826
10951
  ["alibaba/qwen-image-3/text-to-image", QWEN],
10952
+ ["minimax/h3-image/text-to-image", MINIMAX_H3_IMAGE],
10953
+ ["minimax/h3-image/highspeed/text-to-image", MINIMAX_H3_IMAGE_HIGHSPEED],
10827
10954
  ["fal-ai/kling-image/o3/text-to-image", KLING_O3],
10828
10955
  ["fal-ai/kling-image/v3/text-to-image", KLING_V3],
10829
10956
  ["recraft/v4.1/flash/text-to-image", RECRAFT_FLASH],
@@ -15697,8 +15824,8 @@ function checkGenerateSeconds(req, ctx) {
15697
15824
  }
15698
15825
  var MAX_PLAUSIBLE_SECONDS = 60;
15699
15826
  function editedSeconds(req, bytes) {
15700
- const measured = mp4DurationSeconds(bytes);
15701
- const length = measured !== void 0 && measured > 0 && measured <= MAX_PLAUSIBLE_SECONDS ? measured : req.sourceVideo?.durationSeconds;
15827
+ const measured2 = mp4DurationSeconds(bytes);
15828
+ const length = measured2 !== void 0 && measured2 > 0 && measured2 <= MAX_PLAUSIBLE_SECONDS ? measured2 : req.sourceVideo?.durationSeconds;
15702
15829
  return Math.max(length ?? 0, GENERATE_SECONDS);
15703
15830
  }
15704
15831
  function videoUsage4(ctx, req, mode, seconds3) {
@@ -16068,15 +16195,6 @@ var openaiImageAdapter = {
16068
16195
  });
16069
16196
  outputFormat = "png";
16070
16197
  }
16071
- if (isEdit && outputFormat === "svg") {
16072
- throw new ModelKitError({
16073
- code: "unsupported_option",
16074
- message: `${ctx.model.id} cannot make an SVG from reference images`,
16075
- provider: "openai-image",
16076
- model: ctx.model.id,
16077
- retryable: false
16078
- });
16079
- }
16080
16198
  const svgModel = ctx.model.constraints.svgModel;
16081
16199
  if (outputFormat === "svg" && !svgModel) {
16082
16200
  throw new ModelKitError({
@@ -17852,9 +17970,6 @@ function applyImageOutputRules(model, req, onUnsupported, warnings) {
17852
17970
  }
17853
17971
  if (req.outputFormat === "svg") {
17854
17972
  if (!c.svgModel) refuse(model, `${model.id} names no svgModel to write the SVG`);
17855
- if ((req.references ?? []).length > 0) {
17856
- refuse(model, `${model.label} cannot make an SVG from reference images`);
17857
- }
17858
17973
  if ((req.count ?? 1) > 1) {
17859
17974
  if (onUnsupported === "error") {
17860
17975
  refuse(model, `${model.label} makes one SVG per call`);
@@ -18826,6 +18941,126 @@ function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
18826
18941
  return { request: resolved, warnings };
18827
18942
  }
18828
18943
 
18944
+ // src/reference-video-conform.ts
18945
+ var REFERENCE_VIDEO_CONFORM_PROFILE = "model-safe-v1";
18946
+ var SHRINK_MARGIN = 0.998;
18947
+ var GROW_MARGIN = 1.002;
18948
+ var LOW_FPS_TARGET = 24;
18949
+ var HIGH_FPS_TARGET = 30;
18950
+ function measured(value) {
18951
+ return value !== void 0 && Number.isFinite(value) && value > 0;
18952
+ }
18953
+ function evenDown(value) {
18954
+ return Math.max(2, Math.floor(value / 2) * 2);
18955
+ }
18956
+ function evenUp(value) {
18957
+ return Math.max(2, Math.ceil(value / 2) * 2);
18958
+ }
18959
+ function sizeFix(limits, width, height) {
18960
+ if (!limits) return null;
18961
+ const pixels = width * height;
18962
+ const long = Math.max(width, height);
18963
+ const shrink = [];
18964
+ const grow = [];
18965
+ const reasons = [];
18966
+ if (limits.maxPixels !== void 0 && pixels > limits.maxPixels) {
18967
+ shrink.push(Math.sqrt(limits.maxPixels / pixels) * SHRINK_MARGIN);
18968
+ reasons.push("pixels_over");
18969
+ }
18970
+ if (limits.maxSide !== void 0 && long > limits.maxSide) {
18971
+ shrink.push(limits.maxSide / long * SHRINK_MARGIN);
18972
+ reasons.push("side_over");
18973
+ }
18974
+ if (shrink.length > 0) return { scale: Math.min(...shrink), up: false, reasons };
18975
+ if (limits.minPixels !== void 0 && pixels < limits.minPixels) {
18976
+ grow.push(Math.sqrt(limits.minPixels / pixels) * GROW_MARGIN);
18977
+ reasons.push("pixels_under");
18978
+ }
18979
+ const sideUnder = [
18980
+ limits.minWidth !== void 0 && width < limits.minWidth ? limits.minWidth / width * GROW_MARGIN : 0,
18981
+ limits.minHeight !== void 0 && height < limits.minHeight ? limits.minHeight / height * GROW_MARGIN : 0
18982
+ ].filter((scale) => scale > 0);
18983
+ if (sideUnder.length > 0) {
18984
+ grow.push(...sideUnder);
18985
+ reasons.push("side_under");
18986
+ }
18987
+ if (grow.length > 0) return { scale: Math.max(...grow), up: true, reasons };
18988
+ return null;
18989
+ }
18990
+ function fpsFix(model, fps) {
18991
+ const limits = model.constraints.references?.videoFps;
18992
+ if (!limits || !measured(fps)) return void 0;
18993
+ const inRange = (rate) => (limits.min === void 0 || rate >= limits.min) && (limits.max === void 0 || rate <= limits.max);
18994
+ if (limits.min !== void 0 && fps < limits.min) {
18995
+ const target = inRange(LOW_FPS_TARGET) ? LOW_FPS_TARGET : Math.ceil(limits.min);
18996
+ return { fps: target, reason: "fps_under" };
18997
+ }
18998
+ if (limits.max !== void 0 && fps > limits.max) {
18999
+ const target = inRange(HIGH_FPS_TARGET) ? HIGH_FPS_TARGET : Math.floor(limits.max);
19000
+ return { fps: target, reason: "fps_over" };
19001
+ }
19002
+ return void 0;
19003
+ }
19004
+ function referenceVideoConformPlan(model, probe) {
19005
+ const rate = fpsFix(model, probe.fps);
19006
+ const maxBytes = model.constraints.references?.videoMaxBytes;
19007
+ const overBytes = maxBytes !== void 0 && measured(probe.bytes) && probe.bytes > maxBytes;
19008
+ const { width: probedWidth, height: probedHeight } = probe;
19009
+ if (!measured(probedWidth) || !measured(probedHeight)) return null;
19010
+ const width = Math.round(probedWidth);
19011
+ const height = Math.round(probedHeight);
19012
+ const size = sizeFix(model.constraints.references?.videoPixels, width, height);
19013
+ if (!size && !rate && !overBytes) return null;
19014
+ const round = size?.up ? evenUp : evenDown;
19015
+ const scale = size?.scale ?? 1;
19016
+ const reasons = [...size?.reasons ?? []];
19017
+ if (rate) reasons.push(rate.reason);
19018
+ if (overBytes) reasons.push("bytes_over");
19019
+ const plan4 = {
19020
+ width: round(width * scale),
19021
+ height: round(height * scale),
19022
+ reasons
19023
+ };
19024
+ if (rate) plan4.fps = rate.fps;
19025
+ if (maxBytes !== void 0) plan4.maxBytes = maxBytes;
19026
+ return plan4;
19027
+ }
19028
+ function referenceImageConformPlan(model, probe) {
19029
+ const { width: probedWidth, height: probedHeight } = probe;
19030
+ if (!measured(probedWidth) || !measured(probedHeight)) return null;
19031
+ const references = model.constraints.references;
19032
+ const width = Math.round(probedWidth);
19033
+ const height = Math.round(probedHeight);
19034
+ const reasons = [];
19035
+ let frameWidth = width;
19036
+ let frameHeight = height;
19037
+ const aspect = references?.imageAspect;
19038
+ if (aspect?.min !== void 0 && width / height < aspect.min) {
19039
+ frameWidth = Math.ceil(height * aspect.min);
19040
+ reasons.push("aspect");
19041
+ } else if (aspect?.max !== void 0 && width / height > aspect.max) {
19042
+ frameHeight = Math.ceil(width / aspect.max);
19043
+ reasons.push("aspect");
19044
+ }
19045
+ const size = sizeFix(references?.imagePixels, frameWidth, frameHeight);
19046
+ if (!size && reasons.length === 0) return null;
19047
+ if (size) reasons.push(...size.reasons);
19048
+ const scale = size?.scale ?? 1;
19049
+ const round = size?.up ? Math.ceil : Math.floor;
19050
+ const frame = {
19051
+ width: Math.max(1, round(frameWidth * scale)),
19052
+ height: Math.max(1, round(frameHeight * scale))
19053
+ };
19054
+ const image = frameWidth > width ? {
19055
+ width: Math.max(1, Math.round(frame.height * width / height)),
19056
+ height: frame.height
19057
+ } : frameHeight > height ? {
19058
+ width: frame.width,
19059
+ height: Math.max(1, Math.round(frame.width * height / width))
19060
+ } : { ...frame };
19061
+ return { ...frame, image, reasons };
19062
+ }
19063
+
18829
19064
  // src/keys.ts
18830
19065
  var ADAPTER_KEYS = {
18831
19066
  "ai-sdk-text": [],
@@ -20315,6 +20550,7 @@ export {
20315
20550
  MODEL3D_MODELS,
20316
20551
  MODELS,
20317
20552
  ModelKitError,
20553
+ REFERENCE_VIDEO_CONFORM_PROFILE,
20318
20554
  SURFACES2 as SURFACES,
20319
20555
  SurfaceSchema,
20320
20556
  VIDEO_INPUT_SPEC_KEYS,
@@ -20382,6 +20618,8 @@ export {
20382
20618
  primeCatalog,
20383
20619
  prodiaAdapter,
20384
20620
  readErrorBody,
20621
+ referenceImageConformPlan,
20622
+ referenceVideoConformPlan,
20385
20623
  replicateAdapter,
20386
20624
  resetLiveCatalog,
20387
20625
  resolutionTier,