@shop-os/modelkit 0.28.0 → 0.30.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 +21 -0
- package/dist/catalog.cjs +193 -13
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.js +193 -13
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +308 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +308 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -915,6 +915,65 @@ var IMAGE_MODELS = [
|
|
|
915
915
|
description: "Ideogram's precise edit model: repeated edits keep the untouched pixels and colours intact, at the source's native resolution. Also generates from text."
|
|
916
916
|
}
|
|
917
917
|
},
|
|
918
|
+
{
|
|
919
|
+
// Generation only: fal charges edits more, so editing is its own row
|
|
920
|
+
// (ideogram-4.6-edit) with its own prices. fal bills any output above
|
|
921
|
+
// 2048x2048 in area at the 4K price; very_low renders at most 2K, so it is
|
|
922
|
+
// not exposed (no 4K price exists for it, and the catalog seed gate needs
|
|
923
|
+
// every size x quality priced). https://fal.ai/models/ideogram/v4.6
|
|
924
|
+
id: "ideogram-4.6",
|
|
925
|
+
aliases: [],
|
|
926
|
+
label: "Ideogram 4.6",
|
|
927
|
+
type: "image",
|
|
928
|
+
adapter: "fal",
|
|
929
|
+
providerModelId: "ideogram/v4.6",
|
|
930
|
+
lifecycle: "active",
|
|
931
|
+
exposure: ["cowork", "space_builder"],
|
|
932
|
+
constraints: {
|
|
933
|
+
aspectRatios: ["1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "5:4", "4:5"],
|
|
934
|
+
sizes: ["2K", "4K"],
|
|
935
|
+
qualityOptions: ["auto", "low", "medium", "high"],
|
|
936
|
+
references: { images: 0 },
|
|
937
|
+
supports: ["quality", "count", "seed"]
|
|
938
|
+
},
|
|
939
|
+
defaults: { size: "2K", aspectRatio: "1:1", quality: "medium", count: 1 },
|
|
940
|
+
usage: { ...IMAGE_USAGE3, slug: "ideogram" },
|
|
941
|
+
pricingKind: "image_size",
|
|
942
|
+
display: {
|
|
943
|
+
provider: "ideogram",
|
|
944
|
+
description: "Ideogram 4.6 text-to-image from a prompt, at 2K or 4K. Edits go to Ideogram 4.6 Edit."
|
|
945
|
+
}
|
|
946
|
+
},
|
|
947
|
+
{
|
|
948
|
+
// Precise Edit only: references switch to the /edit endpoint, where the
|
|
949
|
+
// first is the image to edit and the rest (up to 4) guide it, so 5 images
|
|
950
|
+
// in all. The output keeps the source size, so `size` only picks the
|
|
951
|
+
// billed tier. Same provider model as the generate row, whose adapter
|
|
952
|
+
// routes on references. https://fal.ai/models/ideogram/v4.6/edit
|
|
953
|
+
id: "ideogram-4.6-edit",
|
|
954
|
+
aliases: [],
|
|
955
|
+
label: "Ideogram 4.6 Edit",
|
|
956
|
+
type: "image",
|
|
957
|
+
adapter: "fal",
|
|
958
|
+
providerModelId: "ideogram/v4.6",
|
|
959
|
+
lifecycle: "active",
|
|
960
|
+
exposure: ["cowork", "space_builder"],
|
|
961
|
+
constraints: {
|
|
962
|
+
aspectRatios: ["1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "5:4", "4:5"],
|
|
963
|
+
sizes: ["2K", "4K"],
|
|
964
|
+
qualityOptions: ["auto", "low", "medium", "high"],
|
|
965
|
+
references: { images: 5 },
|
|
966
|
+
requires: ["references"],
|
|
967
|
+
supports: ["quality", "count", "seed"]
|
|
968
|
+
},
|
|
969
|
+
defaults: { size: "2K", aspectRatio: "1:1", quality: "medium", count: 1 },
|
|
970
|
+
usage: { ...IMAGE_USAGE3, slug: "ideogram" },
|
|
971
|
+
pricingKind: "image_size",
|
|
972
|
+
display: {
|
|
973
|
+
provider: "ideogram",
|
|
974
|
+
description: "Ideogram 4.6 Precise Edit: the first image is edited and up to 4 more guide it. Repeated edits keep the untouched pixels and colours intact, and the output keeps the source size."
|
|
975
|
+
}
|
|
976
|
+
},
|
|
918
977
|
{
|
|
919
978
|
id: "seedream-5-0-pro",
|
|
920
979
|
aliases: ["seedream-4-5"],
|
|
@@ -5542,6 +5601,7 @@ var KLING_LOGO2 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0
|
|
|
5542
5601
|
var MINIMAX_LOGO4 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
|
|
5543
5602
|
var BYTEDANCE_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/3bba5d81-4e57-4e71-911b-cdfa05acca2c_compressed.png";
|
|
5544
5603
|
var XAI_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/858b7fcc-9bd5-411d-aea1-a7b35ecfffab_compressed.png";
|
|
5604
|
+
var LIGHTRICKS_LOGO = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/lightricks.png";
|
|
5545
5605
|
var H3_RATIOS = ["21:9", "16:9", "4:3", "1:1", "3:4", "9:16"];
|
|
5546
5606
|
var HAPPY_HORSE_RATIOS = [
|
|
5547
5607
|
"16:9",
|
|
@@ -6140,6 +6200,77 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
6140
6200
|
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."
|
|
6141
6201
|
},
|
|
6142
6202
|
capabilities: {}
|
|
6203
|
+
},
|
|
6204
|
+
{
|
|
6205
|
+
// https://fal.ai/models/fal-ai/ltx-2.3/text-to-video/api (+ /image-to-video): one row;
|
|
6206
|
+
// a start frame routes to image-to-video, else text-to-video. The kit's 2k/4k tiers
|
|
6207
|
+
// are fal's 1440p/2160p (adapters/fal-ltx.ts). "adaptive" is fal's "auto" on
|
|
6208
|
+
// image-to-video; text-to-video leaves an adaptive ratio at fal's 16:9 default.
|
|
6209
|
+
id: "ltx-2.3",
|
|
6210
|
+
aliases: ["ltx-2-3", "ltx23"],
|
|
6211
|
+
label: "LTX 2.3",
|
|
6212
|
+
type: "video",
|
|
6213
|
+
adapter: "fal",
|
|
6214
|
+
providerModelId: "fal-ai/ltx-2.3/text-to-video",
|
|
6215
|
+
lifecycle: "active",
|
|
6216
|
+
exposure: ["cowork", "space_builder"],
|
|
6217
|
+
constraints: {
|
|
6218
|
+
aspectRatios: ["adaptive", "16:9", "9:16"],
|
|
6219
|
+
resolutions: ["1080p", "2k", "4k"],
|
|
6220
|
+
durations: [6, 8, 10],
|
|
6221
|
+
supports: ["generateAudio", "lastFrame", "safetyChecker"],
|
|
6222
|
+
prompt: { referenceSyntax: "numbered", maxChars: 5e3 },
|
|
6223
|
+
audio: "optional"
|
|
6224
|
+
},
|
|
6225
|
+
defaults: {
|
|
6226
|
+
durationSeconds: 6,
|
|
6227
|
+
resolution: "1080p",
|
|
6228
|
+
aspectRatio: "adaptive",
|
|
6229
|
+
generateAudio: true
|
|
6230
|
+
},
|
|
6231
|
+
usage: { ...VIDEO_USAGE },
|
|
6232
|
+
pricingKind: "video_per_second",
|
|
6233
|
+
display: {
|
|
6234
|
+
provider: "lightricks",
|
|
6235
|
+
logo: LIGHTRICKS_LOGO,
|
|
6236
|
+
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."
|
|
6237
|
+
},
|
|
6238
|
+
capabilities: { lastFrameRequiresFirstFrame: true }
|
|
6239
|
+
},
|
|
6240
|
+
{
|
|
6241
|
+
// https://fal.ai/models/fal-ai/ltx-2.3/text-to-video/fast/api (+ /image-to-video/fast):
|
|
6242
|
+
// the fast tier at the same resolutions; even durations 6-20 s, but over 10 s is
|
|
6243
|
+
// 1080p at 25 fps only (the kit never sends fps, so the rule checks the tier).
|
|
6244
|
+
id: "ltx-2.3-fast",
|
|
6245
|
+
aliases: ["ltx-2-3-fast", "ltx23-fast"],
|
|
6246
|
+
label: "LTX 2.3 Fast",
|
|
6247
|
+
type: "video",
|
|
6248
|
+
adapter: "fal",
|
|
6249
|
+
providerModelId: "fal-ai/ltx-2.3/text-to-video/fast",
|
|
6250
|
+
lifecycle: "active",
|
|
6251
|
+
exposure: ["cowork", "space_builder"],
|
|
6252
|
+
constraints: {
|
|
6253
|
+
aspectRatios: ["adaptive", "16:9", "9:16"],
|
|
6254
|
+
resolutions: ["1080p", "2k", "4k"],
|
|
6255
|
+
durations: [6, 8, 10, 12, 14, 16, 18, 20],
|
|
6256
|
+
supports: ["generateAudio", "lastFrame", "safetyChecker"],
|
|
6257
|
+
prompt: { referenceSyntax: "numbered", maxChars: 5e3 },
|
|
6258
|
+
audio: "optional"
|
|
6259
|
+
},
|
|
6260
|
+
defaults: {
|
|
6261
|
+
durationSeconds: 6,
|
|
6262
|
+
resolution: "1080p",
|
|
6263
|
+
aspectRatio: "adaptive",
|
|
6264
|
+
generateAudio: true
|
|
6265
|
+
},
|
|
6266
|
+
usage: { ...VIDEO_USAGE },
|
|
6267
|
+
pricingKind: "video_per_second",
|
|
6268
|
+
display: {
|
|
6269
|
+
provider: "lightricks",
|
|
6270
|
+
logo: LIGHTRICKS_LOGO,
|
|
6271
|
+
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."
|
|
6272
|
+
},
|
|
6273
|
+
capabilities: { lastFrameRequiresFirstFrame: true }
|
|
6143
6274
|
}
|
|
6144
6275
|
];
|
|
6145
6276
|
|
|
@@ -9442,6 +9573,17 @@ function falImageSpec(providerModelId) {
|
|
|
9442
9573
|
}
|
|
9443
9574
|
var AREA_1K = 1024 * 1024;
|
|
9444
9575
|
var AREA_2K = 2048 * 2048;
|
|
9576
|
+
var IDEOGRAM_46_EXACT = {
|
|
9577
|
+
minSide: 256,
|
|
9578
|
+
maxSide: 4096,
|
|
9579
|
+
minArea: 256 * 256,
|
|
9580
|
+
maxArea: 4096 * 4096,
|
|
9581
|
+
multipleOf: 32,
|
|
9582
|
+
maxAspect: 6,
|
|
9583
|
+
minTier: "2K",
|
|
9584
|
+
topTier: "4K"
|
|
9585
|
+
};
|
|
9586
|
+
var IDEOGRAM_46_IDS = /* @__PURE__ */ new Set(["ideogram/v4.6"]);
|
|
9445
9587
|
function checkExactSize(exact, b) {
|
|
9446
9588
|
const match = /^(\d+)x(\d+)$/.exec(exact);
|
|
9447
9589
|
if (match === null) {
|
|
@@ -9465,7 +9607,7 @@ function checkExactSize(exact, b) {
|
|
|
9465
9607
|
return { ok: true, size: { width, height, tier: exactTier(area, b) } };
|
|
9466
9608
|
}
|
|
9467
9609
|
function exactTier(area, b) {
|
|
9468
|
-
if (area <= AREA_1K) return "1K";
|
|
9610
|
+
if (area <= AREA_1K) return b.minTier ?? "1K";
|
|
9469
9611
|
if (b.topTier === void 0 || area <= AREA_2K) return "2K";
|
|
9470
9612
|
return b.topTier;
|
|
9471
9613
|
}
|
|
@@ -9527,23 +9669,43 @@ function falImageProblem(spec, req) {
|
|
|
9527
9669
|
}
|
|
9528
9670
|
function falExactSize(spec, req) {
|
|
9529
9671
|
if (req.exactSize === void 0 || spec.exactSize === void 0) return void 0;
|
|
9530
|
-
|
|
9672
|
+
return checkedExactSize(req.exactSize, spec.exactSize);
|
|
9673
|
+
}
|
|
9674
|
+
function checkedExactSize(exact, bounds) {
|
|
9675
|
+
const check = checkExactSize(exact, bounds);
|
|
9531
9676
|
return check.ok ? check.size : void 0;
|
|
9532
9677
|
}
|
|
9678
|
+
function ideogram46ExactSize(model, req) {
|
|
9679
|
+
if (req.exactSize === void 0) return void 0;
|
|
9680
|
+
const check = checkExactSize(req.exactSize, IDEOGRAM_46_EXACT);
|
|
9681
|
+
if (check.ok) return check.size;
|
|
9682
|
+
throw new ModelKitError({
|
|
9683
|
+
code: "unsupported_option",
|
|
9684
|
+
message: `${model.label}: ${check.message}`,
|
|
9685
|
+
model: model.id,
|
|
9686
|
+
retryable: false
|
|
9687
|
+
});
|
|
9688
|
+
}
|
|
9533
9689
|
function applyFalImageRules(model, req, callerSize, warnings) {
|
|
9534
9690
|
if (model.adapter !== "fal" && model.adapter !== "alibaba") return;
|
|
9535
9691
|
const spec = falImageSpec(model.providerModelId);
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
|
|
9541
|
-
|
|
9542
|
-
|
|
9543
|
-
|
|
9544
|
-
|
|
9692
|
+
const ideogram46 = IDEOGRAM_46_IDS.has(model.providerModelId.toLowerCase());
|
|
9693
|
+
if (spec === void 0 && !ideogram46) return;
|
|
9694
|
+
let exact;
|
|
9695
|
+
if (spec === void 0) {
|
|
9696
|
+
exact = ideogram46ExactSize(model, req);
|
|
9697
|
+
} else {
|
|
9698
|
+
const problem = falImageProblem(spec, withPromptForResolve(req));
|
|
9699
|
+
if (problem !== void 0) {
|
|
9700
|
+
throw new ModelKitError({
|
|
9701
|
+
code: problem.code,
|
|
9702
|
+
message: problem.message,
|
|
9703
|
+
model: model.id,
|
|
9704
|
+
retryable: false
|
|
9705
|
+
});
|
|
9706
|
+
}
|
|
9707
|
+
exact = falExactSize(spec, req);
|
|
9545
9708
|
}
|
|
9546
|
-
const exact = falExactSize(spec, req);
|
|
9547
9709
|
if (exact === void 0) return;
|
|
9548
9710
|
if (callerSize !== void 0 && callerSize !== exact.tier) {
|
|
9549
9711
|
warnings.push({
|
|
@@ -10202,6 +10364,8 @@ var HAPPY_HORSE = "happyhorse-1.1";
|
|
|
10202
10364
|
var HAPPY_HORSE_EDIT = "alibaba/happy-horse/video-edit";
|
|
10203
10365
|
var VIDU_Q4 = "fal-ai/vidu/q4";
|
|
10204
10366
|
var OMNIHUMAN_V2 = "bytedance/omnihuman/v2";
|
|
10367
|
+
var LTX_T2V = "fal-ai/ltx-2.3/text-to-video";
|
|
10368
|
+
var LTX_FAST_T2V = "fal-ai/ltx-2.3/text-to-video/fast";
|
|
10205
10369
|
var KLING_O3_IMAGE_CAP = 7;
|
|
10206
10370
|
var KLING_V4_IMAGE_CAP = 10;
|
|
10207
10371
|
var TURBO_AUDIO_MIN_SECONDS = 2;
|
|
@@ -10378,6 +10542,20 @@ function imageAndAudio(req, audioSeconds) {
|
|
|
10378
10542
|
}
|
|
10379
10543
|
return inputSeconds("audio", audio, audioSeconds);
|
|
10380
10544
|
}
|
|
10545
|
+
function ltx(fast) {
|
|
10546
|
+
return (req) => {
|
|
10547
|
+
if (req.lastFrame !== void 0 && req.firstFrame === void 0) {
|
|
10548
|
+
return missing("takes an end frame only together with a start frame");
|
|
10549
|
+
}
|
|
10550
|
+
if (count(req.referenceImages) + count(req.referenceVideos) + count(req.referenceAudios) > 0) {
|
|
10551
|
+
return unsupported3("takes no reference images, videos or audio");
|
|
10552
|
+
}
|
|
10553
|
+
if (fast && (req.durationSeconds ?? 6) > 10 && req.resolution !== void 0 && req.resolution !== "1080p") {
|
|
10554
|
+
return unsupported3("renders over 10 s at 1080p only");
|
|
10555
|
+
}
|
|
10556
|
+
return needsPrompt(req);
|
|
10557
|
+
};
|
|
10558
|
+
}
|
|
10381
10559
|
var RULES = new Map([
|
|
10382
10560
|
[MOTION_PRO, motionControl],
|
|
10383
10561
|
[MOTION_STANDARD, motionControl],
|
|
@@ -10401,7 +10579,9 @@ var RULES = new Map([
|
|
|
10401
10579
|
[OMNIHUMAN_V2, (req) => imageAndAudio(req, OMNIHUMAN_AUDIO_SECONDS)],
|
|
10402
10580
|
...AVATAR_AUDIO.map(
|
|
10403
10581
|
([id, limits]) => [id, (req) => imageAndAudio(req, limits)]
|
|
10404
|
-
)
|
|
10582
|
+
),
|
|
10583
|
+
[LTX_T2V, ltx(false)],
|
|
10584
|
+
[LTX_FAST_T2V, ltx(true)]
|
|
10405
10585
|
]);
|
|
10406
10586
|
function falVideoProblem(providerModelId, req) {
|
|
10407
10587
|
return RULES.get(providerModelId.toLowerCase())?.(req);
|
|
@@ -12492,6 +12672,17 @@ async function generateFalMask(req, ctx, run) {
|
|
|
12492
12672
|
return result;
|
|
12493
12673
|
}
|
|
12494
12674
|
|
|
12675
|
+
// src/adapters/png-size.ts
|
|
12676
|
+
var PNG_SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10];
|
|
12677
|
+
function pngDimensions(bytes) {
|
|
12678
|
+
if (bytes.length < 24) return void 0;
|
|
12679
|
+
if (PNG_SIGNATURE.some((byte, index) => bytes[index] !== byte)) return void 0;
|
|
12680
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
12681
|
+
const width = view.getUint32(16);
|
|
12682
|
+
const height = view.getUint32(20);
|
|
12683
|
+
return width > 0 && height > 0 ? { width, height } : void 0;
|
|
12684
|
+
}
|
|
12685
|
+
|
|
12495
12686
|
// src/adapters/fal-audio-plan.ts
|
|
12496
12687
|
import { z as z19 } from "zod";
|
|
12497
12688
|
var ELEVENLABS_MUSIC = FAL_AUDIO.elevenLabsMusic;
|
|
@@ -13591,6 +13782,58 @@ var klingOmniFamily = {
|
|
|
13591
13782
|
plan: plan2
|
|
13592
13783
|
};
|
|
13593
13784
|
|
|
13785
|
+
// src/adapters/fal-ltx.ts
|
|
13786
|
+
var LTX_T2V2 = "fal-ai/ltx-2.3/text-to-video";
|
|
13787
|
+
var LTX_I2V = "fal-ai/ltx-2.3/image-to-video";
|
|
13788
|
+
var LTX_FAST_T2V2 = "fal-ai/ltx-2.3/text-to-video/fast";
|
|
13789
|
+
var LTX_FAST_I2V = "fal-ai/ltx-2.3/image-to-video/fast";
|
|
13790
|
+
var LTX_TIERS = {
|
|
13791
|
+
"360p": "360p",
|
|
13792
|
+
"480p": "480p",
|
|
13793
|
+
"720p": "720p",
|
|
13794
|
+
"768p": "768p",
|
|
13795
|
+
"1080p": "1080p",
|
|
13796
|
+
"2k": "1440p",
|
|
13797
|
+
"4k": "2160p"
|
|
13798
|
+
};
|
|
13799
|
+
function ltxGenerate(fast, req, ctx) {
|
|
13800
|
+
const resolution = resolutionOf2(req, ctx);
|
|
13801
|
+
const duration = wholeSeconds(req, ctx);
|
|
13802
|
+
const input = {
|
|
13803
|
+
prompt: req.prompt.trim(),
|
|
13804
|
+
duration,
|
|
13805
|
+
resolution: LTX_TIERS[resolution],
|
|
13806
|
+
generate_audio: req.generateAudio ?? true
|
|
13807
|
+
};
|
|
13808
|
+
if (req.safetyChecker !== void 0) input["enable_safety_checker"] = req.safetyChecker;
|
|
13809
|
+
const firstFrame = req.firstFrame;
|
|
13810
|
+
const endpoint = firstFrame === void 0 ? fast ? LTX_FAST_T2V2 : LTX_T2V2 : fast ? LTX_FAST_I2V : LTX_I2V;
|
|
13811
|
+
if (firstFrame === void 0) {
|
|
13812
|
+
const ratio = concreteRatio(req);
|
|
13813
|
+
if (ratio !== void 0) input["aspect_ratio"] = ratio;
|
|
13814
|
+
} else {
|
|
13815
|
+
input["image_url"] = refToUrl(firstFrame);
|
|
13816
|
+
if (req.lastFrame !== void 0) input["end_image_url"] = refToUrl(req.lastFrame);
|
|
13817
|
+
if (req.aspectRatio !== void 0) {
|
|
13818
|
+
input["aspect_ratio"] = req.aspectRatio === "adaptive" ? "auto" : req.aspectRatio;
|
|
13819
|
+
}
|
|
13820
|
+
}
|
|
13821
|
+
return { endpoint, input, resolution, seconds: requestedSeconds(duration) };
|
|
13822
|
+
}
|
|
13823
|
+
var LTX_MODEL_IDS = /* @__PURE__ */ new Set([
|
|
13824
|
+
LTX_T2V2,
|
|
13825
|
+
LTX_I2V,
|
|
13826
|
+
LTX_FAST_T2V2,
|
|
13827
|
+
LTX_FAST_I2V
|
|
13828
|
+
]);
|
|
13829
|
+
var ltxFamily = {
|
|
13830
|
+
ids: LTX_MODEL_IDS,
|
|
13831
|
+
plan(req, ctx) {
|
|
13832
|
+
const id = ctx.model.providerModelId.toLowerCase();
|
|
13833
|
+
return ltxGenerate(id === LTX_FAST_T2V2 || id === LTX_FAST_I2V, req, ctx);
|
|
13834
|
+
}
|
|
13835
|
+
};
|
|
13836
|
+
|
|
13594
13837
|
// src/adapters/fal-minimax-h3.ts
|
|
13595
13838
|
var TURBO = "minimax/h3-max-turbo";
|
|
13596
13839
|
var INSERT = MINIMAX_H3_INSERT;
|
|
@@ -13761,6 +14004,7 @@ var FAMILIES2 = [
|
|
|
13761
14004
|
klingV4Family,
|
|
13762
14005
|
minimaxH3MaxFamily,
|
|
13763
14006
|
happyHorseFamily,
|
|
14007
|
+
ltxFamily,
|
|
13764
14008
|
viduFamily,
|
|
13765
14009
|
omnihumanFamily,
|
|
13766
14010
|
avatarFamily
|
|
@@ -14016,20 +14260,39 @@ var museImageResultSchema = z23.object({
|
|
|
14016
14260
|
images: z23.array(
|
|
14017
14261
|
z23.object({
|
|
14018
14262
|
url: z23.string().optional(),
|
|
14019
|
-
content_type: z23.string().nullable().optional()
|
|
14263
|
+
content_type: z23.string().nullable().optional(),
|
|
14264
|
+
// Some fal image endpoints report the delivered dimensions (Kling); Ideogram
|
|
14265
|
+
// 4.6's File schema reports none, so its files are measured instead.
|
|
14266
|
+
width: z23.number().int().positive().optional(),
|
|
14267
|
+
height: z23.number().int().positive().optional()
|
|
14020
14268
|
})
|
|
14021
14269
|
).optional()
|
|
14022
14270
|
});
|
|
14271
|
+
var IDEOGRAM_46_ID = "ideogram/v4.6";
|
|
14272
|
+
var IDEOGRAM_46_4K_AREA = 2048 * 2048;
|
|
14273
|
+
function isIdeogram46(providerModelId) {
|
|
14274
|
+
return providerModelId.toLowerCase() === IDEOGRAM_46_ID;
|
|
14275
|
+
}
|
|
14276
|
+
function ideogramBilledSize(delivered, fallback) {
|
|
14277
|
+
const areas = delivered.flatMap((image) => {
|
|
14278
|
+
const size = image.width !== void 0 && image.height !== void 0 ? { width: image.width, height: image.height } : pngDimensions(image.bytes);
|
|
14279
|
+
return size === void 0 ? [] : [size.width * size.height];
|
|
14280
|
+
});
|
|
14281
|
+
if (areas.length === 0) return fallback;
|
|
14282
|
+
return Math.max(...areas) > IDEOGRAM_46_4K_AREA ? "4K" : "2K";
|
|
14283
|
+
}
|
|
14023
14284
|
async function collectFalImages(payload, ctx, req, label) {
|
|
14024
14285
|
const parsed = museImageResultSchema.safeParse(payload);
|
|
14025
14286
|
const images = parsed.success ? parsed.data.images ?? [] : [];
|
|
14026
|
-
const
|
|
14027
|
-
images.
|
|
14028
|
-
if (
|
|
14029
|
-
|
|
14287
|
+
const downloaded = await Promise.all(
|
|
14288
|
+
images.map(async (image) => {
|
|
14289
|
+
if (image.url === void 0) return void 0;
|
|
14290
|
+
const file = await decodeImage(ctx, image.url, image.content_type ?? void 0);
|
|
14291
|
+
return image.width !== void 0 && image.height !== void 0 ? { ...file, width: image.width, height: image.height } : file;
|
|
14030
14292
|
})
|
|
14031
14293
|
);
|
|
14032
|
-
|
|
14294
|
+
const delivered = downloaded.filter((image) => image !== void 0);
|
|
14295
|
+
if (delivered.length === 0) {
|
|
14033
14296
|
throw new ModelKitError({
|
|
14034
14297
|
code: "provider_rejected",
|
|
14035
14298
|
message: `${label} returned no image`,
|
|
@@ -14038,9 +14301,14 @@ async function collectFalImages(payload, ctx, req, label) {
|
|
|
14038
14301
|
retryable: false
|
|
14039
14302
|
});
|
|
14040
14303
|
}
|
|
14304
|
+
const usage6 = imageUsage(ctx, req, delivered.length);
|
|
14305
|
+
if (isIdeogram46(ctx.model.providerModelId)) {
|
|
14306
|
+
const billed = ideogramBilledSize(delivered, req.size);
|
|
14307
|
+
if (billed !== void 0) usage6.imageSize = billed;
|
|
14308
|
+
}
|
|
14041
14309
|
return {
|
|
14042
|
-
images:
|
|
14043
|
-
usage:
|
|
14310
|
+
images: delivered.map(({ bytes, mime }) => ({ bytes, mime })),
|
|
14311
|
+
usage: usage6,
|
|
14044
14312
|
raw: payload
|
|
14045
14313
|
};
|
|
14046
14314
|
}
|
|
@@ -14068,7 +14336,7 @@ async function generateMuseImage(req, ctx, deps) {
|
|
|
14068
14336
|
const payload = await runJob(ctx, deps, endpoint, input);
|
|
14069
14337
|
return collectFalImages(payload, ctx, req, "fal Meta Muse");
|
|
14070
14338
|
}
|
|
14071
|
-
var IDEOGRAM_MODEL_IDS = /* @__PURE__ */ new Set(["ideogram/v4.5"]);
|
|
14339
|
+
var IDEOGRAM_MODEL_IDS = /* @__PURE__ */ new Set(["ideogram/v4.5", "ideogram/v4.6"]);
|
|
14072
14340
|
function isIdeogram(providerModelId) {
|
|
14073
14341
|
return IDEOGRAM_MODEL_IDS.has(providerModelId.toLowerCase());
|
|
14074
14342
|
}
|
|
@@ -14087,10 +14355,26 @@ function parseExactSize(value) {
|
|
|
14087
14355
|
const match = /^(\d+)x(\d+)$/.exec(value ?? "");
|
|
14088
14356
|
return match ? { width: Number(match[1]), height: Number(match[2]) } : void 0;
|
|
14089
14357
|
}
|
|
14090
|
-
|
|
14358
|
+
var IDEOGRAM_46_SIZES = {
|
|
14359
|
+
"1:1": { "2K": "2048x2048", "4K": "4096x4096" },
|
|
14360
|
+
"16:9": { "2K": "2560x1440", "4K": "4096x2304" },
|
|
14361
|
+
"9:16": { "2K": "1440x2560", "4K": "2304x4096" },
|
|
14362
|
+
"4:3": { "2K": "2304x1728", "4K": "4096x3072" },
|
|
14363
|
+
"3:4": { "2K": "1728x2304", "4K": "3072x4096" },
|
|
14364
|
+
"3:2": { "2K": "2496x1664", "4K": "4096x2720" },
|
|
14365
|
+
"2:3": { "2K": "1664x2496", "4K": "2720x4096" },
|
|
14366
|
+
"5:4": { "2K": "2240x1792", "4K": "4096x3264" },
|
|
14367
|
+
"4:5": { "2K": "1792x2240", "4K": "3264x4096" }
|
|
14368
|
+
};
|
|
14369
|
+
function ideogramImageSize(ctx, req) {
|
|
14091
14370
|
const exact = parseExactSize(req.exactSize);
|
|
14092
14371
|
if (exact) return exact;
|
|
14093
14372
|
if (req.aspectRatio === void 0 || req.aspectRatio === "adaptive") return void 0;
|
|
14373
|
+
if (ctx.model.providerModelId.toLowerCase() === "ideogram/v4.6") {
|
|
14374
|
+
return parseExactSize(
|
|
14375
|
+
IDEOGRAM_46_SIZES[req.aspectRatio]?.[req.size === "4K" ? "4K" : "2K"]
|
|
14376
|
+
);
|
|
14377
|
+
}
|
|
14094
14378
|
return parseExactSize(IDEOGRAM_SIZES[req.aspectRatio]?.[req.size === "1K" ? "1K" : "2K"]);
|
|
14095
14379
|
}
|
|
14096
14380
|
async function generateIdeogramImage(req, ctx, deps) {
|
|
@@ -14102,7 +14386,7 @@ async function generateIdeogramImage(req, ctx, deps) {
|
|
|
14102
14386
|
let endpoint = id;
|
|
14103
14387
|
if (source2 === void 0) {
|
|
14104
14388
|
input.enable_prompt_expansion = false;
|
|
14105
|
-
const size = ideogramImageSize(req);
|
|
14389
|
+
const size = ideogramImageSize(ctx, req);
|
|
14106
14390
|
if (size) input.image_size = size;
|
|
14107
14391
|
} else {
|
|
14108
14392
|
endpoint = `${id}/edit`;
|