@shop-os/modelkit 0.29.0 → 0.31.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 +24 -0
- package/dist/catalog.cjs +181 -17
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.js +181 -17
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +261 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +261 -38
- 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"],
|
|
@@ -6212,6 +6271,76 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
6212
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."
|
|
6213
6272
|
},
|
|
6214
6273
|
capabilities: { lastFrameRequiresFirstFrame: true }
|
|
6274
|
+
},
|
|
6275
|
+
{
|
|
6276
|
+
// https://fal.ai/models/lightricks/ltx-2.5/text-to-video/pro/api (+ /image-to-video/pro):
|
|
6277
|
+
// a Lightricks partner endpoint on fal. Pro renders 720p and 1080p only, 6/8/10 s;
|
|
6278
|
+
// no safety checker field. Routing and tiers as LTX 2.3 (adapters/fal-ltx.ts).
|
|
6279
|
+
id: "ltx-2.5",
|
|
6280
|
+
aliases: ["ltx-2-5", "ltx25", "ltx-2.5-pro"],
|
|
6281
|
+
label: "LTX 2.5",
|
|
6282
|
+
type: "video",
|
|
6283
|
+
adapter: "fal",
|
|
6284
|
+
providerModelId: "lightricks/ltx-2.5/text-to-video/pro",
|
|
6285
|
+
lifecycle: "active",
|
|
6286
|
+
exposure: ["cowork", "space_builder"],
|
|
6287
|
+
constraints: {
|
|
6288
|
+
aspectRatios: ["adaptive", "16:9", "9:16"],
|
|
6289
|
+
resolutions: ["720p", "1080p"],
|
|
6290
|
+
durations: [6, 8, 10],
|
|
6291
|
+
supports: ["generateAudio", "lastFrame"],
|
|
6292
|
+
prompt: { referenceSyntax: "numbered", maxChars: 5e3 },
|
|
6293
|
+
audio: "optional"
|
|
6294
|
+
},
|
|
6295
|
+
defaults: {
|
|
6296
|
+
durationSeconds: 6,
|
|
6297
|
+
resolution: "1080p",
|
|
6298
|
+
aspectRatio: "adaptive",
|
|
6299
|
+
generateAudio: true
|
|
6300
|
+
},
|
|
6301
|
+
usage: { ...VIDEO_USAGE },
|
|
6302
|
+
pricingKind: "video_per_second",
|
|
6303
|
+
display: {
|
|
6304
|
+
provider: "lightricks",
|
|
6305
|
+
logo: LIGHTRICKS_LOGO,
|
|
6306
|
+
description: "Lightricks LTX 2.5 Pro text-to-video and start/end-frame image-to-video with native audio; 6, 8 or 10 seconds at 720p or 1080p in landscape or portrait."
|
|
6307
|
+
},
|
|
6308
|
+
capabilities: { lastFrameRequiresFirstFrame: true }
|
|
6309
|
+
},
|
|
6310
|
+
{
|
|
6311
|
+
// https://fal.ai/models/lightricks/ltx-2.5/text-to-video/fast/api (+ /image-to-video/fast):
|
|
6312
|
+
// 720p to 2160p, even durations 6-20 s; over 10 s is 720p or 1080p at 24/25 fps only
|
|
6313
|
+
// (the kit never sends fps, so the rule checks the tier).
|
|
6314
|
+
id: "ltx-2.5-fast",
|
|
6315
|
+
aliases: ["ltx-2-5-fast", "ltx25-fast"],
|
|
6316
|
+
label: "LTX 2.5 Fast",
|
|
6317
|
+
type: "video",
|
|
6318
|
+
adapter: "fal",
|
|
6319
|
+
providerModelId: "lightricks/ltx-2.5/text-to-video/fast",
|
|
6320
|
+
lifecycle: "active",
|
|
6321
|
+
exposure: ["cowork", "space_builder"],
|
|
6322
|
+
constraints: {
|
|
6323
|
+
aspectRatios: ["adaptive", "16:9", "9:16"],
|
|
6324
|
+
resolutions: ["720p", "1080p", "2k", "4k"],
|
|
6325
|
+
durations: [6, 8, 10, 12, 14, 16, 18, 20],
|
|
6326
|
+
supports: ["generateAudio", "lastFrame"],
|
|
6327
|
+
prompt: { referenceSyntax: "numbered", maxChars: 5e3 },
|
|
6328
|
+
audio: "optional"
|
|
6329
|
+
},
|
|
6330
|
+
defaults: {
|
|
6331
|
+
durationSeconds: 6,
|
|
6332
|
+
resolution: "1080p",
|
|
6333
|
+
aspectRatio: "adaptive",
|
|
6334
|
+
generateAudio: true
|
|
6335
|
+
},
|
|
6336
|
+
usage: { ...VIDEO_USAGE },
|
|
6337
|
+
pricingKind: "video_per_second",
|
|
6338
|
+
display: {
|
|
6339
|
+
provider: "lightricks",
|
|
6340
|
+
logo: LIGHTRICKS_LOGO,
|
|
6341
|
+
description: "Speed-optimized Lightricks LTX 2.5 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 720p or 1080p."
|
|
6342
|
+
},
|
|
6343
|
+
capabilities: { lastFrameRequiresFirstFrame: true }
|
|
6215
6344
|
}
|
|
6216
6345
|
];
|
|
6217
6346
|
|
|
@@ -9514,6 +9643,17 @@ function falImageSpec(providerModelId) {
|
|
|
9514
9643
|
}
|
|
9515
9644
|
var AREA_1K = 1024 * 1024;
|
|
9516
9645
|
var AREA_2K = 2048 * 2048;
|
|
9646
|
+
var IDEOGRAM_46_EXACT = {
|
|
9647
|
+
minSide: 256,
|
|
9648
|
+
maxSide: 4096,
|
|
9649
|
+
minArea: 256 * 256,
|
|
9650
|
+
maxArea: 4096 * 4096,
|
|
9651
|
+
multipleOf: 32,
|
|
9652
|
+
maxAspect: 6,
|
|
9653
|
+
minTier: "2K",
|
|
9654
|
+
topTier: "4K"
|
|
9655
|
+
};
|
|
9656
|
+
var IDEOGRAM_46_IDS = /* @__PURE__ */ new Set(["ideogram/v4.6"]);
|
|
9517
9657
|
function checkExactSize(exact, b) {
|
|
9518
9658
|
const match = /^(\d+)x(\d+)$/.exec(exact);
|
|
9519
9659
|
if (match === null) {
|
|
@@ -9537,7 +9677,7 @@ function checkExactSize(exact, b) {
|
|
|
9537
9677
|
return { ok: true, size: { width, height, tier: exactTier(area, b) } };
|
|
9538
9678
|
}
|
|
9539
9679
|
function exactTier(area, b) {
|
|
9540
|
-
if (area <= AREA_1K) return "1K";
|
|
9680
|
+
if (area <= AREA_1K) return b.minTier ?? "1K";
|
|
9541
9681
|
if (b.topTier === void 0 || area <= AREA_2K) return "2K";
|
|
9542
9682
|
return b.topTier;
|
|
9543
9683
|
}
|
|
@@ -9599,23 +9739,43 @@ function falImageProblem(spec, req) {
|
|
|
9599
9739
|
}
|
|
9600
9740
|
function falExactSize(spec, req) {
|
|
9601
9741
|
if (req.exactSize === void 0 || spec.exactSize === void 0) return void 0;
|
|
9602
|
-
|
|
9742
|
+
return checkedExactSize(req.exactSize, spec.exactSize);
|
|
9743
|
+
}
|
|
9744
|
+
function checkedExactSize(exact, bounds) {
|
|
9745
|
+
const check = checkExactSize(exact, bounds);
|
|
9603
9746
|
return check.ok ? check.size : void 0;
|
|
9604
9747
|
}
|
|
9748
|
+
function ideogram46ExactSize(model, req) {
|
|
9749
|
+
if (req.exactSize === void 0) return void 0;
|
|
9750
|
+
const check = checkExactSize(req.exactSize, IDEOGRAM_46_EXACT);
|
|
9751
|
+
if (check.ok) return check.size;
|
|
9752
|
+
throw new ModelKitError({
|
|
9753
|
+
code: "unsupported_option",
|
|
9754
|
+
message: `${model.label}: ${check.message}`,
|
|
9755
|
+
model: model.id,
|
|
9756
|
+
retryable: false
|
|
9757
|
+
});
|
|
9758
|
+
}
|
|
9605
9759
|
function applyFalImageRules(model, req, callerSize, warnings) {
|
|
9606
9760
|
if (model.adapter !== "fal" && model.adapter !== "alibaba") return;
|
|
9607
9761
|
const spec = falImageSpec(model.providerModelId);
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
|
|
9613
|
-
|
|
9614
|
-
|
|
9615
|
-
|
|
9616
|
-
|
|
9762
|
+
const ideogram46 = IDEOGRAM_46_IDS.has(model.providerModelId.toLowerCase());
|
|
9763
|
+
if (spec === void 0 && !ideogram46) return;
|
|
9764
|
+
let exact;
|
|
9765
|
+
if (spec === void 0) {
|
|
9766
|
+
exact = ideogram46ExactSize(model, req);
|
|
9767
|
+
} else {
|
|
9768
|
+
const problem = falImageProblem(spec, withPromptForResolve(req));
|
|
9769
|
+
if (problem !== void 0) {
|
|
9770
|
+
throw new ModelKitError({
|
|
9771
|
+
code: problem.code,
|
|
9772
|
+
message: problem.message,
|
|
9773
|
+
model: model.id,
|
|
9774
|
+
retryable: false
|
|
9775
|
+
});
|
|
9776
|
+
}
|
|
9777
|
+
exact = falExactSize(spec, req);
|
|
9617
9778
|
}
|
|
9618
|
-
const exact = falExactSize(spec, req);
|
|
9619
9779
|
if (exact === void 0) return;
|
|
9620
9780
|
if (callerSize !== void 0 && callerSize !== exact.tier) {
|
|
9621
9781
|
warnings.push({
|
|
@@ -10276,6 +10436,8 @@ var VIDU_Q4 = "fal-ai/vidu/q4";
|
|
|
10276
10436
|
var OMNIHUMAN_V2 = "bytedance/omnihuman/v2";
|
|
10277
10437
|
var LTX_T2V = "fal-ai/ltx-2.3/text-to-video";
|
|
10278
10438
|
var LTX_FAST_T2V = "fal-ai/ltx-2.3/text-to-video/fast";
|
|
10439
|
+
var LTX25_T2V = "lightricks/ltx-2.5/text-to-video/pro";
|
|
10440
|
+
var LTX25_FAST_T2V = "lightricks/ltx-2.5/text-to-video/fast";
|
|
10279
10441
|
var KLING_O3_IMAGE_CAP = 7;
|
|
10280
10442
|
var KLING_V4_IMAGE_CAP = 10;
|
|
10281
10443
|
var TURBO_AUDIO_MIN_SECONDS = 2;
|
|
@@ -10452,7 +10614,7 @@ function imageAndAudio(req, audioSeconds) {
|
|
|
10452
10614
|
}
|
|
10453
10615
|
return inputSeconds("audio", audio, audioSeconds);
|
|
10454
10616
|
}
|
|
10455
|
-
function ltx(
|
|
10617
|
+
function ltx(longTiers) {
|
|
10456
10618
|
return (req) => {
|
|
10457
10619
|
if (req.lastFrame !== void 0 && req.firstFrame === void 0) {
|
|
10458
10620
|
return missing("takes an end frame only together with a start frame");
|
|
@@ -10460,8 +10622,8 @@ function ltx(fast) {
|
|
|
10460
10622
|
if (count(req.referenceImages) + count(req.referenceVideos) + count(req.referenceAudios) > 0) {
|
|
10461
10623
|
return unsupported3("takes no reference images, videos or audio");
|
|
10462
10624
|
}
|
|
10463
|
-
if (
|
|
10464
|
-
return unsupported3(
|
|
10625
|
+
if (longTiers !== null && (req.durationSeconds ?? 6) > 10 && req.resolution !== void 0 && !longTiers.includes(req.resolution)) {
|
|
10626
|
+
return unsupported3(`renders over 10 s at ${longTiers.join(" or ")} only`);
|
|
10465
10627
|
}
|
|
10466
10628
|
return needsPrompt(req);
|
|
10467
10629
|
};
|
|
@@ -10490,8 +10652,10 @@ var RULES = new Map([
|
|
|
10490
10652
|
...AVATAR_AUDIO.map(
|
|
10491
10653
|
([id, limits]) => [id, (req) => imageAndAudio(req, limits)]
|
|
10492
10654
|
),
|
|
10493
|
-
[LTX_T2V, ltx(
|
|
10494
|
-
[LTX_FAST_T2V, ltx(
|
|
10655
|
+
[LTX_T2V, ltx(null)],
|
|
10656
|
+
[LTX_FAST_T2V, ltx(["1080p"])],
|
|
10657
|
+
[LTX25_T2V, ltx(null)],
|
|
10658
|
+
[LTX25_FAST_T2V, ltx(["720p", "1080p"])]
|
|
10495
10659
|
]);
|
|
10496
10660
|
function falVideoProblem(providerModelId, req) {
|
|
10497
10661
|
return RULES.get(providerModelId.toLowerCase())?.(req);
|
|
@@ -12582,6 +12746,17 @@ async function generateFalMask(req, ctx, run) {
|
|
|
12582
12746
|
return result;
|
|
12583
12747
|
}
|
|
12584
12748
|
|
|
12749
|
+
// src/adapters/png-size.ts
|
|
12750
|
+
var PNG_SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10];
|
|
12751
|
+
function pngDimensions(bytes) {
|
|
12752
|
+
if (bytes.length < 24) return void 0;
|
|
12753
|
+
if (PNG_SIGNATURE.some((byte, index) => bytes[index] !== byte)) return void 0;
|
|
12754
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
12755
|
+
const width = view.getUint32(16);
|
|
12756
|
+
const height = view.getUint32(20);
|
|
12757
|
+
return width > 0 && height > 0 ? { width, height } : void 0;
|
|
12758
|
+
}
|
|
12759
|
+
|
|
12585
12760
|
// src/adapters/fal-audio-plan.ts
|
|
12586
12761
|
import { z as z19 } from "zod";
|
|
12587
12762
|
var ELEVENLABS_MUSIC = FAL_AUDIO.elevenLabsMusic;
|
|
@@ -13686,6 +13861,10 @@ var LTX_T2V2 = "fal-ai/ltx-2.3/text-to-video";
|
|
|
13686
13861
|
var LTX_I2V = "fal-ai/ltx-2.3/image-to-video";
|
|
13687
13862
|
var LTX_FAST_T2V2 = "fal-ai/ltx-2.3/text-to-video/fast";
|
|
13688
13863
|
var LTX_FAST_I2V = "fal-ai/ltx-2.3/image-to-video/fast";
|
|
13864
|
+
var LTX25_T2V2 = "lightricks/ltx-2.5/text-to-video/pro";
|
|
13865
|
+
var LTX25_I2V = "lightricks/ltx-2.5/image-to-video/pro";
|
|
13866
|
+
var LTX25_FAST_T2V2 = "lightricks/ltx-2.5/text-to-video/fast";
|
|
13867
|
+
var LTX25_FAST_I2V = "lightricks/ltx-2.5/image-to-video/fast";
|
|
13689
13868
|
var LTX_TIERS = {
|
|
13690
13869
|
"360p": "360p",
|
|
13691
13870
|
"480p": "480p",
|
|
@@ -13695,7 +13874,13 @@ var LTX_TIERS = {
|
|
|
13695
13874
|
"2k": "1440p",
|
|
13696
13875
|
"4k": "2160p"
|
|
13697
13876
|
};
|
|
13698
|
-
|
|
13877
|
+
var I2V_OF = /* @__PURE__ */ new Map([
|
|
13878
|
+
[LTX_T2V2, LTX_I2V],
|
|
13879
|
+
[LTX_FAST_T2V2, LTX_FAST_I2V],
|
|
13880
|
+
[LTX25_T2V2, LTX25_I2V],
|
|
13881
|
+
[LTX25_FAST_T2V2, LTX25_FAST_I2V]
|
|
13882
|
+
]);
|
|
13883
|
+
function ltxGenerate(t2v, i2v, req, ctx) {
|
|
13699
13884
|
const resolution = resolutionOf2(req, ctx);
|
|
13700
13885
|
const duration = wholeSeconds(req, ctx);
|
|
13701
13886
|
const input = {
|
|
@@ -13704,9 +13889,11 @@ function ltxGenerate(fast, req, ctx) {
|
|
|
13704
13889
|
resolution: LTX_TIERS[resolution],
|
|
13705
13890
|
generate_audio: req.generateAudio ?? true
|
|
13706
13891
|
};
|
|
13707
|
-
if (req.safetyChecker !== void 0
|
|
13892
|
+
if (req.safetyChecker !== void 0 && t2v.startsWith("fal-ai/ltx-2.3/")) {
|
|
13893
|
+
input["enable_safety_checker"] = req.safetyChecker;
|
|
13894
|
+
}
|
|
13708
13895
|
const firstFrame = req.firstFrame;
|
|
13709
|
-
const endpoint = firstFrame === void 0 ?
|
|
13896
|
+
const endpoint = firstFrame === void 0 ? t2v : i2v;
|
|
13710
13897
|
if (firstFrame === void 0) {
|
|
13711
13898
|
const ratio = concreteRatio(req);
|
|
13712
13899
|
if (ratio !== void 0) input["aspect_ratio"] = ratio;
|
|
@@ -13719,17 +13906,13 @@ function ltxGenerate(fast, req, ctx) {
|
|
|
13719
13906
|
}
|
|
13720
13907
|
return { endpoint, input, resolution, seconds: requestedSeconds(duration) };
|
|
13721
13908
|
}
|
|
13722
|
-
var LTX_MODEL_IDS =
|
|
13723
|
-
LTX_T2V2,
|
|
13724
|
-
LTX_I2V,
|
|
13725
|
-
LTX_FAST_T2V2,
|
|
13726
|
-
LTX_FAST_I2V
|
|
13727
|
-
]);
|
|
13909
|
+
var LTX_MODEL_IDS = new Set([...I2V_OF.entries()].flat());
|
|
13728
13910
|
var ltxFamily = {
|
|
13729
13911
|
ids: LTX_MODEL_IDS,
|
|
13730
13912
|
plan(req, ctx) {
|
|
13731
13913
|
const id = ctx.model.providerModelId.toLowerCase();
|
|
13732
|
-
|
|
13914
|
+
const t2v = I2V_OF.has(id) ? id : [...I2V_OF.entries()].find(([, i2v]) => i2v === id)?.[0] ?? LTX_T2V2;
|
|
13915
|
+
return ltxGenerate(t2v, I2V_OF.get(t2v) ?? LTX_I2V, req, ctx);
|
|
13733
13916
|
}
|
|
13734
13917
|
};
|
|
13735
13918
|
|
|
@@ -14159,20 +14342,39 @@ var museImageResultSchema = z23.object({
|
|
|
14159
14342
|
images: z23.array(
|
|
14160
14343
|
z23.object({
|
|
14161
14344
|
url: z23.string().optional(),
|
|
14162
|
-
content_type: z23.string().nullable().optional()
|
|
14345
|
+
content_type: z23.string().nullable().optional(),
|
|
14346
|
+
// Some fal image endpoints report the delivered dimensions (Kling); Ideogram
|
|
14347
|
+
// 4.6's File schema reports none, so its files are measured instead.
|
|
14348
|
+
width: z23.number().int().positive().optional(),
|
|
14349
|
+
height: z23.number().int().positive().optional()
|
|
14163
14350
|
})
|
|
14164
14351
|
).optional()
|
|
14165
14352
|
});
|
|
14353
|
+
var IDEOGRAM_46_ID = "ideogram/v4.6";
|
|
14354
|
+
var IDEOGRAM_46_4K_AREA = 2048 * 2048;
|
|
14355
|
+
function isIdeogram46(providerModelId) {
|
|
14356
|
+
return providerModelId.toLowerCase() === IDEOGRAM_46_ID;
|
|
14357
|
+
}
|
|
14358
|
+
function ideogramBilledSize(delivered, fallback) {
|
|
14359
|
+
const areas = delivered.flatMap((image) => {
|
|
14360
|
+
const size = image.width !== void 0 && image.height !== void 0 ? { width: image.width, height: image.height } : pngDimensions(image.bytes);
|
|
14361
|
+
return size === void 0 ? [] : [size.width * size.height];
|
|
14362
|
+
});
|
|
14363
|
+
if (areas.length === 0) return fallback;
|
|
14364
|
+
return Math.max(...areas) > IDEOGRAM_46_4K_AREA ? "4K" : "2K";
|
|
14365
|
+
}
|
|
14166
14366
|
async function collectFalImages(payload, ctx, req, label) {
|
|
14167
14367
|
const parsed = museImageResultSchema.safeParse(payload);
|
|
14168
14368
|
const images = parsed.success ? parsed.data.images ?? [] : [];
|
|
14169
|
-
const
|
|
14170
|
-
images.
|
|
14171
|
-
if (
|
|
14172
|
-
|
|
14369
|
+
const downloaded = await Promise.all(
|
|
14370
|
+
images.map(async (image) => {
|
|
14371
|
+
if (image.url === void 0) return void 0;
|
|
14372
|
+
const file = await decodeImage(ctx, image.url, image.content_type ?? void 0);
|
|
14373
|
+
return image.width !== void 0 && image.height !== void 0 ? { ...file, width: image.width, height: image.height } : file;
|
|
14173
14374
|
})
|
|
14174
14375
|
);
|
|
14175
|
-
|
|
14376
|
+
const delivered = downloaded.filter((image) => image !== void 0);
|
|
14377
|
+
if (delivered.length === 0) {
|
|
14176
14378
|
throw new ModelKitError({
|
|
14177
14379
|
code: "provider_rejected",
|
|
14178
14380
|
message: `${label} returned no image`,
|
|
@@ -14181,9 +14383,14 @@ async function collectFalImages(payload, ctx, req, label) {
|
|
|
14181
14383
|
retryable: false
|
|
14182
14384
|
});
|
|
14183
14385
|
}
|
|
14386
|
+
const usage6 = imageUsage(ctx, req, delivered.length);
|
|
14387
|
+
if (isIdeogram46(ctx.model.providerModelId)) {
|
|
14388
|
+
const billed = ideogramBilledSize(delivered, req.size);
|
|
14389
|
+
if (billed !== void 0) usage6.imageSize = billed;
|
|
14390
|
+
}
|
|
14184
14391
|
return {
|
|
14185
|
-
images:
|
|
14186
|
-
usage:
|
|
14392
|
+
images: delivered.map(({ bytes, mime }) => ({ bytes, mime })),
|
|
14393
|
+
usage: usage6,
|
|
14187
14394
|
raw: payload
|
|
14188
14395
|
};
|
|
14189
14396
|
}
|
|
@@ -14211,7 +14418,7 @@ async function generateMuseImage(req, ctx, deps) {
|
|
|
14211
14418
|
const payload = await runJob(ctx, deps, endpoint, input);
|
|
14212
14419
|
return collectFalImages(payload, ctx, req, "fal Meta Muse");
|
|
14213
14420
|
}
|
|
14214
|
-
var IDEOGRAM_MODEL_IDS = /* @__PURE__ */ new Set(["ideogram/v4.5"]);
|
|
14421
|
+
var IDEOGRAM_MODEL_IDS = /* @__PURE__ */ new Set(["ideogram/v4.5", "ideogram/v4.6"]);
|
|
14215
14422
|
function isIdeogram(providerModelId) {
|
|
14216
14423
|
return IDEOGRAM_MODEL_IDS.has(providerModelId.toLowerCase());
|
|
14217
14424
|
}
|
|
@@ -14230,10 +14437,26 @@ function parseExactSize(value) {
|
|
|
14230
14437
|
const match = /^(\d+)x(\d+)$/.exec(value ?? "");
|
|
14231
14438
|
return match ? { width: Number(match[1]), height: Number(match[2]) } : void 0;
|
|
14232
14439
|
}
|
|
14233
|
-
|
|
14440
|
+
var IDEOGRAM_46_SIZES = {
|
|
14441
|
+
"1:1": { "2K": "2048x2048", "4K": "4096x4096" },
|
|
14442
|
+
"16:9": { "2K": "2560x1440", "4K": "4096x2304" },
|
|
14443
|
+
"9:16": { "2K": "1440x2560", "4K": "2304x4096" },
|
|
14444
|
+
"4:3": { "2K": "2304x1728", "4K": "4096x3072" },
|
|
14445
|
+
"3:4": { "2K": "1728x2304", "4K": "3072x4096" },
|
|
14446
|
+
"3:2": { "2K": "2496x1664", "4K": "4096x2720" },
|
|
14447
|
+
"2:3": { "2K": "1664x2496", "4K": "2720x4096" },
|
|
14448
|
+
"5:4": { "2K": "2240x1792", "4K": "4096x3264" },
|
|
14449
|
+
"4:5": { "2K": "1792x2240", "4K": "3264x4096" }
|
|
14450
|
+
};
|
|
14451
|
+
function ideogramImageSize(ctx, req) {
|
|
14234
14452
|
const exact = parseExactSize(req.exactSize);
|
|
14235
14453
|
if (exact) return exact;
|
|
14236
14454
|
if (req.aspectRatio === void 0 || req.aspectRatio === "adaptive") return void 0;
|
|
14455
|
+
if (ctx.model.providerModelId.toLowerCase() === "ideogram/v4.6") {
|
|
14456
|
+
return parseExactSize(
|
|
14457
|
+
IDEOGRAM_46_SIZES[req.aspectRatio]?.[req.size === "4K" ? "4K" : "2K"]
|
|
14458
|
+
);
|
|
14459
|
+
}
|
|
14237
14460
|
return parseExactSize(IDEOGRAM_SIZES[req.aspectRatio]?.[req.size === "1K" ? "1K" : "2K"]);
|
|
14238
14461
|
}
|
|
14239
14462
|
async function generateIdeogramImage(req, ctx, deps) {
|
|
@@ -14245,7 +14468,7 @@ async function generateIdeogramImage(req, ctx, deps) {
|
|
|
14245
14468
|
let endpoint = id;
|
|
14246
14469
|
if (source2 === void 0) {
|
|
14247
14470
|
input.enable_prompt_expansion = false;
|
|
14248
|
-
const size = ideogramImageSize(req);
|
|
14471
|
+
const size = ideogramImageSize(ctx, req);
|
|
14249
14472
|
if (size) input.image_size = size;
|
|
14250
14473
|
} else {
|
|
14251
14474
|
endpoint = `${id}/edit`;
|