@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/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"],
@@ -6369,6 +6428,76 @@ var VIDEO_FAMILY_MODELS = [
6369
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."
6370
6429
  },
6371
6430
  capabilities: { lastFrameRequiresFirstFrame: true }
6431
+ },
6432
+ {
6433
+ // https://fal.ai/models/lightricks/ltx-2.5/text-to-video/pro/api (+ /image-to-video/pro):
6434
+ // a Lightricks partner endpoint on fal. Pro renders 720p and 1080p only, 6/8/10 s;
6435
+ // no safety checker field. Routing and tiers as LTX 2.3 (adapters/fal-ltx.ts).
6436
+ id: "ltx-2.5",
6437
+ aliases: ["ltx-2-5", "ltx25", "ltx-2.5-pro"],
6438
+ label: "LTX 2.5",
6439
+ type: "video",
6440
+ adapter: "fal",
6441
+ providerModelId: "lightricks/ltx-2.5/text-to-video/pro",
6442
+ lifecycle: "active",
6443
+ exposure: ["cowork", "space_builder"],
6444
+ constraints: {
6445
+ aspectRatios: ["adaptive", "16:9", "9:16"],
6446
+ resolutions: ["720p", "1080p"],
6447
+ durations: [6, 8, 10],
6448
+ supports: ["generateAudio", "lastFrame"],
6449
+ prompt: { referenceSyntax: "numbered", maxChars: 5e3 },
6450
+ audio: "optional"
6451
+ },
6452
+ defaults: {
6453
+ durationSeconds: 6,
6454
+ resolution: "1080p",
6455
+ aspectRatio: "adaptive",
6456
+ generateAudio: true
6457
+ },
6458
+ usage: { ...VIDEO_USAGE },
6459
+ pricingKind: "video_per_second",
6460
+ display: {
6461
+ provider: "lightricks",
6462
+ logo: LIGHTRICKS_LOGO,
6463
+ 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."
6464
+ },
6465
+ capabilities: { lastFrameRequiresFirstFrame: true }
6466
+ },
6467
+ {
6468
+ // https://fal.ai/models/lightricks/ltx-2.5/text-to-video/fast/api (+ /image-to-video/fast):
6469
+ // 720p to 2160p, even durations 6-20 s; over 10 s is 720p or 1080p at 24/25 fps only
6470
+ // (the kit never sends fps, so the rule checks the tier).
6471
+ id: "ltx-2.5-fast",
6472
+ aliases: ["ltx-2-5-fast", "ltx25-fast"],
6473
+ label: "LTX 2.5 Fast",
6474
+ type: "video",
6475
+ adapter: "fal",
6476
+ providerModelId: "lightricks/ltx-2.5/text-to-video/fast",
6477
+ lifecycle: "active",
6478
+ exposure: ["cowork", "space_builder"],
6479
+ constraints: {
6480
+ aspectRatios: ["adaptive", "16:9", "9:16"],
6481
+ resolutions: ["720p", "1080p", "2k", "4k"],
6482
+ durations: [6, 8, 10, 12, 14, 16, 18, 20],
6483
+ supports: ["generateAudio", "lastFrame"],
6484
+ prompt: { referenceSyntax: "numbered", maxChars: 5e3 },
6485
+ audio: "optional"
6486
+ },
6487
+ defaults: {
6488
+ durationSeconds: 6,
6489
+ resolution: "1080p",
6490
+ aspectRatio: "adaptive",
6491
+ generateAudio: true
6492
+ },
6493
+ usage: { ...VIDEO_USAGE },
6494
+ pricingKind: "video_per_second",
6495
+ display: {
6496
+ provider: "lightricks",
6497
+ logo: LIGHTRICKS_LOGO,
6498
+ 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."
6499
+ },
6500
+ capabilities: { lastFrameRequiresFirstFrame: true }
6372
6501
  }
6373
6502
  ];
6374
6503
 
@@ -9671,6 +9800,17 @@ function falImageSpec(providerModelId) {
9671
9800
  }
9672
9801
  var AREA_1K = 1024 * 1024;
9673
9802
  var AREA_2K = 2048 * 2048;
9803
+ var IDEOGRAM_46_EXACT = {
9804
+ minSide: 256,
9805
+ maxSide: 4096,
9806
+ minArea: 256 * 256,
9807
+ maxArea: 4096 * 4096,
9808
+ multipleOf: 32,
9809
+ maxAspect: 6,
9810
+ minTier: "2K",
9811
+ topTier: "4K"
9812
+ };
9813
+ var IDEOGRAM_46_IDS = /* @__PURE__ */ new Set(["ideogram/v4.6"]);
9674
9814
  function checkExactSize(exact, b) {
9675
9815
  const match = /^(\d+)x(\d+)$/.exec(exact);
9676
9816
  if (match === null) {
@@ -9694,7 +9834,7 @@ function checkExactSize(exact, b) {
9694
9834
  return { ok: true, size: { width, height, tier: exactTier(area, b) } };
9695
9835
  }
9696
9836
  function exactTier(area, b) {
9697
- if (area <= AREA_1K) return "1K";
9837
+ if (area <= AREA_1K) return b.minTier ?? "1K";
9698
9838
  if (b.topTier === void 0 || area <= AREA_2K) return "2K";
9699
9839
  return b.topTier;
9700
9840
  }
@@ -9756,23 +9896,43 @@ function falImageProblem(spec, req) {
9756
9896
  }
9757
9897
  function falExactSize(spec, req) {
9758
9898
  if (req.exactSize === void 0 || spec.exactSize === void 0) return void 0;
9759
- const check = checkExactSize(req.exactSize, spec.exactSize);
9899
+ return checkedExactSize(req.exactSize, spec.exactSize);
9900
+ }
9901
+ function checkedExactSize(exact, bounds) {
9902
+ const check = checkExactSize(exact, bounds);
9760
9903
  return check.ok ? check.size : void 0;
9761
9904
  }
9905
+ function ideogram46ExactSize(model, req) {
9906
+ if (req.exactSize === void 0) return void 0;
9907
+ const check = checkExactSize(req.exactSize, IDEOGRAM_46_EXACT);
9908
+ if (check.ok) return check.size;
9909
+ throw new ModelKitError({
9910
+ code: "unsupported_option",
9911
+ message: `${model.label}: ${check.message}`,
9912
+ model: model.id,
9913
+ retryable: false
9914
+ });
9915
+ }
9762
9916
  function applyFalImageRules(model, req, callerSize, warnings) {
9763
9917
  if (model.adapter !== "fal" && model.adapter !== "alibaba") return;
9764
9918
  const spec = falImageSpec(model.providerModelId);
9765
- if (spec === void 0) return;
9766
- const problem = falImageProblem(spec, withPromptForResolve(req));
9767
- if (problem !== void 0) {
9768
- throw new ModelKitError({
9769
- code: problem.code,
9770
- message: problem.message,
9771
- model: model.id,
9772
- retryable: false
9773
- });
9919
+ const ideogram46 = IDEOGRAM_46_IDS.has(model.providerModelId.toLowerCase());
9920
+ if (spec === void 0 && !ideogram46) return;
9921
+ let exact;
9922
+ if (spec === void 0) {
9923
+ exact = ideogram46ExactSize(model, req);
9924
+ } else {
9925
+ const problem = falImageProblem(spec, withPromptForResolve(req));
9926
+ if (problem !== void 0) {
9927
+ throw new ModelKitError({
9928
+ code: problem.code,
9929
+ message: problem.message,
9930
+ model: model.id,
9931
+ retryable: false
9932
+ });
9933
+ }
9934
+ exact = falExactSize(spec, req);
9774
9935
  }
9775
- const exact = falExactSize(spec, req);
9776
9936
  if (exact === void 0) return;
9777
9937
  if (callerSize !== void 0 && callerSize !== exact.tier) {
9778
9938
  warnings.push({
@@ -10433,6 +10593,8 @@ var VIDU_Q4 = "fal-ai/vidu/q4";
10433
10593
  var OMNIHUMAN_V2 = "bytedance/omnihuman/v2";
10434
10594
  var LTX_T2V = "fal-ai/ltx-2.3/text-to-video";
10435
10595
  var LTX_FAST_T2V = "fal-ai/ltx-2.3/text-to-video/fast";
10596
+ var LTX25_T2V = "lightricks/ltx-2.5/text-to-video/pro";
10597
+ var LTX25_FAST_T2V = "lightricks/ltx-2.5/text-to-video/fast";
10436
10598
  var KLING_O3_IMAGE_CAP = 7;
10437
10599
  var KLING_V4_IMAGE_CAP = 10;
10438
10600
  var TURBO_AUDIO_MIN_SECONDS = 2;
@@ -10609,7 +10771,7 @@ function imageAndAudio(req, audioSeconds) {
10609
10771
  }
10610
10772
  return inputSeconds("audio", audio, audioSeconds);
10611
10773
  }
10612
- function ltx(fast) {
10774
+ function ltx(longTiers) {
10613
10775
  return (req) => {
10614
10776
  if (req.lastFrame !== void 0 && req.firstFrame === void 0) {
10615
10777
  return missing("takes an end frame only together with a start frame");
@@ -10617,8 +10779,8 @@ function ltx(fast) {
10617
10779
  if (count(req.referenceImages) + count(req.referenceVideos) + count(req.referenceAudios) > 0) {
10618
10780
  return unsupported3("takes no reference images, videos or audio");
10619
10781
  }
10620
- if (fast && (req.durationSeconds ?? 6) > 10 && req.resolution !== void 0 && req.resolution !== "1080p") {
10621
- return unsupported3("renders over 10 s at 1080p only");
10782
+ if (longTiers !== null && (req.durationSeconds ?? 6) > 10 && req.resolution !== void 0 && !longTiers.includes(req.resolution)) {
10783
+ return unsupported3(`renders over 10 s at ${longTiers.join(" or ")} only`);
10622
10784
  }
10623
10785
  return needsPrompt(req);
10624
10786
  };
@@ -10647,8 +10809,10 @@ var RULES = new Map([
10647
10809
  ...AVATAR_AUDIO.map(
10648
10810
  ([id, limits]) => [id, (req) => imageAndAudio(req, limits)]
10649
10811
  ),
10650
- [LTX_T2V, ltx(false)],
10651
- [LTX_FAST_T2V, ltx(true)]
10812
+ [LTX_T2V, ltx(null)],
10813
+ [LTX_FAST_T2V, ltx(["1080p"])],
10814
+ [LTX25_T2V, ltx(null)],
10815
+ [LTX25_FAST_T2V, ltx(["720p", "1080p"])]
10652
10816
  ]);
10653
10817
  function falVideoProblem(providerModelId, req) {
10654
10818
  return RULES.get(providerModelId.toLowerCase())?.(req);
@@ -12739,6 +12903,17 @@ async function generateFalMask(req, ctx, run) {
12739
12903
  return result;
12740
12904
  }
12741
12905
 
12906
+ // src/adapters/png-size.ts
12907
+ var PNG_SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10];
12908
+ function pngDimensions(bytes) {
12909
+ if (bytes.length < 24) return void 0;
12910
+ if (PNG_SIGNATURE.some((byte, index) => bytes[index] !== byte)) return void 0;
12911
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
12912
+ const width = view.getUint32(16);
12913
+ const height = view.getUint32(20);
12914
+ return width > 0 && height > 0 ? { width, height } : void 0;
12915
+ }
12916
+
12742
12917
  // src/adapters/fal-audio-plan.ts
12743
12918
  var import_zod19 = require("zod");
12744
12919
  var ELEVENLABS_MUSIC = FAL_AUDIO.elevenLabsMusic;
@@ -13843,6 +14018,10 @@ var LTX_T2V2 = "fal-ai/ltx-2.3/text-to-video";
13843
14018
  var LTX_I2V = "fal-ai/ltx-2.3/image-to-video";
13844
14019
  var LTX_FAST_T2V2 = "fal-ai/ltx-2.3/text-to-video/fast";
13845
14020
  var LTX_FAST_I2V = "fal-ai/ltx-2.3/image-to-video/fast";
14021
+ var LTX25_T2V2 = "lightricks/ltx-2.5/text-to-video/pro";
14022
+ var LTX25_I2V = "lightricks/ltx-2.5/image-to-video/pro";
14023
+ var LTX25_FAST_T2V2 = "lightricks/ltx-2.5/text-to-video/fast";
14024
+ var LTX25_FAST_I2V = "lightricks/ltx-2.5/image-to-video/fast";
13846
14025
  var LTX_TIERS = {
13847
14026
  "360p": "360p",
13848
14027
  "480p": "480p",
@@ -13852,7 +14031,13 @@ var LTX_TIERS = {
13852
14031
  "2k": "1440p",
13853
14032
  "4k": "2160p"
13854
14033
  };
13855
- function ltxGenerate(fast, req, ctx) {
14034
+ var I2V_OF = /* @__PURE__ */ new Map([
14035
+ [LTX_T2V2, LTX_I2V],
14036
+ [LTX_FAST_T2V2, LTX_FAST_I2V],
14037
+ [LTX25_T2V2, LTX25_I2V],
14038
+ [LTX25_FAST_T2V2, LTX25_FAST_I2V]
14039
+ ]);
14040
+ function ltxGenerate(t2v, i2v, req, ctx) {
13856
14041
  const resolution = resolutionOf2(req, ctx);
13857
14042
  const duration = wholeSeconds(req, ctx);
13858
14043
  const input = {
@@ -13861,9 +14046,11 @@ function ltxGenerate(fast, req, ctx) {
13861
14046
  resolution: LTX_TIERS[resolution],
13862
14047
  generate_audio: req.generateAudio ?? true
13863
14048
  };
13864
- if (req.safetyChecker !== void 0) input["enable_safety_checker"] = req.safetyChecker;
14049
+ if (req.safetyChecker !== void 0 && t2v.startsWith("fal-ai/ltx-2.3/")) {
14050
+ input["enable_safety_checker"] = req.safetyChecker;
14051
+ }
13865
14052
  const firstFrame = req.firstFrame;
13866
- const endpoint = firstFrame === void 0 ? fast ? LTX_FAST_T2V2 : LTX_T2V2 : fast ? LTX_FAST_I2V : LTX_I2V;
14053
+ const endpoint = firstFrame === void 0 ? t2v : i2v;
13867
14054
  if (firstFrame === void 0) {
13868
14055
  const ratio = concreteRatio(req);
13869
14056
  if (ratio !== void 0) input["aspect_ratio"] = ratio;
@@ -13876,17 +14063,13 @@ function ltxGenerate(fast, req, ctx) {
13876
14063
  }
13877
14064
  return { endpoint, input, resolution, seconds: requestedSeconds(duration) };
13878
14065
  }
13879
- var LTX_MODEL_IDS = /* @__PURE__ */ new Set([
13880
- LTX_T2V2,
13881
- LTX_I2V,
13882
- LTX_FAST_T2V2,
13883
- LTX_FAST_I2V
13884
- ]);
14066
+ var LTX_MODEL_IDS = new Set([...I2V_OF.entries()].flat());
13885
14067
  var ltxFamily = {
13886
14068
  ids: LTX_MODEL_IDS,
13887
14069
  plan(req, ctx) {
13888
14070
  const id = ctx.model.providerModelId.toLowerCase();
13889
- return ltxGenerate(id === LTX_FAST_T2V2 || id === LTX_FAST_I2V, req, ctx);
14071
+ const t2v = I2V_OF.has(id) ? id : [...I2V_OF.entries()].find(([, i2v]) => i2v === id)?.[0] ?? LTX_T2V2;
14072
+ return ltxGenerate(t2v, I2V_OF.get(t2v) ?? LTX_I2V, req, ctx);
13890
14073
  }
13891
14074
  };
13892
14075
 
@@ -14316,20 +14499,39 @@ var museImageResultSchema = import_zod23.z.object({
14316
14499
  images: import_zod23.z.array(
14317
14500
  import_zod23.z.object({
14318
14501
  url: import_zod23.z.string().optional(),
14319
- content_type: import_zod23.z.string().nullable().optional()
14502
+ content_type: import_zod23.z.string().nullable().optional(),
14503
+ // Some fal image endpoints report the delivered dimensions (Kling); Ideogram
14504
+ // 4.6's File schema reports none, so its files are measured instead.
14505
+ width: import_zod23.z.number().int().positive().optional(),
14506
+ height: import_zod23.z.number().int().positive().optional()
14320
14507
  })
14321
14508
  ).optional()
14322
14509
  });
14510
+ var IDEOGRAM_46_ID = "ideogram/v4.6";
14511
+ var IDEOGRAM_46_4K_AREA = 2048 * 2048;
14512
+ function isIdeogram46(providerModelId) {
14513
+ return providerModelId.toLowerCase() === IDEOGRAM_46_ID;
14514
+ }
14515
+ function ideogramBilledSize(delivered, fallback) {
14516
+ const areas = delivered.flatMap((image) => {
14517
+ const size = image.width !== void 0 && image.height !== void 0 ? { width: image.width, height: image.height } : pngDimensions(image.bytes);
14518
+ return size === void 0 ? [] : [size.width * size.height];
14519
+ });
14520
+ if (areas.length === 0) return fallback;
14521
+ return Math.max(...areas) > IDEOGRAM_46_4K_AREA ? "4K" : "2K";
14522
+ }
14323
14523
  async function collectFalImages(payload, ctx, req, label) {
14324
14524
  const parsed = museImageResultSchema.safeParse(payload);
14325
14525
  const images = parsed.success ? parsed.data.images ?? [] : [];
14326
- const files = await Promise.all(
14327
- images.flatMap((img) => {
14328
- if (img.url === void 0) return [];
14329
- return [decodeImage(ctx, img.url, img.content_type ?? void 0)];
14526
+ const downloaded = await Promise.all(
14527
+ images.map(async (image) => {
14528
+ if (image.url === void 0) return void 0;
14529
+ const file = await decodeImage(ctx, image.url, image.content_type ?? void 0);
14530
+ return image.width !== void 0 && image.height !== void 0 ? { ...file, width: image.width, height: image.height } : file;
14330
14531
  })
14331
14532
  );
14332
- if (files.length === 0) {
14533
+ const delivered = downloaded.filter((image) => image !== void 0);
14534
+ if (delivered.length === 0) {
14333
14535
  throw new ModelKitError({
14334
14536
  code: "provider_rejected",
14335
14537
  message: `${label} returned no image`,
@@ -14338,9 +14540,14 @@ async function collectFalImages(payload, ctx, req, label) {
14338
14540
  retryable: false
14339
14541
  });
14340
14542
  }
14543
+ const usage6 = imageUsage(ctx, req, delivered.length);
14544
+ if (isIdeogram46(ctx.model.providerModelId)) {
14545
+ const billed = ideogramBilledSize(delivered, req.size);
14546
+ if (billed !== void 0) usage6.imageSize = billed;
14547
+ }
14341
14548
  return {
14342
- images: files.map((f) => ({ bytes: f.bytes, mime: f.mime })),
14343
- usage: imageUsage(ctx, req, files.length),
14549
+ images: delivered.map(({ bytes, mime }) => ({ bytes, mime })),
14550
+ usage: usage6,
14344
14551
  raw: payload
14345
14552
  };
14346
14553
  }
@@ -14368,7 +14575,7 @@ async function generateMuseImage(req, ctx, deps) {
14368
14575
  const payload = await runJob(ctx, deps, endpoint, input);
14369
14576
  return collectFalImages(payload, ctx, req, "fal Meta Muse");
14370
14577
  }
14371
- var IDEOGRAM_MODEL_IDS = /* @__PURE__ */ new Set(["ideogram/v4.5"]);
14578
+ var IDEOGRAM_MODEL_IDS = /* @__PURE__ */ new Set(["ideogram/v4.5", "ideogram/v4.6"]);
14372
14579
  function isIdeogram(providerModelId) {
14373
14580
  return IDEOGRAM_MODEL_IDS.has(providerModelId.toLowerCase());
14374
14581
  }
@@ -14387,10 +14594,26 @@ function parseExactSize(value) {
14387
14594
  const match = /^(\d+)x(\d+)$/.exec(value ?? "");
14388
14595
  return match ? { width: Number(match[1]), height: Number(match[2]) } : void 0;
14389
14596
  }
14390
- function ideogramImageSize(req) {
14597
+ var IDEOGRAM_46_SIZES = {
14598
+ "1:1": { "2K": "2048x2048", "4K": "4096x4096" },
14599
+ "16:9": { "2K": "2560x1440", "4K": "4096x2304" },
14600
+ "9:16": { "2K": "1440x2560", "4K": "2304x4096" },
14601
+ "4:3": { "2K": "2304x1728", "4K": "4096x3072" },
14602
+ "3:4": { "2K": "1728x2304", "4K": "3072x4096" },
14603
+ "3:2": { "2K": "2496x1664", "4K": "4096x2720" },
14604
+ "2:3": { "2K": "1664x2496", "4K": "2720x4096" },
14605
+ "5:4": { "2K": "2240x1792", "4K": "4096x3264" },
14606
+ "4:5": { "2K": "1792x2240", "4K": "3264x4096" }
14607
+ };
14608
+ function ideogramImageSize(ctx, req) {
14391
14609
  const exact = parseExactSize(req.exactSize);
14392
14610
  if (exact) return exact;
14393
14611
  if (req.aspectRatio === void 0 || req.aspectRatio === "adaptive") return void 0;
14612
+ if (ctx.model.providerModelId.toLowerCase() === "ideogram/v4.6") {
14613
+ return parseExactSize(
14614
+ IDEOGRAM_46_SIZES[req.aspectRatio]?.[req.size === "4K" ? "4K" : "2K"]
14615
+ );
14616
+ }
14394
14617
  return parseExactSize(IDEOGRAM_SIZES[req.aspectRatio]?.[req.size === "1K" ? "1K" : "2K"]);
14395
14618
  }
14396
14619
  async function generateIdeogramImage(req, ctx, deps) {
@@ -14402,7 +14625,7 @@ async function generateIdeogramImage(req, ctx, deps) {
14402
14625
  let endpoint = id;
14403
14626
  if (source2 === void 0) {
14404
14627
  input.enable_prompt_expansion = false;
14405
- const size = ideogramImageSize(req);
14628
+ const size = ideogramImageSize(ctx, req);
14406
14629
  if (size) input.image_size = size;
14407
14630
  } else {
14408
14631
  endpoint = `${id}/edit`;