@shop-os/modelkit 0.27.0 → 0.29.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
@@ -5699,6 +5699,7 @@ var KLING_LOGO2 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0
5699
5699
  var MINIMAX_LOGO4 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
5700
5700
  var BYTEDANCE_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/3bba5d81-4e57-4e71-911b-cdfa05acca2c_compressed.png";
5701
5701
  var XAI_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/858b7fcc-9bd5-411d-aea1-a7b35ecfffab_compressed.png";
5702
+ var LIGHTRICKS_LOGO = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/lightricks.png";
5702
5703
  var H3_RATIOS = ["21:9", "16:9", "4:3", "1:1", "3:4", "9:16"];
5703
5704
  var HAPPY_HORSE_RATIOS = [
5704
5705
  "16:9",
@@ -5829,7 +5830,9 @@ var VIDEO_FAMILY_MODELS = [
5829
5830
  // start frame included (fal: "counts toward the image reference limit"), 300 px min.
5830
5831
  // Reference videos: 5, 3-30.05 s each and 30 s combined, 700 px min, 23.9-60.05 fps.
5831
5832
  // The prompt names references as @Image1, @Video1 (no space; @Element1 for elements,
5832
- // which the kit does not send). No sound switch on any endpoint.
5833
+ // which the kit does not send). No sound switch on any endpoint. 4K since 2026-11-19;
5834
+ // the endpoints also take `hdr` (10-bit, 1080p and 4K, billed per output second on top),
5835
+ // which the kit does not send: no price row can carry that fee yet (ENG-4272).
5833
5836
  id: "kling-4.0",
5834
5837
  aliases: ["kling-4", "kling-v4"],
5835
5838
  label: "Kling 4.0",
@@ -5841,7 +5844,7 @@ var VIDEO_FAMILY_MODELS = [
5841
5844
  constraints: {
5842
5845
  inputBilling: "kling-v4",
5843
5846
  aspectRatios: ["adaptive", "16:9", "9:16", "1:1", "21:9"],
5844
- resolutions: ["720p", "1080p"],
5847
+ resolutions: ["720p", "1080p", "4k"],
5845
5848
  durations: { min: 3, max: 30 },
5846
5849
  durationPresets: [5, 10, 15, 30],
5847
5850
  references: {
@@ -5862,7 +5865,7 @@ var VIDEO_FAMILY_MODELS = [
5862
5865
  display: {
5863
5866
  provider: "kuaishou",
5864
5867
  logo: KLING_LOGO2,
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."
5868
+ 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."
5866
5869
  },
5867
5870
  capabilities: { lastFrameRequiresFirstFrame: true }
5868
5871
  },
@@ -5880,7 +5883,7 @@ var VIDEO_FAMILY_MODELS = [
5880
5883
  exposure: ["cowork", "space_builder"],
5881
5884
  constraints: {
5882
5885
  inputBilling: "kling-v4",
5883
- resolutions: ["720p", "1080p"],
5886
+ resolutions: ["720p", "1080p", "4k"],
5884
5887
  durations: { min: 3, max: 30 },
5885
5888
  references: { ...NO_REFERENCES, images: 10 },
5886
5889
  requires: ["sourceVideo"],
@@ -5896,7 +5899,7 @@ var VIDEO_FAMILY_MODELS = [
5896
5899
  display: {
5897
5900
  provider: "kuaishou",
5898
5901
  logo: KLING_LOGO2,
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."
5902
+ 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."
5900
5903
  },
5901
5904
  capabilities: { acceptsSourceVideo: true, videoEdit: true }
5902
5905
  },
@@ -6295,6 +6298,77 @@ var VIDEO_FAMILY_MODELS = [
6295
6298
  description: "xAI Grok Imagine 1.5: text- and image-to-video at native 1080p with lip-synced audio, or up to 14 reference images and pinned first and last frames at 720p, up to 15 seconds."
6296
6299
  },
6297
6300
  capabilities: {}
6301
+ },
6302
+ {
6303
+ // https://fal.ai/models/fal-ai/ltx-2.3/text-to-video/api (+ /image-to-video): one row;
6304
+ // a start frame routes to image-to-video, else text-to-video. The kit's 2k/4k tiers
6305
+ // are fal's 1440p/2160p (adapters/fal-ltx.ts). "adaptive" is fal's "auto" on
6306
+ // image-to-video; text-to-video leaves an adaptive ratio at fal's 16:9 default.
6307
+ id: "ltx-2.3",
6308
+ aliases: ["ltx-2-3", "ltx23"],
6309
+ label: "LTX 2.3",
6310
+ type: "video",
6311
+ adapter: "fal",
6312
+ providerModelId: "fal-ai/ltx-2.3/text-to-video",
6313
+ lifecycle: "active",
6314
+ exposure: ["cowork", "space_builder"],
6315
+ constraints: {
6316
+ aspectRatios: ["adaptive", "16:9", "9:16"],
6317
+ resolutions: ["1080p", "2k", "4k"],
6318
+ durations: [6, 8, 10],
6319
+ supports: ["generateAudio", "lastFrame", "safetyChecker"],
6320
+ prompt: { referenceSyntax: "numbered", maxChars: 5e3 },
6321
+ audio: "optional"
6322
+ },
6323
+ defaults: {
6324
+ durationSeconds: 6,
6325
+ resolution: "1080p",
6326
+ aspectRatio: "adaptive",
6327
+ generateAudio: true
6328
+ },
6329
+ usage: { ...VIDEO_USAGE },
6330
+ pricingKind: "video_per_second",
6331
+ display: {
6332
+ provider: "lightricks",
6333
+ logo: LIGHTRICKS_LOGO,
6334
+ description: "Lightricks LTX 2.3 open-source text-to-video and start/end-frame image-to-video with native audio; 6, 8 or 10 seconds at up to 4K in landscape or portrait."
6335
+ },
6336
+ capabilities: { lastFrameRequiresFirstFrame: true }
6337
+ },
6338
+ {
6339
+ // https://fal.ai/models/fal-ai/ltx-2.3/text-to-video/fast/api (+ /image-to-video/fast):
6340
+ // the fast tier at the same resolutions; even durations 6-20 s, but over 10 s is
6341
+ // 1080p at 25 fps only (the kit never sends fps, so the rule checks the tier).
6342
+ id: "ltx-2.3-fast",
6343
+ aliases: ["ltx-2-3-fast", "ltx23-fast"],
6344
+ label: "LTX 2.3 Fast",
6345
+ type: "video",
6346
+ adapter: "fal",
6347
+ providerModelId: "fal-ai/ltx-2.3/text-to-video/fast",
6348
+ lifecycle: "active",
6349
+ exposure: ["cowork", "space_builder"],
6350
+ constraints: {
6351
+ aspectRatios: ["adaptive", "16:9", "9:16"],
6352
+ resolutions: ["1080p", "2k", "4k"],
6353
+ durations: [6, 8, 10, 12, 14, 16, 18, 20],
6354
+ supports: ["generateAudio", "lastFrame", "safetyChecker"],
6355
+ prompt: { referenceSyntax: "numbered", maxChars: 5e3 },
6356
+ audio: "optional"
6357
+ },
6358
+ defaults: {
6359
+ durationSeconds: 6,
6360
+ resolution: "1080p",
6361
+ aspectRatio: "adaptive",
6362
+ generateAudio: true
6363
+ },
6364
+ usage: { ...VIDEO_USAGE },
6365
+ pricingKind: "video_per_second",
6366
+ display: {
6367
+ provider: "lightricks",
6368
+ logo: LIGHTRICKS_LOGO,
6369
+ description: "Speed-optimized Lightricks LTX 2.3 Fast text-to-video and start/end-frame image-to-video with native audio; 6-20 seconds at up to 4K, over 10 seconds at 1080p."
6370
+ },
6371
+ capabilities: { lastFrameRequiresFirstFrame: true }
6298
6372
  }
6299
6373
  ];
6300
6374
 
@@ -10357,6 +10431,8 @@ var HAPPY_HORSE = "happyhorse-1.1";
10357
10431
  var HAPPY_HORSE_EDIT = "alibaba/happy-horse/video-edit";
10358
10432
  var VIDU_Q4 = "fal-ai/vidu/q4";
10359
10433
  var OMNIHUMAN_V2 = "bytedance/omnihuman/v2";
10434
+ var LTX_T2V = "fal-ai/ltx-2.3/text-to-video";
10435
+ var LTX_FAST_T2V = "fal-ai/ltx-2.3/text-to-video/fast";
10360
10436
  var KLING_O3_IMAGE_CAP = 7;
10361
10437
  var KLING_V4_IMAGE_CAP = 10;
10362
10438
  var TURBO_AUDIO_MIN_SECONDS = 2;
@@ -10426,7 +10502,17 @@ function o3Reference(req) {
10426
10502
  function hasReferences(req) {
10427
10503
  return count(req.referenceImages) + count(req.referenceVideos) > 0;
10428
10504
  }
10505
+ var KLING_V4_4K_MAX_SECONDS = 15;
10506
+ function klingV4FourK(seconds3, req) {
10507
+ if (req.resolution !== "4k") return void 0;
10508
+ if (seconds3 === void 0) {
10509
+ return missing(`needs a measured source video of up to ${KLING_V4_4K_MAX_SECONDS} s at 4K`);
10510
+ }
10511
+ return seconds3 > KLING_V4_4K_MAX_SECONDS ? unsupported3(`renders at most ${KLING_V4_4K_MAX_SECONDS} s at 4K`) : void 0;
10512
+ }
10429
10513
  function klingV4(req) {
10514
+ const fourK = klingV4FourK(req.durationSeconds ?? 5, req);
10515
+ if (fourK !== void 0) return fourK;
10430
10516
  if (hasReferences(req)) {
10431
10517
  if (req.lastFrame !== void 0) {
10432
10518
  return unsupported3("takes an end frame only without reference images or videos");
@@ -10523,6 +10609,20 @@ function imageAndAudio(req, audioSeconds) {
10523
10609
  }
10524
10610
  return inputSeconds("audio", audio, audioSeconds);
10525
10611
  }
10612
+ function ltx(fast) {
10613
+ return (req) => {
10614
+ if (req.lastFrame !== void 0 && req.firstFrame === void 0) {
10615
+ return missing("takes an end frame only together with a start frame");
10616
+ }
10617
+ if (count(req.referenceImages) + count(req.referenceVideos) + count(req.referenceAudios) > 0) {
10618
+ return unsupported3("takes no reference images, videos or audio");
10619
+ }
10620
+ if (fast && (req.durationSeconds ?? 6) > 10 && req.resolution !== void 0 && req.resolution !== "1080p") {
10621
+ return unsupported3("renders over 10 s at 1080p only");
10622
+ }
10623
+ return needsPrompt(req);
10624
+ };
10625
+ }
10526
10626
  var RULES = new Map([
10527
10627
  [MOTION_PRO, motionControl],
10528
10628
  [MOTION_STANDARD, motionControl],
@@ -10530,7 +10630,10 @@ var RULES = new Map([
10530
10630
  [KLING_O3_OMNI, o3Reference],
10531
10631
  [O3_EDIT, (req) => needsSource(req) ?? needsPrompt(req)],
10532
10632
  [KLING_V4, klingV4],
10533
- [KLING_V4_EDIT, (req) => needsSource(req) ?? needsPrompt(req)],
10633
+ [
10634
+ KLING_V4_EDIT,
10635
+ (req) => needsSource(req) ?? klingV4FourK(req.durationSeconds ?? req.sourceVideo?.durationSeconds, req) ?? needsPrompt(req)
10636
+ ],
10534
10637
  [KLING_V4_FLASH, klingV4Flash],
10535
10638
  [KLING_V4_FLASH_EDIT, (req) => needsSource(req) ?? needsPrompt(req)],
10536
10639
  [H3_TURBO, h3Turbo],
@@ -10543,7 +10646,9 @@ var RULES = new Map([
10543
10646
  [OMNIHUMAN_V2, (req) => imageAndAudio(req, OMNIHUMAN_AUDIO_SECONDS)],
10544
10647
  ...AVATAR_AUDIO.map(
10545
10648
  ([id, limits]) => [id, (req) => imageAndAudio(req, limits)]
10546
- )
10649
+ ),
10650
+ [LTX_T2V, ltx(false)],
10651
+ [LTX_FAST_T2V, ltx(true)]
10547
10652
  ]);
10548
10653
  function falVideoProblem(providerModelId, req) {
10549
10654
  return RULES.get(providerModelId.toLowerCase())?.(req);
@@ -13733,6 +13838,58 @@ var klingOmniFamily = {
13733
13838
  plan: plan2
13734
13839
  };
13735
13840
 
13841
+ // src/adapters/fal-ltx.ts
13842
+ var LTX_T2V2 = "fal-ai/ltx-2.3/text-to-video";
13843
+ var LTX_I2V = "fal-ai/ltx-2.3/image-to-video";
13844
+ var LTX_FAST_T2V2 = "fal-ai/ltx-2.3/text-to-video/fast";
13845
+ var LTX_FAST_I2V = "fal-ai/ltx-2.3/image-to-video/fast";
13846
+ var LTX_TIERS = {
13847
+ "360p": "360p",
13848
+ "480p": "480p",
13849
+ "720p": "720p",
13850
+ "768p": "768p",
13851
+ "1080p": "1080p",
13852
+ "2k": "1440p",
13853
+ "4k": "2160p"
13854
+ };
13855
+ function ltxGenerate(fast, req, ctx) {
13856
+ const resolution = resolutionOf2(req, ctx);
13857
+ const duration = wholeSeconds(req, ctx);
13858
+ const input = {
13859
+ prompt: req.prompt.trim(),
13860
+ duration,
13861
+ resolution: LTX_TIERS[resolution],
13862
+ generate_audio: req.generateAudio ?? true
13863
+ };
13864
+ if (req.safetyChecker !== void 0) input["enable_safety_checker"] = req.safetyChecker;
13865
+ const firstFrame = req.firstFrame;
13866
+ const endpoint = firstFrame === void 0 ? fast ? LTX_FAST_T2V2 : LTX_T2V2 : fast ? LTX_FAST_I2V : LTX_I2V;
13867
+ if (firstFrame === void 0) {
13868
+ const ratio = concreteRatio(req);
13869
+ if (ratio !== void 0) input["aspect_ratio"] = ratio;
13870
+ } else {
13871
+ input["image_url"] = refToUrl(firstFrame);
13872
+ if (req.lastFrame !== void 0) input["end_image_url"] = refToUrl(req.lastFrame);
13873
+ if (req.aspectRatio !== void 0) {
13874
+ input["aspect_ratio"] = req.aspectRatio === "adaptive" ? "auto" : req.aspectRatio;
13875
+ }
13876
+ }
13877
+ return { endpoint, input, resolution, seconds: requestedSeconds(duration) };
13878
+ }
13879
+ var LTX_MODEL_IDS = /* @__PURE__ */ new Set([
13880
+ LTX_T2V2,
13881
+ LTX_I2V,
13882
+ LTX_FAST_T2V2,
13883
+ LTX_FAST_I2V
13884
+ ]);
13885
+ var ltxFamily = {
13886
+ ids: LTX_MODEL_IDS,
13887
+ plan(req, ctx) {
13888
+ const id = ctx.model.providerModelId.toLowerCase();
13889
+ return ltxGenerate(id === LTX_FAST_T2V2 || id === LTX_FAST_I2V, req, ctx);
13890
+ }
13891
+ };
13892
+
13736
13893
  // src/adapters/fal-minimax-h3.ts
13737
13894
  var TURBO = "minimax/h3-max-turbo";
13738
13895
  var INSERT = MINIMAX_H3_INSERT;
@@ -13903,6 +14060,7 @@ var FAMILIES2 = [
13903
14060
  klingV4Family,
13904
14061
  minimaxH3MaxFamily,
13905
14062
  happyHorseFamily,
14063
+ ltxFamily,
13906
14064
  viduFamily,
13907
14065
  omnihumanFamily,
13908
14066
  avatarFamily