@nodaro/shared 3.59.0 → 3.60.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.
Files changed (144) hide show
  1. package/dist/{chunk-QE7W4YIK.cjs → chunk-5G23AJBU.cjs} +6 -6
  2. package/dist/{chunk-QE7W4YIK.cjs.map → chunk-5G23AJBU.cjs.map} +1 -1
  3. package/dist/{chunk-DKZGLIFW.cjs → chunk-5HK5Z5OB.cjs} +4 -4
  4. package/dist/{chunk-DKZGLIFW.cjs.map → chunk-5HK5Z5OB.cjs.map} +1 -1
  5. package/dist/{chunk-RSXQOFM7.cjs → chunk-5Y42RIGY.cjs} +8 -8
  6. package/dist/{chunk-RSXQOFM7.cjs.map → chunk-5Y42RIGY.cjs.map} +1 -1
  7. package/dist/{chunk-FHCMYGBV.js → chunk-6AJOTEVC.js} +3 -3
  8. package/dist/{chunk-FHCMYGBV.js.map → chunk-6AJOTEVC.js.map} +1 -1
  9. package/dist/{chunk-ZVUVSD5X.js → chunk-6Q6SI7AG.js} +3 -3
  10. package/dist/{chunk-ZVUVSD5X.js.map → chunk-6Q6SI7AG.js.map} +1 -1
  11. package/dist/{chunk-V3NONYLA.cjs → chunk-A6HRY3WF.cjs} +269 -18
  12. package/dist/chunk-A6HRY3WF.cjs.map +1 -0
  13. package/dist/{chunk-D574HZ35.cjs → chunk-AXT7YNOR.cjs} +51 -51
  14. package/dist/{chunk-D574HZ35.cjs.map → chunk-AXT7YNOR.cjs.map} +1 -1
  15. package/dist/{chunk-TA7ODVYJ.js → chunk-AZGONXWV.js} +4 -4
  16. package/dist/{chunk-TA7ODVYJ.js.map → chunk-AZGONXWV.js.map} +1 -1
  17. package/dist/{chunk-OFL4UH6L.cjs → chunk-BDXXOEBZ.cjs} +80 -57
  18. package/dist/chunk-BDXXOEBZ.cjs.map +1 -0
  19. package/dist/{chunk-NSZTHJZJ.cjs → chunk-BGIJO5V4.cjs} +39 -39
  20. package/dist/{chunk-NSZTHJZJ.cjs.map → chunk-BGIJO5V4.cjs.map} +1 -1
  21. package/dist/{chunk-NZRG5CXQ.cjs → chunk-BLJUCPMV.cjs} +5 -2
  22. package/dist/chunk-BLJUCPMV.cjs.map +1 -0
  23. package/dist/{chunk-NHZWVKGV.cjs → chunk-BXNPO3PL.cjs} +8 -8
  24. package/dist/{chunk-NHZWVKGV.cjs.map → chunk-BXNPO3PL.cjs.map} +1 -1
  25. package/dist/{chunk-UPD7W2KJ.cjs → chunk-CIOXUPCJ.cjs} +12 -12
  26. package/dist/{chunk-UPD7W2KJ.cjs.map → chunk-CIOXUPCJ.cjs.map} +1 -1
  27. package/dist/{chunk-YE4EDT57.cjs → chunk-DQIJPDHC.cjs} +11 -11
  28. package/dist/{chunk-YE4EDT57.cjs.map → chunk-DQIJPDHC.cjs.map} +1 -1
  29. package/dist/{chunk-UMPZR56R.js → chunk-DS2TOM32.js} +3 -3
  30. package/dist/{chunk-UMPZR56R.js.map → chunk-DS2TOM32.js.map} +1 -1
  31. package/dist/{chunk-YSEJOJNQ.js → chunk-EN2YI5TV.js} +3 -3
  32. package/dist/{chunk-YSEJOJNQ.js.map → chunk-EN2YI5TV.js.map} +1 -1
  33. package/dist/{chunk-ZU56AMFK.js → chunk-G6GMY5BC.js} +20 -4
  34. package/dist/chunk-G6GMY5BC.js.map +1 -0
  35. package/dist/chunk-G7ZYZQKO.cjs +27 -0
  36. package/dist/{chunk-6VXDW2U3.cjs.map → chunk-G7ZYZQKO.cjs.map} +1 -1
  37. package/dist/{chunk-PEATSEAD.cjs → chunk-GNPJ2JLE.cjs} +6 -6
  38. package/dist/{chunk-PEATSEAD.cjs.map → chunk-GNPJ2JLE.cjs.map} +1 -1
  39. package/dist/{chunk-VLQW4CVW.cjs → chunk-GWBQ3GPO.cjs} +41 -21
  40. package/dist/chunk-GWBQ3GPO.cjs.map +1 -0
  41. package/dist/{chunk-P7KSB5T6.cjs → chunk-HDHLZK7C.cjs} +5 -5
  42. package/dist/{chunk-P7KSB5T6.cjs.map → chunk-HDHLZK7C.cjs.map} +1 -1
  43. package/dist/{chunk-QLLR7GUY.cjs → chunk-HNEF2N5C.cjs} +5 -5
  44. package/dist/{chunk-QLLR7GUY.cjs.map → chunk-HNEF2N5C.cjs.map} +1 -1
  45. package/dist/{chunk-7JM5EZF3.cjs → chunk-HOKWJXHA.cjs} +13 -13
  46. package/dist/{chunk-7JM5EZF3.cjs.map → chunk-HOKWJXHA.cjs.map} +1 -1
  47. package/dist/{chunk-RGBNOCIO.js → chunk-ICDLYU4I.js} +9 -9
  48. package/dist/{chunk-RGBNOCIO.js.map → chunk-ICDLYU4I.js.map} +1 -1
  49. package/dist/{chunk-FJCRWDU5.js → chunk-IV6IDECY.js} +4 -4
  50. package/dist/{chunk-FJCRWDU5.js.map → chunk-IV6IDECY.js.map} +1 -1
  51. package/dist/{chunk-PIX4OCCQ.js → chunk-JKZVRKN3.js} +36 -14
  52. package/dist/chunk-JKZVRKN3.js.map +1 -0
  53. package/dist/{chunk-MTXVODG3.js → chunk-KJZVQIN4.js} +3 -3
  54. package/dist/{chunk-MTXVODG3.js.map → chunk-KJZVQIN4.js.map} +1 -1
  55. package/dist/{chunk-2VQHPILW.js → chunk-KOLC7AF2.js} +262 -19
  56. package/dist/chunk-KOLC7AF2.js.map +1 -0
  57. package/dist/{chunk-IP7QOHWQ.js → chunk-LN3EVFRS.js} +5 -5
  58. package/dist/{chunk-IP7QOHWQ.js.map → chunk-LN3EVFRS.js.map} +1 -1
  59. package/dist/{chunk-EO4W4MA3.js → chunk-MHY47BLL.js} +4 -4
  60. package/dist/{chunk-EO4W4MA3.js.map → chunk-MHY47BLL.js.map} +1 -1
  61. package/dist/{chunk-AWS4BWEC.js → chunk-Q6IES3U2.js} +5 -2
  62. package/dist/chunk-Q6IES3U2.js.map +1 -0
  63. package/dist/{chunk-62RC6K62.cjs → chunk-RRPPXZ36.cjs} +4 -4
  64. package/dist/{chunk-62RC6K62.cjs.map → chunk-RRPPXZ36.cjs.map} +1 -1
  65. package/dist/{chunk-3R2KVYXN.js → chunk-SCYBGTX6.js} +3 -3
  66. package/dist/{chunk-3R2KVYXN.js.map → chunk-SCYBGTX6.js.map} +1 -1
  67. package/dist/{chunk-K4L4G76I.cjs → chunk-SKFJIFEV.cjs} +21 -21
  68. package/dist/{chunk-K4L4G76I.cjs.map → chunk-SKFJIFEV.cjs.map} +1 -1
  69. package/dist/{chunk-2S7YYCRT.js → chunk-TZ42IVSF.js} +4 -4
  70. package/dist/{chunk-2S7YYCRT.js.map → chunk-TZ42IVSF.js.map} +1 -1
  71. package/dist/{chunk-PIEMWFSJ.js → chunk-URLDVK67.js} +3 -3
  72. package/dist/{chunk-PIEMWFSJ.js.map → chunk-URLDVK67.js.map} +1 -1
  73. package/dist/{chunk-IOET54EV.js → chunk-VB2ARGQ6.js} +35 -3
  74. package/dist/chunk-VB2ARGQ6.js.map +1 -0
  75. package/dist/{chunk-VOZI5F7V.js → chunk-VYQ25YQF.js} +3 -3
  76. package/dist/{chunk-VOZI5F7V.js.map → chunk-VYQ25YQF.js.map} +1 -1
  77. package/dist/{chunk-QSWUSXRL.cjs → chunk-WGKAOUEQ.cjs} +41 -2
  78. package/dist/chunk-WGKAOUEQ.cjs.map +1 -0
  79. package/dist/{chunk-ORJ5HQAB.js → chunk-YHVEZVAO.js} +4 -4
  80. package/dist/{chunk-ORJ5HQAB.js.map → chunk-YHVEZVAO.js.map} +1 -1
  81. package/dist/entries/apps.cjs +43 -43
  82. package/dist/entries/apps.js +8 -8
  83. package/dist/entries/credits.cjs +155 -151
  84. package/dist/entries/credits.d.cts +32 -3
  85. package/dist/entries/credits.d.ts +32 -3
  86. package/dist/entries/credits.js +8 -8
  87. package/dist/entries/llm-models.d.cts +1 -1
  88. package/dist/entries/llm-models.d.ts +1 -1
  89. package/dist/entries/model-catalog.cjs +144 -84
  90. package/dist/entries/model-catalog.d.cts +4 -47
  91. package/dist/entries/model-catalog.d.ts +4 -47
  92. package/dist/entries/model-catalog.js +5 -5
  93. package/dist/entries/models.cjs +305 -289
  94. package/dist/entries/models.d.cts +3 -3
  95. package/dist/entries/models.d.ts +3 -3
  96. package/dist/entries/models.js +4 -4
  97. package/dist/entries/nodes.cjs +208 -208
  98. package/dist/entries/nodes.d.cts +1 -1
  99. package/dist/entries/nodes.d.ts +1 -1
  100. package/dist/entries/nodes.js +10 -10
  101. package/dist/entries/pipeline.cjs +152 -152
  102. package/dist/entries/pipeline.d.cts +1 -1
  103. package/dist/entries/pipeline.d.ts +1 -1
  104. package/dist/entries/pipeline.js +3 -3
  105. package/dist/entries/ugc.cjs +71 -71
  106. package/dist/entries/ugc.js +4 -4
  107. package/dist/entries/video.cjs +117 -117
  108. package/dist/entries/video.js +4 -4
  109. package/dist/entries/workflow.cjs +147 -147
  110. package/dist/entries/workflow.d.cts +8 -0
  111. package/dist/entries/workflow.d.ts +8 -0
  112. package/dist/entries/workflow.js +2 -2
  113. package/dist/gpt-image-2-6-BeZdT-pW.d.cts +98 -0
  114. package/dist/gpt-image-2-6-BeZdT-pW.d.ts +98 -0
  115. package/dist/index.cjs +1314 -1234
  116. package/dist/index.d.cts +5 -4
  117. package/dist/index.d.ts +5 -4
  118. package/dist/index.js +20 -20
  119. package/dist/{model-catalog-QJ_AO9l0.d.cts → model-catalog-D6Es7VG-.d.cts} +56 -2
  120. package/dist/{model-catalog-QJ_AO9l0.d.ts → model-catalog-D6Es7VG-.d.ts} +56 -2
  121. package/dist/{model-constants-BwBdh6Rn.d.ts → model-constants-22k3fjp1.d.cts} +16 -1
  122. package/dist/{model-constants-BwBdh6Rn.d.cts → model-constants-22k3fjp1.d.ts} +16 -1
  123. package/package.json +1 -1
  124. package/src/__tests__/gpt-image-2-6-formats.test.ts +171 -0
  125. package/src/credit-identifiers.ts +63 -3
  126. package/src/entries/credits.ts +1 -0
  127. package/src/entries/model-catalog.ts +17 -0
  128. package/src/entries/models.ts +6 -0
  129. package/src/gpt-image-2-6.ts +72 -0
  130. package/src/model-catalog.ts +336 -13
  131. package/src/model-constants.ts +33 -0
  132. package/src/node-execution-state.ts +8 -0
  133. package/src/node-runtime-keys.ts +3 -0
  134. package/dist/chunk-2VQHPILW.js.map +0 -1
  135. package/dist/chunk-6VXDW2U3.cjs +0 -27
  136. package/dist/chunk-AWS4BWEC.js.map +0 -1
  137. package/dist/chunk-IOET54EV.js.map +0 -1
  138. package/dist/chunk-NZRG5CXQ.cjs.map +0 -1
  139. package/dist/chunk-OFL4UH6L.cjs.map +0 -1
  140. package/dist/chunk-PIX4OCCQ.js.map +0 -1
  141. package/dist/chunk-QSWUSXRL.cjs.map +0 -1
  142. package/dist/chunk-V3NONYLA.cjs.map +0 -1
  143. package/dist/chunk-VLQW4CVW.cjs.map +0 -1
  144. package/dist/chunk-ZU56AMFK.js.map +0 -1
@@ -379,6 +379,25 @@ export interface ModelCatalogEntry {
379
379
  * `transparentResolution`. Above it nothing is sent.
380
380
  */
381
381
  backgroundOnlyAtTransparentResolution?: true
382
+ /**
383
+ * The files this image model can write (`png`, `jpeg`, `webp`, `gif`, `svg`),
384
+ * the first being what it writes when none is named. Absent: a single format,
385
+ * not a setting, and a value sent is dropped. With `gif` the aspect ratio and
386
+ * size do not apply (a GIF is square, `IMAGE_GIF_FRAME_SIZE` a frame), and a
387
+ * transparent background is only kept with `png` and `webp`
388
+ * (`TRANSPARENT_OUTPUT_FORMATS`); `normalizeModelInput` says what it moved.
389
+ */
390
+ outputFormats?: readonly string[]
391
+ /**
392
+ * How many frames a GIF of this model can have: a whole number from `min` to
393
+ * `max`, or one of `values` when the provider takes only some. Read only when
394
+ * `outputFormats` lists `gif`.
395
+ */
396
+ gifFrames?: { readonly min: number; readonly max: number; readonly default: number; readonly values?: readonly number[] }
397
+ /** How long each frame of a GIF shows, in ms: `min` to `max` in steps of `step`. */
398
+ gifFrameDurationMs?: { readonly min: number; readonly max: number; readonly step: number; readonly default: number }
399
+ /** The levels of detail an SVG of this model is drawn at (`standard`, `detailed`, `max`), the first the default. Read only when `outputFormats` lists `svg`. */
400
+ svgLevels?: readonly string[]
382
401
  durations?: readonly number[]
383
402
  /**
384
403
  * The length (seconds) this model renders when the request names no duration
@@ -542,6 +561,17 @@ const GPT_IMAGE_2_6_VALUE_LABELS = {
542
561
  // The GPT Image background setting. KIE renders a transparent one at 1K only
543
562
  // (`transparentResolution`), which normalizeModelInput enforces.
544
563
  const GPT_IMAGE_BACKGROUNDS = ["auto", "opaque", "transparent"] as const
564
+ // GPT Image 2.6's files (docs.kie.ai/market/gpt/gpt-image-2-6-*). Flare and
565
+ // Sunburst write PNG, JPEG, WebP, an animated GIF or an SVG, from a prompt and
566
+ // from an edit; a GIF has 2 to 16 frames (KIE's cap, not the 64 of the model's
567
+ // own guide), each shown 20 to 2000 ms in steps of 10. Economy writes a PNG or
568
+ // a GIF from a prompt and a PNG from an edit, and takes a GIF's frames only as
569
+ // 4, 9, 16, 25, 36 or 64: the platform offers those up to 16.
570
+ const GPT_IMAGE_2_6_FORMATS = ["png", "jpeg", "webp", "gif", "svg"] as const
571
+ const GPT_IMAGE_2_6_GIF_FRAMES = { min: 2, max: 16, default: 9 } as const
572
+ const GPT_IMAGE_2_6_GIF_FRAME_DURATION = { min: 20, max: 2000, step: 10, default: 200 } as const
573
+ const GPT_IMAGE_2_6_ECONOMY_GIF_FRAMES = { min: 4, max: 16, default: 9, values: [4, 9, 16] } as const
574
+ const GPT_IMAGE_2_6_SVG_LEVELS = ["standard", "detailed", "max"] as const
545
575
  const IMAGEN4_RATIOS = ["1:1", "16:9", "9:16", "4:3", "3:4"] as const
546
576
  const IDEOGRAM_RATIOS = ["1:1", "16:9", "9:16", "4:3", "3:4"] as const
547
577
  const SEEDREAM_RATIOS = ["1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "21:9"] as const
@@ -1072,7 +1102,7 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1072
1102
  maker: "openai",
1073
1103
  label: "GPT Image 2.6 Flare",
1074
1104
  series: "GPT Image",
1075
- description: "Fast GPT Image 2.6 - pick it for speed: posters, product shots and quick iteration, with stronger layouts. Up to 4K, quality from low to max or auto (priced up to the max), a transparent background at 1K.",
1105
+ description: "Fast GPT Image 2.6 - pick it for speed: posters, product shots and quick iteration, with stronger layouts. Up to 4K, quality from low to max or auto (priced up to the max), a transparent background at 1K. Writes PNG, JPEG, WebP, an animated GIF or an SVG.",
1076
1106
  useCases: ["typography", "high-res", "general", "draft"],
1077
1107
  features: ["reference-image"],
1078
1108
  aspectRatios: GPT_IMAGE_2_6_RATIOS,
@@ -1082,6 +1112,10 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1082
1112
  defaultQuality: "medium",
1083
1113
  backgrounds: GPT_IMAGE_BACKGROUNDS,
1084
1114
  transparentResolution: "1K",
1115
+ outputFormats: GPT_IMAGE_2_6_FORMATS,
1116
+ gifFrames: GPT_IMAGE_2_6_GIF_FRAMES,
1117
+ gifFrameDurationMs: GPT_IMAGE_2_6_GIF_FRAME_DURATION,
1118
+ svgLevels: GPT_IMAGE_2_6_SVG_LEVELS,
1085
1119
  pricing: [
1086
1120
  { identifier: "gpt-image-2-6-flare", credits: 20, note: "medium, 1K default" },
1087
1121
  { identifier: "gpt-image-2-6-flare:low:1K", credits: 12, note: "low, 1K" },
@@ -1102,6 +1136,33 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1102
1136
  { identifier: "gpt-image-2-6-flare:auto:1K", credits: 96, note: "auto, 1K: the most it can cost, settled on what it really cost" },
1103
1137
  { identifier: "gpt-image-2-6-flare:auto:2K", credits: 193, note: "auto, 2K: the most it can cost, settled on what it really cost" },
1104
1138
  { identifier: "gpt-image-2-6-flare:auto:4K", credits: 321, note: "auto, 4K: the most it can cost, settled on what it really cost" },
1139
+ { identifier: "gpt-image-2-6-flare:low:gif-2-8", credits: 8, note: "GIF, low, 2 to 8 frames" },
1140
+ { identifier: "gpt-image-2-6-flare:low:gif-9-12", credits: 17, note: "GIF, low, 9 to 12 frames" },
1141
+ { identifier: "gpt-image-2-6-flare:low:gif-13-16", credits: 23, note: "GIF, low, 13 to 16 frames" },
1142
+ { identifier: "gpt-image-2-6-flare:medium:gif-2-8", credits: 14, note: "GIF, medium, 2 to 8 frames" },
1143
+ { identifier: "gpt-image-2-6-flare:medium:gif-9-12", credits: 29, note: "GIF, medium, 9 to 12 frames" },
1144
+ { identifier: "gpt-image-2-6-flare:medium:gif-13-16", credits: 41, note: "GIF, medium, 13 to 16 frames" },
1145
+ { identifier: "gpt-image-2-6-flare:high:gif-2-8", credits: 17, note: "GIF, high, 2 to 8 frames" },
1146
+ { identifier: "gpt-image-2-6-flare:high:gif-9-12", credits: 35, note: "GIF, high, 9 to 12 frames" },
1147
+ { identifier: "gpt-image-2-6-flare:high:gif-13-16", credits: 49, note: "GIF, high, 13 to 16 frames" },
1148
+ { identifier: "gpt-image-2-6-flare:xhigh:gif-2-8", credits: 29, note: "GIF, extra high, 2 to 8 frames" },
1149
+ { identifier: "gpt-image-2-6-flare:xhigh:gif-9-12", credits: 61, note: "GIF, extra high, 9 to 12 frames" },
1150
+ { identifier: "gpt-image-2-6-flare:xhigh:gif-13-16", credits: 86, note: "GIF, extra high, 13 to 16 frames" },
1151
+ { identifier: "gpt-image-2-6-flare:max:gif-2-8", credits: 65, note: "GIF, max, 2 to 8 frames" },
1152
+ { identifier: "gpt-image-2-6-flare:max:gif-9-12", credits: 136, note: "GIF, max, 9 to 12 frames" },
1153
+ { identifier: "gpt-image-2-6-flare:max:gif-13-16", credits: 194, note: "GIF, max, 13 to 16 frames" },
1154
+ { identifier: "gpt-image-2-6-flare:auto:gif-2-8", credits: 65, note: "GIF, auto, 2 to 8 frames: the most it can cost, settled on what it really cost" },
1155
+ { identifier: "gpt-image-2-6-flare:auto:gif-9-12", credits: 136, note: "GIF, auto, 9 to 12 frames: the most it can cost, settled on what it really cost" },
1156
+ { identifier: "gpt-image-2-6-flare:auto:gif-13-16", credits: 194, note: "GIF, auto, 13 to 16 frames: the most it can cost, settled on what it really cost" },
1157
+ { identifier: "gpt-image-2-6-flare:medium:1K:svg-standard", credits: 25, note: "SVG standard, medium, 1K" },
1158
+ { identifier: "gpt-image-2-6-flare:medium:2K:svg-standard", credits: 45, note: "SVG standard, medium, 2K" },
1159
+ { identifier: "gpt-image-2-6-flare:medium:4K:svg-standard", credits: 72, note: "SVG standard, medium, 4K" },
1160
+ { identifier: "gpt-image-2-6-flare:medium:1K:svg-detailed", credits: 64, note: "SVG detailed, medium, 1K" },
1161
+ { identifier: "gpt-image-2-6-flare:medium:2K:svg-detailed", credits: 84, note: "SVG detailed, medium, 2K" },
1162
+ { identifier: "gpt-image-2-6-flare:medium:4K:svg-detailed", credits: 111, note: "SVG detailed, medium, 4K" },
1163
+ { identifier: "gpt-image-2-6-flare:medium:1K:svg-max", credits: 81, note: "SVG max, medium, 1K" },
1164
+ { identifier: "gpt-image-2-6-flare:medium:2K:svg-max", credits: 101, note: "SVG max, medium, 2K" },
1165
+ { identifier: "gpt-image-2-6-flare:medium:4K:svg-max", credits: 128, note: "SVG max, medium, 4K" },
1105
1166
  ],
1106
1167
  valueLabels: GPT_IMAGE_2_6_VALUE_LABELS,
1107
1168
  safetyFilter: { stochastic: true, fallback: "nano-banana-pro" },
@@ -1114,7 +1175,7 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1114
1175
  maker: "openai",
1115
1176
  label: "GPT Image 2.6 Flare (I2I)",
1116
1177
  series: "GPT Image",
1117
- description: "Fast GPT Image 2.6 edits - up to 16 input images, priced per image. Pick it while iterating.",
1178
+ description: "Fast GPT Image 2.6 edits - up to 16 input images, priced per image. Writes PNG, JPEG, WebP, an animated GIF or an SVG. Pick it while iterating.",
1118
1179
  useCases: ["edit", "high-res"],
1119
1180
  features: ["reference-image"],
1120
1181
  aspectRatios: GPT_IMAGE_2_6_RATIOS,
@@ -1124,6 +1185,10 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1124
1185
  defaultQuality: "medium",
1125
1186
  backgrounds: GPT_IMAGE_BACKGROUNDS,
1126
1187
  transparentResolution: "1K",
1188
+ outputFormats: GPT_IMAGE_2_6_FORMATS,
1189
+ gifFrames: GPT_IMAGE_2_6_GIF_FRAMES,
1190
+ gifFrameDurationMs: GPT_IMAGE_2_6_GIF_FRAME_DURATION,
1191
+ svgLevels: GPT_IMAGE_2_6_SVG_LEVELS,
1127
1192
  pricing: [
1128
1193
  { identifier: "gpt-image-2-6-flare-i2i", credits: 20, note: "medium, 1K default" },
1129
1194
  { identifier: "gpt-image-2-6-flare-i2i:low:1K:1ref", credits: 17, note: "low, 1K, one input image (the least)" },
@@ -1131,6 +1196,8 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1131
1196
  { identifier: "gpt-image-2-6-flare-i2i:high:4K:16ref", credits: 169, note: "high, 4K, sixteen input images" },
1132
1197
  { identifier: "gpt-image-2-6-flare-i2i:max:4K:16ref", credits: 409, note: "max, 4K, sixteen input images (the most)" },
1133
1198
  { identifier: "gpt-image-2-6-flare-i2i:auto:1K:1ref", credits: 101, note: "auto, 1K, one input image: the most it can cost, settled on what it really cost" },
1199
+ { identifier: "gpt-image-2-6-flare-i2i:medium:gif-9-12:1ref", credits: 34, note: "GIF, medium, 9 to 12 frames, one input image" },
1200
+ { identifier: "gpt-image-2-6-flare-i2i:medium:1K:svg-standard:1ref", credits: 31, note: "SVG standard, medium, 1K, one input image" },
1134
1201
  ],
1135
1202
  valueLabels: GPT_IMAGE_2_6_VALUE_LABELS,
1136
1203
  safetyFilter: { stochastic: true, fallback: "nano-banana-pro" },
@@ -1143,7 +1210,7 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1143
1210
  maker: "openai",
1144
1211
  label: "GPT Image 2.6 Sunburst",
1145
1212
  series: "GPT Image",
1146
- description: "Precision GPT Image 2.6 - pick it when every detail counts: the strongest consistency across edits and the finest detail. Up to 4K, quality from low to max or auto (priced up to the max), a transparent background at 1K.",
1213
+ description: "Precision GPT Image 2.6 - pick it when every detail counts: the strongest consistency across edits and the finest detail. Up to 4K, quality from low to max or auto (priced up to the max), a transparent background at 1K. Writes PNG, JPEG, WebP, an animated GIF or an SVG.",
1147
1214
  useCases: ["typography", "high-res", "general"],
1148
1215
  features: ["reference-image"],
1149
1216
  aspectRatios: GPT_IMAGE_2_6_RATIOS,
@@ -1153,6 +1220,10 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1153
1220
  defaultQuality: "medium",
1154
1221
  backgrounds: GPT_IMAGE_BACKGROUNDS,
1155
1222
  transparentResolution: "1K",
1223
+ outputFormats: GPT_IMAGE_2_6_FORMATS,
1224
+ gifFrames: GPT_IMAGE_2_6_GIF_FRAMES,
1225
+ gifFrameDurationMs: GPT_IMAGE_2_6_GIF_FRAME_DURATION,
1226
+ svgLevels: GPT_IMAGE_2_6_SVG_LEVELS,
1156
1227
  pricing: [
1157
1228
  { identifier: "gpt-image-2-6-sunburst", credits: 20, note: "medium, 1K default" },
1158
1229
  { identifier: "gpt-image-2-6-sunburst:low:1K", credits: 12, note: "low, 1K" },
@@ -1173,6 +1244,33 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1173
1244
  { identifier: "gpt-image-2-6-sunburst:auto:1K", credits: 96, note: "auto, 1K: the most it can cost, settled on what it really cost" },
1174
1245
  { identifier: "gpt-image-2-6-sunburst:auto:2K", credits: 193, note: "auto, 2K: the most it can cost, settled on what it really cost" },
1175
1246
  { identifier: "gpt-image-2-6-sunburst:auto:4K", credits: 321, note: "auto, 4K: the most it can cost, settled on what it really cost" },
1247
+ { identifier: "gpt-image-2-6-sunburst:low:gif-2-8", credits: 8, note: "GIF, low, 2 to 8 frames" },
1248
+ { identifier: "gpt-image-2-6-sunburst:low:gif-9-12", credits: 17, note: "GIF, low, 9 to 12 frames" },
1249
+ { identifier: "gpt-image-2-6-sunburst:low:gif-13-16", credits: 23, note: "GIF, low, 13 to 16 frames" },
1250
+ { identifier: "gpt-image-2-6-sunburst:medium:gif-2-8", credits: 14, note: "GIF, medium, 2 to 8 frames" },
1251
+ { identifier: "gpt-image-2-6-sunburst:medium:gif-9-12", credits: 29, note: "GIF, medium, 9 to 12 frames" },
1252
+ { identifier: "gpt-image-2-6-sunburst:medium:gif-13-16", credits: 41, note: "GIF, medium, 13 to 16 frames" },
1253
+ { identifier: "gpt-image-2-6-sunburst:high:gif-2-8", credits: 17, note: "GIF, high, 2 to 8 frames" },
1254
+ { identifier: "gpt-image-2-6-sunburst:high:gif-9-12", credits: 35, note: "GIF, high, 9 to 12 frames" },
1255
+ { identifier: "gpt-image-2-6-sunburst:high:gif-13-16", credits: 49, note: "GIF, high, 13 to 16 frames" },
1256
+ { identifier: "gpt-image-2-6-sunburst:xhigh:gif-2-8", credits: 29, note: "GIF, extra high, 2 to 8 frames" },
1257
+ { identifier: "gpt-image-2-6-sunburst:xhigh:gif-9-12", credits: 61, note: "GIF, extra high, 9 to 12 frames" },
1258
+ { identifier: "gpt-image-2-6-sunburst:xhigh:gif-13-16", credits: 86, note: "GIF, extra high, 13 to 16 frames" },
1259
+ { identifier: "gpt-image-2-6-sunburst:max:gif-2-8", credits: 65, note: "GIF, max, 2 to 8 frames" },
1260
+ { identifier: "gpt-image-2-6-sunburst:max:gif-9-12", credits: 136, note: "GIF, max, 9 to 12 frames" },
1261
+ { identifier: "gpt-image-2-6-sunburst:max:gif-13-16", credits: 194, note: "GIF, max, 13 to 16 frames" },
1262
+ { identifier: "gpt-image-2-6-sunburst:auto:gif-2-8", credits: 65, note: "GIF, auto, 2 to 8 frames: the most it can cost, settled on what it really cost" },
1263
+ { identifier: "gpt-image-2-6-sunburst:auto:gif-9-12", credits: 136, note: "GIF, auto, 9 to 12 frames: the most it can cost, settled on what it really cost" },
1264
+ { identifier: "gpt-image-2-6-sunburst:auto:gif-13-16", credits: 194, note: "GIF, auto, 13 to 16 frames: the most it can cost, settled on what it really cost" },
1265
+ { identifier: "gpt-image-2-6-sunburst:medium:1K:svg-standard", credits: 25, note: "SVG standard, medium, 1K" },
1266
+ { identifier: "gpt-image-2-6-sunburst:medium:2K:svg-standard", credits: 45, note: "SVG standard, medium, 2K" },
1267
+ { identifier: "gpt-image-2-6-sunburst:medium:4K:svg-standard", credits: 72, note: "SVG standard, medium, 4K" },
1268
+ { identifier: "gpt-image-2-6-sunburst:medium:1K:svg-detailed", credits: 64, note: "SVG detailed, medium, 1K" },
1269
+ { identifier: "gpt-image-2-6-sunburst:medium:2K:svg-detailed", credits: 84, note: "SVG detailed, medium, 2K" },
1270
+ { identifier: "gpt-image-2-6-sunburst:medium:4K:svg-detailed", credits: 111, note: "SVG detailed, medium, 4K" },
1271
+ { identifier: "gpt-image-2-6-sunburst:medium:1K:svg-max", credits: 81, note: "SVG max, medium, 1K" },
1272
+ { identifier: "gpt-image-2-6-sunburst:medium:2K:svg-max", credits: 101, note: "SVG max, medium, 2K" },
1273
+ { identifier: "gpt-image-2-6-sunburst:medium:4K:svg-max", credits: 128, note: "SVG max, medium, 4K" },
1176
1274
  ],
1177
1275
  valueLabels: GPT_IMAGE_2_6_VALUE_LABELS,
1178
1276
  safetyFilter: { stochastic: true, fallback: "nano-banana-pro" },
@@ -1185,7 +1283,7 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1185
1283
  maker: "openai",
1186
1284
  label: "GPT Image 2.6 Sunburst (I2I)",
1187
1285
  series: "GPT Image",
1188
- description: "Precision GPT Image 2.6 edits - up to 16 input images, priced per image. Pick it for finished, detail-critical edits.",
1286
+ description: "Precision GPT Image 2.6 edits - up to 16 input images, priced per image. Writes PNG, JPEG, WebP, an animated GIF or an SVG. Pick it for finished, detail-critical edits.",
1189
1287
  useCases: ["edit", "high-res"],
1190
1288
  features: ["reference-image"],
1191
1289
  aspectRatios: GPT_IMAGE_2_6_RATIOS,
@@ -1195,6 +1293,10 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1195
1293
  defaultQuality: "medium",
1196
1294
  backgrounds: GPT_IMAGE_BACKGROUNDS,
1197
1295
  transparentResolution: "1K",
1296
+ outputFormats: GPT_IMAGE_2_6_FORMATS,
1297
+ gifFrames: GPT_IMAGE_2_6_GIF_FRAMES,
1298
+ gifFrameDurationMs: GPT_IMAGE_2_6_GIF_FRAME_DURATION,
1299
+ svgLevels: GPT_IMAGE_2_6_SVG_LEVELS,
1198
1300
  pricing: [
1199
1301
  { identifier: "gpt-image-2-6-sunburst-i2i", credits: 20, note: "medium, 1K default" },
1200
1302
  { identifier: "gpt-image-2-6-sunburst-i2i:low:1K:1ref", credits: 17, note: "low, 1K, one input image (the least)" },
@@ -1202,6 +1304,8 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1202
1304
  { identifier: "gpt-image-2-6-sunburst-i2i:high:4K:16ref", credits: 169, note: "high, 4K, sixteen input images" },
1203
1305
  { identifier: "gpt-image-2-6-sunburst-i2i:max:4K:16ref", credits: 409, note: "max, 4K, sixteen input images (the most)" },
1204
1306
  { identifier: "gpt-image-2-6-sunburst-i2i:auto:1K:1ref", credits: 101, note: "auto, 1K, one input image: the most it can cost, settled on what it really cost" },
1307
+ { identifier: "gpt-image-2-6-sunburst-i2i:medium:gif-9-12:1ref", credits: 34, note: "GIF, medium, 9 to 12 frames, one input image" },
1308
+ { identifier: "gpt-image-2-6-sunburst-i2i:medium:1K:svg-standard:1ref", credits: 31, note: "SVG standard, medium, 1K, one input image" },
1205
1309
  ],
1206
1310
  valueLabels: GPT_IMAGE_2_6_VALUE_LABELS,
1207
1311
  safetyFilter: { stochastic: true, fallback: "nano-banana-pro" },
@@ -1226,6 +1330,11 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1226
1330
  aspectRatios: GPT_IMAGE_2_6_ECONOMY_RATIOS,
1227
1331
  autoAspectFromSourceImage: true,
1228
1332
  backgrounds: GPT_IMAGE_BACKGROUNDS,
1333
+ // A GIF is priced at the flat row for now: check its price on a real run
1334
+ // before Economy is switched back on (backend gpt-image-2-6-pricing.ts).
1335
+ outputFormats: ["png", "gif"],
1336
+ gifFrames: GPT_IMAGE_2_6_ECONOMY_GIF_FRAMES,
1337
+ gifFrameDurationMs: GPT_IMAGE_2_6_GIF_FRAME_DURATION,
1229
1338
  pricing: [{ identifier: "gpt-image-2-6-economy", credits: 13, note: "1K flat" }],
1230
1339
  valueLabels: GPT_IMAGE_2_6_VALUE_LABELS,
1231
1340
  safetyFilter: { stochastic: true, fallback: "nano-banana-pro" },
@@ -1245,6 +1354,7 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1245
1354
  aspectRatios: GPT_IMAGE_2_6_ECONOMY_RATIOS,
1246
1355
  autoAspectFromSourceImage: true,
1247
1356
  backgrounds: GPT_IMAGE_BACKGROUNDS,
1357
+ outputFormats: ["png"],
1248
1358
  pricing: [{ identifier: "gpt-image-2-6-economy-i2i", credits: 13, note: "1K flat" }],
1249
1359
  valueLabels: GPT_IMAGE_2_6_VALUE_LABELS,
1250
1360
  safetyFilter: { stochastic: true, fallback: "nano-banana-pro" },
@@ -4020,9 +4130,25 @@ function sameOptionValue(a: string | number, b: string | number): boolean {
4020
4130
  return Number.isFinite(fa) && Number.isFinite(fb) && fa === fb
4021
4131
  }
4022
4132
 
4133
+ /** Every lever `normalizeModelInput` can correct, as an adjustment names it. */
4134
+ export const MODEL_INPUT_ADJUSTMENT_FIELDS = [
4135
+ "aspectRatio", "resolution", "quality", "duration", "background",
4136
+ "outputFormat", "gifFrames", "gifFrameDurationMs", "svgLevel",
4137
+ ] as const
4138
+ export type ModelInputAdjustmentField = (typeof MODEL_INPUT_ADJUSTMENT_FIELDS)[number]
4139
+
4140
+ /** The pixel size of every frame of a GIF the platform asks for: a GIF is square. */
4141
+ export const IMAGE_GIF_FRAME_SIZE = 512
4142
+
4143
+ /** The output formats that take no inpainting mask: the image routes refuse a mask with them (a 400). */
4144
+ export const MASKLESS_OUTPUT_FORMATS: readonly string[] = ["gif", "svg"]
4145
+
4146
+ /** The output formats that keep a transparent background; with any other a transparent one becomes `auto`. */
4147
+ export const TRANSPARENT_OUTPUT_FORMATS: readonly string[] = ["png", "webp"]
4148
+
4023
4149
  /** One correction `normalizeModelInput` made, for disclosure to the user. */
4024
4150
  export interface ModelInputAdjustment {
4025
- field: "aspectRatio" | "resolution" | "quality" | "duration" | "background"
4151
+ field: ModelInputAdjustmentField
4026
4152
  /** The value that was asked for. */
4027
4153
  from: string | number
4028
4154
  /** What it became — `undefined` means the lever was dropped entirely. */
@@ -4036,6 +4162,10 @@ export interface NormalizedModelInput {
4036
4162
  quality?: string
4037
4163
  duration?: number
4038
4164
  background?: string
4165
+ outputFormat?: string
4166
+ gifFrames?: number
4167
+ gifFrameDurationMs?: number
4168
+ svgLevel?: string
4039
4169
  /** Empty when the input was already valid. */
4040
4170
  adjustments: ModelInputAdjustment[]
4041
4171
  }
@@ -4207,6 +4337,10 @@ export function normalizeModelInput(
4207
4337
  quality?: string
4208
4338
  duration?: number
4209
4339
  background?: string
4340
+ outputFormat?: string
4341
+ gifFrames?: number
4342
+ gifFrameDurationMs?: number
4343
+ svgLevel?: string
4210
4344
  },
4211
4345
  context: ModelInputContext = {},
4212
4346
  ): NormalizedModelInput {
@@ -4251,11 +4385,31 @@ export function normalizeModelInput(
4251
4385
  return next
4252
4386
  }
4253
4387
 
4388
+ // The file first: a GIF's ratio and size, and every format's background, follow it.
4389
+ const format = normalizeOutputFormat(m, input, adjustments)
4390
+ out.outputFormat = format.levers.outputFormat
4391
+ out.gifFrames = format.levers.gifFrames
4392
+ out.gifFrameDurationMs = format.levers.gifFrameDurationMs
4393
+ out.svgLevel = format.levers.svgLevel
4394
+ const gif = format.levers.outputFormat === "gif"
4395
+
4254
4396
  const sourceRatio =
4255
- autoAspectNeedsSourceImage(modelId, input.aspectRatio) && usableSize(context.sourceImage)
4397
+ !gif && autoAspectNeedsSourceImage(modelId, input.aspectRatio) && usableSize(context.sourceImage)
4256
4398
  ? nearestCatalogAspectRatio(context.sourceImage.width, context.sourceImage.height, m.aspectRatios ?? [])
4257
4399
  : undefined
4258
- if (sourceRatio !== undefined && input.aspectRatio !== undefined) {
4400
+ if (gif) {
4401
+ // A GIF is square, IMAGE_GIF_FRAME_SIZE a frame: neither lever applies.
4402
+ // "auto" leaves the shape to the model, and square is its answer.
4403
+ if (input.aspectRatio !== undefined && input.aspectRatio !== "1:1" && !isAutoAspectToken(input.aspectRatio)) {
4404
+ adjustments.push({
4405
+ field: "aspectRatio",
4406
+ from: input.aspectRatio,
4407
+ to: "1:1",
4408
+ reason: `A GIF from ${m.label} is square (${IMAGE_GIF_FRAME_SIZE}x${IMAGE_GIF_FRAME_SIZE} a frame), so the aspect ratio does not apply.`,
4409
+ })
4410
+ }
4411
+ out.aspectRatio = input.aspectRatio === undefined ? undefined : "1:1"
4412
+ } else if (sourceRatio !== undefined && input.aspectRatio !== undefined) {
4259
4413
  const { width, height } = context.sourceImage!
4260
4414
  const why = m.autoAspectFromSourceImage === true
4261
4415
  ? `${m.label}'s own "auto" does not keep the photo's shape`
@@ -4270,14 +4424,43 @@ export function normalizeModelInput(
4270
4424
  } else {
4271
4425
  out.aspectRatio = snap("aspectRatio", input.aspectRatio, m.aspectRatios)
4272
4426
  }
4273
- out.resolution = snap(
4274
- "resolution",
4275
- input.resolution,
4276
- m.resolutions,
4277
- defaultResolutionFor(modelId),
4278
- )
4427
+ if (gif) {
4428
+ if (input.resolution !== undefined) {
4429
+ adjustments.push({
4430
+ field: "resolution",
4431
+ from: input.resolution,
4432
+ to: undefined,
4433
+ reason: `A GIF from ${m.label} is ${IMAGE_GIF_FRAME_SIZE}x${IMAGE_GIF_FRAME_SIZE} a frame, so the size does not apply.`,
4434
+ })
4435
+ }
4436
+ out.resolution = undefined
4437
+ } else {
4438
+ out.resolution = snap(
4439
+ "resolution",
4440
+ input.resolution,
4441
+ m.resolutions,
4442
+ defaultResolutionFor(modelId),
4443
+ )
4444
+ }
4279
4445
  out.quality = snap("quality", input.quality, m.qualities, m.defaultQuality)
4280
4446
  out.background = snap("background", input.background, m.backgrounds)
4447
+ // A transparent background is kept only by a format with an alpha channel the
4448
+ // provider fills (PNG, WebP); an SVG takes no background setting at all.
4449
+ const writes = format.levers.outputFormat
4450
+ if (writes !== undefined && out.background !== undefined && out.background !== "auto") {
4451
+ const dropped = writes === "svg" || (out.background === "transparent" && !TRANSPARENT_OUTPUT_FORMATS.includes(writes))
4452
+ if (dropped) {
4453
+ adjustments.push({
4454
+ field: "background",
4455
+ from: out.background,
4456
+ to: "auto",
4457
+ reason: writes === "svg"
4458
+ ? `An SVG from ${m.label} takes no background setting.`
4459
+ : `${m.label} only keeps a transparent background in PNG or WebP, not ${writes.toUpperCase()}.`,
4460
+ })
4461
+ out.background = "auto"
4462
+ }
4463
+ }
4281
4464
  out.duration =
4282
4465
  m.autoDuration === true && isAutoVideoDuration(input.duration)
4283
4466
  ? input.duration
@@ -4339,6 +4522,110 @@ export function normalizeModelInput(
4339
4522
  return out
4340
4523
  }
4341
4524
 
4525
+ /** The format levers of a request after `normalizeOutputFormat`: a GIF's and an SVG's only when that is the file written. */
4526
+ interface NormalizedFormatLevers {
4527
+ outputFormat?: string
4528
+ gifFrames?: number
4529
+ gifFrameDurationMs?: number
4530
+ svgLevel?: string
4531
+ }
4532
+
4533
+ /**
4534
+ * The file a request writes, snapped to what the model writes, and the levers
4535
+ * of that file: a GIF's frames and speed, an SVG's level. Each takes its
4536
+ * default when the file is written and it is not named (so what is sent and
4537
+ * priced is what is recorded), and is left out for any other file, a value
4538
+ * the canvas keeps on a node for when GIF is chosen again. No format named is
4539
+ * the model's own (PNG), and nothing is set.
4540
+ */
4541
+ function normalizeOutputFormat(
4542
+ m: ModelCatalogEntry,
4543
+ input: { outputFormat?: string; gifFrames?: number; gifFrameDurationMs?: number; svgLevel?: string },
4544
+ adjustments: ModelInputAdjustment[],
4545
+ ): { levers: NormalizedFormatLevers } {
4546
+ if (input.outputFormat === undefined) return { levers: {} }
4547
+ const asked = input.outputFormat.trim().toLowerCase()
4548
+ const value = asked === "jpg" ? "jpeg" : asked
4549
+ const formats = m.outputFormats
4550
+ if (!formats || formats.length === 0) {
4551
+ adjustments.push({
4552
+ field: "outputFormat",
4553
+ from: input.outputFormat,
4554
+ to: undefined,
4555
+ reason: `${m.label} has no outputFormat setting — the value was dropped.`,
4556
+ })
4557
+ return { levers: {} }
4558
+ }
4559
+ let outputFormat = formats.find((f) => f === value)
4560
+ if (outputFormat === undefined) {
4561
+ outputFormat = formats[0]!
4562
+ adjustments.push({
4563
+ field: "outputFormat",
4564
+ from: input.outputFormat,
4565
+ to: outputFormat,
4566
+ reason: `${m.label} does not write "${input.outputFormat}" — using "${outputFormat}" instead. Supported: ${formats.join(", ")}.`,
4567
+ })
4568
+ }
4569
+ if (outputFormat === "gif") {
4570
+ return { levers: { outputFormat, gifFrames: gifFramesFor(m, input.gifFrames, adjustments), gifFrameDurationMs: gifFrameDurationFor(m, input.gifFrameDurationMs, adjustments) } }
4571
+ }
4572
+ if (outputFormat === "svg") {
4573
+ const levels = m.svgLevels ?? []
4574
+ const askedLevel = input.svgLevel?.trim().toLowerCase()
4575
+ let svgLevel = askedLevel === undefined ? levels[0] : levels.find((l) => l === askedLevel)
4576
+ if (input.svgLevel !== undefined && svgLevel === undefined && levels.length > 0) {
4577
+ svgLevel = levels[0]
4578
+ adjustments.push({
4579
+ field: "svgLevel",
4580
+ from: input.svgLevel,
4581
+ to: svgLevel,
4582
+ reason: `${m.label} does not draw an SVG at level "${input.svgLevel}" — using "${svgLevel}" instead. Supported: ${levels.join(", ")}.`,
4583
+ })
4584
+ }
4585
+ return { levers: { outputFormat, ...(svgLevel !== undefined && { svgLevel }) } }
4586
+ }
4587
+ return { levers: { outputFormat } }
4588
+ }
4589
+
4590
+ /** A GIF's frames on `m`: the default when none, else a whole number in its range, or the nearest it takes. */
4591
+ function gifFramesFor(m: ModelCatalogEntry, asked: number | undefined, adjustments: ModelInputAdjustment[]): number | undefined {
4592
+ const spec = m.gifFrames
4593
+ if (!spec) return asked
4594
+ if (asked === undefined || !Number.isFinite(asked)) return spec.default
4595
+ const inRange = Math.min(Math.max(Math.round(asked), spec.min), spec.max)
4596
+ const frames = spec.values && spec.values.length > 0
4597
+ ? spec.values.reduce((best, v) => (Math.abs(v - inRange) < Math.abs(best - inRange) ? v : best), spec.values[0]!)
4598
+ : inRange
4599
+ if (frames !== asked) {
4600
+ adjustments.push({
4601
+ field: "gifFrames",
4602
+ from: asked,
4603
+ to: frames,
4604
+ reason: spec.values && spec.values.length > 0
4605
+ ? `A GIF from ${m.label} has ${spec.values.join(", ")} frames — using ${frames}.`
4606
+ : `A GIF from ${m.label} has ${spec.min} to ${spec.max} frames — using ${frames}.`,
4607
+ })
4608
+ }
4609
+ return frames
4610
+ }
4611
+
4612
+ /** How long each GIF frame shows on `m`: the default when none, else inside its range, rounded to its step. */
4613
+ function gifFrameDurationFor(m: ModelCatalogEntry, asked: number | undefined, adjustments: ModelInputAdjustment[]): number | undefined {
4614
+ const spec = m.gifFrameDurationMs
4615
+ if (!spec) return asked
4616
+ if (asked === undefined || !Number.isFinite(asked)) return spec.default
4617
+ const ms = Math.min(Math.max(Math.round(asked / spec.step) * spec.step, spec.min), spec.max)
4618
+ if (ms !== asked) {
4619
+ adjustments.push({
4620
+ field: "gifFrameDurationMs",
4621
+ from: asked,
4622
+ to: ms,
4623
+ reason: `${m.label} shows each GIF frame ${spec.min} to ${spec.max} ms, in steps of ${spec.step} — using ${ms}.`,
4624
+ })
4625
+ }
4626
+ return ms
4627
+ }
4628
+
4342
4629
  /** Aspect tokens that mean "match the input" or "let the provider decide". They
4343
4630
  * are NOT concrete ratios, so snapping them onto one is always wrong — the
4344
4631
  * provider adapter (applySeedance2Params, applyMinimaxH3Params) resolves them
@@ -4733,6 +5020,42 @@ export function backgroundOptionsByKind(kind: ModelKind): Record<string, Labeled
4733
5020
  return out
4734
5021
  }
4735
5022
 
5023
+ /** How an output format is named in a menu. */
5024
+ export const IMAGE_OUTPUT_FORMAT_LABELS: Readonly<Record<string, string>> = {
5025
+ png: "PNG",
5026
+ jpeg: "JPEG",
5027
+ webp: "WebP",
5028
+ gif: "GIF (animated)",
5029
+ svg: "SVG (vector)",
5030
+ }
5031
+
5032
+ /** How an SVG level of detail is named in a menu (its own table: `max` is also a quality). */
5033
+ export const IMAGE_SVG_LEVEL_LABELS: Readonly<Record<string, string>> = {
5034
+ standard: "SVG Standard",
5035
+ detailed: "SVG Detailed",
5036
+ max: "SVG Max",
5037
+ }
5038
+
5039
+ /** The output formats per model of a kind, the model's default first. No entry: a single format, not a setting. */
5040
+ export function outputFormatOptionsByKind(kind: ModelKind): Record<string, LabeledOption[]> {
5041
+ const out: Record<string, LabeledOption[]> = {}
5042
+ for (const m of Object.values(MODEL_CATALOG)) {
5043
+ if (m.kind !== kind || !m.outputFormats || m.outputFormats.length < 2) continue
5044
+ out[m.id] = m.outputFormats.map((v) => ({ value: v, label: IMAGE_OUTPUT_FORMAT_LABELS[v] ?? v }))
5045
+ }
5046
+ return out
5047
+ }
5048
+
5049
+ /** The SVG levels per model of a kind that writes SVG. */
5050
+ export function svgLevelOptionsByKind(kind: ModelKind): Record<string, LabeledOption[]> {
5051
+ const out: Record<string, LabeledOption[]> = {}
5052
+ for (const m of Object.values(MODEL_CATALOG)) {
5053
+ if (m.kind !== kind || !m.outputFormats?.includes("svg") || !m.svgLevels) continue
5054
+ out[m.id] = m.svgLevels.map((v) => ({ value: v, label: IMAGE_SVG_LEVEL_LABELS[v] ?? v }))
5055
+ }
5056
+ return out
5057
+ }
5058
+
4736
5059
  /** One shaped model row for a picker — capabilities derived from the catalog. */
4737
5060
  export interface ModelMenuOption {
4738
5061
  /** Catalog id (the API enum value). */
@@ -74,6 +74,39 @@ export type ImageQuality = typeof IMAGE_QUALITY_VALUES[number]
74
74
  export const IMAGE_BACKGROUND_VALUES = ["auto", "opaque", "transparent"] as const
75
75
  export type ImageBackground = typeof IMAGE_BACKGROUND_VALUES[number]
76
76
 
77
+ /**
78
+ * The `outputFormat` vocabulary of the same two routes: the file a run writes
79
+ * (vocabulary bound; the catalog snap gates per model, `outputFormats`). No
80
+ * value is PNG. `gif` is an animation of square frames, `svg` a vector drawing.
81
+ */
82
+ export const IMAGE_OUTPUT_FORMAT_VALUES = ["png", "jpeg", "webp", "gif", "svg"] as const
83
+ export type ImageOutputFormat = typeof IMAGE_OUTPUT_FORMAT_VALUES[number]
84
+
85
+ /** The `svgLevel` vocabulary: how much detail an SVG is drawn with, Standard to Max. */
86
+ export const IMAGE_SVG_LEVEL_VALUES = ["standard", "detailed", "max"] as const
87
+ export type ImageSvgLevel = typeof IMAGE_SVG_LEVEL_VALUES[number]
88
+
89
+ /** The pixel size of every frame of a GIF the platform asks for (square). Declared beside the catalog rule that reads it. */
90
+ export { IMAGE_GIF_FRAME_SIZE } from "./model-catalog.js"
91
+
92
+ /** The MIME type of each output format, as it is stored and served. */
93
+ export const IMAGE_OUTPUT_FORMAT_MIME: Readonly<Record<ImageOutputFormat, string>> = {
94
+ png: "image/png",
95
+ jpeg: "image/jpeg",
96
+ webp: "image/webp",
97
+ gif: "image/gif",
98
+ svg: "image/svg+xml",
99
+ }
100
+
101
+ /** The file extension each output format is stored under. */
102
+ export const IMAGE_OUTPUT_FORMAT_EXT: Readonly<Record<ImageOutputFormat, string>> = {
103
+ png: "png",
104
+ jpeg: "jpg",
105
+ webp: "webp",
106
+ gif: "gif",
107
+ svg: "svg",
108
+ }
109
+
77
110
  /** The `renderingSpeed` vocabulary (Ideogram's speed tiers — see {@link RENDERING_SPEED_SUPPORT}). */
78
111
  export const IMAGE_RENDERING_SPEED_VALUES = ["TURBO", "BALANCED", "QUALITY"] as const
79
112
  export type ImageRenderingSpeed = typeof IMAGE_RENDERING_SPEED_VALUES[number]
@@ -89,6 +89,14 @@ export interface NodeExecutionStateWire<TOutput = Record<string, unknown>> {
89
89
  error?: string | null
90
90
  /** Stable code for a refusal a client may branch on — never on the text. */
91
91
  errorCode?: string
92
+ /**
93
+ * The provider's own words for a `failed` node's failure (the job's
94
+ * `error_detail`), with links cut to their host and secrets removed; absent
95
+ * when the failure had no provider text (a platform refusal, a timeout).
96
+ * Display-only, beside `error`: branch on `errorCode` or the hint, never on
97
+ * these words. A published app's runner never receives it.
98
+ */
99
+ errorDetail?: string | null
92
100
  /**
93
101
  * What the node produced.
94
102
  *
@@ -25,6 +25,9 @@ export const EXECUTION_DATA_KEYS: ReadonlySet<string> = new Set([
25
25
  // lifecycle as errorMessage: a RESULT the user expects to survive reload,
26
26
  // never user-edited config.
27
27
  "errorHint",
28
+ // The provider's own words for the failure (the job's `error_detail`),
29
+ // beside errorMessage and with its lifecycle: a result, never config.
30
+ "errorDetail",
28
31
  // A job policy registered by the deployment held this node's result for a
29
32
  // human reviewer (`jobs.status = "pending_review"`). Pure run state, like
30
33
  // executionStatus: the node is still "running" and the flag disappears the