@shop-os/modelkit 0.26.1 → 0.28.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.cjs CHANGED
@@ -5583,10 +5583,119 @@ var TEXT_MODELS = [
5583
5583
  })
5584
5584
  ];
5585
5585
 
5586
- // src/catalog/video-families.ts
5587
- var VIDEO_USAGE = { unit: "seconds" };
5586
+ // src/catalog/video-avatars.ts
5588
5587
  var MB = 1024 * 1024;
5589
5588
  var KLING_LOGO = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/kling-color.png";
5589
+ var VEED_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/d540d2bb-0022-4371-8889-48aefaf46bbe.png";
5590
+ var SYNC_LOGO2 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/sync.png";
5591
+ var KIT_AUDIO_CAP_SECONDS = 300;
5592
+ function avatar(row2) {
5593
+ const { min, max, formats, maxBytes } = row2.audio;
5594
+ return {
5595
+ id: row2.id,
5596
+ aliases: row2.aliases,
5597
+ label: row2.label,
5598
+ type: "video",
5599
+ adapter: "fal",
5600
+ providerModelId: row2.providerModelId,
5601
+ lifecycle: "active",
5602
+ exposure: ["cowork", "space_builder"],
5603
+ constraints: {
5604
+ ...row2.resolutions !== void 0 && { resolutions: [...row2.resolutions] },
5605
+ references: {
5606
+ images: 1,
5607
+ videos: 0,
5608
+ audios: 1,
5609
+ audioOnly: false,
5610
+ audioSeconds: { ...min !== void 0 && { min }, max },
5611
+ audioFormats: formats,
5612
+ ...maxBytes !== void 0 && { audioMaxBytes: maxBytes },
5613
+ min: { images: 1, audios: 1 }
5614
+ },
5615
+ requires: ["references"],
5616
+ supports: [],
5617
+ ...row2.promptMaxChars === void 0 ? { noPrompt: true } : { prompt: { referenceSyntax: "descriptive", maxChars: row2.promptMaxChars } },
5618
+ audio: "always"
5619
+ },
5620
+ defaults: row2.resolutions === void 0 ? {} : { resolution: row2.resolutions[0] },
5621
+ usage: { unit: "seconds" },
5622
+ pricingKind: "video_per_second",
5623
+ display: {
5624
+ provider: row2.provider,
5625
+ ...row2.logo !== void 0 && { logo: row2.logo },
5626
+ description: row2.description
5627
+ },
5628
+ capabilities: {}
5629
+ };
5630
+ }
5631
+ function heygenAvatar6(tier) {
5632
+ const turbo2 = tier === "turbo";
5633
+ return avatar({
5634
+ id: turbo2 ? "heygen-avatar-6-turbo" : "heygen-avatar-6",
5635
+ aliases: [],
5636
+ label: turbo2 ? "HeyGen Avatar 6 Turbo" : "HeyGen Avatar 6",
5637
+ providerModelId: turbo2 ? "heygen/avatar-6/turbo/image-to-video" : "heygen/avatar-6/image-to-video",
5638
+ provider: "heygen",
5639
+ description: turbo2 ? "HeyGen Avatar 6 Turbo: the lower-cost tier; turns one photo of a person and a speech clip of up to 5 minutes into a talking video as long as the speech, at 1080p or 2K, with an optional motion prompt." : "HeyGen Avatar 6: turns one photo of a person and a speech clip of up to 5 minutes into a talking video as long as the speech, at 1080p or 2K, with an optional motion prompt.",
5640
+ audio: { max: KIT_AUDIO_CAP_SECONDS, formats: ["wav", "mp3"], maxBytes: 50 * MB },
5641
+ resolutions: ["1080p", "2k"],
5642
+ promptMaxChars: 1200
5643
+ });
5644
+ }
5645
+ function klingAvatar(tier) {
5646
+ const label = tier === "pro" ? "Pro" : "Standard";
5647
+ return avatar({
5648
+ id: `kling-ai-avatar-v2-${tier}`,
5649
+ aliases: [],
5650
+ label: `Kling AI Avatar 2.0 ${label}`,
5651
+ providerModelId: `fal-ai/kling-video/ai-avatar/v2/${tier}`,
5652
+ provider: "kuaishou",
5653
+ logo: KLING_LOGO,
5654
+ description: `Kuaishou Kling AI Avatar 2.0 (${label}): turns one image of a person, animal or character and a 2-300 second audio clip into a talking video as long as the audio.`,
5655
+ audio: { min: 2, max: 300, formats: ["mp3", "wav", "m4a", "aac"], maxBytes: 5 * MB },
5656
+ promptMaxChars: 2500
5657
+ });
5658
+ }
5659
+ function veedFabric(tier) {
5660
+ const fast = tier === "fast";
5661
+ return avatar({
5662
+ id: fast ? "veed-fabric-1.0-fast" : "veed-fabric-1.0",
5663
+ aliases: [fast ? "veed/fabric-1.0/fast" : "veed/fabric-1.0"],
5664
+ label: fast ? "VEED Fabric 1.0 Fast" : "VEED Fabric 1.0",
5665
+ providerModelId: fast ? "veed/fabric-1.0/fast" : "veed/fabric-1.0",
5666
+ provider: "veed",
5667
+ logo: VEED_LOGO,
5668
+ description: fast ? "VEED Fabric 1.0 Fast: the quicker tier; turns one image and a speech clip into a lip-synced talking video as long as the speech, at 480p or 720p." : "VEED Fabric 1.0: turns one image and a speech clip into a lip-synced talking video as long as the speech, at 480p or 720p.",
5669
+ audio: { max: KIT_AUDIO_CAP_SECONDS, formats: ["mp3", "ogg", "wav", "m4a", "aac"] },
5670
+ resolutions: ["720p", "480p"]
5671
+ });
5672
+ }
5673
+ var VIDEO_AVATAR_MODELS = [
5674
+ heygenAvatar6("regular"),
5675
+ heygenAvatar6("turbo"),
5676
+ klingAvatar("standard"),
5677
+ klingAvatar("pro"),
5678
+ veedFabric("regular"),
5679
+ veedFabric("fast"),
5680
+ // https://fal.ai/models/fal-ai/sync-lipsync/v3/image-to-video/api: image_url and audio_url
5681
+ // only; the video matches the audio's length. sync takes WAV or MP3
5682
+ // (https://sync.so/docs/quickstart); the length is the kit cap.
5683
+ avatar({
5684
+ id: "sync-3-image-to-video",
5685
+ aliases: ["fal-ai/sync-lipsync/v3/image-to-video"],
5686
+ label: "Sync 3 Avatar",
5687
+ providerModelId: "fal-ai/sync-lipsync/v3/image-to-video",
5688
+ provider: "sync",
5689
+ logo: SYNC_LOGO2,
5690
+ description: "Sync 3 (sync-3) image-to-video: animates the face in one image so it lip-syncs to a speech clip, as long as the speech.",
5691
+ audio: { max: KIT_AUDIO_CAP_SECONDS, formats: ["wav", "mp3"] }
5692
+ })
5693
+ ];
5694
+
5695
+ // src/catalog/video-families.ts
5696
+ var VIDEO_USAGE = { unit: "seconds" };
5697
+ var MB2 = 1024 * 1024;
5698
+ var KLING_LOGO2 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/kling-color.png";
5590
5699
  var MINIMAX_LOGO4 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
5591
5700
  var BYTEDANCE_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/3bba5d81-4e57-4e71-911b-cdfa05acca2c_compressed.png";
5592
5701
  var XAI_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/858b7fcc-9bd5-411d-aea1-a7b35ecfffab_compressed.png";
@@ -5644,7 +5753,7 @@ function klingMotionControl(tier) {
5644
5753
  pricingKind: "video_per_second",
5645
5754
  display: {
5646
5755
  provider: "kuaishou",
5647
- logo: KLING_LOGO,
5756
+ logo: KLING_LOGO2,
5648
5757
  description: `Kuaishou Kling 3.0 Motion Control (${label}): a character image performs the motion of a 3-30 second reference video, keeping its timing and sound.`
5649
5758
  },
5650
5759
  capabilities: {}
@@ -5677,7 +5786,7 @@ var VIDEO_FAMILY_MODELS = [
5677
5786
  pricingKind: "video_per_second",
5678
5787
  display: {
5679
5788
  provider: "kuaishou",
5680
- logo: KLING_LOGO,
5789
+ logo: KLING_LOGO2,
5681
5790
  description: "Kuaishou Kling O3 Pro: text, start/end frames and up to 7 reference images in one 3-15 second clip with consistent characters and optional native audio."
5682
5791
  },
5683
5792
  capabilities: { lastFrameRequiresFirstFrame: true }
@@ -5708,7 +5817,7 @@ var VIDEO_FAMILY_MODELS = [
5708
5817
  pricingKind: "video_per_second",
5709
5818
  display: {
5710
5819
  provider: "kuaishou",
5711
- logo: KLING_LOGO,
5820
+ logo: KLING_LOGO2,
5712
5821
  description: "Kuaishou Kling O3 Pro video edit: change a 3-15 second clip with a prompt and up to 4 reference images while keeping its motion and timing."
5713
5822
  },
5714
5823
  capabilities: { acceptsSourceVideo: true, videoEdit: true }
@@ -5720,7 +5829,9 @@ var VIDEO_FAMILY_MODELS = [
5720
5829
  // start frame included (fal: "counts toward the image reference limit"), 300 px min.
5721
5830
  // Reference videos: 5, 3-30.05 s each and 30 s combined, 700 px min, 23.9-60.05 fps.
5722
5831
  // The prompt names references as @Image1, @Video1 (no space; @Element1 for elements,
5723
- // which the kit does not send). No sound switch on any endpoint.
5832
+ // which the kit does not send). No sound switch on any endpoint. 4K since 2026-11-19;
5833
+ // the endpoints also take `hdr` (10-bit, 1080p and 4K, billed per output second on top),
5834
+ // which the kit does not send: no price row can carry that fee yet (ENG-4272).
5724
5835
  id: "kling-4.0",
5725
5836
  aliases: ["kling-4", "kling-v4"],
5726
5837
  label: "Kling 4.0",
@@ -5732,7 +5843,7 @@ var VIDEO_FAMILY_MODELS = [
5732
5843
  constraints: {
5733
5844
  inputBilling: "kling-v4",
5734
5845
  aspectRatios: ["adaptive", "16:9", "9:16", "1:1", "21:9"],
5735
- resolutions: ["720p", "1080p"],
5846
+ resolutions: ["720p", "1080p", "4k"],
5736
5847
  durations: { min: 3, max: 30 },
5737
5848
  durationPresets: [5, 10, 15, 30],
5738
5849
  references: {
@@ -5752,8 +5863,8 @@ var VIDEO_FAMILY_MODELS = [
5752
5863
  pricingKind: "video_per_second",
5753
5864
  display: {
5754
5865
  provider: "kuaishou",
5755
- logo: KLING_LOGO,
5756
- description: "Kuaishou Kling 4.0: text-to-video, start/end frames, or reference-to-video from up to 10 images and 5 videos (30 seconds combined), up to 30 seconds at 720p or 1080p. Prompts name references @Image1, @Video1."
5866
+ logo: KLING_LOGO2,
5867
+ description: "Kuaishou Kling 4.0: text-to-video, start/end frames, or reference-to-video from up to 10 images and 5 videos (30 seconds combined), up to 30 seconds at 720p or 1080p and up to 15 seconds at 4K. Prompts name references @Image1, @Video1."
5757
5868
  },
5758
5869
  capabilities: { lastFrameRequiresFirstFrame: true }
5759
5870
  },
@@ -5771,7 +5882,7 @@ var VIDEO_FAMILY_MODELS = [
5771
5882
  exposure: ["cowork", "space_builder"],
5772
5883
  constraints: {
5773
5884
  inputBilling: "kling-v4",
5774
- resolutions: ["720p", "1080p"],
5885
+ resolutions: ["720p", "1080p", "4k"],
5775
5886
  durations: { min: 3, max: 30 },
5776
5887
  references: { ...NO_REFERENCES, images: 10 },
5777
5888
  requires: ["sourceVideo"],
@@ -5786,8 +5897,8 @@ var VIDEO_FAMILY_MODELS = [
5786
5897
  pricingKind: "video_per_second",
5787
5898
  display: {
5788
5899
  provider: "kuaishou",
5789
- logo: KLING_LOGO,
5790
- description: "Kuaishou Kling 4.0 video edit: change a 3-30 second clip with a prompt and up to 10 reference images, at 720p or 1080p, as long as the source or a set 3-30 seconds. Prompts name the source @Video1 and images @Image1."
5900
+ logo: KLING_LOGO2,
5901
+ description: "Kuaishou Kling 4.0 video edit: change a 3-30 second clip with a prompt and up to 10 reference images, at 720p, 1080p or 4K (up to 15 seconds at 4K), as long as the source or a set 3-30 seconds. Prompts name the source @Video1 and images @Image1."
5791
5902
  },
5792
5903
  capabilities: { acceptsSourceVideo: true, videoEdit: true }
5793
5904
  },
@@ -5827,7 +5938,7 @@ var VIDEO_FAMILY_MODELS = [
5827
5938
  pricingKind: "video_per_second",
5828
5939
  display: {
5829
5940
  provider: "kuaishou",
5830
- logo: KLING_LOGO,
5941
+ logo: KLING_LOGO2,
5831
5942
  description: "Kuaishou Kling 4.0 Flash: fast text-to-video, a start frame, or reference-to-video from up to 10 images and 5 videos (20 seconds combined), 3 to 20 seconds at 720p. Prompts name references @Image1, @Video1."
5832
5943
  }
5833
5944
  },
@@ -5867,7 +5978,7 @@ var VIDEO_FAMILY_MODELS = [
5867
5978
  pricingKind: "video_per_second",
5868
5979
  display: {
5869
5980
  provider: "kuaishou",
5870
- logo: KLING_LOGO,
5981
+ logo: KLING_LOGO2,
5871
5982
  description: "Kuaishou Kling 4.0 Flash video edit: change a 3-20 second clip with a prompt, up to 10 reference images and 4 reference videos (20 seconds in all with the source), at 720p, as long as the source or a set 3-20 seconds. Prompts name the source @Video1."
5872
5983
  },
5873
5984
  capabilities: { acceptsSourceVideo: true, videoEdit: true }
@@ -5894,7 +6005,7 @@ var VIDEO_FAMILY_MODELS = [
5894
6005
  ...NO_REFERENCES,
5895
6006
  audios: 1,
5896
6007
  audioSeconds: { min: 2 },
5897
- audioMaxBytes: 15 * MB
6008
+ audioMaxBytes: 15 * MB2
5898
6009
  },
5899
6010
  supports: ["seed", "promptExpansion", "lastFrame", "safetyChecker"],
5900
6011
  prompt: H3_PROMPT,
@@ -6093,7 +6204,7 @@ var VIDEO_FAMILY_MODELS = [
6093
6204
  audioOnly: false,
6094
6205
  audioSeconds: { min: 3, max: 12 },
6095
6206
  audioFormats: ["mp3"],
6096
- audioMaxBytes: 50 * MB
6207
+ audioMaxBytes: 50 * MB2
6097
6208
  },
6098
6209
  // Sound (dialogue and effects) is a reference-to-video option; image-to-video is silent.
6099
6210
  supports: ["seed", "generateAudio", "safetyChecker"],
@@ -6134,7 +6245,7 @@ var VIDEO_FAMILY_MODELS = [
6134
6245
  audioOnly: false,
6135
6246
  audioSeconds: { min: 4, max: 300 },
6136
6247
  audioFormats: ["wav", "mp3"],
6137
- audioMaxBytes: 15 * MB,
6248
+ audioMaxBytes: 15 * MB2,
6138
6249
  min: { images: 1, audios: 1 }
6139
6250
  },
6140
6251
  requires: ["references"],
@@ -7237,6 +7348,7 @@ var VIDEO_MODELS = [
7237
7348
  capabilities: {}
7238
7349
  },
7239
7350
  ...VIDEO_FAMILY_MODELS,
7351
+ ...VIDEO_AVATAR_MODELS,
7240
7352
  ...LUMA_VIDEO_MODELS
7241
7353
  ];
7242
7354
 
@@ -10251,6 +10363,15 @@ var KLING_O3_IMAGE_CAP = 7;
10251
10363
  var KLING_V4_IMAGE_CAP = 10;
10252
10364
  var TURBO_AUDIO_MIN_SECONDS = 2;
10253
10365
  var OMNIHUMAN_AUDIO_SECONDS = { min: 4, max: 300 };
10366
+ var AVATAR_AUDIO = [
10367
+ ["heygen/avatar-6/image-to-video", { max: 300 }],
10368
+ ["heygen/avatar-6/turbo/image-to-video", { max: 300 }],
10369
+ ["fal-ai/kling-video/ai-avatar/v2/standard", { min: 2, max: 300 }],
10370
+ ["fal-ai/kling-video/ai-avatar/v2/pro", { min: 2, max: 300 }],
10371
+ ["veed/fabric-1.0", { max: 300, urlOnly: true }],
10372
+ ["veed/fabric-1.0/fast", { max: 300, urlOnly: true }],
10373
+ ["fal-ai/sync-lipsync/v3/image-to-video", { max: 300, urlOnly: true }]
10374
+ ];
10254
10375
  function missing(message) {
10255
10376
  return { code: "missing_input", message };
10256
10377
  }
@@ -10307,7 +10428,17 @@ function o3Reference(req) {
10307
10428
  function hasReferences(req) {
10308
10429
  return count(req.referenceImages) + count(req.referenceVideos) > 0;
10309
10430
  }
10431
+ var KLING_V4_4K_MAX_SECONDS = 15;
10432
+ function klingV4FourK(seconds3, req) {
10433
+ if (req.resolution !== "4k") return void 0;
10434
+ if (seconds3 === void 0) {
10435
+ return missing(`needs a measured source video of up to ${KLING_V4_4K_MAX_SECONDS} s at 4K`);
10436
+ }
10437
+ return seconds3 > KLING_V4_4K_MAX_SECONDS ? unsupported3(`renders at most ${KLING_V4_4K_MAX_SECONDS} s at 4K`) : void 0;
10438
+ }
10310
10439
  function klingV4(req) {
10440
+ const fourK = klingV4FourK(req.durationSeconds ?? 5, req);
10441
+ if (fourK !== void 0) return fourK;
10311
10442
  if (hasReferences(req)) {
10312
10443
  if (req.lastFrame !== void 0) {
10313
10444
  return unsupported3("takes an end frame only without reference images or videos");
@@ -10384,7 +10515,10 @@ function viduQ4(req) {
10384
10515
  }
10385
10516
  return req.firstFrame === void 0 ? missing("needs a start frame or reference images") : void 0;
10386
10517
  }
10387
- function omnihuman(req) {
10518
+ function isPublicUrl(ref) {
10519
+ return "url" in ref && !ref.url.startsWith("data:");
10520
+ }
10521
+ function imageAndAudio(req, audioSeconds) {
10388
10522
  const frames = noFrames(req);
10389
10523
  if (frames !== void 0) return frames;
10390
10524
  if (count(req.referenceVideos) > 0) return unsupported3("takes no reference videos");
@@ -10396,16 +10530,22 @@ function omnihuman(req) {
10396
10530
  if (extraImages.length > 0 || extraAudios.length > 0) {
10397
10531
  return unsupported3("takes exactly one image and one audio clip");
10398
10532
  }
10399
- return inputSeconds("audio", audio, OMNIHUMAN_AUDIO_SECONDS);
10533
+ if (audioSeconds.urlOnly === true && !(isPublicUrl(image) && isPublicUrl(audio))) {
10534
+ return unsupported3("takes its image and audio as public URLs, not inline bytes");
10535
+ }
10536
+ return inputSeconds("audio", audio, audioSeconds);
10400
10537
  }
10401
- var RULES = /* @__PURE__ */ new Map([
10538
+ var RULES = new Map([
10402
10539
  [MOTION_PRO, motionControl],
10403
10540
  [MOTION_STANDARD, motionControl],
10404
10541
  [O3_REFERENCE, o3Reference],
10405
10542
  [KLING_O3_OMNI, o3Reference],
10406
10543
  [O3_EDIT, (req) => needsSource(req) ?? needsPrompt(req)],
10407
10544
  [KLING_V4, klingV4],
10408
- [KLING_V4_EDIT, (req) => needsSource(req) ?? needsPrompt(req)],
10545
+ [
10546
+ KLING_V4_EDIT,
10547
+ (req) => needsSource(req) ?? klingV4FourK(req.durationSeconds ?? req.sourceVideo?.durationSeconds, req) ?? needsPrompt(req)
10548
+ ],
10409
10549
  [KLING_V4_FLASH, klingV4Flash],
10410
10550
  [KLING_V4_FLASH_EDIT, (req) => needsSource(req) ?? needsPrompt(req)],
10411
10551
  [H3_TURBO, h3Turbo],
@@ -10415,7 +10555,10 @@ var RULES = /* @__PURE__ */ new Map([
10415
10555
  [HAPPY_HORSE, happyHorse],
10416
10556
  [HAPPY_HORSE_EDIT, happyHorseEdit],
10417
10557
  [VIDU_Q4, viduQ4],
10418
- [OMNIHUMAN_V2, omnihuman]
10558
+ [OMNIHUMAN_V2, (req) => imageAndAudio(req, OMNIHUMAN_AUDIO_SECONDS)],
10559
+ ...AVATAR_AUDIO.map(
10560
+ ([id, limits]) => [id, (req) => imageAndAudio(req, limits)]
10561
+ )
10419
10562
  ]);
10420
10563
  function falVideoProblem(providerModelId, req) {
10421
10564
  return RULES.get(providerModelId.toLowerCase())?.(req);
@@ -11992,11 +12135,11 @@ function toolInput(ctx, req, output) {
11992
12135
  }
11993
12136
  var EXR_DEFAULT_PROMPT = "The same video in high dynamic range, with unchanged content, motion, framing and timing.";
11994
12137
  async function submitFalVideoTool(req, ctx, opts) {
11995
- const plan4 = planVideoTool(ctx.model, req);
11996
- if (!plan4.ok) {
12138
+ const plan5 = planVideoTool(ctx.model, req);
12139
+ if (!plan5.ok) {
11997
12140
  throw new ModelKitError({
11998
12141
  code: "unsupported_option",
11999
- message: plan4.error,
12142
+ message: plan5.error,
12000
12143
  provider: "fal",
12001
12144
  model: ctx.model.id,
12002
12145
  retryable: false
@@ -12004,7 +12147,7 @@ async function submitFalVideoTool(req, ctx, opts) {
12004
12147
  }
12005
12148
  const target = new URL(`${FAL_QUEUE_ORIGIN}/${ctx.model.providerModelId}`);
12006
12149
  if (opts.webhookUrl !== void 0) target.searchParams.set("fal_webhook", opts.webhookUrl);
12007
- const res = await queueFetch(ctx, target.toString(), "POST", toolInput(ctx, req, plan4.output));
12150
+ const res = await queueFetch(ctx, target.toString(), "POST", toolInput(ctx, req, plan5.output));
12008
12151
  const parsed = submitResponseSchema.safeParse(await readJson(ctx, res));
12009
12152
  if (!parsed.success) {
12010
12153
  throw new ModelKitError({
@@ -12022,7 +12165,7 @@ async function submitFalVideoTool(req, ctx, opts) {
12022
12165
  statusUrl: parsed.data.status_url,
12023
12166
  responseUrl: parsed.data.response_url,
12024
12167
  cancelUrl: parsed.data.cancel_url,
12025
- output: plan4.output
12168
+ output: plan5.output
12026
12169
  };
12027
12170
  }
12028
12171
  async function falVideoToolStatus(sub, ctx) {
@@ -12344,14 +12487,14 @@ function planFalImage(req, providerModelId, model) {
12344
12487
  const exact = falExactSize(spec, req);
12345
12488
  const call = { label: spec.label, req, refs, edit: edit2, ...exact !== void 0 && { exact } };
12346
12489
  const built = family.build(call, model);
12347
- const plan4 = {
12490
+ const plan5 = {
12348
12491
  endpoint: edit2 && family.editEndpoint !== void 0 ? family.editEndpoint : id,
12349
12492
  input: built.input,
12350
12493
  output: family.output ?? "images"
12351
12494
  };
12352
- if (built.imageQuality !== void 0) plan4.imageQuality = built.imageQuality;
12353
- if (built.imageSize !== void 0) plan4.imageSize = built.imageSize;
12354
- return plan4;
12495
+ if (built.imageQuality !== void 0) plan5.imageQuality = built.imageQuality;
12496
+ if (built.imageSize !== void 0) plan5.imageSize = built.imageSize;
12497
+ return plan5;
12355
12498
  }
12356
12499
  var FalFileSchema = import_zod17.z.object({ url: import_zod17.z.string(), content_type: import_zod17.z.string().nullish() });
12357
12500
  var ImagesPayloadSchema = import_zod17.z.object({ images: import_zod17.z.array(FalFileSchema) });
@@ -12373,18 +12516,18 @@ async function downloadFalFile(ctx, file) {
12373
12516
  const mime = res.headers.get("content-type") ?? file.content_type ?? "";
12374
12517
  return { bytes: new Uint8Array(await res.arrayBuffer()), mime };
12375
12518
  }
12376
- function filesOf(payload, plan4) {
12377
- if (plan4.output === "image") {
12519
+ function filesOf(payload, plan5) {
12520
+ if (plan5.output === "image") {
12378
12521
  const parsed2 = ImagePayloadSchema.safeParse(payload);
12379
12522
  return parsed2.success ? [parsed2.data.image] : [];
12380
12523
  }
12381
12524
  const parsed = ImagesPayloadSchema.safeParse(payload);
12382
12525
  return parsed.success ? parsed.data.images : [];
12383
12526
  }
12384
- async function collectFalPlanImages(payload, plan4, ctx, req) {
12385
- const files = filesOf(payload, plan4);
12527
+ async function collectFalPlanImages(payload, plan5, ctx, req) {
12528
+ const files = filesOf(payload, plan5);
12386
12529
  if (files.length === 0) {
12387
- throw fail2(ctx.model.id, `fal ${plan4.endpoint} returned no image`, "provider_rejected");
12530
+ throw fail2(ctx.model.id, `fal ${plan5.endpoint} returned no image`, "provider_rejected");
12388
12531
  }
12389
12532
  const images = await Promise.all(
12390
12533
  files.map(async (file) => {
@@ -12399,18 +12542,18 @@ async function collectFalPlanImages(payload, plan4, ctx, req) {
12399
12542
  unit: "images",
12400
12543
  quantity: images.length
12401
12544
  };
12402
- const billedSize = plan4.imageSize ?? req.size;
12545
+ const billedSize = plan5.imageSize ?? req.size;
12403
12546
  if (billedSize !== void 0 && ctx.model.type === "image") usage6.imageSize = billedSize;
12404
- if (plan4.imageQuality !== void 0) usage6.imageQuality = plan4.imageQuality;
12547
+ if (plan5.imageQuality !== void 0) usage6.imageQuality = plan5.imageQuality;
12405
12548
  const result = { images, usage: usage6, raw: payload };
12406
12549
  const remote = files.find((f) => !f.url.startsWith("data:"));
12407
12550
  if (remote !== void 0) result.outputUrl = remote.url;
12408
12551
  return result;
12409
12552
  }
12410
12553
  async function generateFalFamilyImage(req, ctx, run) {
12411
- const plan4 = planFalImage(req, ctx.model.providerModelId, ctx.model.id);
12412
- const payload = await run(plan4.endpoint, plan4.input);
12413
- return collectFalPlanImages(payload, plan4, ctx, req);
12554
+ const plan5 = planFalImage(req, ctx.model.providerModelId, ctx.model.id);
12555
+ const payload = await run(plan5.endpoint, plan5.input);
12556
+ return collectFalPlanImages(payload, plan5, ctx, req);
12414
12557
  }
12415
12558
 
12416
12559
  // src/adapters/fal-mask.ts
@@ -13370,6 +13513,39 @@ function inputLengthSeconds(req, input) {
13370
13513
  return (payload) => reportedSeconds2(payload) ?? input?.durationSeconds ?? req.durationSeconds ?? 5;
13371
13514
  }
13372
13515
 
13516
+ // src/adapters/fal-avatar.ts
13517
+ var ENDPOINTS = /* @__PURE__ */ new Map([
13518
+ ["heygen/avatar-6/image-to-video", { promptField: "motion_prompt", resolution: true }],
13519
+ ["heygen/avatar-6/turbo/image-to-video", { promptField: "motion_prompt", resolution: true }],
13520
+ ["fal-ai/kling-video/ai-avatar/v2/standard", { promptField: "prompt", resolution: false }],
13521
+ ["fal-ai/kling-video/ai-avatar/v2/pro", { promptField: "prompt", resolution: false }],
13522
+ ["veed/fabric-1.0", { resolution: true }],
13523
+ ["veed/fabric-1.0/fast", { resolution: true }],
13524
+ ["fal-ai/sync-lipsync/v3/image-to-video", { resolution: false }]
13525
+ ]);
13526
+ function plan(req, ctx) {
13527
+ const id = ctx.model.providerModelId.toLowerCase();
13528
+ const endpoint = ENDPOINTS.get(id);
13529
+ const [image] = req.referenceImages ?? [];
13530
+ const [audio] = req.referenceAudios ?? [];
13531
+ if (endpoint === void 0 || image === void 0 || audio === void 0) {
13532
+ throw refusal2(ctx, "needs one image and one audio clip", "missing_input");
13533
+ }
13534
+ const input = { image_url: refToUrl(image), audio_url: refToUrl(audio) };
13535
+ const prompt = req.prompt.trim();
13536
+ if (endpoint.promptField !== void 0 && prompt.length > 0) {
13537
+ input[endpoint.promptField] = prompt;
13538
+ }
13539
+ const cap = ctx.model.constraints.references?.audioSeconds?.max;
13540
+ const measured2 = audio.durationSeconds;
13541
+ const seconds3 = (payload) => reportedSeconds2(payload) ?? measured2 ?? cap ?? req.durationSeconds ?? 5;
13542
+ if (!endpoint.resolution) return { endpoint: id, input, seconds: seconds3 };
13543
+ const resolution = resolutionOf2(req, ctx);
13544
+ input["resolution"] = resolution;
13545
+ return { endpoint: id, input, resolution, seconds: seconds3 };
13546
+ }
13547
+ var avatarFamily = { ids: new Set(ENDPOINTS.keys()), plan };
13548
+
13373
13549
  // src/adapters/fal-happy-horse.ts
13374
13550
  var VIDEO_EDIT = "alibaba/happy-horse/video-edit";
13375
13551
  function edit(req, ctx) {
@@ -13534,7 +13710,7 @@ var klingV4Family = {
13534
13710
  };
13535
13711
 
13536
13712
  // src/adapters/fal-kling-omni.ts
13537
- function plan(req, ctx) {
13713
+ function plan2(req, ctx) {
13538
13714
  const tier = klingTier(req);
13539
13715
  const duration = wholeSeconds(req, ctx);
13540
13716
  const input = {
@@ -13569,7 +13745,7 @@ function plan(req, ctx) {
13569
13745
  }
13570
13746
  var klingOmniFamily = {
13571
13747
  ids: /* @__PURE__ */ new Set([KLING_O3_OMNI]),
13572
- plan
13748
+ plan: plan2
13573
13749
  };
13574
13750
 
13575
13751
  // src/adapters/fal-minimax-h3.ts
@@ -13688,7 +13864,7 @@ var minimaxH3MaxFamily = {
13688
13864
 
13689
13865
  // src/adapters/fal-omnihuman.ts
13690
13866
  var OMNIHUMAN_V22 = "bytedance/omnihuman/v2";
13691
- function plan2(req, ctx) {
13867
+ function plan3(req, ctx) {
13692
13868
  const [image] = req.referenceImages ?? [];
13693
13869
  const [audio] = req.referenceAudios ?? [];
13694
13870
  if (image === void 0 || audio === void 0) {
@@ -13699,14 +13875,14 @@ function plan2(req, ctx) {
13699
13875
  return { endpoint: OMNIHUMAN_V22, input, seconds: inputLengthSeconds(req, audio) };
13700
13876
  }
13701
13877
  var OMNIHUMAN_MODEL_IDS = /* @__PURE__ */ new Set([OMNIHUMAN_V22]);
13702
- var omnihumanFamily = { ids: OMNIHUMAN_MODEL_IDS, plan: plan2 };
13878
+ var omnihumanFamily = { ids: OMNIHUMAN_MODEL_IDS, plan: plan3 };
13703
13879
 
13704
13880
  // src/adapters/fal-vidu.ts
13705
13881
  var FAMILY = "fal-ai/vidu/q4";
13706
13882
  function viduTier(resolution) {
13707
13883
  return resolution === "2k" || resolution === "4k" ? upperTier(resolution) : resolution;
13708
13884
  }
13709
- function plan3(req, ctx) {
13885
+ function plan4(req, ctx) {
13710
13886
  const images = urls(req.referenceImages);
13711
13887
  const audios = urls(req.referenceAudios);
13712
13888
  const duration = wholeSeconds(req, ctx);
@@ -13733,7 +13909,7 @@ function plan3(req, ctx) {
13733
13909
  return { endpoint, input, resolution, seconds: requestedSeconds(duration) };
13734
13910
  }
13735
13911
  var VIDU_MODEL_IDS = /* @__PURE__ */ new Set([FAMILY]);
13736
- var viduFamily = { ids: VIDU_MODEL_IDS, plan: plan3 };
13912
+ var viduFamily = { ids: VIDU_MODEL_IDS, plan: plan4 };
13737
13913
 
13738
13914
  // src/adapters/fal-video-families.ts
13739
13915
  var FAMILIES2 = [
@@ -13743,7 +13919,8 @@ var FAMILIES2 = [
13743
13919
  minimaxH3MaxFamily,
13744
13920
  happyHorseFamily,
13745
13921
  viduFamily,
13746
- omnihumanFamily
13922
+ omnihumanFamily,
13923
+ avatarFamily
13747
13924
  ];
13748
13925
  function isFalFamilyVideo(providerModelId) {
13749
13926
  const id = providerModelId.toLowerCase();
@@ -14174,7 +14351,7 @@ function extractVideoUrl(result, endpoint, model) {
14174
14351
  }
14175
14352
  async function generateFalVideo(req, ctx, deps) {
14176
14353
  const providerModelId = ctx.model.providerModelId;
14177
- const plan4 = planFalFamilyVideo(req, ctx);
14354
+ const plan5 = planFalFamilyVideo(req, ctx);
14178
14355
  const start = (endpoint2, input, usageOf2) => startFalVideoJob(
14179
14356
  ctx,
14180
14357
  () => falClientOf(ctx, deps),
@@ -14182,7 +14359,7 @@ async function generateFalVideo(req, ctx, deps) {
14182
14359
  input,
14183
14360
  videoFileDecoder(ctx, req, endpoint2, usageOf2)
14184
14361
  );
14185
- if (plan4 !== void 0) return start(plan4.endpoint, plan4.input, planUsage(ctx, plan4));
14362
+ if (plan5 !== void 0) return start(plan5.endpoint, plan5.input, planUsage(ctx, plan5));
14186
14363
  if (isKling(providerModelId)) return start(KLING_O1_ENDPOINT, klingO1Input(req));
14187
14364
  if (!isMinimax(providerModelId)) {
14188
14365
  throw new ModelKitError({
@@ -14228,9 +14405,9 @@ function videoFileDecoder(ctx, req, endpoint, usageOf2) {
14228
14405
  raw: payload
14229
14406
  });
14230
14407
  }
14231
- function planUsage(ctx, plan4) {
14408
+ function planUsage(ctx, plan5) {
14232
14409
  return (payload) => {
14233
- const seconds3 = plan4.seconds(payload);
14410
+ const seconds3 = plan5.seconds(payload);
14234
14411
  return {
14235
14412
  model: ctx.model.id,
14236
14413
  provider: "fal",
@@ -14238,7 +14415,7 @@ function planUsage(ctx, plan4) {
14238
14415
  unit: "seconds",
14239
14416
  quantity: seconds3,
14240
14417
  durationSeconds: seconds3,
14241
- ...plan4.resolution !== void 0 && { resolution: plan4.resolution }
14418
+ ...plan5.resolution !== void 0 && { resolution: plan5.resolution }
14242
14419
  };
14243
14420
  };
14244
14421
  }
@@ -20395,14 +20572,14 @@ function referenceVideoConformPlan(model, probe) {
20395
20572
  const reasons = [...size?.reasons ?? []];
20396
20573
  if (rate) reasons.push(rate.reason);
20397
20574
  if (overBytes) reasons.push("bytes_over");
20398
- const plan4 = {
20575
+ const plan5 = {
20399
20576
  width: round(width * scale),
20400
20577
  height: round(height * scale),
20401
20578
  reasons
20402
20579
  };
20403
- if (rate) plan4.fps = rate.fps;
20404
- if (maxBytes !== void 0) plan4.maxBytes = maxBytes;
20405
- return plan4;
20580
+ if (rate) plan5.fps = rate.fps;
20581
+ if (maxBytes !== void 0) plan5.maxBytes = maxBytes;
20582
+ return plan5;
20406
20583
  }
20407
20584
  function referenceImageConformPlan(model, probe) {
20408
20585
  const { width: probedWidth, height: probedHeight } = probe;