@shop-os/modelkit 0.16.0 → 0.17.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 +8 -0
- package/dist/catalog.cjs +90 -1
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.js +90 -1
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +118 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +118 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5074,6 +5074,7 @@ var KLING_PROMPT = { referenceSyntax: "numbered", maxChars: 2500 };
|
|
|
5074
5074
|
var H3_PROMPT = { referenceSyntax: "numbered", maxChars: 5e4 };
|
|
5075
5075
|
var KLING_V4_PROMPT = { referenceSyntax: "numbered", maxChars: 2500 };
|
|
5076
5076
|
var KLING_V4_AUDIO = "always";
|
|
5077
|
+
var KLING_V4_FLASH_PROMPT = { referenceSyntax: "numbered", maxChars: 26e3 };
|
|
5077
5078
|
var NO_REFERENCES = { images: 0, videos: 0, audios: 0 };
|
|
5078
5079
|
function klingMotionControl(tier) {
|
|
5079
5080
|
const label = tier === "pro" ? "Pro" : "Standard";
|
|
@@ -5251,6 +5252,85 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5251
5252
|
},
|
|
5252
5253
|
capabilities: { acceptsSourceVideo: true, videoEdit: true }
|
|
5253
5254
|
},
|
|
5255
|
+
{
|
|
5256
|
+
// https://fal.ai/models/kling/v4/flash/reference-to-video/api (+ /text-to-video,
|
|
5257
|
+
// /image-to-video): routed like kling-4.0, at 720p only and 3-20 s. image-to-video takes
|
|
5258
|
+
// a start frame (300 px min, ratio 0.40-2.50) and no end frame; its prompt is optional.
|
|
5259
|
+
// Reference images: 10, the start frame included. Reference videos: 5, 3-20.05 s each
|
|
5260
|
+
// and 20 s combined, 700 px min. Prompts up to 26,000 characters. No sound switch.
|
|
5261
|
+
id: "kling-4.0-flash",
|
|
5262
|
+
aliases: ["kling-4-flash", "kling-v4-flash"],
|
|
5263
|
+
label: "Kling 4.0 Flash",
|
|
5264
|
+
type: "video",
|
|
5265
|
+
adapter: "fal",
|
|
5266
|
+
providerModelId: "kling/v4/flash",
|
|
5267
|
+
lifecycle: "active",
|
|
5268
|
+
exposure: ["cowork", "space_builder"],
|
|
5269
|
+
constraints: {
|
|
5270
|
+
aspectRatios: ["adaptive", "16:9", "9:16", "1:1", "21:9"],
|
|
5271
|
+
resolutions: ["720p"],
|
|
5272
|
+
durations: { min: 3, max: 20 },
|
|
5273
|
+
durationPresets: [5, 10, 15, 20],
|
|
5274
|
+
references: {
|
|
5275
|
+
...NO_REFERENCES,
|
|
5276
|
+
images: 10,
|
|
5277
|
+
videos: 5,
|
|
5278
|
+
videoSeconds: { min: 3, max: 20.05, total: 20 },
|
|
5279
|
+
videoPixels: { minWidth: 700, minHeight: 700 }
|
|
5280
|
+
},
|
|
5281
|
+
supports: [],
|
|
5282
|
+
prompt: KLING_V4_FLASH_PROMPT,
|
|
5283
|
+
audio: KLING_V4_AUDIO
|
|
5284
|
+
},
|
|
5285
|
+
defaults: { durationSeconds: 5, resolution: "720p", aspectRatio: "16:9" },
|
|
5286
|
+
usage: { ...VIDEO_USAGE },
|
|
5287
|
+
pricingKind: "video_per_second",
|
|
5288
|
+
display: {
|
|
5289
|
+
provider: "kuaishou",
|
|
5290
|
+
logo: KLING_LOGO,
|
|
5291
|
+
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."
|
|
5292
|
+
}
|
|
5293
|
+
},
|
|
5294
|
+
{
|
|
5295
|
+
// https://fal.ai/models/kling/v4/flash/video-to-video/api: source 3-20.05 s (700 px
|
|
5296
|
+
// min, 23.9-60.05 fps), up to 10 reference images and 4 reference videos; the source
|
|
5297
|
+
// and reference videos total 20 s at most. duration 3-20, or left out for the source's
|
|
5298
|
+
// length. The prompt names the source @Video1, reference videos @Video2 on, images @Image1.
|
|
5299
|
+
id: "kling-4.0-flash-edit",
|
|
5300
|
+
aliases: ["kling-4-flash-edit", "kling-v4-flash-edit"],
|
|
5301
|
+
label: "Kling 4.0 Flash Edit",
|
|
5302
|
+
type: "video",
|
|
5303
|
+
adapter: "fal",
|
|
5304
|
+
providerModelId: "kling/v4/flash/video-to-video",
|
|
5305
|
+
lifecycle: "active",
|
|
5306
|
+
exposure: ["cowork", "space_builder"],
|
|
5307
|
+
constraints: {
|
|
5308
|
+
resolutions: ["720p"],
|
|
5309
|
+
durations: { min: 3, max: 20 },
|
|
5310
|
+
references: {
|
|
5311
|
+
...NO_REFERENCES,
|
|
5312
|
+
images: 10,
|
|
5313
|
+
videos: 4,
|
|
5314
|
+
videoSeconds: { min: 3, max: 20.05, total: 20 },
|
|
5315
|
+
videoPixels: { minWidth: 700, minHeight: 700 }
|
|
5316
|
+
},
|
|
5317
|
+
requires: ["sourceVideo"],
|
|
5318
|
+
sourceVideoSeconds: { min: 3, max: 20.05, inReferenceTotal: true },
|
|
5319
|
+
sourceVideoPixels: { minWidth: 700, minHeight: 700 },
|
|
5320
|
+
supports: [],
|
|
5321
|
+
prompt: KLING_V4_FLASH_PROMPT,
|
|
5322
|
+
audio: KLING_V4_AUDIO
|
|
5323
|
+
},
|
|
5324
|
+
defaults: { resolution: "720p" },
|
|
5325
|
+
usage: { ...VIDEO_USAGE },
|
|
5326
|
+
pricingKind: "video_per_second",
|
|
5327
|
+
display: {
|
|
5328
|
+
provider: "kuaishou",
|
|
5329
|
+
logo: KLING_LOGO,
|
|
5330
|
+
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."
|
|
5331
|
+
},
|
|
5332
|
+
capabilities: { acceptsSourceVideo: true, videoEdit: true }
|
|
5333
|
+
},
|
|
5254
5334
|
{
|
|
5255
5335
|
// https://fal.ai/models/minimax/h3-max-turbo/text-to-video/api (+ /image-to-video).
|
|
5256
5336
|
// image-to-video takes a start frame, an end frame, or both, and no aspect_ratio.
|
|
@@ -11706,8 +11786,13 @@ var MOTION_PRO = "fal-ai/kling-video/v3/pro/motion-control";
|
|
|
11706
11786
|
var MOTION_STANDARD = "fal-ai/kling-video/v3/standard/motion-control";
|
|
11707
11787
|
var O3_REFERENCE = "fal-ai/kling-video/o3/pro/reference-to-video";
|
|
11708
11788
|
var O3_EDIT = "fal-ai/kling-video/o3/pro/video-to-video/edit";
|
|
11709
|
-
var
|
|
11710
|
-
var
|
|
11789
|
+
var V4 = { generate: "kling/v4", edit: "kling/v4/video-to-video/edit", flash: false };
|
|
11790
|
+
var V4_FLASH = {
|
|
11791
|
+
generate: "kling/v4/flash",
|
|
11792
|
+
edit: "kling/v4/flash/video-to-video",
|
|
11793
|
+
flash: true
|
|
11794
|
+
};
|
|
11795
|
+
var V4_VARIANTS = [V4, V4_FLASH];
|
|
11711
11796
|
function motionControl(endpoint, req, ctx) {
|
|
11712
11797
|
const [character] = req.referenceImages ?? [];
|
|
11713
11798
|
const [motion] = req.referenceVideos ?? [];
|
|
@@ -11767,15 +11852,18 @@ var klingV3Family = {
|
|
|
11767
11852
|
return motionControl(id, req, ctx);
|
|
11768
11853
|
}
|
|
11769
11854
|
};
|
|
11770
|
-
function v4Generate(req, ctx) {
|
|
11855
|
+
function v4Generate(variant, req, ctx) {
|
|
11771
11856
|
const images = urls(req.referenceImages);
|
|
11772
11857
|
const videos = urls(req.referenceVideos);
|
|
11773
11858
|
const duration = wholeSeconds(req, ctx);
|
|
11774
11859
|
const resolution = resolutionOf(req, ctx);
|
|
11775
|
-
const
|
|
11860
|
+
const references = images.length + videos.length > 0;
|
|
11861
|
+
const input = { duration, resolution };
|
|
11862
|
+
if (variant.flash && !references && req.firstFrame) optionalPrompt(input, req);
|
|
11863
|
+
else input["prompt"] = req.prompt.trim();
|
|
11776
11864
|
let endpoint;
|
|
11777
|
-
if (
|
|
11778
|
-
endpoint = `${
|
|
11865
|
+
if (references) {
|
|
11866
|
+
endpoint = `${variant.generate}/reference-to-video`;
|
|
11779
11867
|
if (images.length > 0) input["image_urls"] = images;
|
|
11780
11868
|
if (videos.length > 0) input["video_urls"] = videos;
|
|
11781
11869
|
if (req.firstFrame) input["start_image_url"] = refToUrl(req.firstFrame);
|
|
@@ -11783,17 +11871,17 @@ function v4Generate(req, ctx) {
|
|
|
11783
11871
|
input["aspect_ratio"] = req.aspectRatio === "adaptive" ? "auto" : req.aspectRatio;
|
|
11784
11872
|
}
|
|
11785
11873
|
} else if (req.firstFrame) {
|
|
11786
|
-
endpoint = `${
|
|
11874
|
+
endpoint = `${variant.generate}/image-to-video`;
|
|
11787
11875
|
input["start_image_url"] = refToUrl(req.firstFrame);
|
|
11788
11876
|
if (req.lastFrame) input["end_image_url"] = refToUrl(req.lastFrame);
|
|
11789
11877
|
} else {
|
|
11790
|
-
endpoint = `${
|
|
11878
|
+
endpoint = `${variant.generate}/text-to-video`;
|
|
11791
11879
|
const ratio = concreteRatio(req);
|
|
11792
11880
|
if (ratio !== void 0) input["aspect_ratio"] = ratio;
|
|
11793
11881
|
}
|
|
11794
11882
|
return { endpoint, input, resolution, seconds: requestedSeconds(duration) };
|
|
11795
11883
|
}
|
|
11796
|
-
function v4Edit(req, ctx) {
|
|
11884
|
+
function v4Edit(variant, req, ctx) {
|
|
11797
11885
|
if (req.sourceVideo === void 0) throw refusal(ctx, "needs a source video", "missing_input");
|
|
11798
11886
|
const resolution = resolutionOf(req, ctx);
|
|
11799
11887
|
const input = {
|
|
@@ -11803,9 +11891,11 @@ function v4Edit(req, ctx) {
|
|
|
11803
11891
|
};
|
|
11804
11892
|
const images = urls(req.referenceImages);
|
|
11805
11893
|
if (images.length > 0) input["image_urls"] = images;
|
|
11894
|
+
const videos = urls(req.referenceVideos);
|
|
11895
|
+
if (variant.flash && videos.length > 0) input["video_urls"] = videos;
|
|
11806
11896
|
if (req.durationSeconds === void 0) {
|
|
11807
11897
|
return {
|
|
11808
|
-
endpoint:
|
|
11898
|
+
endpoint: variant.edit,
|
|
11809
11899
|
input,
|
|
11810
11900
|
resolution,
|
|
11811
11901
|
seconds: inputLengthSeconds(req, req.sourceVideo)
|
|
@@ -11813,13 +11903,18 @@ function v4Edit(req, ctx) {
|
|
|
11813
11903
|
}
|
|
11814
11904
|
const duration = wholeSeconds(req, ctx);
|
|
11815
11905
|
input["duration"] = duration;
|
|
11816
|
-
return { endpoint:
|
|
11906
|
+
return { endpoint: variant.edit, input, resolution, seconds: requestedSeconds(duration) };
|
|
11817
11907
|
}
|
|
11818
|
-
var KLING_V4_VIDEO_IDS =
|
|
11908
|
+
var KLING_V4_VIDEO_IDS = new Set(
|
|
11909
|
+
V4_VARIANTS.flatMap((v) => [v.generate, v.edit])
|
|
11910
|
+
);
|
|
11819
11911
|
var klingV4Family = {
|
|
11820
11912
|
ids: KLING_V4_VIDEO_IDS,
|
|
11821
11913
|
plan(req, ctx) {
|
|
11822
|
-
|
|
11914
|
+
const id = ctx.model.providerModelId.toLowerCase();
|
|
11915
|
+
const edit2 = V4_VARIANTS.find((v) => v.edit === id);
|
|
11916
|
+
if (edit2 !== void 0) return v4Edit(edit2, req, ctx);
|
|
11917
|
+
return v4Generate(V4_VARIANTS.find((v) => v.generate === id) ?? V4, req, ctx);
|
|
11823
11918
|
}
|
|
11824
11919
|
};
|
|
11825
11920
|
|
|
@@ -11894,6 +11989,8 @@ var O3_REFERENCE2 = "fal-ai/kling-video/o3/pro/reference-to-video";
|
|
|
11894
11989
|
var O3_EDIT2 = "fal-ai/kling-video/o3/pro/video-to-video/edit";
|
|
11895
11990
|
var KLING_V4 = "kling/v4";
|
|
11896
11991
|
var KLING_V4_EDIT = "kling/v4/video-to-video/edit";
|
|
11992
|
+
var KLING_V4_FLASH = "kling/v4/flash";
|
|
11993
|
+
var KLING_V4_FLASH_EDIT = "kling/v4/flash/video-to-video";
|
|
11897
11994
|
var H3_TURBO = "minimax/h3-max-turbo";
|
|
11898
11995
|
var H3_RECAST = "minimax/h3-max/recast";
|
|
11899
11996
|
var H3_RELIGHT = "minimax/h3-max/relight";
|
|
@@ -11975,6 +12072,11 @@ function klingV4(req) {
|
|
|
11975
12072
|
}
|
|
11976
12073
|
return needsPrompt(req);
|
|
11977
12074
|
}
|
|
12075
|
+
function klingV4Flash(req) {
|
|
12076
|
+
if (req.lastFrame !== void 0) return unsupported2("takes no end frame");
|
|
12077
|
+
if (!hasReferences(req) && req.firstFrame !== void 0) return void 0;
|
|
12078
|
+
return klingV4(req);
|
|
12079
|
+
}
|
|
11978
12080
|
function h3Turbo(req) {
|
|
11979
12081
|
if (count(req.referenceImages) + count(req.referenceVideos) > 0) {
|
|
11980
12082
|
return unsupported2("takes no reference images or videos");
|
|
@@ -12055,6 +12157,8 @@ var RULES = /* @__PURE__ */ new Map([
|
|
|
12055
12157
|
[O3_EDIT2, (req) => needsSource(req) ?? needsPrompt(req)],
|
|
12056
12158
|
[KLING_V4, klingV4],
|
|
12057
12159
|
[KLING_V4_EDIT, (req) => needsSource(req) ?? needsPrompt(req)],
|
|
12160
|
+
[KLING_V4_FLASH, klingV4Flash],
|
|
12161
|
+
[KLING_V4_FLASH_EDIT, (req) => needsSource(req) ?? needsPrompt(req)],
|
|
12058
12162
|
[H3_TURBO, h3Turbo],
|
|
12059
12163
|
[MINIMAX_H3_INSERT, h3Insert],
|
|
12060
12164
|
[H3_RECAST, h3Recast],
|
|
@@ -12104,7 +12208,7 @@ function applyFalVideoRules(model, req, callerRatio, warnings) {
|
|
|
12104
12208
|
warnings.push(viduSilentWarning(model));
|
|
12105
12209
|
req.generateAudio = false;
|
|
12106
12210
|
}
|
|
12107
|
-
if (id === KLING_V4 && req.firstFrame !== void 0 && !hasReferences(req)) {
|
|
12211
|
+
if ((id === KLING_V4 || id === KLING_V4_FLASH) && req.firstFrame !== void 0 && !hasReferences(req)) {
|
|
12108
12212
|
if (req.aspectRatio !== void 0) {
|
|
12109
12213
|
if (callerRatio !== void 0) {
|
|
12110
12214
|
warnings.push({
|