@shop-os/modelkit 0.26.0 → 0.27.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
@@ -535,7 +535,8 @@ var FAL_IMAGE_MODELS = [
535
535
  constraints: {
536
536
  aspectRatios: [...KLING_RATIOS, "adaptive"],
537
537
  sizes: ["2K", "4K", "8K"],
538
- references: { images: 10 },
538
+ // fal refuses a reference under 300x300 (422 image_too_small, prod COWORK-5S).
539
+ references: { images: 10, imagePixels: { minWidth: 300, minHeight: 300 } },
539
540
  supports: ["count"],
540
541
  prompt: { referenceSyntax: "numbered", maxChars: 21e3 }
541
542
  },
@@ -5582,10 +5583,119 @@ var TEXT_MODELS = [
5582
5583
  })
5583
5584
  ];
5584
5585
 
5585
- // src/catalog/video-families.ts
5586
- var VIDEO_USAGE = { unit: "seconds" };
5586
+ // src/catalog/video-avatars.ts
5587
5587
  var MB = 1024 * 1024;
5588
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";
5589
5699
  var MINIMAX_LOGO4 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
5590
5700
  var BYTEDANCE_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/3bba5d81-4e57-4e71-911b-cdfa05acca2c_compressed.png";
5591
5701
  var XAI_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/858b7fcc-9bd5-411d-aea1-a7b35ecfffab_compressed.png";
@@ -5643,7 +5753,7 @@ function klingMotionControl(tier) {
5643
5753
  pricingKind: "video_per_second",
5644
5754
  display: {
5645
5755
  provider: "kuaishou",
5646
- logo: KLING_LOGO,
5756
+ logo: KLING_LOGO2,
5647
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.`
5648
5758
  },
5649
5759
  capabilities: {}
@@ -5676,7 +5786,7 @@ var VIDEO_FAMILY_MODELS = [
5676
5786
  pricingKind: "video_per_second",
5677
5787
  display: {
5678
5788
  provider: "kuaishou",
5679
- logo: KLING_LOGO,
5789
+ logo: KLING_LOGO2,
5680
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."
5681
5791
  },
5682
5792
  capabilities: { lastFrameRequiresFirstFrame: true }
@@ -5707,7 +5817,7 @@ var VIDEO_FAMILY_MODELS = [
5707
5817
  pricingKind: "video_per_second",
5708
5818
  display: {
5709
5819
  provider: "kuaishou",
5710
- logo: KLING_LOGO,
5820
+ logo: KLING_LOGO2,
5711
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."
5712
5822
  },
5713
5823
  capabilities: { acceptsSourceVideo: true, videoEdit: true }
@@ -5751,7 +5861,7 @@ var VIDEO_FAMILY_MODELS = [
5751
5861
  pricingKind: "video_per_second",
5752
5862
  display: {
5753
5863
  provider: "kuaishou",
5754
- logo: KLING_LOGO,
5864
+ logo: KLING_LOGO2,
5755
5865
  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."
5756
5866
  },
5757
5867
  capabilities: { lastFrameRequiresFirstFrame: true }
@@ -5785,7 +5895,7 @@ var VIDEO_FAMILY_MODELS = [
5785
5895
  pricingKind: "video_per_second",
5786
5896
  display: {
5787
5897
  provider: "kuaishou",
5788
- logo: KLING_LOGO,
5898
+ logo: KLING_LOGO2,
5789
5899
  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."
5790
5900
  },
5791
5901
  capabilities: { acceptsSourceVideo: true, videoEdit: true }
@@ -5826,7 +5936,7 @@ var VIDEO_FAMILY_MODELS = [
5826
5936
  pricingKind: "video_per_second",
5827
5937
  display: {
5828
5938
  provider: "kuaishou",
5829
- logo: KLING_LOGO,
5939
+ logo: KLING_LOGO2,
5830
5940
  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."
5831
5941
  }
5832
5942
  },
@@ -5866,7 +5976,7 @@ var VIDEO_FAMILY_MODELS = [
5866
5976
  pricingKind: "video_per_second",
5867
5977
  display: {
5868
5978
  provider: "kuaishou",
5869
- logo: KLING_LOGO,
5979
+ logo: KLING_LOGO2,
5870
5980
  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."
5871
5981
  },
5872
5982
  capabilities: { acceptsSourceVideo: true, videoEdit: true }
@@ -5893,7 +6003,7 @@ var VIDEO_FAMILY_MODELS = [
5893
6003
  ...NO_REFERENCES,
5894
6004
  audios: 1,
5895
6005
  audioSeconds: { min: 2 },
5896
- audioMaxBytes: 15 * MB
6006
+ audioMaxBytes: 15 * MB2
5897
6007
  },
5898
6008
  supports: ["seed", "promptExpansion", "lastFrame", "safetyChecker"],
5899
6009
  prompt: H3_PROMPT,
@@ -6092,7 +6202,7 @@ var VIDEO_FAMILY_MODELS = [
6092
6202
  audioOnly: false,
6093
6203
  audioSeconds: { min: 3, max: 12 },
6094
6204
  audioFormats: ["mp3"],
6095
- audioMaxBytes: 50 * MB
6205
+ audioMaxBytes: 50 * MB2
6096
6206
  },
6097
6207
  // Sound (dialogue and effects) is a reference-to-video option; image-to-video is silent.
6098
6208
  supports: ["seed", "generateAudio", "safetyChecker"],
@@ -6133,7 +6243,7 @@ var VIDEO_FAMILY_MODELS = [
6133
6243
  audioOnly: false,
6134
6244
  audioSeconds: { min: 4, max: 300 },
6135
6245
  audioFormats: ["wav", "mp3"],
6136
- audioMaxBytes: 15 * MB,
6246
+ audioMaxBytes: 15 * MB2,
6137
6247
  min: { images: 1, audios: 1 }
6138
6248
  },
6139
6249
  requires: ["references"],
@@ -7236,6 +7346,7 @@ var VIDEO_MODELS = [
7236
7346
  capabilities: {}
7237
7347
  },
7238
7348
  ...VIDEO_FAMILY_MODELS,
7349
+ ...VIDEO_AVATAR_MODELS,
7239
7350
  ...LUMA_VIDEO_MODELS
7240
7351
  ];
7241
7352
 
@@ -10250,6 +10361,15 @@ var KLING_O3_IMAGE_CAP = 7;
10250
10361
  var KLING_V4_IMAGE_CAP = 10;
10251
10362
  var TURBO_AUDIO_MIN_SECONDS = 2;
10252
10363
  var OMNIHUMAN_AUDIO_SECONDS = { min: 4, max: 300 };
10364
+ var AVATAR_AUDIO = [
10365
+ ["heygen/avatar-6/image-to-video", { max: 300 }],
10366
+ ["heygen/avatar-6/turbo/image-to-video", { max: 300 }],
10367
+ ["fal-ai/kling-video/ai-avatar/v2/standard", { min: 2, max: 300 }],
10368
+ ["fal-ai/kling-video/ai-avatar/v2/pro", { min: 2, max: 300 }],
10369
+ ["veed/fabric-1.0", { max: 300, urlOnly: true }],
10370
+ ["veed/fabric-1.0/fast", { max: 300, urlOnly: true }],
10371
+ ["fal-ai/sync-lipsync/v3/image-to-video", { max: 300, urlOnly: true }]
10372
+ ];
10253
10373
  function missing(message) {
10254
10374
  return { code: "missing_input", message };
10255
10375
  }
@@ -10383,7 +10503,10 @@ function viduQ4(req) {
10383
10503
  }
10384
10504
  return req.firstFrame === void 0 ? missing("needs a start frame or reference images") : void 0;
10385
10505
  }
10386
- function omnihuman(req) {
10506
+ function isPublicUrl(ref) {
10507
+ return "url" in ref && !ref.url.startsWith("data:");
10508
+ }
10509
+ function imageAndAudio(req, audioSeconds) {
10387
10510
  const frames = noFrames(req);
10388
10511
  if (frames !== void 0) return frames;
10389
10512
  if (count(req.referenceVideos) > 0) return unsupported3("takes no reference videos");
@@ -10395,9 +10518,12 @@ function omnihuman(req) {
10395
10518
  if (extraImages.length > 0 || extraAudios.length > 0) {
10396
10519
  return unsupported3("takes exactly one image and one audio clip");
10397
10520
  }
10398
- return inputSeconds("audio", audio, OMNIHUMAN_AUDIO_SECONDS);
10521
+ if (audioSeconds.urlOnly === true && !(isPublicUrl(image) && isPublicUrl(audio))) {
10522
+ return unsupported3("takes its image and audio as public URLs, not inline bytes");
10523
+ }
10524
+ return inputSeconds("audio", audio, audioSeconds);
10399
10525
  }
10400
- var RULES = /* @__PURE__ */ new Map([
10526
+ var RULES = new Map([
10401
10527
  [MOTION_PRO, motionControl],
10402
10528
  [MOTION_STANDARD, motionControl],
10403
10529
  [O3_REFERENCE, o3Reference],
@@ -10414,7 +10540,10 @@ var RULES = /* @__PURE__ */ new Map([
10414
10540
  [HAPPY_HORSE, happyHorse],
10415
10541
  [HAPPY_HORSE_EDIT, happyHorseEdit],
10416
10542
  [VIDU_Q4, viduQ4],
10417
- [OMNIHUMAN_V2, omnihuman]
10543
+ [OMNIHUMAN_V2, (req) => imageAndAudio(req, OMNIHUMAN_AUDIO_SECONDS)],
10544
+ ...AVATAR_AUDIO.map(
10545
+ ([id, limits]) => [id, (req) => imageAndAudio(req, limits)]
10546
+ )
10418
10547
  ]);
10419
10548
  function falVideoProblem(providerModelId, req) {
10420
10549
  return RULES.get(providerModelId.toLowerCase())?.(req);
@@ -11991,11 +12120,11 @@ function toolInput(ctx, req, output) {
11991
12120
  }
11992
12121
  var EXR_DEFAULT_PROMPT = "The same video in high dynamic range, with unchanged content, motion, framing and timing.";
11993
12122
  async function submitFalVideoTool(req, ctx, opts) {
11994
- const plan4 = planVideoTool(ctx.model, req);
11995
- if (!plan4.ok) {
12123
+ const plan5 = planVideoTool(ctx.model, req);
12124
+ if (!plan5.ok) {
11996
12125
  throw new ModelKitError({
11997
12126
  code: "unsupported_option",
11998
- message: plan4.error,
12127
+ message: plan5.error,
11999
12128
  provider: "fal",
12000
12129
  model: ctx.model.id,
12001
12130
  retryable: false
@@ -12003,7 +12132,7 @@ async function submitFalVideoTool(req, ctx, opts) {
12003
12132
  }
12004
12133
  const target = new URL(`${FAL_QUEUE_ORIGIN}/${ctx.model.providerModelId}`);
12005
12134
  if (opts.webhookUrl !== void 0) target.searchParams.set("fal_webhook", opts.webhookUrl);
12006
- const res = await queueFetch(ctx, target.toString(), "POST", toolInput(ctx, req, plan4.output));
12135
+ const res = await queueFetch(ctx, target.toString(), "POST", toolInput(ctx, req, plan5.output));
12007
12136
  const parsed = submitResponseSchema.safeParse(await readJson(ctx, res));
12008
12137
  if (!parsed.success) {
12009
12138
  throw new ModelKitError({
@@ -12021,7 +12150,7 @@ async function submitFalVideoTool(req, ctx, opts) {
12021
12150
  statusUrl: parsed.data.status_url,
12022
12151
  responseUrl: parsed.data.response_url,
12023
12152
  cancelUrl: parsed.data.cancel_url,
12024
- output: plan4.output
12153
+ output: plan5.output
12025
12154
  };
12026
12155
  }
12027
12156
  async function falVideoToolStatus(sub, ctx) {
@@ -12343,14 +12472,14 @@ function planFalImage(req, providerModelId, model) {
12343
12472
  const exact = falExactSize(spec, req);
12344
12473
  const call = { label: spec.label, req, refs, edit: edit2, ...exact !== void 0 && { exact } };
12345
12474
  const built = family.build(call, model);
12346
- const plan4 = {
12475
+ const plan5 = {
12347
12476
  endpoint: edit2 && family.editEndpoint !== void 0 ? family.editEndpoint : id,
12348
12477
  input: built.input,
12349
12478
  output: family.output ?? "images"
12350
12479
  };
12351
- if (built.imageQuality !== void 0) plan4.imageQuality = built.imageQuality;
12352
- if (built.imageSize !== void 0) plan4.imageSize = built.imageSize;
12353
- return plan4;
12480
+ if (built.imageQuality !== void 0) plan5.imageQuality = built.imageQuality;
12481
+ if (built.imageSize !== void 0) plan5.imageSize = built.imageSize;
12482
+ return plan5;
12354
12483
  }
12355
12484
  var FalFileSchema = import_zod17.z.object({ url: import_zod17.z.string(), content_type: import_zod17.z.string().nullish() });
12356
12485
  var ImagesPayloadSchema = import_zod17.z.object({ images: import_zod17.z.array(FalFileSchema) });
@@ -12372,18 +12501,18 @@ async function downloadFalFile(ctx, file) {
12372
12501
  const mime = res.headers.get("content-type") ?? file.content_type ?? "";
12373
12502
  return { bytes: new Uint8Array(await res.arrayBuffer()), mime };
12374
12503
  }
12375
- function filesOf(payload, plan4) {
12376
- if (plan4.output === "image") {
12504
+ function filesOf(payload, plan5) {
12505
+ if (plan5.output === "image") {
12377
12506
  const parsed2 = ImagePayloadSchema.safeParse(payload);
12378
12507
  return parsed2.success ? [parsed2.data.image] : [];
12379
12508
  }
12380
12509
  const parsed = ImagesPayloadSchema.safeParse(payload);
12381
12510
  return parsed.success ? parsed.data.images : [];
12382
12511
  }
12383
- async function collectFalPlanImages(payload, plan4, ctx, req) {
12384
- const files = filesOf(payload, plan4);
12512
+ async function collectFalPlanImages(payload, plan5, ctx, req) {
12513
+ const files = filesOf(payload, plan5);
12385
12514
  if (files.length === 0) {
12386
- throw fail2(ctx.model.id, `fal ${plan4.endpoint} returned no image`, "provider_rejected");
12515
+ throw fail2(ctx.model.id, `fal ${plan5.endpoint} returned no image`, "provider_rejected");
12387
12516
  }
12388
12517
  const images = await Promise.all(
12389
12518
  files.map(async (file) => {
@@ -12398,18 +12527,18 @@ async function collectFalPlanImages(payload, plan4, ctx, req) {
12398
12527
  unit: "images",
12399
12528
  quantity: images.length
12400
12529
  };
12401
- const billedSize = plan4.imageSize ?? req.size;
12530
+ const billedSize = plan5.imageSize ?? req.size;
12402
12531
  if (billedSize !== void 0 && ctx.model.type === "image") usage6.imageSize = billedSize;
12403
- if (plan4.imageQuality !== void 0) usage6.imageQuality = plan4.imageQuality;
12532
+ if (plan5.imageQuality !== void 0) usage6.imageQuality = plan5.imageQuality;
12404
12533
  const result = { images, usage: usage6, raw: payload };
12405
12534
  const remote = files.find((f) => !f.url.startsWith("data:"));
12406
12535
  if (remote !== void 0) result.outputUrl = remote.url;
12407
12536
  return result;
12408
12537
  }
12409
12538
  async function generateFalFamilyImage(req, ctx, run) {
12410
- const plan4 = planFalImage(req, ctx.model.providerModelId, ctx.model.id);
12411
- const payload = await run(plan4.endpoint, plan4.input);
12412
- return collectFalPlanImages(payload, plan4, ctx, req);
12539
+ const plan5 = planFalImage(req, ctx.model.providerModelId, ctx.model.id);
12540
+ const payload = await run(plan5.endpoint, plan5.input);
12541
+ return collectFalPlanImages(payload, plan5, ctx, req);
12413
12542
  }
12414
12543
 
12415
12544
  // src/adapters/fal-mask.ts
@@ -13369,6 +13498,39 @@ function inputLengthSeconds(req, input) {
13369
13498
  return (payload) => reportedSeconds2(payload) ?? input?.durationSeconds ?? req.durationSeconds ?? 5;
13370
13499
  }
13371
13500
 
13501
+ // src/adapters/fal-avatar.ts
13502
+ var ENDPOINTS = /* @__PURE__ */ new Map([
13503
+ ["heygen/avatar-6/image-to-video", { promptField: "motion_prompt", resolution: true }],
13504
+ ["heygen/avatar-6/turbo/image-to-video", { promptField: "motion_prompt", resolution: true }],
13505
+ ["fal-ai/kling-video/ai-avatar/v2/standard", { promptField: "prompt", resolution: false }],
13506
+ ["fal-ai/kling-video/ai-avatar/v2/pro", { promptField: "prompt", resolution: false }],
13507
+ ["veed/fabric-1.0", { resolution: true }],
13508
+ ["veed/fabric-1.0/fast", { resolution: true }],
13509
+ ["fal-ai/sync-lipsync/v3/image-to-video", { resolution: false }]
13510
+ ]);
13511
+ function plan(req, ctx) {
13512
+ const id = ctx.model.providerModelId.toLowerCase();
13513
+ const endpoint = ENDPOINTS.get(id);
13514
+ const [image] = req.referenceImages ?? [];
13515
+ const [audio] = req.referenceAudios ?? [];
13516
+ if (endpoint === void 0 || image === void 0 || audio === void 0) {
13517
+ throw refusal2(ctx, "needs one image and one audio clip", "missing_input");
13518
+ }
13519
+ const input = { image_url: refToUrl(image), audio_url: refToUrl(audio) };
13520
+ const prompt = req.prompt.trim();
13521
+ if (endpoint.promptField !== void 0 && prompt.length > 0) {
13522
+ input[endpoint.promptField] = prompt;
13523
+ }
13524
+ const cap = ctx.model.constraints.references?.audioSeconds?.max;
13525
+ const measured2 = audio.durationSeconds;
13526
+ const seconds3 = (payload) => reportedSeconds2(payload) ?? measured2 ?? cap ?? req.durationSeconds ?? 5;
13527
+ if (!endpoint.resolution) return { endpoint: id, input, seconds: seconds3 };
13528
+ const resolution = resolutionOf2(req, ctx);
13529
+ input["resolution"] = resolution;
13530
+ return { endpoint: id, input, resolution, seconds: seconds3 };
13531
+ }
13532
+ var avatarFamily = { ids: new Set(ENDPOINTS.keys()), plan };
13533
+
13372
13534
  // src/adapters/fal-happy-horse.ts
13373
13535
  var VIDEO_EDIT = "alibaba/happy-horse/video-edit";
13374
13536
  function edit(req, ctx) {
@@ -13533,7 +13695,7 @@ var klingV4Family = {
13533
13695
  };
13534
13696
 
13535
13697
  // src/adapters/fal-kling-omni.ts
13536
- function plan(req, ctx) {
13698
+ function plan2(req, ctx) {
13537
13699
  const tier = klingTier(req);
13538
13700
  const duration = wholeSeconds(req, ctx);
13539
13701
  const input = {
@@ -13568,7 +13730,7 @@ function plan(req, ctx) {
13568
13730
  }
13569
13731
  var klingOmniFamily = {
13570
13732
  ids: /* @__PURE__ */ new Set([KLING_O3_OMNI]),
13571
- plan
13733
+ plan: plan2
13572
13734
  };
13573
13735
 
13574
13736
  // src/adapters/fal-minimax-h3.ts
@@ -13687,7 +13849,7 @@ var minimaxH3MaxFamily = {
13687
13849
 
13688
13850
  // src/adapters/fal-omnihuman.ts
13689
13851
  var OMNIHUMAN_V22 = "bytedance/omnihuman/v2";
13690
- function plan2(req, ctx) {
13852
+ function plan3(req, ctx) {
13691
13853
  const [image] = req.referenceImages ?? [];
13692
13854
  const [audio] = req.referenceAudios ?? [];
13693
13855
  if (image === void 0 || audio === void 0) {
@@ -13698,14 +13860,14 @@ function plan2(req, ctx) {
13698
13860
  return { endpoint: OMNIHUMAN_V22, input, seconds: inputLengthSeconds(req, audio) };
13699
13861
  }
13700
13862
  var OMNIHUMAN_MODEL_IDS = /* @__PURE__ */ new Set([OMNIHUMAN_V22]);
13701
- var omnihumanFamily = { ids: OMNIHUMAN_MODEL_IDS, plan: plan2 };
13863
+ var omnihumanFamily = { ids: OMNIHUMAN_MODEL_IDS, plan: plan3 };
13702
13864
 
13703
13865
  // src/adapters/fal-vidu.ts
13704
13866
  var FAMILY = "fal-ai/vidu/q4";
13705
13867
  function viduTier(resolution) {
13706
13868
  return resolution === "2k" || resolution === "4k" ? upperTier(resolution) : resolution;
13707
13869
  }
13708
- function plan3(req, ctx) {
13870
+ function plan4(req, ctx) {
13709
13871
  const images = urls(req.referenceImages);
13710
13872
  const audios = urls(req.referenceAudios);
13711
13873
  const duration = wholeSeconds(req, ctx);
@@ -13732,7 +13894,7 @@ function plan3(req, ctx) {
13732
13894
  return { endpoint, input, resolution, seconds: requestedSeconds(duration) };
13733
13895
  }
13734
13896
  var VIDU_MODEL_IDS = /* @__PURE__ */ new Set([FAMILY]);
13735
- var viduFamily = { ids: VIDU_MODEL_IDS, plan: plan3 };
13897
+ var viduFamily = { ids: VIDU_MODEL_IDS, plan: plan4 };
13736
13898
 
13737
13899
  // src/adapters/fal-video-families.ts
13738
13900
  var FAMILIES2 = [
@@ -13742,7 +13904,8 @@ var FAMILIES2 = [
13742
13904
  minimaxH3MaxFamily,
13743
13905
  happyHorseFamily,
13744
13906
  viduFamily,
13745
- omnihumanFamily
13907
+ omnihumanFamily,
13908
+ avatarFamily
13746
13909
  ];
13747
13910
  function isFalFamilyVideo(providerModelId) {
13748
13911
  const id = providerModelId.toLowerCase();
@@ -14173,7 +14336,7 @@ function extractVideoUrl(result, endpoint, model) {
14173
14336
  }
14174
14337
  async function generateFalVideo(req, ctx, deps) {
14175
14338
  const providerModelId = ctx.model.providerModelId;
14176
- const plan4 = planFalFamilyVideo(req, ctx);
14339
+ const plan5 = planFalFamilyVideo(req, ctx);
14177
14340
  const start = (endpoint2, input, usageOf2) => startFalVideoJob(
14178
14341
  ctx,
14179
14342
  () => falClientOf(ctx, deps),
@@ -14181,7 +14344,7 @@ async function generateFalVideo(req, ctx, deps) {
14181
14344
  input,
14182
14345
  videoFileDecoder(ctx, req, endpoint2, usageOf2)
14183
14346
  );
14184
- if (plan4 !== void 0) return start(plan4.endpoint, plan4.input, planUsage(ctx, plan4));
14347
+ if (plan5 !== void 0) return start(plan5.endpoint, plan5.input, planUsage(ctx, plan5));
14185
14348
  if (isKling(providerModelId)) return start(KLING_O1_ENDPOINT, klingO1Input(req));
14186
14349
  if (!isMinimax(providerModelId)) {
14187
14350
  throw new ModelKitError({
@@ -14227,9 +14390,9 @@ function videoFileDecoder(ctx, req, endpoint, usageOf2) {
14227
14390
  raw: payload
14228
14391
  });
14229
14392
  }
14230
- function planUsage(ctx, plan4) {
14393
+ function planUsage(ctx, plan5) {
14231
14394
  return (payload) => {
14232
- const seconds3 = plan4.seconds(payload);
14395
+ const seconds3 = plan5.seconds(payload);
14233
14396
  return {
14234
14397
  model: ctx.model.id,
14235
14398
  provider: "fal",
@@ -14237,7 +14400,7 @@ function planUsage(ctx, plan4) {
14237
14400
  unit: "seconds",
14238
14401
  quantity: seconds3,
14239
14402
  durationSeconds: seconds3,
14240
- ...plan4.resolution !== void 0 && { resolution: plan4.resolution }
14403
+ ...plan5.resolution !== void 0 && { resolution: plan5.resolution }
14241
14404
  };
14242
14405
  };
14243
14406
  }
@@ -20394,14 +20557,14 @@ function referenceVideoConformPlan(model, probe) {
20394
20557
  const reasons = [...size?.reasons ?? []];
20395
20558
  if (rate) reasons.push(rate.reason);
20396
20559
  if (overBytes) reasons.push("bytes_over");
20397
- const plan4 = {
20560
+ const plan5 = {
20398
20561
  width: round(width * scale),
20399
20562
  height: round(height * scale),
20400
20563
  reasons
20401
20564
  };
20402
- if (rate) plan4.fps = rate.fps;
20403
- if (maxBytes !== void 0) plan4.maxBytes = maxBytes;
20404
- return plan4;
20565
+ if (rate) plan5.fps = rate.fps;
20566
+ if (maxBytes !== void 0) plan5.maxBytes = maxBytes;
20567
+ return plan5;
20405
20568
  }
20406
20569
  function referenceImageConformPlan(model, probe) {
20407
20570
  const { width: probedWidth, height: probedHeight } = probe;