@shop-os/modelkit 0.23.1 → 0.24.1
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 +25 -0
- package/dist/catalog.cjs +123 -1
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +35 -0
- package/dist/catalog.d.ts +35 -0
- package/dist/catalog.js +123 -1
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +202 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +202 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -519,6 +519,34 @@ var FAL_IMAGE_MODELS = [
|
|
|
519
519
|
logo: `${LOBE}/kling-color.png`
|
|
520
520
|
}
|
|
521
521
|
},
|
|
522
|
+
{
|
|
523
|
+
// kling/v4/text-to-image; references switch to kling/v4/image-to-image (up to 10,
|
|
524
|
+
// "@Image1".."@Image10"). Per output image: $0.063 at 2K, $0.094 at 4K (Kling price page,
|
|
525
|
+
// 2026-11-17); each reference adds $0.003, which we absorb. Native 8K is ENG-4137.
|
|
526
|
+
id: "kling-image-4.0",
|
|
527
|
+
aliases: [],
|
|
528
|
+
label: "Kling Image 4.0",
|
|
529
|
+
type: "image",
|
|
530
|
+
adapter: "fal",
|
|
531
|
+
providerModelId: "kling/v4/text-to-image",
|
|
532
|
+
lifecycle: "active",
|
|
533
|
+
exposure: EXPOSURE,
|
|
534
|
+
constraints: {
|
|
535
|
+
aspectRatios: [...KLING_RATIOS, "adaptive"],
|
|
536
|
+
sizes: ["2K", "4K"],
|
|
537
|
+
references: { images: 10 },
|
|
538
|
+
supports: ["count"],
|
|
539
|
+
prompt: { referenceSyntax: "numbered", maxChars: 21e3 }
|
|
540
|
+
},
|
|
541
|
+
defaults: { size: "2K", aspectRatio: "adaptive", count: 1 },
|
|
542
|
+
usage: { ...IMAGE_USAGE },
|
|
543
|
+
pricingKind: "image_size",
|
|
544
|
+
display: {
|
|
545
|
+
provider: "kuaishou",
|
|
546
|
+
description: "Kling Image 4.0 for photoreal text-to-image, long in-image text and multi-reference editing; takes a prompt and up to 10 reference images and outputs 2K or 4K.",
|
|
547
|
+
logo: `${LOBE}/kling-color.png`
|
|
548
|
+
}
|
|
549
|
+
},
|
|
522
550
|
{
|
|
523
551
|
// fal-ai/kling-image/v3/text-to-image; a reference switches to .../v3/image-to-image, which
|
|
524
552
|
// takes exactly one image_url and no "auto" ratio. $0.028 per image.
|
|
@@ -6509,6 +6537,54 @@ var VIDEO_MODELS = [
|
|
|
6509
6537
|
},
|
|
6510
6538
|
capabilities: { acceptsSourceVideo: true, videoEdit: true, ...FRAMES_EXCLUDE_REFERENCES }
|
|
6511
6539
|
},
|
|
6540
|
+
{
|
|
6541
|
+
// The same BytePlus model in draft mode. Probed 2026-11-17: a draft must be 480p; its
|
|
6542
|
+
// final is a second task on this row (draftTaskId), and 720p or no resolution is refused
|
|
6543
|
+
// there. A 4k final also rendered, but the docs list 1080p only. No alias for the provider
|
|
6544
|
+
// id: that alias resolves usage to seedance-2.5. Edit and extend stay on seedance-2.5.
|
|
6545
|
+
id: "seedance-2.5-draft",
|
|
6546
|
+
aliases: ["seedance-2-5-draft"],
|
|
6547
|
+
label: "Seedance 2.5 Draft",
|
|
6548
|
+
type: "video",
|
|
6549
|
+
adapter: "ark",
|
|
6550
|
+
providerModelId: "dreamina-seedance-2-5-260628",
|
|
6551
|
+
lifecycle: "active",
|
|
6552
|
+
exposure: [],
|
|
6553
|
+
constraints: {
|
|
6554
|
+
aspectRatios: [...SEEDANCE_RATIOS],
|
|
6555
|
+
resolutions: ["480p"],
|
|
6556
|
+
durations: { min: 4, max: 30 },
|
|
6557
|
+
references: {
|
|
6558
|
+
images: 30,
|
|
6559
|
+
videos: 10,
|
|
6560
|
+
audios: 10,
|
|
6561
|
+
videoSeconds: { min: 2, max: 30, total: 30 },
|
|
6562
|
+
...SEEDANCE_REFERENCE_MEDIA,
|
|
6563
|
+
audioSeconds: { min: 2, max: 30, total: 30 },
|
|
6564
|
+
audioFormats: ["wav", "mp3"],
|
|
6565
|
+
audioMaxBytes: 15 * 1024 * 1024
|
|
6566
|
+
},
|
|
6567
|
+
ratioIgnoredWith: ["firstFrame"],
|
|
6568
|
+
supports: ["generateAudio", "lastFrame", "watermark"],
|
|
6569
|
+
draft: { resolution: "480p", finalResolutions: ["1080p"], ttlDays: 14 },
|
|
6570
|
+
prompt: SEEDANCE_PROMPT,
|
|
6571
|
+
audio: "optional"
|
|
6572
|
+
},
|
|
6573
|
+
defaults: {
|
|
6574
|
+
durationSeconds: 5,
|
|
6575
|
+
resolution: "480p",
|
|
6576
|
+
aspectRatio: "16:9",
|
|
6577
|
+
generateAudio: true
|
|
6578
|
+
},
|
|
6579
|
+
usage: { ...VIDEO_USAGE3 },
|
|
6580
|
+
pricingKind: "video_per_second",
|
|
6581
|
+
display: {
|
|
6582
|
+
provider: "bytedance",
|
|
6583
|
+
logo: BYTEDANCE_LOGO2,
|
|
6584
|
+
description: "A quick 480p Seedance 2.5 preview. Render the 1080p final from it within 14 days; the final keeps the draft's scene and motion."
|
|
6585
|
+
},
|
|
6586
|
+
capabilities: { acceptsSourceVideo: false, videoEdit: false, ...FRAMES_EXCLUDE_REFERENCES }
|
|
6587
|
+
},
|
|
6512
6588
|
{
|
|
6513
6589
|
// Limits probed on the live API 2026-11-16 (1080p is refused). Extend probe: a 4 s
|
|
6514
6590
|
// extend returned 4 s of new footage only and billed input + output tokens, as on 2.5.
|
|
@@ -8486,6 +8562,13 @@ var ModelConstraintsSchema = import_zod3.z.looseObject({
|
|
|
8486
8562
|
maxTotalSeconds: import_zod3.z.number(),
|
|
8487
8563
|
returns: import_zod3.z.enum(["new", "joined"]).optional()
|
|
8488
8564
|
}).optional(),
|
|
8565
|
+
// Loose so a kit before 0.24.0 keeps a row that carries it (an unknown `supports` value
|
|
8566
|
+
// would drop the row there).
|
|
8567
|
+
draft: import_zod3.z.looseObject({
|
|
8568
|
+
resolution: VideoResolutionSchema,
|
|
8569
|
+
finalResolutions: import_zod3.z.array(VideoResolutionSchema).min(1),
|
|
8570
|
+
ttlDays: import_zod3.z.number().positive()
|
|
8571
|
+
}).optional(),
|
|
8489
8572
|
tool: VideoToolConstraintsSchema.optional(),
|
|
8490
8573
|
model3d: Model3dConstraintsSchema.optional(),
|
|
8491
8574
|
// Loose on purpose: the read path keeps a row whose value is invalid (the accessors in
|
|
@@ -9199,6 +9282,20 @@ var FAL_IMAGE_SPECS = /* @__PURE__ */ new Map([
|
|
|
9199
9282
|
aspectRatios: KLING_RATIOS3
|
|
9200
9283
|
}
|
|
9201
9284
|
],
|
|
9285
|
+
[
|
|
9286
|
+
// No output_format or seed field. Kling caps non-English prompts at 21,000 characters
|
|
9287
|
+
// (API update 2026-11-17), under the schema's 50,000.
|
|
9288
|
+
"kling/v4/text-to-image",
|
|
9289
|
+
{
|
|
9290
|
+
label: "Kling Image 4.0",
|
|
9291
|
+
maxReferences: 10,
|
|
9292
|
+
maxCount: 9,
|
|
9293
|
+
outputFormats: [],
|
|
9294
|
+
promptMax: 21e3,
|
|
9295
|
+
promptRequired: true,
|
|
9296
|
+
aspectRatios: [...KLING_RATIOS3, "adaptive"]
|
|
9297
|
+
}
|
|
9298
|
+
],
|
|
9202
9299
|
[
|
|
9203
9300
|
"recraft/v4.1/flash/text-to-image",
|
|
9204
9301
|
{
|
|
@@ -10751,8 +10848,12 @@ var SeedanceErrorSchema = import_zod10.z.object({
|
|
|
10751
10848
|
code: import_zod10.z.string().optional(),
|
|
10752
10849
|
message: import_zod10.z.string().optional()
|
|
10753
10850
|
});
|
|
10754
|
-
function seedanceResolution(req) {
|
|
10755
|
-
|
|
10851
|
+
function seedanceResolution(req, ctx) {
|
|
10852
|
+
const draft = ctx.model.constraints.draft;
|
|
10853
|
+
if (!draft) return req.resolution ?? "720p";
|
|
10854
|
+
if (req.draftTaskId !== void 0)
|
|
10855
|
+
return req.resolution ?? draft.finalResolutions[0] ?? "1080p";
|
|
10856
|
+
return draft.resolution;
|
|
10756
10857
|
}
|
|
10757
10858
|
function seedanceUsage(ctx, req, duration) {
|
|
10758
10859
|
return {
|
|
@@ -10762,7 +10863,7 @@ function seedanceUsage(ctx, req, duration) {
|
|
|
10762
10863
|
unit: "seconds",
|
|
10763
10864
|
quantity: duration,
|
|
10764
10865
|
durationSeconds: duration,
|
|
10765
|
-
resolution: seedanceResolution(req)
|
|
10866
|
+
resolution: seedanceResolution(req, ctx)
|
|
10766
10867
|
};
|
|
10767
10868
|
}
|
|
10768
10869
|
function seedanceInitialDuration(req) {
|
|
@@ -10860,8 +10961,67 @@ function seedanceJob(ctx, key, jobId, usage5) {
|
|
|
10860
10961
|
}
|
|
10861
10962
|
};
|
|
10862
10963
|
}
|
|
10863
|
-
|
|
10964
|
+
function draftRefusal(ctx, message) {
|
|
10965
|
+
return new ModelKitError({
|
|
10966
|
+
code: "unsupported_option",
|
|
10967
|
+
message: `${ctx.model.id} ${message}`,
|
|
10968
|
+
provider: "ark",
|
|
10969
|
+
model: ctx.model.id,
|
|
10970
|
+
retryable: false
|
|
10971
|
+
});
|
|
10972
|
+
}
|
|
10973
|
+
function assertDraftRequest(req, ctx) {
|
|
10974
|
+
const draft = ctx.model.constraints.draft;
|
|
10975
|
+
if (!draft) {
|
|
10976
|
+
if (req.draftTaskId !== void 0) throw draftRefusal(ctx, "has no draft mode");
|
|
10977
|
+
return;
|
|
10978
|
+
}
|
|
10979
|
+
if (req.draftTaskId === void 0 && req.resolution !== void 0 && req.resolution !== draft.resolution)
|
|
10980
|
+
throw draftRefusal(ctx, `renders a draft at ${draft.resolution} only`);
|
|
10981
|
+
if (req.draftTaskId === void 0 && req.taskType !== void 0)
|
|
10982
|
+
throw draftRefusal(ctx, "renders drafts without a task type");
|
|
10983
|
+
if (req.draftTaskId !== void 0 && req.resolution !== void 0 && !draft.finalResolutions.includes(req.resolution))
|
|
10984
|
+
throw draftRefusal(
|
|
10985
|
+
ctx,
|
|
10986
|
+
`renders a final from a draft at ${draft.finalResolutions.join(", ")} only`
|
|
10987
|
+
);
|
|
10988
|
+
}
|
|
10989
|
+
async function submitSeedanceTask(ctx, key, body) {
|
|
10864
10990
|
const modelId = ctx.model.id;
|
|
10991
|
+
const submit = await withRetry(
|
|
10992
|
+
async () => {
|
|
10993
|
+
const res = await arkFetch(ctx, `${arkBaseUrl(ctx)}${SUBMIT_PATH2}`, {
|
|
10994
|
+
method: "POST",
|
|
10995
|
+
headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json" },
|
|
10996
|
+
body: JSON.stringify(body)
|
|
10997
|
+
});
|
|
10998
|
+
if (!res.ok) {
|
|
10999
|
+
const text2 = await res.text().catch(() => "");
|
|
11000
|
+
throwArkError(res.status, text2, modelId);
|
|
11001
|
+
}
|
|
11002
|
+
const parsed = SeedanceResponseSchema.safeParse(await res.json());
|
|
11003
|
+
const decoded = parsed.success ? parsed.data : {};
|
|
11004
|
+
return decoded;
|
|
11005
|
+
},
|
|
11006
|
+
mediaRetryOptions(ctx.call, ctx.signal)
|
|
11007
|
+
);
|
|
11008
|
+
if (!submit.id) throwArkError(void 0, "Seedance task create returned no id", modelId);
|
|
11009
|
+
return submit.id;
|
|
11010
|
+
}
|
|
11011
|
+
async function finalizeSeedanceDraft(req, draftTaskId, ctx) {
|
|
11012
|
+
const key = arkKey(ctx);
|
|
11013
|
+
const body = {
|
|
11014
|
+
model: ctx.model.providerModelId,
|
|
11015
|
+
content: [{ type: "draft_task", draft_task: { id: draftTaskId } }],
|
|
11016
|
+
resolution: seedanceResolution(req, ctx)
|
|
11017
|
+
};
|
|
11018
|
+
if (req.watermark !== void 0) body.watermark = req.watermark;
|
|
11019
|
+
const jobId = await submitSeedanceTask(ctx, key, body);
|
|
11020
|
+
return seedanceJob(ctx, key, jobId, seedanceUsage(ctx, req, seedanceInitialDuration(req)));
|
|
11021
|
+
}
|
|
11022
|
+
async function generateSeedanceVideo(req, ctx) {
|
|
11023
|
+
assertDraftRequest(req, ctx);
|
|
11024
|
+
if (req.draftTaskId !== void 0) return finalizeSeedanceDraft(req, req.draftTaskId, ctx);
|
|
10865
11025
|
const taskType = req.taskType;
|
|
10866
11026
|
const hasVideo = Boolean(req.sourceVideo) || (req.referenceVideos?.length ?? 0) > 0;
|
|
10867
11027
|
if ((taskType === "edit" || taskType === "extend") && !hasVideo) {
|
|
@@ -10877,7 +11037,7 @@ async function generateSeedanceVideo(req, ctx) {
|
|
|
10877
11037
|
const requestedDuration = seedanceInitialDuration(req);
|
|
10878
11038
|
let duration = requestedDuration;
|
|
10879
11039
|
if (taskType === "edit") duration = -1;
|
|
10880
|
-
const resolution = seedanceResolution(req);
|
|
11040
|
+
const resolution = seedanceResolution(req, ctx);
|
|
10881
11041
|
const content = [{ type: "text", text: req.prompt }];
|
|
10882
11042
|
if (req.firstFrame) {
|
|
10883
11043
|
content.push({
|
|
@@ -10935,25 +11095,8 @@ async function generateSeedanceVideo(req, ctx) {
|
|
|
10935
11095
|
if (req.generateAudio !== void 0) body.generate_audio = req.generateAudio;
|
|
10936
11096
|
if (req.seed !== void 0) body.seed = req.seed;
|
|
10937
11097
|
if (req.watermark !== void 0) body.watermark = req.watermark;
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
const res = await arkFetch(ctx, `${arkBaseUrl(ctx)}${SUBMIT_PATH2}`, {
|
|
10941
|
-
method: "POST",
|
|
10942
|
-
headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json" },
|
|
10943
|
-
body: JSON.stringify(body)
|
|
10944
|
-
});
|
|
10945
|
-
if (!res.ok) {
|
|
10946
|
-
const text2 = await res.text().catch(() => "");
|
|
10947
|
-
throwArkError(res.status, text2, modelId);
|
|
10948
|
-
}
|
|
10949
|
-
const parsed = SeedanceResponseSchema.safeParse(await res.json());
|
|
10950
|
-
const decoded = parsed.success ? parsed.data : {};
|
|
10951
|
-
return decoded;
|
|
10952
|
-
},
|
|
10953
|
-
mediaRetryOptions(ctx.call, ctx.signal)
|
|
10954
|
-
);
|
|
10955
|
-
if (!submit.id) throwArkError(void 0, "Seedance task create returned no id", modelId);
|
|
10956
|
-
const jobId = submit.id;
|
|
11098
|
+
if (ctx.model.constraints.draft) body.draft = true;
|
|
11099
|
+
const jobId = await submitSeedanceTask(ctx, key, body);
|
|
10957
11100
|
const usage5 = seedanceUsage(ctx, req, taskType === "edit" ? requestedDuration : duration);
|
|
10958
11101
|
return seedanceJob(ctx, key, jobId, usage5);
|
|
10959
11102
|
}
|
|
@@ -11937,13 +12080,13 @@ function minimaxH3Image(editEndpoint) {
|
|
|
11937
12080
|
var H3_IMAGE_AREAS = { ...TIER_AREAS2, "4K": 4096 * 4096 };
|
|
11938
12081
|
var MINIMAX_H3_IMAGE = minimaxH3Image("minimax/h3-image/edit");
|
|
11939
12082
|
var MINIMAX_H3_IMAGE_HIGHSPEED = minimaxH3Image("minimax/h3-image/highspeed/edit");
|
|
11940
|
-
function klingImage(editEndpoint, sizes, field) {
|
|
12083
|
+
function klingImage(editEndpoint, sizes, field, fallbackSize = "1K") {
|
|
11941
12084
|
return {
|
|
11942
12085
|
editEndpoint,
|
|
11943
12086
|
build({ label, req, refs, edit: edit2 }, model) {
|
|
11944
12087
|
const input = {
|
|
11945
12088
|
prompt: req.prompt,
|
|
11946
|
-
resolution: pick(model, label, "size", req.size ??
|
|
12089
|
+
resolution: pick(model, label, "size", req.size ?? fallbackSize, sizes)
|
|
11947
12090
|
};
|
|
11948
12091
|
if (req.aspectRatio === "adaptive") {
|
|
11949
12092
|
if (edit2) input["aspect_ratio"] = "auto";
|
|
@@ -11965,6 +12108,12 @@ var KLING_V3 = klingImage(
|
|
|
11965
12108
|
{ "1K": "1K", "2K": "2K" },
|
|
11966
12109
|
"image_url"
|
|
11967
12110
|
);
|
|
12111
|
+
var KLING_V42 = klingImage(
|
|
12112
|
+
"kling/v4/image-to-image",
|
|
12113
|
+
{ "2K": "2K", "4K": "4K" },
|
|
12114
|
+
"image_urls",
|
|
12115
|
+
"2K"
|
|
12116
|
+
);
|
|
11968
12117
|
var RECRAFT_SIZES = {
|
|
11969
12118
|
"1:1": "square_hd",
|
|
11970
12119
|
"4:3": "landscape_4_3",
|
|
@@ -12021,6 +12170,7 @@ var FAMILIES = /* @__PURE__ */ new Map([
|
|
|
12021
12170
|
["minimax/h3-image/highspeed/text-to-image", MINIMAX_H3_IMAGE_HIGHSPEED],
|
|
12022
12171
|
["fal-ai/kling-image/o3/text-to-image", KLING_O3],
|
|
12023
12172
|
["fal-ai/kling-image/v3/text-to-image", KLING_V3],
|
|
12173
|
+
["kling/v4/text-to-image", KLING_V42],
|
|
12024
12174
|
["recraft/v4.1/flash/text-to-image", RECRAFT_FLASH],
|
|
12025
12175
|
["fal-ai/sensenova-u1-infographic", SENSENOVA],
|
|
12026
12176
|
["fal-ai/seedvr/upscale/image", SEEDVR]
|
|
@@ -18872,6 +19022,25 @@ function resolveVideoResolution(requested, model, onUnsupported, warnings) {
|
|
|
18872
19022
|
warnings
|
|
18873
19023
|
);
|
|
18874
19024
|
}
|
|
19025
|
+
function resolveDraftFinalResolution(requested, draft, model, onUnsupported, warnings) {
|
|
19026
|
+
const [first] = draft.finalResolutions;
|
|
19027
|
+
if (requested === void 0 || draft.finalResolutions.includes(requested))
|
|
19028
|
+
return requested ?? first;
|
|
19029
|
+
if (onUnsupported === "error") {
|
|
19030
|
+
throw new ModelKitError({
|
|
19031
|
+
code: "unsupported_option",
|
|
19032
|
+
message: `${model.id} renders a final from a draft at ${draft.finalResolutions.join(", ")} only`,
|
|
19033
|
+
model: model.id,
|
|
19034
|
+
retryable: false
|
|
19035
|
+
});
|
|
19036
|
+
}
|
|
19037
|
+
warnings.push({
|
|
19038
|
+
code: "resolution_coerced",
|
|
19039
|
+
field: "resolution",
|
|
19040
|
+
message: `${model.id} renders a final at ${String(first)}, not ${requested}`
|
|
19041
|
+
});
|
|
19042
|
+
return first;
|
|
19043
|
+
}
|
|
18875
19044
|
function resolveDuration(requested, durations, model, onUnsupported, warnings) {
|
|
18876
19045
|
if (requested === void 0 || !durations) return requested;
|
|
18877
19046
|
const inSet = Array.isArray(durations) ? durations.includes(requested) : requested >= durations.min && requested <= durations.max;
|
|
@@ -19199,7 +19368,13 @@ function resolveVideoOptions(model, request, onUnsupported = "error") {
|
|
|
19199
19368
|
);
|
|
19200
19369
|
if (aspectRatio !== void 0) merged.aspectRatio = aspectRatio;
|
|
19201
19370
|
fillKlingModeResolution(model, merged);
|
|
19202
|
-
const resolution =
|
|
19371
|
+
const resolution = merged.draftTaskId !== void 0 && c.draft ? resolveDraftFinalResolution(
|
|
19372
|
+
request.resolution,
|
|
19373
|
+
c.draft,
|
|
19374
|
+
model,
|
|
19375
|
+
onUnsupported,
|
|
19376
|
+
warnings
|
|
19377
|
+
) : resolveVideoResolution(merged.resolution, model, onUnsupported, warnings);
|
|
19203
19378
|
if (resolution !== void 0) merged.resolution = resolution;
|
|
19204
19379
|
if (takesKlingMode(model)) delete merged.mode;
|
|
19205
19380
|
const duration = resolveDuration(
|