@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/CHANGELOG.md +34 -0
- package/dist/catalog.cjs +165 -22
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.js +165 -22
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +234 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +234 -57
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5426,10 +5426,119 @@ var TEXT_MODELS = [
|
|
|
5426
5426
|
})
|
|
5427
5427
|
];
|
|
5428
5428
|
|
|
5429
|
-
// src/catalog/video-
|
|
5430
|
-
var VIDEO_USAGE = { unit: "seconds" };
|
|
5429
|
+
// src/catalog/video-avatars.ts
|
|
5431
5430
|
var MB = 1024 * 1024;
|
|
5432
5431
|
var KLING_LOGO = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/kling-color.png";
|
|
5432
|
+
var VEED_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/d540d2bb-0022-4371-8889-48aefaf46bbe.png";
|
|
5433
|
+
var SYNC_LOGO2 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/sync.png";
|
|
5434
|
+
var KIT_AUDIO_CAP_SECONDS = 300;
|
|
5435
|
+
function avatar(row2) {
|
|
5436
|
+
const { min, max, formats, maxBytes } = row2.audio;
|
|
5437
|
+
return {
|
|
5438
|
+
id: row2.id,
|
|
5439
|
+
aliases: row2.aliases,
|
|
5440
|
+
label: row2.label,
|
|
5441
|
+
type: "video",
|
|
5442
|
+
adapter: "fal",
|
|
5443
|
+
providerModelId: row2.providerModelId,
|
|
5444
|
+
lifecycle: "active",
|
|
5445
|
+
exposure: ["cowork", "space_builder"],
|
|
5446
|
+
constraints: {
|
|
5447
|
+
...row2.resolutions !== void 0 && { resolutions: [...row2.resolutions] },
|
|
5448
|
+
references: {
|
|
5449
|
+
images: 1,
|
|
5450
|
+
videos: 0,
|
|
5451
|
+
audios: 1,
|
|
5452
|
+
audioOnly: false,
|
|
5453
|
+
audioSeconds: { ...min !== void 0 && { min }, max },
|
|
5454
|
+
audioFormats: formats,
|
|
5455
|
+
...maxBytes !== void 0 && { audioMaxBytes: maxBytes },
|
|
5456
|
+
min: { images: 1, audios: 1 }
|
|
5457
|
+
},
|
|
5458
|
+
requires: ["references"],
|
|
5459
|
+
supports: [],
|
|
5460
|
+
...row2.promptMaxChars === void 0 ? { noPrompt: true } : { prompt: { referenceSyntax: "descriptive", maxChars: row2.promptMaxChars } },
|
|
5461
|
+
audio: "always"
|
|
5462
|
+
},
|
|
5463
|
+
defaults: row2.resolutions === void 0 ? {} : { resolution: row2.resolutions[0] },
|
|
5464
|
+
usage: { unit: "seconds" },
|
|
5465
|
+
pricingKind: "video_per_second",
|
|
5466
|
+
display: {
|
|
5467
|
+
provider: row2.provider,
|
|
5468
|
+
...row2.logo !== void 0 && { logo: row2.logo },
|
|
5469
|
+
description: row2.description
|
|
5470
|
+
},
|
|
5471
|
+
capabilities: {}
|
|
5472
|
+
};
|
|
5473
|
+
}
|
|
5474
|
+
function heygenAvatar6(tier) {
|
|
5475
|
+
const turbo2 = tier === "turbo";
|
|
5476
|
+
return avatar({
|
|
5477
|
+
id: turbo2 ? "heygen-avatar-6-turbo" : "heygen-avatar-6",
|
|
5478
|
+
aliases: [],
|
|
5479
|
+
label: turbo2 ? "HeyGen Avatar 6 Turbo" : "HeyGen Avatar 6",
|
|
5480
|
+
providerModelId: turbo2 ? "heygen/avatar-6/turbo/image-to-video" : "heygen/avatar-6/image-to-video",
|
|
5481
|
+
provider: "heygen",
|
|
5482
|
+
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.",
|
|
5483
|
+
audio: { max: KIT_AUDIO_CAP_SECONDS, formats: ["wav", "mp3"], maxBytes: 50 * MB },
|
|
5484
|
+
resolutions: ["1080p", "2k"],
|
|
5485
|
+
promptMaxChars: 1200
|
|
5486
|
+
});
|
|
5487
|
+
}
|
|
5488
|
+
function klingAvatar(tier) {
|
|
5489
|
+
const label = tier === "pro" ? "Pro" : "Standard";
|
|
5490
|
+
return avatar({
|
|
5491
|
+
id: `kling-ai-avatar-v2-${tier}`,
|
|
5492
|
+
aliases: [],
|
|
5493
|
+
label: `Kling AI Avatar 2.0 ${label}`,
|
|
5494
|
+
providerModelId: `fal-ai/kling-video/ai-avatar/v2/${tier}`,
|
|
5495
|
+
provider: "kuaishou",
|
|
5496
|
+
logo: KLING_LOGO,
|
|
5497
|
+
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.`,
|
|
5498
|
+
audio: { min: 2, max: 300, formats: ["mp3", "wav", "m4a", "aac"], maxBytes: 5 * MB },
|
|
5499
|
+
promptMaxChars: 2500
|
|
5500
|
+
});
|
|
5501
|
+
}
|
|
5502
|
+
function veedFabric(tier) {
|
|
5503
|
+
const fast = tier === "fast";
|
|
5504
|
+
return avatar({
|
|
5505
|
+
id: fast ? "veed-fabric-1.0-fast" : "veed-fabric-1.0",
|
|
5506
|
+
aliases: [fast ? "veed/fabric-1.0/fast" : "veed/fabric-1.0"],
|
|
5507
|
+
label: fast ? "VEED Fabric 1.0 Fast" : "VEED Fabric 1.0",
|
|
5508
|
+
providerModelId: fast ? "veed/fabric-1.0/fast" : "veed/fabric-1.0",
|
|
5509
|
+
provider: "veed",
|
|
5510
|
+
logo: VEED_LOGO,
|
|
5511
|
+
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.",
|
|
5512
|
+
audio: { max: KIT_AUDIO_CAP_SECONDS, formats: ["mp3", "ogg", "wav", "m4a", "aac"] },
|
|
5513
|
+
resolutions: ["720p", "480p"]
|
|
5514
|
+
});
|
|
5515
|
+
}
|
|
5516
|
+
var VIDEO_AVATAR_MODELS = [
|
|
5517
|
+
heygenAvatar6("regular"),
|
|
5518
|
+
heygenAvatar6("turbo"),
|
|
5519
|
+
klingAvatar("standard"),
|
|
5520
|
+
klingAvatar("pro"),
|
|
5521
|
+
veedFabric("regular"),
|
|
5522
|
+
veedFabric("fast"),
|
|
5523
|
+
// https://fal.ai/models/fal-ai/sync-lipsync/v3/image-to-video/api: image_url and audio_url
|
|
5524
|
+
// only; the video matches the audio's length. sync takes WAV or MP3
|
|
5525
|
+
// (https://sync.so/docs/quickstart); the length is the kit cap.
|
|
5526
|
+
avatar({
|
|
5527
|
+
id: "sync-3-image-to-video",
|
|
5528
|
+
aliases: ["fal-ai/sync-lipsync/v3/image-to-video"],
|
|
5529
|
+
label: "Sync 3 Avatar",
|
|
5530
|
+
providerModelId: "fal-ai/sync-lipsync/v3/image-to-video",
|
|
5531
|
+
provider: "sync",
|
|
5532
|
+
logo: SYNC_LOGO2,
|
|
5533
|
+
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.",
|
|
5534
|
+
audio: { max: KIT_AUDIO_CAP_SECONDS, formats: ["wav", "mp3"] }
|
|
5535
|
+
})
|
|
5536
|
+
];
|
|
5537
|
+
|
|
5538
|
+
// src/catalog/video-families.ts
|
|
5539
|
+
var VIDEO_USAGE = { unit: "seconds" };
|
|
5540
|
+
var MB2 = 1024 * 1024;
|
|
5541
|
+
var KLING_LOGO2 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/kling-color.png";
|
|
5433
5542
|
var MINIMAX_LOGO4 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
|
|
5434
5543
|
var BYTEDANCE_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/3bba5d81-4e57-4e71-911b-cdfa05acca2c_compressed.png";
|
|
5435
5544
|
var XAI_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/858b7fcc-9bd5-411d-aea1-a7b35ecfffab_compressed.png";
|
|
@@ -5487,7 +5596,7 @@ function klingMotionControl(tier) {
|
|
|
5487
5596
|
pricingKind: "video_per_second",
|
|
5488
5597
|
display: {
|
|
5489
5598
|
provider: "kuaishou",
|
|
5490
|
-
logo:
|
|
5599
|
+
logo: KLING_LOGO2,
|
|
5491
5600
|
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.`
|
|
5492
5601
|
},
|
|
5493
5602
|
capabilities: {}
|
|
@@ -5520,7 +5629,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5520
5629
|
pricingKind: "video_per_second",
|
|
5521
5630
|
display: {
|
|
5522
5631
|
provider: "kuaishou",
|
|
5523
|
-
logo:
|
|
5632
|
+
logo: KLING_LOGO2,
|
|
5524
5633
|
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."
|
|
5525
5634
|
},
|
|
5526
5635
|
capabilities: { lastFrameRequiresFirstFrame: true }
|
|
@@ -5551,7 +5660,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5551
5660
|
pricingKind: "video_per_second",
|
|
5552
5661
|
display: {
|
|
5553
5662
|
provider: "kuaishou",
|
|
5554
|
-
logo:
|
|
5663
|
+
logo: KLING_LOGO2,
|
|
5555
5664
|
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."
|
|
5556
5665
|
},
|
|
5557
5666
|
capabilities: { acceptsSourceVideo: true, videoEdit: true }
|
|
@@ -5563,7 +5672,9 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5563
5672
|
// start frame included (fal: "counts toward the image reference limit"), 300 px min.
|
|
5564
5673
|
// Reference videos: 5, 3-30.05 s each and 30 s combined, 700 px min, 23.9-60.05 fps.
|
|
5565
5674
|
// The prompt names references as @Image1, @Video1 (no space; @Element1 for elements,
|
|
5566
|
-
// which the kit does not send). No sound switch on any endpoint.
|
|
5675
|
+
// which the kit does not send). No sound switch on any endpoint. 4K since 2026-11-19;
|
|
5676
|
+
// the endpoints also take `hdr` (10-bit, 1080p and 4K, billed per output second on top),
|
|
5677
|
+
// which the kit does not send: no price row can carry that fee yet (ENG-4272).
|
|
5567
5678
|
id: "kling-4.0",
|
|
5568
5679
|
aliases: ["kling-4", "kling-v4"],
|
|
5569
5680
|
label: "Kling 4.0",
|
|
@@ -5575,7 +5686,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5575
5686
|
constraints: {
|
|
5576
5687
|
inputBilling: "kling-v4",
|
|
5577
5688
|
aspectRatios: ["adaptive", "16:9", "9:16", "1:1", "21:9"],
|
|
5578
|
-
resolutions: ["720p", "1080p"],
|
|
5689
|
+
resolutions: ["720p", "1080p", "4k"],
|
|
5579
5690
|
durations: { min: 3, max: 30 },
|
|
5580
5691
|
durationPresets: [5, 10, 15, 30],
|
|
5581
5692
|
references: {
|
|
@@ -5595,8 +5706,8 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5595
5706
|
pricingKind: "video_per_second",
|
|
5596
5707
|
display: {
|
|
5597
5708
|
provider: "kuaishou",
|
|
5598
|
-
logo:
|
|
5599
|
-
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."
|
|
5709
|
+
logo: KLING_LOGO2,
|
|
5710
|
+
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."
|
|
5600
5711
|
},
|
|
5601
5712
|
capabilities: { lastFrameRequiresFirstFrame: true }
|
|
5602
5713
|
},
|
|
@@ -5614,7 +5725,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5614
5725
|
exposure: ["cowork", "space_builder"],
|
|
5615
5726
|
constraints: {
|
|
5616
5727
|
inputBilling: "kling-v4",
|
|
5617
|
-
resolutions: ["720p", "1080p"],
|
|
5728
|
+
resolutions: ["720p", "1080p", "4k"],
|
|
5618
5729
|
durations: { min: 3, max: 30 },
|
|
5619
5730
|
references: { ...NO_REFERENCES, images: 10 },
|
|
5620
5731
|
requires: ["sourceVideo"],
|
|
@@ -5629,8 +5740,8 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5629
5740
|
pricingKind: "video_per_second",
|
|
5630
5741
|
display: {
|
|
5631
5742
|
provider: "kuaishou",
|
|
5632
|
-
logo:
|
|
5633
|
-
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
|
|
5743
|
+
logo: KLING_LOGO2,
|
|
5744
|
+
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."
|
|
5634
5745
|
},
|
|
5635
5746
|
capabilities: { acceptsSourceVideo: true, videoEdit: true }
|
|
5636
5747
|
},
|
|
@@ -5670,7 +5781,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5670
5781
|
pricingKind: "video_per_second",
|
|
5671
5782
|
display: {
|
|
5672
5783
|
provider: "kuaishou",
|
|
5673
|
-
logo:
|
|
5784
|
+
logo: KLING_LOGO2,
|
|
5674
5785
|
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."
|
|
5675
5786
|
}
|
|
5676
5787
|
},
|
|
@@ -5710,7 +5821,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5710
5821
|
pricingKind: "video_per_second",
|
|
5711
5822
|
display: {
|
|
5712
5823
|
provider: "kuaishou",
|
|
5713
|
-
logo:
|
|
5824
|
+
logo: KLING_LOGO2,
|
|
5714
5825
|
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."
|
|
5715
5826
|
},
|
|
5716
5827
|
capabilities: { acceptsSourceVideo: true, videoEdit: true }
|
|
@@ -5737,7 +5848,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5737
5848
|
...NO_REFERENCES,
|
|
5738
5849
|
audios: 1,
|
|
5739
5850
|
audioSeconds: { min: 2 },
|
|
5740
|
-
audioMaxBytes: 15 *
|
|
5851
|
+
audioMaxBytes: 15 * MB2
|
|
5741
5852
|
},
|
|
5742
5853
|
supports: ["seed", "promptExpansion", "lastFrame", "safetyChecker"],
|
|
5743
5854
|
prompt: H3_PROMPT,
|
|
@@ -5936,7 +6047,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5936
6047
|
audioOnly: false,
|
|
5937
6048
|
audioSeconds: { min: 3, max: 12 },
|
|
5938
6049
|
audioFormats: ["mp3"],
|
|
5939
|
-
audioMaxBytes: 50 *
|
|
6050
|
+
audioMaxBytes: 50 * MB2
|
|
5940
6051
|
},
|
|
5941
6052
|
// Sound (dialogue and effects) is a reference-to-video option; image-to-video is silent.
|
|
5942
6053
|
supports: ["seed", "generateAudio", "safetyChecker"],
|
|
@@ -5977,7 +6088,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5977
6088
|
audioOnly: false,
|
|
5978
6089
|
audioSeconds: { min: 4, max: 300 },
|
|
5979
6090
|
audioFormats: ["wav", "mp3"],
|
|
5980
|
-
audioMaxBytes: 15 *
|
|
6091
|
+
audioMaxBytes: 15 * MB2,
|
|
5981
6092
|
min: { images: 1, audios: 1 }
|
|
5982
6093
|
},
|
|
5983
6094
|
requires: ["references"],
|
|
@@ -7080,6 +7191,7 @@ var VIDEO_MODELS = [
|
|
|
7080
7191
|
capabilities: {}
|
|
7081
7192
|
},
|
|
7082
7193
|
...VIDEO_FAMILY_MODELS,
|
|
7194
|
+
...VIDEO_AVATAR_MODELS,
|
|
7083
7195
|
...LUMA_VIDEO_MODELS
|
|
7084
7196
|
];
|
|
7085
7197
|
|
|
@@ -10094,6 +10206,15 @@ var KLING_O3_IMAGE_CAP = 7;
|
|
|
10094
10206
|
var KLING_V4_IMAGE_CAP = 10;
|
|
10095
10207
|
var TURBO_AUDIO_MIN_SECONDS = 2;
|
|
10096
10208
|
var OMNIHUMAN_AUDIO_SECONDS = { min: 4, max: 300 };
|
|
10209
|
+
var AVATAR_AUDIO = [
|
|
10210
|
+
["heygen/avatar-6/image-to-video", { max: 300 }],
|
|
10211
|
+
["heygen/avatar-6/turbo/image-to-video", { max: 300 }],
|
|
10212
|
+
["fal-ai/kling-video/ai-avatar/v2/standard", { min: 2, max: 300 }],
|
|
10213
|
+
["fal-ai/kling-video/ai-avatar/v2/pro", { min: 2, max: 300 }],
|
|
10214
|
+
["veed/fabric-1.0", { max: 300, urlOnly: true }],
|
|
10215
|
+
["veed/fabric-1.0/fast", { max: 300, urlOnly: true }],
|
|
10216
|
+
["fal-ai/sync-lipsync/v3/image-to-video", { max: 300, urlOnly: true }]
|
|
10217
|
+
];
|
|
10097
10218
|
function missing(message) {
|
|
10098
10219
|
return { code: "missing_input", message };
|
|
10099
10220
|
}
|
|
@@ -10150,7 +10271,17 @@ function o3Reference(req) {
|
|
|
10150
10271
|
function hasReferences(req) {
|
|
10151
10272
|
return count(req.referenceImages) + count(req.referenceVideos) > 0;
|
|
10152
10273
|
}
|
|
10274
|
+
var KLING_V4_4K_MAX_SECONDS = 15;
|
|
10275
|
+
function klingV4FourK(seconds3, req) {
|
|
10276
|
+
if (req.resolution !== "4k") return void 0;
|
|
10277
|
+
if (seconds3 === void 0) {
|
|
10278
|
+
return missing(`needs a measured source video of up to ${KLING_V4_4K_MAX_SECONDS} s at 4K`);
|
|
10279
|
+
}
|
|
10280
|
+
return seconds3 > KLING_V4_4K_MAX_SECONDS ? unsupported3(`renders at most ${KLING_V4_4K_MAX_SECONDS} s at 4K`) : void 0;
|
|
10281
|
+
}
|
|
10153
10282
|
function klingV4(req) {
|
|
10283
|
+
const fourK = klingV4FourK(req.durationSeconds ?? 5, req);
|
|
10284
|
+
if (fourK !== void 0) return fourK;
|
|
10154
10285
|
if (hasReferences(req)) {
|
|
10155
10286
|
if (req.lastFrame !== void 0) {
|
|
10156
10287
|
return unsupported3("takes an end frame only without reference images or videos");
|
|
@@ -10227,7 +10358,10 @@ function viduQ4(req) {
|
|
|
10227
10358
|
}
|
|
10228
10359
|
return req.firstFrame === void 0 ? missing("needs a start frame or reference images") : void 0;
|
|
10229
10360
|
}
|
|
10230
|
-
function
|
|
10361
|
+
function isPublicUrl(ref) {
|
|
10362
|
+
return "url" in ref && !ref.url.startsWith("data:");
|
|
10363
|
+
}
|
|
10364
|
+
function imageAndAudio(req, audioSeconds) {
|
|
10231
10365
|
const frames = noFrames(req);
|
|
10232
10366
|
if (frames !== void 0) return frames;
|
|
10233
10367
|
if (count(req.referenceVideos) > 0) return unsupported3("takes no reference videos");
|
|
@@ -10239,16 +10373,22 @@ function omnihuman(req) {
|
|
|
10239
10373
|
if (extraImages.length > 0 || extraAudios.length > 0) {
|
|
10240
10374
|
return unsupported3("takes exactly one image and one audio clip");
|
|
10241
10375
|
}
|
|
10242
|
-
|
|
10376
|
+
if (audioSeconds.urlOnly === true && !(isPublicUrl(image) && isPublicUrl(audio))) {
|
|
10377
|
+
return unsupported3("takes its image and audio as public URLs, not inline bytes");
|
|
10378
|
+
}
|
|
10379
|
+
return inputSeconds("audio", audio, audioSeconds);
|
|
10243
10380
|
}
|
|
10244
|
-
var RULES =
|
|
10381
|
+
var RULES = new Map([
|
|
10245
10382
|
[MOTION_PRO, motionControl],
|
|
10246
10383
|
[MOTION_STANDARD, motionControl],
|
|
10247
10384
|
[O3_REFERENCE, o3Reference],
|
|
10248
10385
|
[KLING_O3_OMNI, o3Reference],
|
|
10249
10386
|
[O3_EDIT, (req) => needsSource(req) ?? needsPrompt(req)],
|
|
10250
10387
|
[KLING_V4, klingV4],
|
|
10251
|
-
[
|
|
10388
|
+
[
|
|
10389
|
+
KLING_V4_EDIT,
|
|
10390
|
+
(req) => needsSource(req) ?? klingV4FourK(req.durationSeconds ?? req.sourceVideo?.durationSeconds, req) ?? needsPrompt(req)
|
|
10391
|
+
],
|
|
10252
10392
|
[KLING_V4_FLASH, klingV4Flash],
|
|
10253
10393
|
[KLING_V4_FLASH_EDIT, (req) => needsSource(req) ?? needsPrompt(req)],
|
|
10254
10394
|
[H3_TURBO, h3Turbo],
|
|
@@ -10258,7 +10398,10 @@ var RULES = /* @__PURE__ */ new Map([
|
|
|
10258
10398
|
[HAPPY_HORSE, happyHorse],
|
|
10259
10399
|
[HAPPY_HORSE_EDIT, happyHorseEdit],
|
|
10260
10400
|
[VIDU_Q4, viduQ4],
|
|
10261
|
-
[OMNIHUMAN_V2,
|
|
10401
|
+
[OMNIHUMAN_V2, (req) => imageAndAudio(req, OMNIHUMAN_AUDIO_SECONDS)],
|
|
10402
|
+
...AVATAR_AUDIO.map(
|
|
10403
|
+
([id, limits]) => [id, (req) => imageAndAudio(req, limits)]
|
|
10404
|
+
)
|
|
10262
10405
|
]);
|
|
10263
10406
|
function falVideoProblem(providerModelId, req) {
|
|
10264
10407
|
return RULES.get(providerModelId.toLowerCase())?.(req);
|
|
@@ -11835,11 +11978,11 @@ function toolInput(ctx, req, output) {
|
|
|
11835
11978
|
}
|
|
11836
11979
|
var EXR_DEFAULT_PROMPT = "The same video in high dynamic range, with unchanged content, motion, framing and timing.";
|
|
11837
11980
|
async function submitFalVideoTool(req, ctx, opts) {
|
|
11838
|
-
const
|
|
11839
|
-
if (!
|
|
11981
|
+
const plan5 = planVideoTool(ctx.model, req);
|
|
11982
|
+
if (!plan5.ok) {
|
|
11840
11983
|
throw new ModelKitError({
|
|
11841
11984
|
code: "unsupported_option",
|
|
11842
|
-
message:
|
|
11985
|
+
message: plan5.error,
|
|
11843
11986
|
provider: "fal",
|
|
11844
11987
|
model: ctx.model.id,
|
|
11845
11988
|
retryable: false
|
|
@@ -11847,7 +11990,7 @@ async function submitFalVideoTool(req, ctx, opts) {
|
|
|
11847
11990
|
}
|
|
11848
11991
|
const target = new URL(`${FAL_QUEUE_ORIGIN}/${ctx.model.providerModelId}`);
|
|
11849
11992
|
if (opts.webhookUrl !== void 0) target.searchParams.set("fal_webhook", opts.webhookUrl);
|
|
11850
|
-
const res = await queueFetch(ctx, target.toString(), "POST", toolInput(ctx, req,
|
|
11993
|
+
const res = await queueFetch(ctx, target.toString(), "POST", toolInput(ctx, req, plan5.output));
|
|
11851
11994
|
const parsed = submitResponseSchema.safeParse(await readJson(ctx, res));
|
|
11852
11995
|
if (!parsed.success) {
|
|
11853
11996
|
throw new ModelKitError({
|
|
@@ -11865,7 +12008,7 @@ async function submitFalVideoTool(req, ctx, opts) {
|
|
|
11865
12008
|
statusUrl: parsed.data.status_url,
|
|
11866
12009
|
responseUrl: parsed.data.response_url,
|
|
11867
12010
|
cancelUrl: parsed.data.cancel_url,
|
|
11868
|
-
output:
|
|
12011
|
+
output: plan5.output
|
|
11869
12012
|
};
|
|
11870
12013
|
}
|
|
11871
12014
|
async function falVideoToolStatus(sub, ctx) {
|
|
@@ -12187,14 +12330,14 @@ function planFalImage(req, providerModelId, model) {
|
|
|
12187
12330
|
const exact = falExactSize(spec, req);
|
|
12188
12331
|
const call = { label: spec.label, req, refs, edit: edit2, ...exact !== void 0 && { exact } };
|
|
12189
12332
|
const built = family.build(call, model);
|
|
12190
|
-
const
|
|
12333
|
+
const plan5 = {
|
|
12191
12334
|
endpoint: edit2 && family.editEndpoint !== void 0 ? family.editEndpoint : id,
|
|
12192
12335
|
input: built.input,
|
|
12193
12336
|
output: family.output ?? "images"
|
|
12194
12337
|
};
|
|
12195
|
-
if (built.imageQuality !== void 0)
|
|
12196
|
-
if (built.imageSize !== void 0)
|
|
12197
|
-
return
|
|
12338
|
+
if (built.imageQuality !== void 0) plan5.imageQuality = built.imageQuality;
|
|
12339
|
+
if (built.imageSize !== void 0) plan5.imageSize = built.imageSize;
|
|
12340
|
+
return plan5;
|
|
12198
12341
|
}
|
|
12199
12342
|
var FalFileSchema = z17.object({ url: z17.string(), content_type: z17.string().nullish() });
|
|
12200
12343
|
var ImagesPayloadSchema = z17.object({ images: z17.array(FalFileSchema) });
|
|
@@ -12216,18 +12359,18 @@ async function downloadFalFile(ctx, file) {
|
|
|
12216
12359
|
const mime = res.headers.get("content-type") ?? file.content_type ?? "";
|
|
12217
12360
|
return { bytes: new Uint8Array(await res.arrayBuffer()), mime };
|
|
12218
12361
|
}
|
|
12219
|
-
function filesOf(payload,
|
|
12220
|
-
if (
|
|
12362
|
+
function filesOf(payload, plan5) {
|
|
12363
|
+
if (plan5.output === "image") {
|
|
12221
12364
|
const parsed2 = ImagePayloadSchema.safeParse(payload);
|
|
12222
12365
|
return parsed2.success ? [parsed2.data.image] : [];
|
|
12223
12366
|
}
|
|
12224
12367
|
const parsed = ImagesPayloadSchema.safeParse(payload);
|
|
12225
12368
|
return parsed.success ? parsed.data.images : [];
|
|
12226
12369
|
}
|
|
12227
|
-
async function collectFalPlanImages(payload,
|
|
12228
|
-
const files = filesOf(payload,
|
|
12370
|
+
async function collectFalPlanImages(payload, plan5, ctx, req) {
|
|
12371
|
+
const files = filesOf(payload, plan5);
|
|
12229
12372
|
if (files.length === 0) {
|
|
12230
|
-
throw fail2(ctx.model.id, `fal ${
|
|
12373
|
+
throw fail2(ctx.model.id, `fal ${plan5.endpoint} returned no image`, "provider_rejected");
|
|
12231
12374
|
}
|
|
12232
12375
|
const images = await Promise.all(
|
|
12233
12376
|
files.map(async (file) => {
|
|
@@ -12242,18 +12385,18 @@ async function collectFalPlanImages(payload, plan4, ctx, req) {
|
|
|
12242
12385
|
unit: "images",
|
|
12243
12386
|
quantity: images.length
|
|
12244
12387
|
};
|
|
12245
|
-
const billedSize =
|
|
12388
|
+
const billedSize = plan5.imageSize ?? req.size;
|
|
12246
12389
|
if (billedSize !== void 0 && ctx.model.type === "image") usage6.imageSize = billedSize;
|
|
12247
|
-
if (
|
|
12390
|
+
if (plan5.imageQuality !== void 0) usage6.imageQuality = plan5.imageQuality;
|
|
12248
12391
|
const result = { images, usage: usage6, raw: payload };
|
|
12249
12392
|
const remote = files.find((f) => !f.url.startsWith("data:"));
|
|
12250
12393
|
if (remote !== void 0) result.outputUrl = remote.url;
|
|
12251
12394
|
return result;
|
|
12252
12395
|
}
|
|
12253
12396
|
async function generateFalFamilyImage(req, ctx, run) {
|
|
12254
|
-
const
|
|
12255
|
-
const payload = await run(
|
|
12256
|
-
return collectFalPlanImages(payload,
|
|
12397
|
+
const plan5 = planFalImage(req, ctx.model.providerModelId, ctx.model.id);
|
|
12398
|
+
const payload = await run(plan5.endpoint, plan5.input);
|
|
12399
|
+
return collectFalPlanImages(payload, plan5, ctx, req);
|
|
12257
12400
|
}
|
|
12258
12401
|
|
|
12259
12402
|
// src/adapters/fal-mask.ts
|
|
@@ -13213,6 +13356,39 @@ function inputLengthSeconds(req, input) {
|
|
|
13213
13356
|
return (payload) => reportedSeconds2(payload) ?? input?.durationSeconds ?? req.durationSeconds ?? 5;
|
|
13214
13357
|
}
|
|
13215
13358
|
|
|
13359
|
+
// src/adapters/fal-avatar.ts
|
|
13360
|
+
var ENDPOINTS = /* @__PURE__ */ new Map([
|
|
13361
|
+
["heygen/avatar-6/image-to-video", { promptField: "motion_prompt", resolution: true }],
|
|
13362
|
+
["heygen/avatar-6/turbo/image-to-video", { promptField: "motion_prompt", resolution: true }],
|
|
13363
|
+
["fal-ai/kling-video/ai-avatar/v2/standard", { promptField: "prompt", resolution: false }],
|
|
13364
|
+
["fal-ai/kling-video/ai-avatar/v2/pro", { promptField: "prompt", resolution: false }],
|
|
13365
|
+
["veed/fabric-1.0", { resolution: true }],
|
|
13366
|
+
["veed/fabric-1.0/fast", { resolution: true }],
|
|
13367
|
+
["fal-ai/sync-lipsync/v3/image-to-video", { resolution: false }]
|
|
13368
|
+
]);
|
|
13369
|
+
function plan(req, ctx) {
|
|
13370
|
+
const id = ctx.model.providerModelId.toLowerCase();
|
|
13371
|
+
const endpoint = ENDPOINTS.get(id);
|
|
13372
|
+
const [image] = req.referenceImages ?? [];
|
|
13373
|
+
const [audio] = req.referenceAudios ?? [];
|
|
13374
|
+
if (endpoint === void 0 || image === void 0 || audio === void 0) {
|
|
13375
|
+
throw refusal2(ctx, "needs one image and one audio clip", "missing_input");
|
|
13376
|
+
}
|
|
13377
|
+
const input = { image_url: refToUrl(image), audio_url: refToUrl(audio) };
|
|
13378
|
+
const prompt = req.prompt.trim();
|
|
13379
|
+
if (endpoint.promptField !== void 0 && prompt.length > 0) {
|
|
13380
|
+
input[endpoint.promptField] = prompt;
|
|
13381
|
+
}
|
|
13382
|
+
const cap = ctx.model.constraints.references?.audioSeconds?.max;
|
|
13383
|
+
const measured2 = audio.durationSeconds;
|
|
13384
|
+
const seconds3 = (payload) => reportedSeconds2(payload) ?? measured2 ?? cap ?? req.durationSeconds ?? 5;
|
|
13385
|
+
if (!endpoint.resolution) return { endpoint: id, input, seconds: seconds3 };
|
|
13386
|
+
const resolution = resolutionOf2(req, ctx);
|
|
13387
|
+
input["resolution"] = resolution;
|
|
13388
|
+
return { endpoint: id, input, resolution, seconds: seconds3 };
|
|
13389
|
+
}
|
|
13390
|
+
var avatarFamily = { ids: new Set(ENDPOINTS.keys()), plan };
|
|
13391
|
+
|
|
13216
13392
|
// src/adapters/fal-happy-horse.ts
|
|
13217
13393
|
var VIDEO_EDIT = "alibaba/happy-horse/video-edit";
|
|
13218
13394
|
function edit(req, ctx) {
|
|
@@ -13377,7 +13553,7 @@ var klingV4Family = {
|
|
|
13377
13553
|
};
|
|
13378
13554
|
|
|
13379
13555
|
// src/adapters/fal-kling-omni.ts
|
|
13380
|
-
function
|
|
13556
|
+
function plan2(req, ctx) {
|
|
13381
13557
|
const tier = klingTier(req);
|
|
13382
13558
|
const duration = wholeSeconds(req, ctx);
|
|
13383
13559
|
const input = {
|
|
@@ -13412,7 +13588,7 @@ function plan(req, ctx) {
|
|
|
13412
13588
|
}
|
|
13413
13589
|
var klingOmniFamily = {
|
|
13414
13590
|
ids: /* @__PURE__ */ new Set([KLING_O3_OMNI]),
|
|
13415
|
-
plan
|
|
13591
|
+
plan: plan2
|
|
13416
13592
|
};
|
|
13417
13593
|
|
|
13418
13594
|
// src/adapters/fal-minimax-h3.ts
|
|
@@ -13531,7 +13707,7 @@ var minimaxH3MaxFamily = {
|
|
|
13531
13707
|
|
|
13532
13708
|
// src/adapters/fal-omnihuman.ts
|
|
13533
13709
|
var OMNIHUMAN_V22 = "bytedance/omnihuman/v2";
|
|
13534
|
-
function
|
|
13710
|
+
function plan3(req, ctx) {
|
|
13535
13711
|
const [image] = req.referenceImages ?? [];
|
|
13536
13712
|
const [audio] = req.referenceAudios ?? [];
|
|
13537
13713
|
if (image === void 0 || audio === void 0) {
|
|
@@ -13542,14 +13718,14 @@ function plan2(req, ctx) {
|
|
|
13542
13718
|
return { endpoint: OMNIHUMAN_V22, input, seconds: inputLengthSeconds(req, audio) };
|
|
13543
13719
|
}
|
|
13544
13720
|
var OMNIHUMAN_MODEL_IDS = /* @__PURE__ */ new Set([OMNIHUMAN_V22]);
|
|
13545
|
-
var omnihumanFamily = { ids: OMNIHUMAN_MODEL_IDS, plan:
|
|
13721
|
+
var omnihumanFamily = { ids: OMNIHUMAN_MODEL_IDS, plan: plan3 };
|
|
13546
13722
|
|
|
13547
13723
|
// src/adapters/fal-vidu.ts
|
|
13548
13724
|
var FAMILY = "fal-ai/vidu/q4";
|
|
13549
13725
|
function viduTier(resolution) {
|
|
13550
13726
|
return resolution === "2k" || resolution === "4k" ? upperTier(resolution) : resolution;
|
|
13551
13727
|
}
|
|
13552
|
-
function
|
|
13728
|
+
function plan4(req, ctx) {
|
|
13553
13729
|
const images = urls(req.referenceImages);
|
|
13554
13730
|
const audios = urls(req.referenceAudios);
|
|
13555
13731
|
const duration = wholeSeconds(req, ctx);
|
|
@@ -13576,7 +13752,7 @@ function plan3(req, ctx) {
|
|
|
13576
13752
|
return { endpoint, input, resolution, seconds: requestedSeconds(duration) };
|
|
13577
13753
|
}
|
|
13578
13754
|
var VIDU_MODEL_IDS = /* @__PURE__ */ new Set([FAMILY]);
|
|
13579
|
-
var viduFamily = { ids: VIDU_MODEL_IDS, plan:
|
|
13755
|
+
var viduFamily = { ids: VIDU_MODEL_IDS, plan: plan4 };
|
|
13580
13756
|
|
|
13581
13757
|
// src/adapters/fal-video-families.ts
|
|
13582
13758
|
var FAMILIES2 = [
|
|
@@ -13586,7 +13762,8 @@ var FAMILIES2 = [
|
|
|
13586
13762
|
minimaxH3MaxFamily,
|
|
13587
13763
|
happyHorseFamily,
|
|
13588
13764
|
viduFamily,
|
|
13589
|
-
omnihumanFamily
|
|
13765
|
+
omnihumanFamily,
|
|
13766
|
+
avatarFamily
|
|
13590
13767
|
];
|
|
13591
13768
|
function isFalFamilyVideo(providerModelId) {
|
|
13592
13769
|
const id = providerModelId.toLowerCase();
|
|
@@ -14017,7 +14194,7 @@ function extractVideoUrl(result, endpoint, model) {
|
|
|
14017
14194
|
}
|
|
14018
14195
|
async function generateFalVideo(req, ctx, deps) {
|
|
14019
14196
|
const providerModelId = ctx.model.providerModelId;
|
|
14020
|
-
const
|
|
14197
|
+
const plan5 = planFalFamilyVideo(req, ctx);
|
|
14021
14198
|
const start = (endpoint2, input, usageOf2) => startFalVideoJob(
|
|
14022
14199
|
ctx,
|
|
14023
14200
|
() => falClientOf(ctx, deps),
|
|
@@ -14025,7 +14202,7 @@ async function generateFalVideo(req, ctx, deps) {
|
|
|
14025
14202
|
input,
|
|
14026
14203
|
videoFileDecoder(ctx, req, endpoint2, usageOf2)
|
|
14027
14204
|
);
|
|
14028
|
-
if (
|
|
14205
|
+
if (plan5 !== void 0) return start(plan5.endpoint, plan5.input, planUsage(ctx, plan5));
|
|
14029
14206
|
if (isKling(providerModelId)) return start(KLING_O1_ENDPOINT, klingO1Input(req));
|
|
14030
14207
|
if (!isMinimax(providerModelId)) {
|
|
14031
14208
|
throw new ModelKitError({
|
|
@@ -14071,9 +14248,9 @@ function videoFileDecoder(ctx, req, endpoint, usageOf2) {
|
|
|
14071
14248
|
raw: payload
|
|
14072
14249
|
});
|
|
14073
14250
|
}
|
|
14074
|
-
function planUsage(ctx,
|
|
14251
|
+
function planUsage(ctx, plan5) {
|
|
14075
14252
|
return (payload) => {
|
|
14076
|
-
const seconds3 =
|
|
14253
|
+
const seconds3 = plan5.seconds(payload);
|
|
14077
14254
|
return {
|
|
14078
14255
|
model: ctx.model.id,
|
|
14079
14256
|
provider: "fal",
|
|
@@ -14081,7 +14258,7 @@ function planUsage(ctx, plan4) {
|
|
|
14081
14258
|
unit: "seconds",
|
|
14082
14259
|
quantity: seconds3,
|
|
14083
14260
|
durationSeconds: seconds3,
|
|
14084
|
-
...
|
|
14261
|
+
...plan5.resolution !== void 0 && { resolution: plan5.resolution }
|
|
14085
14262
|
};
|
|
14086
14263
|
};
|
|
14087
14264
|
}
|
|
@@ -20240,14 +20417,14 @@ function referenceVideoConformPlan(model, probe) {
|
|
|
20240
20417
|
const reasons = [...size?.reasons ?? []];
|
|
20241
20418
|
if (rate) reasons.push(rate.reason);
|
|
20242
20419
|
if (overBytes) reasons.push("bytes_over");
|
|
20243
|
-
const
|
|
20420
|
+
const plan5 = {
|
|
20244
20421
|
width: round(width * scale),
|
|
20245
20422
|
height: round(height * scale),
|
|
20246
20423
|
reasons
|
|
20247
20424
|
};
|
|
20248
|
-
if (rate)
|
|
20249
|
-
if (maxBytes !== void 0)
|
|
20250
|
-
return
|
|
20425
|
+
if (rate) plan5.fps = rate.fps;
|
|
20426
|
+
if (maxBytes !== void 0) plan5.maxBytes = maxBytes;
|
|
20427
|
+
return plan5;
|
|
20251
20428
|
}
|
|
20252
20429
|
function referenceImageConformPlan(model, probe) {
|
|
20253
20430
|
const { width: probedWidth, height: probedHeight } = probe;
|