@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.cjs
CHANGED
|
@@ -1072,6 +1072,65 @@ var IMAGE_MODELS = [
|
|
|
1072
1072
|
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."
|
|
1073
1073
|
}
|
|
1074
1074
|
},
|
|
1075
|
+
{
|
|
1076
|
+
// Generation only: fal charges edits more, so editing is its own row
|
|
1077
|
+
// (ideogram-4.6-edit) with its own prices. fal bills any output above
|
|
1078
|
+
// 2048x2048 in area at the 4K price; very_low renders at most 2K, so it is
|
|
1079
|
+
// not exposed (no 4K price exists for it, and the catalog seed gate needs
|
|
1080
|
+
// every size x quality priced). https://fal.ai/models/ideogram/v4.6
|
|
1081
|
+
id: "ideogram-4.6",
|
|
1082
|
+
aliases: [],
|
|
1083
|
+
label: "Ideogram 4.6",
|
|
1084
|
+
type: "image",
|
|
1085
|
+
adapter: "fal",
|
|
1086
|
+
providerModelId: "ideogram/v4.6",
|
|
1087
|
+
lifecycle: "active",
|
|
1088
|
+
exposure: ["cowork", "space_builder"],
|
|
1089
|
+
constraints: {
|
|
1090
|
+
aspectRatios: ["1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "5:4", "4:5"],
|
|
1091
|
+
sizes: ["2K", "4K"],
|
|
1092
|
+
qualityOptions: ["auto", "low", "medium", "high"],
|
|
1093
|
+
references: { images: 0 },
|
|
1094
|
+
supports: ["quality", "count", "seed"]
|
|
1095
|
+
},
|
|
1096
|
+
defaults: { size: "2K", aspectRatio: "1:1", quality: "medium", count: 1 },
|
|
1097
|
+
usage: { ...IMAGE_USAGE3, slug: "ideogram" },
|
|
1098
|
+
pricingKind: "image_size",
|
|
1099
|
+
display: {
|
|
1100
|
+
provider: "ideogram",
|
|
1101
|
+
description: "Ideogram 4.6 text-to-image from a prompt, at 2K or 4K. Edits go to Ideogram 4.6 Edit."
|
|
1102
|
+
}
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
// Precise Edit only: references switch to the /edit endpoint, where the
|
|
1106
|
+
// first is the image to edit and the rest (up to 4) guide it, so 5 images
|
|
1107
|
+
// in all. The output keeps the source size, so `size` only picks the
|
|
1108
|
+
// billed tier. Same provider model as the generate row, whose adapter
|
|
1109
|
+
// routes on references. https://fal.ai/models/ideogram/v4.6/edit
|
|
1110
|
+
id: "ideogram-4.6-edit",
|
|
1111
|
+
aliases: [],
|
|
1112
|
+
label: "Ideogram 4.6 Edit",
|
|
1113
|
+
type: "image",
|
|
1114
|
+
adapter: "fal",
|
|
1115
|
+
providerModelId: "ideogram/v4.6",
|
|
1116
|
+
lifecycle: "active",
|
|
1117
|
+
exposure: ["cowork", "space_builder"],
|
|
1118
|
+
constraints: {
|
|
1119
|
+
aspectRatios: ["1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "5:4", "4:5"],
|
|
1120
|
+
sizes: ["2K", "4K"],
|
|
1121
|
+
qualityOptions: ["auto", "low", "medium", "high"],
|
|
1122
|
+
references: { images: 5 },
|
|
1123
|
+
requires: ["references"],
|
|
1124
|
+
supports: ["quality", "count", "seed"]
|
|
1125
|
+
},
|
|
1126
|
+
defaults: { size: "2K", aspectRatio: "1:1", quality: "medium", count: 1 },
|
|
1127
|
+
usage: { ...IMAGE_USAGE3, slug: "ideogram" },
|
|
1128
|
+
pricingKind: "image_size",
|
|
1129
|
+
display: {
|
|
1130
|
+
provider: "ideogram",
|
|
1131
|
+
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."
|
|
1132
|
+
}
|
|
1133
|
+
},
|
|
1075
1134
|
{
|
|
1076
1135
|
id: "seedream-5-0-pro",
|
|
1077
1136
|
aliases: ["seedream-4-5"],
|
|
@@ -5699,6 +5758,7 @@ var KLING_LOGO2 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0
|
|
|
5699
5758
|
var MINIMAX_LOGO4 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
|
|
5700
5759
|
var BYTEDANCE_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/3bba5d81-4e57-4e71-911b-cdfa05acca2c_compressed.png";
|
|
5701
5760
|
var XAI_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/858b7fcc-9bd5-411d-aea1-a7b35ecfffab_compressed.png";
|
|
5761
|
+
var LIGHTRICKS_LOGO = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/lightricks.png";
|
|
5702
5762
|
var H3_RATIOS = ["21:9", "16:9", "4:3", "1:1", "3:4", "9:16"];
|
|
5703
5763
|
var HAPPY_HORSE_RATIOS = [
|
|
5704
5764
|
"16:9",
|
|
@@ -6297,6 +6357,77 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
6297
6357
|
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."
|
|
6298
6358
|
},
|
|
6299
6359
|
capabilities: {}
|
|
6360
|
+
},
|
|
6361
|
+
{
|
|
6362
|
+
// https://fal.ai/models/fal-ai/ltx-2.3/text-to-video/api (+ /image-to-video): one row;
|
|
6363
|
+
// a start frame routes to image-to-video, else text-to-video. The kit's 2k/4k tiers
|
|
6364
|
+
// are fal's 1440p/2160p (adapters/fal-ltx.ts). "adaptive" is fal's "auto" on
|
|
6365
|
+
// image-to-video; text-to-video leaves an adaptive ratio at fal's 16:9 default.
|
|
6366
|
+
id: "ltx-2.3",
|
|
6367
|
+
aliases: ["ltx-2-3", "ltx23"],
|
|
6368
|
+
label: "LTX 2.3",
|
|
6369
|
+
type: "video",
|
|
6370
|
+
adapter: "fal",
|
|
6371
|
+
providerModelId: "fal-ai/ltx-2.3/text-to-video",
|
|
6372
|
+
lifecycle: "active",
|
|
6373
|
+
exposure: ["cowork", "space_builder"],
|
|
6374
|
+
constraints: {
|
|
6375
|
+
aspectRatios: ["adaptive", "16:9", "9:16"],
|
|
6376
|
+
resolutions: ["1080p", "2k", "4k"],
|
|
6377
|
+
durations: [6, 8, 10],
|
|
6378
|
+
supports: ["generateAudio", "lastFrame", "safetyChecker"],
|
|
6379
|
+
prompt: { referenceSyntax: "numbered", maxChars: 5e3 },
|
|
6380
|
+
audio: "optional"
|
|
6381
|
+
},
|
|
6382
|
+
defaults: {
|
|
6383
|
+
durationSeconds: 6,
|
|
6384
|
+
resolution: "1080p",
|
|
6385
|
+
aspectRatio: "adaptive",
|
|
6386
|
+
generateAudio: true
|
|
6387
|
+
},
|
|
6388
|
+
usage: { ...VIDEO_USAGE },
|
|
6389
|
+
pricingKind: "video_per_second",
|
|
6390
|
+
display: {
|
|
6391
|
+
provider: "lightricks",
|
|
6392
|
+
logo: LIGHTRICKS_LOGO,
|
|
6393
|
+
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."
|
|
6394
|
+
},
|
|
6395
|
+
capabilities: { lastFrameRequiresFirstFrame: true }
|
|
6396
|
+
},
|
|
6397
|
+
{
|
|
6398
|
+
// https://fal.ai/models/fal-ai/ltx-2.3/text-to-video/fast/api (+ /image-to-video/fast):
|
|
6399
|
+
// the fast tier at the same resolutions; even durations 6-20 s, but over 10 s is
|
|
6400
|
+
// 1080p at 25 fps only (the kit never sends fps, so the rule checks the tier).
|
|
6401
|
+
id: "ltx-2.3-fast",
|
|
6402
|
+
aliases: ["ltx-2-3-fast", "ltx23-fast"],
|
|
6403
|
+
label: "LTX 2.3 Fast",
|
|
6404
|
+
type: "video",
|
|
6405
|
+
adapter: "fal",
|
|
6406
|
+
providerModelId: "fal-ai/ltx-2.3/text-to-video/fast",
|
|
6407
|
+
lifecycle: "active",
|
|
6408
|
+
exposure: ["cowork", "space_builder"],
|
|
6409
|
+
constraints: {
|
|
6410
|
+
aspectRatios: ["adaptive", "16:9", "9:16"],
|
|
6411
|
+
resolutions: ["1080p", "2k", "4k"],
|
|
6412
|
+
durations: [6, 8, 10, 12, 14, 16, 18, 20],
|
|
6413
|
+
supports: ["generateAudio", "lastFrame", "safetyChecker"],
|
|
6414
|
+
prompt: { referenceSyntax: "numbered", maxChars: 5e3 },
|
|
6415
|
+
audio: "optional"
|
|
6416
|
+
},
|
|
6417
|
+
defaults: {
|
|
6418
|
+
durationSeconds: 6,
|
|
6419
|
+
resolution: "1080p",
|
|
6420
|
+
aspectRatio: "adaptive",
|
|
6421
|
+
generateAudio: true
|
|
6422
|
+
},
|
|
6423
|
+
usage: { ...VIDEO_USAGE },
|
|
6424
|
+
pricingKind: "video_per_second",
|
|
6425
|
+
display: {
|
|
6426
|
+
provider: "lightricks",
|
|
6427
|
+
logo: LIGHTRICKS_LOGO,
|
|
6428
|
+
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."
|
|
6429
|
+
},
|
|
6430
|
+
capabilities: { lastFrameRequiresFirstFrame: true }
|
|
6300
6431
|
}
|
|
6301
6432
|
];
|
|
6302
6433
|
|
|
@@ -9599,6 +9730,17 @@ function falImageSpec(providerModelId) {
|
|
|
9599
9730
|
}
|
|
9600
9731
|
var AREA_1K = 1024 * 1024;
|
|
9601
9732
|
var AREA_2K = 2048 * 2048;
|
|
9733
|
+
var IDEOGRAM_46_EXACT = {
|
|
9734
|
+
minSide: 256,
|
|
9735
|
+
maxSide: 4096,
|
|
9736
|
+
minArea: 256 * 256,
|
|
9737
|
+
maxArea: 4096 * 4096,
|
|
9738
|
+
multipleOf: 32,
|
|
9739
|
+
maxAspect: 6,
|
|
9740
|
+
minTier: "2K",
|
|
9741
|
+
topTier: "4K"
|
|
9742
|
+
};
|
|
9743
|
+
var IDEOGRAM_46_IDS = /* @__PURE__ */ new Set(["ideogram/v4.6"]);
|
|
9602
9744
|
function checkExactSize(exact, b) {
|
|
9603
9745
|
const match = /^(\d+)x(\d+)$/.exec(exact);
|
|
9604
9746
|
if (match === null) {
|
|
@@ -9622,7 +9764,7 @@ function checkExactSize(exact, b) {
|
|
|
9622
9764
|
return { ok: true, size: { width, height, tier: exactTier(area, b) } };
|
|
9623
9765
|
}
|
|
9624
9766
|
function exactTier(area, b) {
|
|
9625
|
-
if (area <= AREA_1K) return "1K";
|
|
9767
|
+
if (area <= AREA_1K) return b.minTier ?? "1K";
|
|
9626
9768
|
if (b.topTier === void 0 || area <= AREA_2K) return "2K";
|
|
9627
9769
|
return b.topTier;
|
|
9628
9770
|
}
|
|
@@ -9684,23 +9826,43 @@ function falImageProblem(spec, req) {
|
|
|
9684
9826
|
}
|
|
9685
9827
|
function falExactSize(spec, req) {
|
|
9686
9828
|
if (req.exactSize === void 0 || spec.exactSize === void 0) return void 0;
|
|
9687
|
-
|
|
9829
|
+
return checkedExactSize(req.exactSize, spec.exactSize);
|
|
9830
|
+
}
|
|
9831
|
+
function checkedExactSize(exact, bounds) {
|
|
9832
|
+
const check = checkExactSize(exact, bounds);
|
|
9688
9833
|
return check.ok ? check.size : void 0;
|
|
9689
9834
|
}
|
|
9835
|
+
function ideogram46ExactSize(model, req) {
|
|
9836
|
+
if (req.exactSize === void 0) return void 0;
|
|
9837
|
+
const check = checkExactSize(req.exactSize, IDEOGRAM_46_EXACT);
|
|
9838
|
+
if (check.ok) return check.size;
|
|
9839
|
+
throw new ModelKitError({
|
|
9840
|
+
code: "unsupported_option",
|
|
9841
|
+
message: `${model.label}: ${check.message}`,
|
|
9842
|
+
model: model.id,
|
|
9843
|
+
retryable: false
|
|
9844
|
+
});
|
|
9845
|
+
}
|
|
9690
9846
|
function applyFalImageRules(model, req, callerSize, warnings) {
|
|
9691
9847
|
if (model.adapter !== "fal" && model.adapter !== "alibaba") return;
|
|
9692
9848
|
const spec = falImageSpec(model.providerModelId);
|
|
9693
|
-
|
|
9694
|
-
|
|
9695
|
-
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
|
|
9701
|
-
|
|
9849
|
+
const ideogram46 = IDEOGRAM_46_IDS.has(model.providerModelId.toLowerCase());
|
|
9850
|
+
if (spec === void 0 && !ideogram46) return;
|
|
9851
|
+
let exact;
|
|
9852
|
+
if (spec === void 0) {
|
|
9853
|
+
exact = ideogram46ExactSize(model, req);
|
|
9854
|
+
} else {
|
|
9855
|
+
const problem = falImageProblem(spec, withPromptForResolve(req));
|
|
9856
|
+
if (problem !== void 0) {
|
|
9857
|
+
throw new ModelKitError({
|
|
9858
|
+
code: problem.code,
|
|
9859
|
+
message: problem.message,
|
|
9860
|
+
model: model.id,
|
|
9861
|
+
retryable: false
|
|
9862
|
+
});
|
|
9863
|
+
}
|
|
9864
|
+
exact = falExactSize(spec, req);
|
|
9702
9865
|
}
|
|
9703
|
-
const exact = falExactSize(spec, req);
|
|
9704
9866
|
if (exact === void 0) return;
|
|
9705
9867
|
if (callerSize !== void 0 && callerSize !== exact.tier) {
|
|
9706
9868
|
warnings.push({
|
|
@@ -10359,6 +10521,8 @@ var HAPPY_HORSE = "happyhorse-1.1";
|
|
|
10359
10521
|
var HAPPY_HORSE_EDIT = "alibaba/happy-horse/video-edit";
|
|
10360
10522
|
var VIDU_Q4 = "fal-ai/vidu/q4";
|
|
10361
10523
|
var OMNIHUMAN_V2 = "bytedance/omnihuman/v2";
|
|
10524
|
+
var LTX_T2V = "fal-ai/ltx-2.3/text-to-video";
|
|
10525
|
+
var LTX_FAST_T2V = "fal-ai/ltx-2.3/text-to-video/fast";
|
|
10362
10526
|
var KLING_O3_IMAGE_CAP = 7;
|
|
10363
10527
|
var KLING_V4_IMAGE_CAP = 10;
|
|
10364
10528
|
var TURBO_AUDIO_MIN_SECONDS = 2;
|
|
@@ -10535,6 +10699,20 @@ function imageAndAudio(req, audioSeconds) {
|
|
|
10535
10699
|
}
|
|
10536
10700
|
return inputSeconds("audio", audio, audioSeconds);
|
|
10537
10701
|
}
|
|
10702
|
+
function ltx(fast) {
|
|
10703
|
+
return (req) => {
|
|
10704
|
+
if (req.lastFrame !== void 0 && req.firstFrame === void 0) {
|
|
10705
|
+
return missing("takes an end frame only together with a start frame");
|
|
10706
|
+
}
|
|
10707
|
+
if (count(req.referenceImages) + count(req.referenceVideos) + count(req.referenceAudios) > 0) {
|
|
10708
|
+
return unsupported3("takes no reference images, videos or audio");
|
|
10709
|
+
}
|
|
10710
|
+
if (fast && (req.durationSeconds ?? 6) > 10 && req.resolution !== void 0 && req.resolution !== "1080p") {
|
|
10711
|
+
return unsupported3("renders over 10 s at 1080p only");
|
|
10712
|
+
}
|
|
10713
|
+
return needsPrompt(req);
|
|
10714
|
+
};
|
|
10715
|
+
}
|
|
10538
10716
|
var RULES = new Map([
|
|
10539
10717
|
[MOTION_PRO, motionControl],
|
|
10540
10718
|
[MOTION_STANDARD, motionControl],
|
|
@@ -10558,7 +10736,9 @@ var RULES = new Map([
|
|
|
10558
10736
|
[OMNIHUMAN_V2, (req) => imageAndAudio(req, OMNIHUMAN_AUDIO_SECONDS)],
|
|
10559
10737
|
...AVATAR_AUDIO.map(
|
|
10560
10738
|
([id, limits]) => [id, (req) => imageAndAudio(req, limits)]
|
|
10561
|
-
)
|
|
10739
|
+
),
|
|
10740
|
+
[LTX_T2V, ltx(false)],
|
|
10741
|
+
[LTX_FAST_T2V, ltx(true)]
|
|
10562
10742
|
]);
|
|
10563
10743
|
function falVideoProblem(providerModelId, req) {
|
|
10564
10744
|
return RULES.get(providerModelId.toLowerCase())?.(req);
|
|
@@ -12649,6 +12829,17 @@ async function generateFalMask(req, ctx, run) {
|
|
|
12649
12829
|
return result;
|
|
12650
12830
|
}
|
|
12651
12831
|
|
|
12832
|
+
// src/adapters/png-size.ts
|
|
12833
|
+
var PNG_SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10];
|
|
12834
|
+
function pngDimensions(bytes) {
|
|
12835
|
+
if (bytes.length < 24) return void 0;
|
|
12836
|
+
if (PNG_SIGNATURE.some((byte, index) => bytes[index] !== byte)) return void 0;
|
|
12837
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
12838
|
+
const width = view.getUint32(16);
|
|
12839
|
+
const height = view.getUint32(20);
|
|
12840
|
+
return width > 0 && height > 0 ? { width, height } : void 0;
|
|
12841
|
+
}
|
|
12842
|
+
|
|
12652
12843
|
// src/adapters/fal-audio-plan.ts
|
|
12653
12844
|
var import_zod19 = require("zod");
|
|
12654
12845
|
var ELEVENLABS_MUSIC = FAL_AUDIO.elevenLabsMusic;
|
|
@@ -13748,6 +13939,58 @@ var klingOmniFamily = {
|
|
|
13748
13939
|
plan: plan2
|
|
13749
13940
|
};
|
|
13750
13941
|
|
|
13942
|
+
// src/adapters/fal-ltx.ts
|
|
13943
|
+
var LTX_T2V2 = "fal-ai/ltx-2.3/text-to-video";
|
|
13944
|
+
var LTX_I2V = "fal-ai/ltx-2.3/image-to-video";
|
|
13945
|
+
var LTX_FAST_T2V2 = "fal-ai/ltx-2.3/text-to-video/fast";
|
|
13946
|
+
var LTX_FAST_I2V = "fal-ai/ltx-2.3/image-to-video/fast";
|
|
13947
|
+
var LTX_TIERS = {
|
|
13948
|
+
"360p": "360p",
|
|
13949
|
+
"480p": "480p",
|
|
13950
|
+
"720p": "720p",
|
|
13951
|
+
"768p": "768p",
|
|
13952
|
+
"1080p": "1080p",
|
|
13953
|
+
"2k": "1440p",
|
|
13954
|
+
"4k": "2160p"
|
|
13955
|
+
};
|
|
13956
|
+
function ltxGenerate(fast, req, ctx) {
|
|
13957
|
+
const resolution = resolutionOf2(req, ctx);
|
|
13958
|
+
const duration = wholeSeconds(req, ctx);
|
|
13959
|
+
const input = {
|
|
13960
|
+
prompt: req.prompt.trim(),
|
|
13961
|
+
duration,
|
|
13962
|
+
resolution: LTX_TIERS[resolution],
|
|
13963
|
+
generate_audio: req.generateAudio ?? true
|
|
13964
|
+
};
|
|
13965
|
+
if (req.safetyChecker !== void 0) input["enable_safety_checker"] = req.safetyChecker;
|
|
13966
|
+
const firstFrame = req.firstFrame;
|
|
13967
|
+
const endpoint = firstFrame === void 0 ? fast ? LTX_FAST_T2V2 : LTX_T2V2 : fast ? LTX_FAST_I2V : LTX_I2V;
|
|
13968
|
+
if (firstFrame === void 0) {
|
|
13969
|
+
const ratio = concreteRatio(req);
|
|
13970
|
+
if (ratio !== void 0) input["aspect_ratio"] = ratio;
|
|
13971
|
+
} else {
|
|
13972
|
+
input["image_url"] = refToUrl(firstFrame);
|
|
13973
|
+
if (req.lastFrame !== void 0) input["end_image_url"] = refToUrl(req.lastFrame);
|
|
13974
|
+
if (req.aspectRatio !== void 0) {
|
|
13975
|
+
input["aspect_ratio"] = req.aspectRatio === "adaptive" ? "auto" : req.aspectRatio;
|
|
13976
|
+
}
|
|
13977
|
+
}
|
|
13978
|
+
return { endpoint, input, resolution, seconds: requestedSeconds(duration) };
|
|
13979
|
+
}
|
|
13980
|
+
var LTX_MODEL_IDS = /* @__PURE__ */ new Set([
|
|
13981
|
+
LTX_T2V2,
|
|
13982
|
+
LTX_I2V,
|
|
13983
|
+
LTX_FAST_T2V2,
|
|
13984
|
+
LTX_FAST_I2V
|
|
13985
|
+
]);
|
|
13986
|
+
var ltxFamily = {
|
|
13987
|
+
ids: LTX_MODEL_IDS,
|
|
13988
|
+
plan(req, ctx) {
|
|
13989
|
+
const id = ctx.model.providerModelId.toLowerCase();
|
|
13990
|
+
return ltxGenerate(id === LTX_FAST_T2V2 || id === LTX_FAST_I2V, req, ctx);
|
|
13991
|
+
}
|
|
13992
|
+
};
|
|
13993
|
+
|
|
13751
13994
|
// src/adapters/fal-minimax-h3.ts
|
|
13752
13995
|
var TURBO = "minimax/h3-max-turbo";
|
|
13753
13996
|
var INSERT = MINIMAX_H3_INSERT;
|
|
@@ -13918,6 +14161,7 @@ var FAMILIES2 = [
|
|
|
13918
14161
|
klingV4Family,
|
|
13919
14162
|
minimaxH3MaxFamily,
|
|
13920
14163
|
happyHorseFamily,
|
|
14164
|
+
ltxFamily,
|
|
13921
14165
|
viduFamily,
|
|
13922
14166
|
omnihumanFamily,
|
|
13923
14167
|
avatarFamily
|
|
@@ -14173,20 +14417,39 @@ var museImageResultSchema = import_zod23.z.object({
|
|
|
14173
14417
|
images: import_zod23.z.array(
|
|
14174
14418
|
import_zod23.z.object({
|
|
14175
14419
|
url: import_zod23.z.string().optional(),
|
|
14176
|
-
content_type: import_zod23.z.string().nullable().optional()
|
|
14420
|
+
content_type: import_zod23.z.string().nullable().optional(),
|
|
14421
|
+
// Some fal image endpoints report the delivered dimensions (Kling); Ideogram
|
|
14422
|
+
// 4.6's File schema reports none, so its files are measured instead.
|
|
14423
|
+
width: import_zod23.z.number().int().positive().optional(),
|
|
14424
|
+
height: import_zod23.z.number().int().positive().optional()
|
|
14177
14425
|
})
|
|
14178
14426
|
).optional()
|
|
14179
14427
|
});
|
|
14428
|
+
var IDEOGRAM_46_ID = "ideogram/v4.6";
|
|
14429
|
+
var IDEOGRAM_46_4K_AREA = 2048 * 2048;
|
|
14430
|
+
function isIdeogram46(providerModelId) {
|
|
14431
|
+
return providerModelId.toLowerCase() === IDEOGRAM_46_ID;
|
|
14432
|
+
}
|
|
14433
|
+
function ideogramBilledSize(delivered, fallback) {
|
|
14434
|
+
const areas = delivered.flatMap((image) => {
|
|
14435
|
+
const size = image.width !== void 0 && image.height !== void 0 ? { width: image.width, height: image.height } : pngDimensions(image.bytes);
|
|
14436
|
+
return size === void 0 ? [] : [size.width * size.height];
|
|
14437
|
+
});
|
|
14438
|
+
if (areas.length === 0) return fallback;
|
|
14439
|
+
return Math.max(...areas) > IDEOGRAM_46_4K_AREA ? "4K" : "2K";
|
|
14440
|
+
}
|
|
14180
14441
|
async function collectFalImages(payload, ctx, req, label) {
|
|
14181
14442
|
const parsed = museImageResultSchema.safeParse(payload);
|
|
14182
14443
|
const images = parsed.success ? parsed.data.images ?? [] : [];
|
|
14183
|
-
const
|
|
14184
|
-
images.
|
|
14185
|
-
if (
|
|
14186
|
-
|
|
14444
|
+
const downloaded = await Promise.all(
|
|
14445
|
+
images.map(async (image) => {
|
|
14446
|
+
if (image.url === void 0) return void 0;
|
|
14447
|
+
const file = await decodeImage(ctx, image.url, image.content_type ?? void 0);
|
|
14448
|
+
return image.width !== void 0 && image.height !== void 0 ? { ...file, width: image.width, height: image.height } : file;
|
|
14187
14449
|
})
|
|
14188
14450
|
);
|
|
14189
|
-
|
|
14451
|
+
const delivered = downloaded.filter((image) => image !== void 0);
|
|
14452
|
+
if (delivered.length === 0) {
|
|
14190
14453
|
throw new ModelKitError({
|
|
14191
14454
|
code: "provider_rejected",
|
|
14192
14455
|
message: `${label} returned no image`,
|
|
@@ -14195,9 +14458,14 @@ async function collectFalImages(payload, ctx, req, label) {
|
|
|
14195
14458
|
retryable: false
|
|
14196
14459
|
});
|
|
14197
14460
|
}
|
|
14461
|
+
const usage6 = imageUsage(ctx, req, delivered.length);
|
|
14462
|
+
if (isIdeogram46(ctx.model.providerModelId)) {
|
|
14463
|
+
const billed = ideogramBilledSize(delivered, req.size);
|
|
14464
|
+
if (billed !== void 0) usage6.imageSize = billed;
|
|
14465
|
+
}
|
|
14198
14466
|
return {
|
|
14199
|
-
images:
|
|
14200
|
-
usage:
|
|
14467
|
+
images: delivered.map(({ bytes, mime }) => ({ bytes, mime })),
|
|
14468
|
+
usage: usage6,
|
|
14201
14469
|
raw: payload
|
|
14202
14470
|
};
|
|
14203
14471
|
}
|
|
@@ -14225,7 +14493,7 @@ async function generateMuseImage(req, ctx, deps) {
|
|
|
14225
14493
|
const payload = await runJob(ctx, deps, endpoint, input);
|
|
14226
14494
|
return collectFalImages(payload, ctx, req, "fal Meta Muse");
|
|
14227
14495
|
}
|
|
14228
|
-
var IDEOGRAM_MODEL_IDS = /* @__PURE__ */ new Set(["ideogram/v4.5"]);
|
|
14496
|
+
var IDEOGRAM_MODEL_IDS = /* @__PURE__ */ new Set(["ideogram/v4.5", "ideogram/v4.6"]);
|
|
14229
14497
|
function isIdeogram(providerModelId) {
|
|
14230
14498
|
return IDEOGRAM_MODEL_IDS.has(providerModelId.toLowerCase());
|
|
14231
14499
|
}
|
|
@@ -14244,10 +14512,26 @@ function parseExactSize(value) {
|
|
|
14244
14512
|
const match = /^(\d+)x(\d+)$/.exec(value ?? "");
|
|
14245
14513
|
return match ? { width: Number(match[1]), height: Number(match[2]) } : void 0;
|
|
14246
14514
|
}
|
|
14247
|
-
|
|
14515
|
+
var IDEOGRAM_46_SIZES = {
|
|
14516
|
+
"1:1": { "2K": "2048x2048", "4K": "4096x4096" },
|
|
14517
|
+
"16:9": { "2K": "2560x1440", "4K": "4096x2304" },
|
|
14518
|
+
"9:16": { "2K": "1440x2560", "4K": "2304x4096" },
|
|
14519
|
+
"4:3": { "2K": "2304x1728", "4K": "4096x3072" },
|
|
14520
|
+
"3:4": { "2K": "1728x2304", "4K": "3072x4096" },
|
|
14521
|
+
"3:2": { "2K": "2496x1664", "4K": "4096x2720" },
|
|
14522
|
+
"2:3": { "2K": "1664x2496", "4K": "2720x4096" },
|
|
14523
|
+
"5:4": { "2K": "2240x1792", "4K": "4096x3264" },
|
|
14524
|
+
"4:5": { "2K": "1792x2240", "4K": "3264x4096" }
|
|
14525
|
+
};
|
|
14526
|
+
function ideogramImageSize(ctx, req) {
|
|
14248
14527
|
const exact = parseExactSize(req.exactSize);
|
|
14249
14528
|
if (exact) return exact;
|
|
14250
14529
|
if (req.aspectRatio === void 0 || req.aspectRatio === "adaptive") return void 0;
|
|
14530
|
+
if (ctx.model.providerModelId.toLowerCase() === "ideogram/v4.6") {
|
|
14531
|
+
return parseExactSize(
|
|
14532
|
+
IDEOGRAM_46_SIZES[req.aspectRatio]?.[req.size === "4K" ? "4K" : "2K"]
|
|
14533
|
+
);
|
|
14534
|
+
}
|
|
14251
14535
|
return parseExactSize(IDEOGRAM_SIZES[req.aspectRatio]?.[req.size === "1K" ? "1K" : "2K"]);
|
|
14252
14536
|
}
|
|
14253
14537
|
async function generateIdeogramImage(req, ctx, deps) {
|
|
@@ -14259,7 +14543,7 @@ async function generateIdeogramImage(req, ctx, deps) {
|
|
|
14259
14543
|
let endpoint = id;
|
|
14260
14544
|
if (source2 === void 0) {
|
|
14261
14545
|
input.enable_prompt_expansion = false;
|
|
14262
|
-
const size = ideogramImageSize(req);
|
|
14546
|
+
const size = ideogramImageSize(ctx, req);
|
|
14263
14547
|
if (size) input.image_size = size;
|
|
14264
14548
|
} else {
|
|
14265
14549
|
endpoint = `${id}/edit`;
|