@nodaro/shared 3.64.0 → 3.66.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 (208) hide show
  1. package/dist/{chunk-J6B7J73J.cjs → chunk-23IKLMRL.cjs} +49 -49
  2. package/dist/{chunk-J6B7J73J.cjs.map → chunk-23IKLMRL.cjs.map} +1 -1
  3. package/dist/chunk-27HA6YOL.cjs +377 -0
  4. package/dist/chunk-27HA6YOL.cjs.map +1 -0
  5. package/dist/{chunk-OOZW2MM6.cjs → chunk-37ZSFS6A.cjs} +9 -9
  6. package/dist/{chunk-OOZW2MM6.cjs.map → chunk-37ZSFS6A.cjs.map} +1 -1
  7. package/dist/{chunk-AZNZ5WNZ.cjs → chunk-3L7GMQ4M.cjs} +142 -45
  8. package/dist/chunk-3L7GMQ4M.cjs.map +1 -0
  9. package/dist/{chunk-SXHHLZ22.js → chunk-3QJ3UR5Z.js} +9 -9
  10. package/dist/{chunk-SXHHLZ22.js.map → chunk-3QJ3UR5Z.js.map} +1 -1
  11. package/dist/chunk-3YWZ5SOZ.js +164 -0
  12. package/dist/chunk-3YWZ5SOZ.js.map +1 -0
  13. package/dist/{chunk-TTGZ2L3O.js → chunk-5GG4CG4Y.js} +3 -3
  14. package/dist/{chunk-TTGZ2L3O.js.map → chunk-5GG4CG4Y.js.map} +1 -1
  15. package/dist/{chunk-3KTWYYCN.js → chunk-5IZHECUP.js} +3 -3
  16. package/dist/{chunk-3KTWYYCN.js.map → chunk-5IZHECUP.js.map} +1 -1
  17. package/dist/{chunk-Q2Y4JHF7.js → chunk-5J2LIQYU.js} +5 -5
  18. package/dist/{chunk-Q2Y4JHF7.js.map → chunk-5J2LIQYU.js.map} +1 -1
  19. package/dist/{chunk-SHH2T4CR.js → chunk-5LWYX4GV.js} +3 -3
  20. package/dist/{chunk-SHH2T4CR.js.map → chunk-5LWYX4GV.js.map} +1 -1
  21. package/dist/{chunk-7AJGUI7L.cjs → chunk-5NVGKXJV.cjs} +34 -17
  22. package/dist/chunk-5NVGKXJV.cjs.map +1 -0
  23. package/dist/{chunk-D4KWNDPH.cjs → chunk-66QSUUB4.cjs} +12 -12
  24. package/dist/{chunk-D4KWNDPH.cjs.map → chunk-66QSUUB4.cjs.map} +1 -1
  25. package/dist/{chunk-KHH54GRP.cjs → chunk-6ET3KDO4.cjs} +15 -338
  26. package/dist/chunk-6ET3KDO4.cjs.map +1 -0
  27. package/dist/{chunk-ZI3QDUHO.js → chunk-AT53ZQUC.js} +3 -3
  28. package/dist/{chunk-ZI3QDUHO.js.map → chunk-AT53ZQUC.js.map} +1 -1
  29. package/dist/chunk-BMDOPJBP.cjs +185 -0
  30. package/dist/chunk-BMDOPJBP.cjs.map +1 -0
  31. package/dist/{chunk-PJJAZQVZ.js → chunk-BNR5FKL5.js} +3 -3
  32. package/dist/{chunk-PJJAZQVZ.js.map → chunk-BNR5FKL5.js.map} +1 -1
  33. package/dist/{chunk-5OBTGNUQ.cjs → chunk-E62W5I6A.cjs} +298 -2
  34. package/dist/chunk-E62W5I6A.cjs.map +1 -0
  35. package/dist/{chunk-GTWUS6MQ.cjs → chunk-EFYWV2V5.cjs} +61 -61
  36. package/dist/{chunk-GTWUS6MQ.cjs.map → chunk-EFYWV2V5.cjs.map} +1 -1
  37. package/dist/chunk-F6XIH3TZ.cjs +168 -0
  38. package/dist/chunk-F6XIH3TZ.cjs.map +1 -0
  39. package/dist/{chunk-NIAFR5EE.js → chunk-FGBGKBML.js} +32 -3
  40. package/dist/chunk-FGBGKBML.js.map +1 -0
  41. package/dist/{chunk-YQV53HRR.cjs → chunk-G2G7XGFU.cjs} +7 -7
  42. package/dist/{chunk-YQV53HRR.cjs.map → chunk-G2G7XGFU.cjs.map} +1 -1
  43. package/dist/{chunk-7KQ6W5DS.js → chunk-GF7ZA26H.js} +4 -4
  44. package/dist/{chunk-7KQ6W5DS.js.map → chunk-GF7ZA26H.js.map} +1 -1
  45. package/dist/{chunk-SPAHI7DY.cjs → chunk-GNLA5NTT.cjs} +4 -4
  46. package/dist/{chunk-SPAHI7DY.cjs.map → chunk-GNLA5NTT.cjs.map} +1 -1
  47. package/dist/{chunk-VPTA4Z7G.js → chunk-GTBW2KAY.js} +5 -5
  48. package/dist/{chunk-VPTA4Z7G.js.map → chunk-GTBW2KAY.js.map} +1 -1
  49. package/dist/{chunk-CHS2SIP6.cjs → chunk-HTDKEYMY.cjs} +90 -76
  50. package/dist/chunk-HTDKEYMY.cjs.map +1 -0
  51. package/dist/{chunk-EXEVT6D2.cjs → chunk-IWUW3YPM.cjs} +5 -5
  52. package/dist/{chunk-EXEVT6D2.cjs.map → chunk-IWUW3YPM.cjs.map} +1 -1
  53. package/dist/{chunk-ACZZHHFZ.cjs → chunk-JTYCJ5OL.cjs} +44 -22
  54. package/dist/chunk-JTYCJ5OL.cjs.map +1 -0
  55. package/dist/{chunk-HDPJNNMF.cjs → chunk-M5QY464F.cjs} +21 -21
  56. package/dist/{chunk-HDPJNNMF.cjs.map → chunk-M5QY464F.cjs.map} +1 -1
  57. package/dist/{chunk-DZ4IOP3Q.js → chunk-MVXZP6VB.js} +281 -3
  58. package/dist/chunk-MVXZP6VB.js.map +1 -0
  59. package/dist/{chunk-Y4GCJJPF.cjs → chunk-NYZQOIXJ.cjs} +35 -2
  60. package/dist/chunk-NYZQOIXJ.cjs.map +1 -0
  61. package/dist/{chunk-KB2SQAR3.js → chunk-OFQ6CU6S.js} +3 -3
  62. package/dist/{chunk-KB2SQAR3.js.map → chunk-OFQ6CU6S.js.map} +1 -1
  63. package/dist/{chunk-36VWLB4J.js → chunk-OXBU5AGH.js} +3 -3
  64. package/dist/{chunk-36VWLB4J.js.map → chunk-OXBU5AGH.js.map} +1 -1
  65. package/dist/{chunk-CHTZZRAL.cjs → chunk-OXTF4Y3P.cjs} +6 -6
  66. package/dist/{chunk-CHTZZRAL.cjs.map → chunk-OXTF4Y3P.cjs.map} +1 -1
  67. package/dist/{chunk-3AYM47GW.js → chunk-PAUWEWTY.js} +99 -9
  68. package/dist/chunk-PAUWEWTY.js.map +1 -0
  69. package/dist/{chunk-FHGRKQVZ.cjs → chunk-PGDR7CO3.cjs} +8 -8
  70. package/dist/{chunk-FHGRKQVZ.cjs.map → chunk-PGDR7CO3.cjs.map} +1 -1
  71. package/dist/{chunk-W6VJAUGM.cjs → chunk-PJAJCFLP.cjs} +94 -37
  72. package/dist/chunk-PJAJCFLP.cjs.map +1 -0
  73. package/dist/{chunk-IYSOVS7O.js → chunk-RVQW623D.js} +31 -13
  74. package/dist/chunk-RVQW623D.js.map +1 -0
  75. package/dist/{chunk-TPQJKS7D.js → chunk-SCDE676D.js} +21 -7
  76. package/dist/{chunk-CHS2SIP6.cjs.map → chunk-SCDE676D.js.map} +1 -1
  77. package/dist/chunk-SW5ZD7BO.js +143 -0
  78. package/dist/chunk-SW5ZD7BO.js.map +1 -0
  79. package/dist/{chunk-T2OVDF2M.cjs → chunk-T4GIHHXY.cjs} +6 -6
  80. package/dist/{chunk-T2OVDF2M.cjs.map → chunk-T4GIHHXY.cjs.map} +1 -1
  81. package/dist/{chunk-QYU7J5EQ.js → chunk-V6OXSXIX.js} +29 -18
  82. package/dist/chunk-V6OXSXIX.js.map +1 -0
  83. package/dist/{chunk-W7KHHNZR.js → chunk-VBP4DH37.js} +61 -9
  84. package/dist/chunk-VBP4DH37.js.map +1 -0
  85. package/dist/{chunk-67CMMTLN.cjs → chunk-WZG6GZIL.cjs} +4 -4
  86. package/dist/{chunk-67CMMTLN.cjs.map → chunk-WZG6GZIL.cjs.map} +1 -1
  87. package/dist/{chunk-O4RPXBDZ.cjs → chunk-X2YHKP4D.cjs} +8 -8
  88. package/dist/{chunk-O4RPXBDZ.cjs.map → chunk-X2YHKP4D.cjs.map} +1 -1
  89. package/dist/{chunk-OBOOHG3N.js → chunk-XEPKONJC.js} +3 -3
  90. package/dist/{chunk-OBOOHG3N.js.map → chunk-XEPKONJC.js.map} +1 -1
  91. package/dist/{chunk-O7RZRUMZ.js → chunk-XJWED257.js} +14 -309
  92. package/dist/chunk-XJWED257.js.map +1 -0
  93. package/dist/chunk-XSSLNINL.js +346 -0
  94. package/dist/chunk-XSSLNINL.js.map +1 -0
  95. package/dist/{chunk-4IUE2JB7.js → chunk-Z77M7Q2R.js} +3 -3
  96. package/dist/{chunk-4IUE2JB7.js.map → chunk-Z77M7Q2R.js.map} +1 -1
  97. package/dist/entries/apps.cjs +42 -42
  98. package/dist/entries/apps.js +7 -7
  99. package/dist/entries/captions.d.cts +1 -1
  100. package/dist/entries/captions.d.ts +1 -1
  101. package/dist/entries/credits.cjs +230 -214
  102. package/dist/entries/credits.d.cts +51 -14
  103. package/dist/entries/credits.d.ts +51 -14
  104. package/dist/entries/credits.js +10 -10
  105. package/dist/entries/entities.cjs +202 -193
  106. package/dist/entries/entities.d.cts +44 -9
  107. package/dist/entries/entities.d.ts +44 -9
  108. package/dist/entries/entities.js +2 -1
  109. package/dist/entries/llm-models.cjs +86 -62
  110. package/dist/entries/llm-models.d.cts +46 -15
  111. package/dist/entries/llm-models.d.ts +46 -15
  112. package/dist/entries/llm-models.js +2 -2
  113. package/dist/entries/media.cjs +79 -63
  114. package/dist/entries/media.d.cts +154 -1
  115. package/dist/entries/media.d.ts +154 -1
  116. package/dist/entries/media.js +1 -1
  117. package/dist/entries/model-catalog.cjs +175 -119
  118. package/dist/entries/model-catalog.d.cts +4 -54
  119. package/dist/entries/model-catalog.d.ts +4 -54
  120. package/dist/entries/model-catalog.js +4 -4
  121. package/dist/entries/models.cjs +503 -358
  122. package/dist/entries/models.d.cts +86 -7
  123. package/dist/entries/models.d.ts +86 -7
  124. package/dist/entries/models.js +6 -5
  125. package/dist/entries/nodes.cjs +212 -212
  126. package/dist/entries/nodes.d.cts +1 -1
  127. package/dist/entries/nodes.d.ts +1 -1
  128. package/dist/entries/nodes.js +8 -8
  129. package/dist/entries/pipeline.cjs +153 -153
  130. package/dist/entries/pipeline.d.cts +3 -3
  131. package/dist/entries/pipeline.d.ts +3 -3
  132. package/dist/entries/pipeline.js +3 -3
  133. package/dist/entries/social.cjs +177 -177
  134. package/dist/entries/social.js +2 -2
  135. package/dist/entries/ugc.cjs +71 -71
  136. package/dist/entries/ugc.js +4 -4
  137. package/dist/entries/video.cjs +174 -145
  138. package/dist/entries/video.d.cts +119 -2
  139. package/dist/entries/video.d.ts +119 -2
  140. package/dist/entries/video.js +7 -6
  141. package/dist/entries/workflow.d.cts +1 -1
  142. package/dist/entries/workflow.d.ts +1 -1
  143. package/dist/index.cjs +2086 -1793
  144. package/dist/index.d.cts +10 -9
  145. package/dist/index.d.ts +10 -9
  146. package/dist/index.js +24 -23
  147. package/dist/{model-catalog-Cf9fkEUp.d.ts → model-catalog-B-aQnUS8.d.cts} +186 -2
  148. package/dist/{model-catalog-Cf9fkEUp.d.cts → model-catalog-B-aQnUS8.d.ts} +186 -2
  149. package/dist/{model-constants-C_Nyft_i.d.cts → model-constants-BstsUup6.d.cts} +105 -6
  150. package/dist/{model-constants-BxjiWVQ9.d.ts → model-constants-DZ3tPGFO.d.ts} +105 -6
  151. package/dist/tts-capabilities-BJ4N8MIB.d.ts +133 -0
  152. package/dist/tts-capabilities-Cf_4nu1Z.d.cts +133 -0
  153. package/package.json +1 -1
  154. package/src/__tests__/dialogue-capabilities.test.ts +167 -6
  155. package/src/__tests__/extend-providers.test.ts +87 -0
  156. package/src/__tests__/flux-3-klein.test.ts +51 -3
  157. package/src/__tests__/image-run-limit.test.ts +96 -0
  158. package/src/__tests__/kling4-catalog.test.ts +1 -1
  159. package/src/__tests__/llm-models.test.ts +41 -4
  160. package/src/__tests__/seedream-5-5.test.ts +17 -0
  161. package/src/__tests__/speech-pricing.test.ts +62 -1
  162. package/src/__tests__/tts-capabilities.test.ts +160 -4
  163. package/src/__tests__/video-analysis-pricing.test.ts +13 -1
  164. package/src/__tests__/video-subjects.test.ts +209 -0
  165. package/src/__tests__/wired-character-names.test.ts +142 -0
  166. package/src/credit-estimators/index.ts +4 -0
  167. package/src/credit-estimators/speech.ts +57 -9
  168. package/src/credit-identifiers.ts +48 -13
  169. package/src/dialogue-capabilities.ts +220 -3
  170. package/src/dubbing-structure.ts +186 -0
  171. package/src/entries/entities.ts +2 -0
  172. package/src/entries/llm-models.ts +7 -0
  173. package/src/entries/media.ts +3 -1
  174. package/src/entries/model-catalog.ts +17 -0
  175. package/src/entries/models.ts +43 -0
  176. package/src/entries/video.ts +8 -1
  177. package/src/gemini-tts.ts +144 -0
  178. package/src/llm-models.ts +71 -21
  179. package/src/model-catalog.ts +283 -2
  180. package/src/model-constants.ts +167 -8
  181. package/src/tts-capabilities.ts +193 -1
  182. package/src/video-analysis-pricing.ts +11 -0
  183. package/src/video-character-refs.ts +165 -3
  184. package/src/wired-character-names.ts +134 -18
  185. package/src/wired-character-video-subjects.ts +63 -0
  186. package/dist/chunk-3AYM47GW.js.map +0 -1
  187. package/dist/chunk-5OBTGNUQ.cjs.map +0 -1
  188. package/dist/chunk-6YIV37V7.js +0 -31
  189. package/dist/chunk-6YIV37V7.js.map +0 -1
  190. package/dist/chunk-7AJGUI7L.cjs.map +0 -1
  191. package/dist/chunk-ACZZHHFZ.cjs.map +0 -1
  192. package/dist/chunk-AZNZ5WNZ.cjs.map +0 -1
  193. package/dist/chunk-DZ4IOP3Q.js.map +0 -1
  194. package/dist/chunk-IYSOVS7O.js.map +0 -1
  195. package/dist/chunk-KHH54GRP.cjs.map +0 -1
  196. package/dist/chunk-NIAFR5EE.js.map +0 -1
  197. package/dist/chunk-O7RZRUMZ.js.map +0 -1
  198. package/dist/chunk-QYU7J5EQ.js.map +0 -1
  199. package/dist/chunk-S3UGLZSF.js +0 -42
  200. package/dist/chunk-S3UGLZSF.js.map +0 -1
  201. package/dist/chunk-TPQJKS7D.js.map +0 -1
  202. package/dist/chunk-TQW3R44P.cjs +0 -38
  203. package/dist/chunk-TQW3R44P.cjs.map +0 -1
  204. package/dist/chunk-VZ6TE23U.cjs +0 -54
  205. package/dist/chunk-VZ6TE23U.cjs.map +0 -1
  206. package/dist/chunk-W6VJAUGM.cjs.map +0 -1
  207. package/dist/chunk-W7KHHNZR.js.map +0 -1
  208. package/dist/chunk-Y4GCJJPF.cjs.map +0 -1
@@ -34,7 +34,20 @@ import { MINIMAX_H3_IMAGE_DEFAULT_RESOLUTION, MINIMAX_H3_IMAGE_RESOLUTIONS } fro
34
34
  import { isAutoVideoDuration } from "./video-duration-auto.js"
35
35
  import type { DeclaredSeedanceTaskType } from "./seedance-task-type.js"
36
36
  import { SEEDREAM_5_5_DEFAULT_RESOLUTION, SEEDREAM_5_5_RESOLUTIONS } from "./seedream-5-5.js"
37
- import { FLUX_3_KLEIN_RESOLUTIONS } from "./flux-3-klein.js"
37
+ import { FLUX_3_KLEIN_DEFAULT_RESOLUTION, FLUX_3_KLEIN_RESOLUTIONS } from "./flux-3-klein.js"
38
+ import {
39
+ GEMINI_3_1_DEFAULT_VOICE,
40
+ GEMINI_3_1_TTS_ACCENTS,
41
+ GEMINI_3_1_TTS_PACES,
42
+ GEMINI_3_1_TTS_STYLES,
43
+ GEMINI_3_1_TTS_VOICES,
44
+ GEMINI_3_8_DEFAULT_VOICE,
45
+ GEMINI_3_8_TONE_TAGS,
46
+ GEMINI_3_8_TTS_VOICES,
47
+ GEMINI_TTS_MAX_CHARS,
48
+ TTS_DIRECTION_MAX_CHARS,
49
+ type TtsNamedVoice,
50
+ } from "./gemini-tts.js"
38
51
 
39
52
  export type ModelKind = "image" | "video" | "audio"
40
53
 
@@ -108,6 +121,14 @@ export interface PriceVariant {
108
121
  */
109
122
  export const SPEECH_UNIT_PRICE_NOTE = "per started 100 characters, at least 8 units — where length pricing is on; a request costs at most its units × this"
110
123
 
124
+ /**
125
+ * The note on a speech model's `<model>:per-1k-chars` row (`TtsCapabilities.ratePer1kChars`):
126
+ * the same count as {@link SPEECH_UNIT_PRICE_NOTE} — started 100 characters, at
127
+ * least 8 units — quoted per 1,000, so a request costs its hundreds × this ÷ 10,
128
+ * rounded up once (the exact price of N hundreds is the `<model>:per-100-chars:<N>u` id).
129
+ */
130
+ export const SPEECH_PER_1K_PRICE_NOTE = "per 1,000 characters, counted in started 100s, at least 800 — where length pricing is on; a request costs its hundreds × this ÷ 10, rounded up"
131
+
111
132
  /** A voice-setting lever a speech model honours. */
112
133
  export type TtsSettingLever = "stability" | "similarity" | "style" | "speed" | "speakerBoost"
113
134
 
@@ -160,6 +181,81 @@ export interface TtsCapabilities {
160
181
  maxChars: number
161
182
  /** Languages offered in pickers (ISO 639-1; `fil` has no two-letter code). A curated list, not the vendor's full one. */
162
183
  languages: readonly string[]
184
+ /**
185
+ * The model speaks only these named voices, by wire name: a request's
186
+ * `voice` must be one of them (else a 400 before any hold), and none means
187
+ * `defaultVoice`. Absent ⇒ the ElevenLabs voices (premade, library, clones).
188
+ * A client offers this list in place of the ElevenLabs voice browser.
189
+ */
190
+ voices?: readonly TtsNamedVoice[]
191
+ /** With `voices`: the voice a request that names none runs with. */
192
+ defaultVoice?: string
193
+ /**
194
+ * With `audioTags`: the tags are written `<in angle brackets>`, from the
195
+ * closed list `tags`. The platform's `[square]` tags are rewritten to them
196
+ * where they match and the rest are taken out before sending
197
+ * (`@nodaro/prompts` `toAngleTags`). Absent ⇒ `[square]` tags, sent as written.
198
+ */
199
+ tagSyntax?: "angle"
200
+ /** With `tagSyntax: "angle"`: the tags the model performs, by their own names (`laugh`, `short pause`). */
201
+ tags?: readonly string[]
202
+ /**
203
+ * Style direction the model takes beside the text — never spoken, never
204
+ * billed. Absent ⇒ none (the request's direction fields are not sent).
205
+ */
206
+ direction?: TtsDirectionSheet
207
+ /**
208
+ * Dialogue lane only: at most this many speakers (distinct voices) in one
209
+ * script. Absent ⇒ the lane's own limit (ElevenLabs dialogue: 10).
210
+ */
211
+ dialogueSpeakers?: number
212
+ /**
213
+ * Dialogue lane only: the model can add natural filler words ("um", "you
214
+ * know") between two speakers when asked (`fillerWords` on a request).
215
+ */
216
+ fillerWords?: true
217
+ /**
218
+ * Dialogue lane only: the model delivers every speech file format
219
+ * (`TTS_OUTPUT_FORMATS`) — it renders a WAV the platform keeps as it is or
220
+ * encodes to MP3. Absent ⇒ the default MP3 only (the ElevenLabs dialogue
221
+ * endpoint, as the platform calls it).
222
+ */
223
+ dialogueAnyOutputFormat?: true
224
+ /**
225
+ * The model clones a speaker's voice for one request from two recordings
226
+ * (`replica`: a reference and a consent recording, `TtsReplica`), in place of
227
+ * a named voice; nothing is saved as a voice. Gemini 3.8 Flash only: KIE's
228
+ * 3.8 Flash-Lite refuses it ("Inline voice sample replication is not
229
+ * supported", probed 2026-11-13).
230
+ */
231
+ replica?: true
232
+ /**
233
+ * The model's length-price row is quoted per 1,000 characters
234
+ * (`<id>:per-1k-chars`) instead of per started 100 (`<id>:per-100-chars`).
235
+ * The count is the same — started 100 characters, at least 8 — and a
236
+ * request costs its hundreds × the row ÷ 10, rounded up once
237
+ * (`speechRowCredits`). For a rate below one credit per 100 characters,
238
+ * which a whole-credit row cannot hold.
239
+ */
240
+ ratePer1kChars?: true
241
+ }
242
+
243
+ /**
244
+ * The style direction a speech model takes (`styleDirection`, `pace`,
245
+ * `accent`, `audioProfile` on a request). A field the sheet does not name is
246
+ * never sent.
247
+ */
248
+ export interface TtsDirectionSheet {
249
+ /** `styleDirection` is free text — tone, emotion, pace in the person's own words — up to this many characters. */
250
+ styleMaxChars?: number
251
+ /** `styleDirection` is one of these (the model's own names). */
252
+ styles?: readonly string[]
253
+ /** `pace` is one of these. */
254
+ paces?: readonly string[]
255
+ /** `accent` is one of these. */
256
+ accents?: readonly string[]
257
+ /** `audioProfile` (who is speaking, in words) is free text up to this many characters. */
258
+ audioProfileMaxChars?: number
163
259
  }
164
260
 
165
261
  /**
@@ -320,6 +416,23 @@ export interface ModelCatalogEntryFields {
320
416
  * `audio_to_video` task). The node's Audio Refs input then takes one clip.
321
417
  */
322
418
  features?: readonly string[]
419
+ /**
420
+ * A WORKFLOW run that would send this image model more input images than
421
+ * `requestImageLimit` allows, the source or base image counted, is refused
422
+ * before anything is reserved, with a message saying how many to remove
423
+ * (`refusesImagesOverLimit`), as a request is. Nothing trims it first: the
424
+ * prompt assembler sends every image a run attaches, so the count refused
425
+ * is the count the run would send. Set on FLUX 3 Klein, text to image and
426
+ * edit alike (decided 2026-11-12: an 11th image is refused, never left out).
427
+ *
428
+ * Without it, a model with a request image limit of its own (Seedream 5.5,
429
+ * GPT Image 2.6 Flare and Sunburst, MiniMax H3 Image) refuses a request
430
+ * over its limit but a workflow run sends its first images up to it
431
+ * (`refusesImagesOverLimitOn`, decided 2026-11-14), and every other model
432
+ * has its structured references trimmed past its reference limit, as it
433
+ * always has.
434
+ */
435
+ refusesImagesOverLimit?: true
323
436
  /**
324
437
  * How this video model's provider addresses its images in the prompt, by
325
438
  * array order — the syntax its frame / identity binding sentences are written
@@ -389,7 +502,8 @@ export interface ModelCatalogEntryFields {
389
502
  */
390
503
  resolutionsByAspectRatio?: Readonly<Record<string, readonly string[]>>
391
504
  /** The resolution a caller who names none lands on when it is not the
392
- * cheapest entry (see `defaultResolutionFor`). */
505
+ * cheapest entry (see `defaultResolutionFor`). `GET /v1/models` and MCP
506
+ * `list_models` serve it as declared, on the models that declare it. */
393
507
  defaultResolution?: string
394
508
  /**
395
509
  * What this model actually RENDERS for a resolution outside `resolutions`.
@@ -605,6 +719,7 @@ export const MODEL_RECOMMENDATIONS: readonly ModelRecommendation[] = [
605
719
  { intent: "video with start + end frame", modelIds: ["veo3", "veo3.1", "kling-turbo", "minimax", "hailuo-standard", "seedance-2"], note: "All listed support an end frame; VEO uses imageUrls[start, end]." },
606
720
  { intent: "music / song generation", modelIds: ["suno-v6", "suno-v6_wild", "suno-v6_mini", "suno-v5_5"], note: "V6 is the default flagship; V6 Wild for bolder, less predictable results; V6 Mini when speed matters; v5.5 / v5 / v4 keep their own character. Same price." },
607
721
  { intent: "voice over / narration", modelIds: ["elevenlabs-v4", "elevenlabs-v3", "elevenlabs-v4-turbo", "elevenlabs-turbo"], note: "v4 is the default: [audio tags] for emotion and up to 10,000 characters per request. v3 is the previous expressive model, still selectable. v4 Turbo keeps v4's tags at Turbo's credit price; Turbo v2.5 is the cheapest for plain narration without tags." },
722
+ { intent: "low-cost narration with a named voice", modelIds: ["gemini-3-8-flash-lite-tts", "gemini-3-8-flash-tts", "gemini-3-1-flash-tts", "gemini-2-5-pro-tts"], note: "Google's Gemini voices cost far less per character than ElevenLabs. Each speaks only its own named voices (no clones or library voices) and no language is set: the text decides. 3.8 Flash-Lite is the cheapest; 3.8 Flash is the larger 3.8 model; both take their own tone tags (laugh, sigh, short pause…) and a free-text style. 3.1 Flash and 2.5 Pro take [audio tags] and a style, pace, accent and audio profile." },
608
723
  { intent: "lip-sync a portrait to audio", modelIds: ["kling-avatar-pro", "kling-avatar", "infinitalk"], note: "Pro for best mouth shape; InfiniTalk for resolution control." },
609
724
  { intent: "transcription / captions", modelIds: ["elevenlabs-stt", "incredibly-fast-whisper", "whisper", "nemotron-3-5-transcribe"], note: "Captions need WORD timestamps: ElevenLabs STT (always), Incredibly Fast Whisper or Nemotron 3.5 Transcribe (on request, with a speaker per word). Plain Whisper returns phrase segments only. To translate the speech (to or from English) instead of transcribing it, use Nemotron 3.5 Transcribe with a target language; a translation carries no word timings." },
610
725
  { intent: "motion transfer (drive a subject by another video)", modelIds: ["motion-transfer", "kling-3.0-motion"], note: "Kling 2.6 base is cheap; Kling 3.0 is premium." },
@@ -1007,9 +1122,11 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1007
1122
  description: "FLUX 3 Klein - the light model of FLUX 3: fast and low cost, at 1K by default, 2K or 4K, in nine shapes, PNG or JPEG. Add images and it edits from up to 10 references, at the same price.",
1008
1123
  useCases: ["fast", "drafts", "iteration", "realistic"],
1009
1124
  features: ["reference-image"],
1125
+ refusesImagesOverLimit: true,
1010
1126
  aspectRatios: FLUX_3_KLEIN_RATIOS,
1011
1127
  strictAspectRatios: true,
1012
1128
  resolutions: FLUX_3_KLEIN_RESOLUTIONS,
1129
+ defaultResolution: FLUX_3_KLEIN_DEFAULT_RESOLUTION,
1013
1130
  outputFormats: FLUX_3_KLEIN_FORMATS,
1014
1131
  pricing: [
1015
1132
  { identifier: "flux-3-klein", credits: 4, note: "1K default" },
@@ -1029,9 +1146,11 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1029
1146
  description: "FLUX 3 Klein edits - fast, low-cost changes from 1 to 10 reference images, which cost nothing extra. 1K by default, 2K or 4K, PNG or JPEG; auto keeps the first image's shape.",
1030
1147
  useCases: ["edit", "iteration", "multi-reference", "fast"],
1031
1148
  features: ["reference-image"],
1149
+ refusesImagesOverLimit: true,
1032
1150
  aspectRatios: FLUX_3_KLEIN_I2I_RATIOS,
1033
1151
  strictAspectRatios: true,
1034
1152
  resolutions: FLUX_3_KLEIN_RESOLUTIONS,
1153
+ defaultResolution: FLUX_3_KLEIN_DEFAULT_RESOLUTION,
1035
1154
  outputFormats: FLUX_3_KLEIN_FORMATS,
1036
1155
  pricing: [
1037
1156
  { identifier: "flux-3-klein-i2i", credits: 4, note: "1K default" },
@@ -4110,6 +4229,29 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
4110
4229
  { identifier: "video-analysis:gemini-3.1-pro:600s", credits: 1056, note: "10-min ceiling" },
4111
4230
  ],
4112
4231
  },
4232
+ // ULTRA (since 2026-11-13) — the deepest-reasoning analysis model reading
4233
+ // every window, at the same frame sampling as the other single-model tiers.
4234
+ // Priced between the mixed tiers and smart.
4235
+ "gemini-4-carbon-video-analysis": {
4236
+ id: "gemini-4-carbon-video-analysis",
4237
+ kind: "video",
4238
+ modes: ["video-analysis"] as const,
4239
+ family: "Nodaro",
4240
+ maker: "nodaro",
4241
+ label: "Video Analysis (Ultra)",
4242
+ series: "Video Analysis",
4243
+ description: "Deep-reasoning analysis — the most thorough model reads every window of the video. Better on fast cuts and on scenes with many people, and it does not invent cuts. Billed per duration bucket.",
4244
+ // Not `most-accurate`: that tag is Smart's (hand-counted edit list, always
4245
+ // refined). Ultra's strengths are the footage that trips the other tiers.
4246
+ useCases: ["video-analysis", "shot-list", "premium", "fast-cuts", "many-people", "no-invented-cuts"],
4247
+ pricing: [
4248
+ { identifier: "video-analysis:gemini-4-carbon", credits: 1745, note: "10-min ceiling (no duration given)" },
4249
+ { identifier: "video-analysis:gemini-4-carbon:60s", credits: 349 },
4250
+ { identifier: "video-analysis:gemini-4-carbon:180s", credits: 375 },
4251
+ { identifier: "video-analysis:gemini-4-carbon:360s", credits: 1054 },
4252
+ { identifier: "video-analysis:gemini-4-carbon:600s", credits: 1745, note: "10-min ceiling" },
4253
+ ],
4254
+ },
4113
4255
  // Both mixed tiers are variants of the same advanced multi-engine analysis
4114
4256
  // and share this ONE credit family (videoAnalysisCreditSegment maps both;
4115
4257
  // plan internals live in the private analysis plugin).
@@ -4244,6 +4386,65 @@ const DIALOGUE_V4_MAX_CHARS = 10000
4244
4386
  */
4245
4387
  const V4_TURBO_MAX_CHARS = 10000
4246
4388
 
4389
+ /**
4390
+ * Gemini 3.8 (Flash-Lite, Flash) speech, one speaker: its own 70 voices, its
4391
+ * closed list of `<angle>` tone tags, a free-text style per line. No language
4392
+ * field, no timings, no neighbour text, no ElevenLabs levers. From the
4393
+ * provider's schema (2026-11-12); whether each tag is performed rather than
4394
+ * read aloud is to be checked on staging.
4395
+ */
4396
+ const GEMINI_3_8_TTS_SHEET: TtsCapabilities = {
4397
+ audioTags: true,
4398
+ tagSyntax: "angle",
4399
+ tags: GEMINI_3_8_TONE_TAGS,
4400
+ ssmlBreaks: false,
4401
+ levers: [],
4402
+ languageCode: false,
4403
+ timestamps: false,
4404
+ stitching: false,
4405
+ maxChars: GEMINI_TTS_MAX_CHARS,
4406
+ // No picker: the language follows the text.
4407
+ languages: [],
4408
+ voices: GEMINI_3_8_TTS_VOICES,
4409
+ defaultVoice: GEMINI_3_8_DEFAULT_VOICE,
4410
+ direction: { styleMaxChars: TTS_DIRECTION_MAX_CHARS },
4411
+ ratePer1kChars: true,
4412
+ // Two-speaker dialogue (decided 2026-11-12): one or two voices, a style per line, filler words on request.
4413
+ dialogueSpeakers: 2,
4414
+ fillerWords: true,
4415
+ // A dialogue's file is chosen as one speaker's is: MP3 or the WAV as rendered (decided 2026-11-13).
4416
+ dialogueAnyOutputFormat: true,
4417
+ }
4418
+
4419
+ /**
4420
+ * Gemini 3.1 Flash and 2.5 Pro speech, one speaker: 30 voices, `[square]`
4421
+ * tone tags written freely (sent as written), and the speaker's style, pace,
4422
+ * accent and audio profile. Otherwise as the 3.8 sheet.
4423
+ */
4424
+ const GEMINI_3_1_TTS_SHEET: TtsCapabilities = {
4425
+ audioTags: true,
4426
+ ssmlBreaks: false,
4427
+ levers: [],
4428
+ languageCode: false,
4429
+ timestamps: false,
4430
+ stitching: false,
4431
+ maxChars: GEMINI_TTS_MAX_CHARS,
4432
+ languages: [],
4433
+ voices: GEMINI_3_1_TTS_VOICES,
4434
+ defaultVoice: GEMINI_3_1_DEFAULT_VOICE,
4435
+ direction: {
4436
+ styles: GEMINI_3_1_TTS_STYLES,
4437
+ paces: GEMINI_3_1_TTS_PACES,
4438
+ accents: GEMINI_3_1_TTS_ACCENTS,
4439
+ audioProfileMaxChars: TTS_DIRECTION_MAX_CHARS,
4440
+ },
4441
+ ratePer1kChars: true,
4442
+ // Two-speaker dialogue (decided 2026-11-12): one or two voices, the style, pace, accent and profile per speaker.
4443
+ dialogueSpeakers: 2,
4444
+ // A dialogue's file is chosen as one speaker's is: MP3 or the WAV as rendered (decided 2026-11-13).
4445
+ dialogueAnyOutputFormat: true,
4446
+ }
4447
+
4247
4448
  const AUDIO_MODELS: Record<string, ModelCatalogEntry> = {
4248
4449
  // ── ElevenLabs TTS ──
4249
4450
  "elevenlabs-v3": {
@@ -4392,6 +4593,86 @@ const AUDIO_MODELS: Record<string, ModelCatalogEntry> = {
4392
4593
  languages: TTS_LANGS_MULTILINGUAL_V2,
4393
4594
  },
4394
4595
  },
4596
+
4597
+ // ── Google Gemini TTS (through KIE) ──
4598
+ // One id per model for both lanes: the same KIE model takes one speaker
4599
+ // (Text to Speech) and two (Text to Dialogue), and dialogue costs the same per
4600
+ // character as one speaker (decided 2026-11-12) — so `tts` AND `dialogue`,
4601
+ // one sheet and one price row, the same rate by construction.
4602
+ // Named voices of their own (never ElevenLabs'), no language field (the
4603
+ // language follows the text), no timings, no neighbour text. Priced per
4604
+ // 1,000 characters on the same count as every speech model (decided
4605
+ // 2026-11-12, provisional until measured on staging); the flat row is the
4606
+ // price of 1,000 characters.
4607
+ "gemini-3-8-flash-lite-tts": {
4608
+ id: "gemini-3-8-flash-lite-tts",
4609
+ kind: "audio",
4610
+ modes: ["tts", "dialogue"] as const,
4611
+ family: "Google",
4612
+ maker: "google",
4613
+ label: "Gemini 3.8 Flash-Lite TTS",
4614
+ series: "Gemini",
4615
+ description: "Google's lightest Gemini speech model and the cheapest speech on the platform — 70 named voices grouped by use, its own tone tags (laugh, sigh, short pause and more) and a free-text style direction. The language follows the text; up to 10,000 characters per request. Also voices a dialogue of two speakers.",
4616
+ useCases: ["tts", "voice-over", "narration", "fast", "budget"],
4617
+ features: ["audio-tags"],
4618
+ pricing: [
4619
+ { identifier: "gemini-3-8-flash-lite-tts", credits: 4 },
4620
+ { identifier: "gemini-3-8-flash-lite-tts:per-1k-chars", credits: 4, note: SPEECH_PER_1K_PRICE_NOTE },
4621
+ ],
4622
+ tts: GEMINI_3_8_TTS_SHEET,
4623
+ },
4624
+ "gemini-3-8-flash-tts": {
4625
+ id: "gemini-3-8-flash-tts",
4626
+ kind: "audio",
4627
+ modes: ["tts", "dialogue"] as const,
4628
+ family: "Google",
4629
+ maker: "google",
4630
+ label: "Gemini 3.8 Flash TTS",
4631
+ series: "Gemini",
4632
+ description: "Google's Gemini 3.8 speech model — the same 70 voices, tone tags and free-text style direction as Flash-Lite, from the larger model of the generation. The language follows the text; up to 10,000 characters per request. Also voices a dialogue of two speakers.",
4633
+ useCases: ["tts", "voice-over", "narration", "expressive"],
4634
+ features: ["audio-tags"],
4635
+ pricing: [
4636
+ { identifier: "gemini-3-8-flash-tts", credits: 6 },
4637
+ { identifier: "gemini-3-8-flash-tts:per-1k-chars", credits: 6, note: SPEECH_PER_1K_PRICE_NOTE },
4638
+ ],
4639
+ // A one-off clone (`replica`, decided 2026-11-13) on 3.8 Flash alone: its Flash-Lite sibling refuses it.
4640
+ tts: { ...GEMINI_3_8_TTS_SHEET, replica: true },
4641
+ },
4642
+ "gemini-3-1-flash-tts": {
4643
+ id: "gemini-3-1-flash-tts",
4644
+ kind: "audio",
4645
+ modes: ["tts", "dialogue"] as const,
4646
+ family: "Google",
4647
+ maker: "google",
4648
+ label: "Gemini 3.1 Flash TTS",
4649
+ series: "Gemini",
4650
+ description: "Google's Gemini 3.1 speech model — 30 named voices, [audio tags] written freely, and a speaking style, pace, accent and audio profile for the speaker. The language follows the text; up to 10,000 characters per request. Also voices a dialogue of two speakers.",
4651
+ useCases: ["tts", "voice-over", "narration", "expressive"],
4652
+ features: ["audio-tags"],
4653
+ pricing: [
4654
+ { identifier: "gemini-3-1-flash-tts", credits: 13 },
4655
+ { identifier: "gemini-3-1-flash-tts:per-1k-chars", credits: 13, note: SPEECH_PER_1K_PRICE_NOTE },
4656
+ ],
4657
+ tts: GEMINI_3_1_TTS_SHEET,
4658
+ },
4659
+ "gemini-2-5-pro-tts": {
4660
+ id: "gemini-2-5-pro-tts",
4661
+ kind: "audio",
4662
+ modes: ["tts", "dialogue"] as const,
4663
+ family: "Google",
4664
+ maker: "google",
4665
+ label: "Gemini 2.5 Pro TTS",
4666
+ series: "Gemini",
4667
+ description: "Google's Gemini 2.5 Pro speech model — the same 30 voices, [audio tags] and speaker controls (style, pace, accent, audio profile) as Gemini 3.1 Flash TTS, from the Pro model. The language follows the text; up to 10,000 characters per request. Also voices a dialogue of two speakers.",
4668
+ useCases: ["tts", "voice-over", "narration", "expressive", "long-form"],
4669
+ features: ["audio-tags"],
4670
+ pricing: [
4671
+ { identifier: "gemini-2-5-pro-tts", credits: 16 },
4672
+ { identifier: "gemini-2-5-pro-tts:per-1k-chars", credits: 16, note: SPEECH_PER_1K_PRICE_NOTE },
4673
+ ],
4674
+ tts: GEMINI_3_1_TTS_SHEET,
4675
+ },
4395
4676
  "elevenlabs-dialogue": {
4396
4677
  id: "elevenlabs-dialogue",
4397
4678
  kind: "audio",
@@ -854,6 +854,13 @@ export const DEFAULT_REQUEST_IMAGE_LIMIT = 14
854
854
  * 2.6 takes more; a model whose provider takes fewer (Seedream 5.5 and FLUX 3
855
855
  * Klein: 10) is held to its own, so a request is refused before it is
856
856
  * reserved instead of failing at the provider.
857
+ *
858
+ * A row here is also what makes a request over the limit refused rather than
859
+ * trimmed ({@link hasOwnRequestImageLimit}, decided 2026-11-14): the routes,
860
+ * MCP and the editor's Run send every image such a request names, and the
861
+ * route says how many to remove. A workflow run on such a model still sends
862
+ * its first images up to the limit, unless its catalog entry also refuses
863
+ * there ({@link refusesImagesOverLimit}).
857
864
  */
858
865
  const REQUEST_IMAGE_LIMITS: Record<string, number> = {
859
866
  "gpt-image-2-6-flare-i2i": 16,
@@ -875,6 +882,62 @@ export function requestImageLimit(provider: string | undefined): number {
875
882
  return (effective !== undefined ? REQUEST_IMAGE_LIMITS[effective] : undefined) ?? DEFAULT_REQUEST_IMAGE_LIMIT
876
883
  }
877
884
 
885
+ /**
886
+ * True for a model with a request image limit of its own: a row in the table
887
+ * above, read through a text-to-image id's edit sibling as
888
+ * {@link requestImageLimit} reads it (GPT Image 2.6 Flare and Sunburst,
889
+ * MiniMax H3 Image, Seedream 5.5, FLUX 3 Klein). False for a model held to
890
+ * {@link DEFAULT_REQUEST_IMAGE_LIMIT}.
891
+ */
892
+ export function hasOwnRequestImageLimit(provider: string | undefined): boolean {
893
+ if (provider === undefined) return false
894
+ return Object.hasOwn(REQUEST_IMAGE_LIMITS, T2I_TO_I2I_VARIANT[provider] ?? provider)
895
+ }
896
+
897
+ /**
898
+ * True for a model that refuses a WORKFLOW run sending more input images than
899
+ * {@link requestImageLimit} allows, the source or base image counted, instead
900
+ * of having some left out (its catalog entry's `refusesImagesOverLimit`:
901
+ * FLUX 3 Klein). A request is refused on more models
902
+ * ({@link refusesImagesOverLimitOn}). The prompt assembler never trims such a
903
+ * model's references, so every place that refuses counts the images the run
904
+ * would really send. False for every other model, whose workflow runs still
905
+ * trim structured references to its reference limit
906
+ * ({@link imageReferenceLimit}).
907
+ */
908
+ export function refusesImagesOverLimit(provider: string | undefined): boolean {
909
+ return provider !== undefined && MODEL_CATALOG[provider]?.refusesImagesOverLimit === true
910
+ }
911
+
912
+ /**
913
+ * How a run was asked for, which decides what happens to images past a
914
+ * model's limit: `"request"` is one call to a route (the API, an MCP tool,
915
+ * the editor's Run of one node), `"workflow"` a node of a workflow run.
916
+ */
917
+ export type ImageRunKind = "request" | "workflow"
918
+
919
+ /**
920
+ * True when a run of this kind that would send `provider` more input images
921
+ * than {@link requestImageLimit} allows is refused before anything is
922
+ * reserved, saying how many to remove, rather than having the images past the
923
+ * limit left out (decided 2026-11-14):
924
+ *
925
+ * - a request, on every model with a request image limit of its own
926
+ * ({@link hasOwnRequestImageLimit}): nothing trims it first, so the count
927
+ * refused is the count the request names;
928
+ * - a workflow run, only on a model whose catalog entry carries
929
+ * `refusesImagesOverLimit` (FLUX 3 Klein). Every other model's workflow run
930
+ * keeps its rule: its first images up to the limit are sent, so a saved
931
+ * graph keeps running.
932
+ *
933
+ * False on a model held to {@link DEFAULT_REQUEST_IMAGE_LIMIT} (Nano Banana
934
+ * Pro, Flux 2 Pro): its structured references are trimmed to its reference
935
+ * limit on every kind of run, as before.
936
+ */
937
+ export function refusesImagesOverLimitOn(provider: string | undefined, run: ImageRunKind): boolean {
938
+ return refusesImagesOverLimit(provider) || (run === "request" && hasOwnRequestImageLimit(provider))
939
+ }
940
+
878
941
  // Variable pricing: which setting type affects cost per provider
879
942
  export const VARIABLE_PRICING_MODELS: Record<string, "quality" | "resolution" | "rendering-speed"> = {
880
943
  "gpt-image": "quality",
@@ -1805,6 +1868,12 @@ export const TTS_PROVIDERS = [
1805
1868
  "elevenlabs-v4-turbo",
1806
1869
  "elevenlabs-turbo",
1807
1870
  "elevenlabs-multilingual",
1871
+ // Google's Gemini speech through KIE (decided 2026-11-12): named voices of
1872
+ // their own (`TtsCapabilities.voices`), never ElevenLabs'.
1873
+ "gemini-3-8-flash-lite-tts",
1874
+ "gemini-3-8-flash-tts",
1875
+ "gemini-3-1-flash-tts",
1876
+ "gemini-2-5-pro-tts",
1808
1877
  "elevenlabs",
1809
1878
  ] as const
1810
1879
  export type TtsProvider = typeof TTS_PROVIDERS[number]
@@ -1831,10 +1900,20 @@ export const TTS_OUTPUT_FORMAT_FILES: Readonly<Record<TtsOutputFormat, { readonl
1831
1900
  /**
1832
1901
  * Text-to-dialogue models (the `provider` of `/v1/text-to-dialogue` and of the
1833
1902
  * Text to Dialogue node). Each IS its catalog id and its credit identifier.
1834
- * Never members of TTS_PROVIDERS: a dialogue model takes a script of lines, not
1835
- * one text (`dialogue-capabilities.test.ts` pins both directions).
1836
- */
1837
- export const DIALOGUE_PROVIDERS = ["elevenlabs-dialogue", "elevenlabs-dialogue-v4"] as const
1903
+ * The ElevenLabs dialogue models are dialogue-only ids, never members of
1904
+ * TTS_PROVIDERS: their dialogue endpoint is its own model. Google's Gemini
1905
+ * models take one speaker and two under ONE id, so each is in both lists,
1906
+ * priced on its one row (dialogue costs what one speaker costs per character,
1907
+ * decided 2026-11-12); `dialogue-capabilities.test.ts` pins exactly that.
1908
+ */
1909
+ export const DIALOGUE_PROVIDERS = [
1910
+ "elevenlabs-dialogue",
1911
+ "elevenlabs-dialogue-v4",
1912
+ "gemini-3-8-flash-lite-tts",
1913
+ "gemini-3-8-flash-tts",
1914
+ "gemini-3-1-flash-tts",
1915
+ "gemini-2-5-pro-tts",
1916
+ ] as const
1838
1917
  export type DialogueProvider = typeof DIALOGUE_PROVIDERS[number]
1839
1918
 
1840
1919
  /** The model a dialogue request runs on when its provider is missing or unknown: v3 dialogue (decided 2026-10-04 — v3 stays the default). */
@@ -3184,6 +3263,30 @@ export const VIDEO_REF_LIMITS_BY_PROVIDER: Record<
3184
3263
  * `elements[].voice_url`, no standalone `voices`).
3185
3264
  */
3186
3265
  audioBindsToCharacters?: true
3266
+ /**
3267
+ * How many of the `characters` may be VIDEO subjects — a character made
3268
+ * from a short clip of itself (`characterReferences[].videoUrl`) instead of
3269
+ * images. The clip counts as one of the `videos` too: the provider caps
3270
+ * reference videos and video subjects together. Absent ⇒ none (any other
3271
+ * model refuses a character video). Each clip's own length is
3272
+ * `VIDEO_CHARACTER_CLIP_DURATION_LIMITS`.
3273
+ */
3274
+ videoCharacters?: number
3275
+ /**
3276
+ * The provider bills a video subject's clip as reference-video seconds
3277
+ * (its with-video rate on output + input), so the run is priced as a
3278
+ * reference-video run with the clip among its input seconds. Absent ⇒ a
3279
+ * video subject is priced like an image subject: it adds no input seconds
3280
+ * and does not move the run onto the reference-video rate (its clip still
3281
+ * counts toward the `videos` cap and the reference videos' total length).
3282
+ * Read through `videoCharacterClipsBilledAsReferenceVideo`.
3283
+ *
3284
+ * No model sets it today: Kling 4.0 and Kling 4.0 Flash, both measured,
3285
+ * bill a video subject like an image subject (decided 2026-11-14). It stays
3286
+ * for a model whose provider bills the clip, so that model declares it here
3287
+ * and every price path follows.
3288
+ */
3289
+ videoCharactersBillAsReferenceVideo?: true
3187
3290
  } | undefined
3188
3291
  > = {
3189
3292
  // Seedance 2 — full multimodal caps.
@@ -3228,7 +3331,11 @@ export const VIDEO_REF_LIMITS_BY_PROVIDER: Record<
3228
3331
  // (docs.kie.ai/market/kling/v4-reference-to-video). A wired start frame takes
3229
3332
  // one of the 10 image slots. No `voices` key: that names Gemini Omni's
3230
3333
  // preset personas, which Kling does not take.
3231
- "kling-4": { images: 10, videos: 5, audio: 3, characters: 7, materials: 15 },
3334
+ // Of the 7 subjects, at most 3 may be video subjects (a 3-8 s clip each), and
3335
+ // reference videos plus video subjects are at most 5. A video subject is
3336
+ // billed like an image subject (measured, decided 2026-11-14), as on Flash:
3337
+ // no `videoCharactersBillAsReferenceVideo`.
3338
+ "kling-4": { images: 10, videos: 5, audio: 3, characters: 7, materials: 15, videoCharacters: 3 },
3232
3339
  // Kling 4.0 Keyframes — the Image References are the in-between frames
3233
3340
  // (`keyframe_urls`, max 8; the clip's duration lowers the cap, see
3234
3341
  // kling4KeyframeFrameCap). No reference videos or audio.
@@ -3238,8 +3345,9 @@ export const VIDEO_REF_LIMITS_BY_PROVIDER: Record<
3238
3345
  // standalone voices: reference audio clip N becomes wired character N's voice
3239
3346
  // (`voice_url`) when that character is a subject (2-4 images), so at most one
3240
3347
  // per character (7) and none takes a material seat. A wired start frame takes one of the 10 image slots when it
3241
- // runs on this endpoint.
3242
- "kling-4-flash": { images: 10, videos: 5, audio: 7, characters: 7, materials: 15, audioBindsToCharacters: true },
3348
+ // runs on this endpoint. A video subject is billed like an image subject
3349
+ // (measured, decided 2026-11-14): no `videoCharactersBillAsReferenceVideo`.
3350
+ "kling-4-flash": { images: 10, videos: 5, audio: 7, characters: 7, materials: 15, audioBindsToCharacters: true, videoCharacters: 3 },
3243
3351
  "grok-i2v": { images: 7 }, // backend kie/models.ts maxRefImages: 7
3244
3352
  "happyhorse-ref2v": { images: 9 }, // backend kie/models.ts maxRefImages: 9
3245
3353
  // VEO 3.x — REFERENCE_2_VIDEO path caps refs at 3 (kie/video.ts slices to
@@ -3320,6 +3428,56 @@ export const VIDEO_REF_VIDEO_DURATION_LIMITS: Record<string, RefVideoDurationLim
3320
3428
  "kling-4-flash": { minSec: 2, maxSec: 20, maxTotalSec: 20 },
3321
3429
  }
3322
3430
 
3431
+ /**
3432
+ * The length a character's own clip (`characterReferences[].videoUrl`, a video
3433
+ * subject) must have, per provider. Kling 4.0 and Kling 4.0 Flash: "one 3-8
3434
+ * second single-shot character video" (docs.kie.ai/market/kling/v4-reference-to-video,
3435
+ * v4-flash-reference-to-video, read 2026-11-13). The clip is also one of the
3436
+ * run's reference videos, so `VIDEO_REF_VIDEO_DURATION_LIMITS` (its per-clip
3437
+ * bound and the combined `maxTotalSec`) applies to it as well.
3438
+ */
3439
+ export const VIDEO_CHARACTER_CLIP_DURATION_LIMITS: Record<string, { minSec: number; maxSec: number } | undefined> = {
3440
+ "kling-4": { minSec: 3, maxSec: 8 },
3441
+ "kling-4-flash": { minSec: 3, maxSec: 8 },
3442
+ }
3443
+
3444
+ /**
3445
+ * Validate probed character-clip durations against
3446
+ * {@link VIDEO_CHARACTER_CLIP_DURATION_LIMITS}. Unlike a reference video
3447
+ * ({@link checkRefVideoDurations}, which ignores a clip the probe could not
3448
+ * read and charges its worst case), a character's clip must be measured within
3449
+ * its bounds to be accepted (decided 2026-11-13): one the probe could not read
3450
+ * (NaN, ≤0) is refused too, as `character_video_unreadable`.
3451
+ */
3452
+ export function checkCharacterClipDurations(
3453
+ provider: string,
3454
+ durationsSec: readonly number[],
3455
+ ): { ok: true } | { ok: false; code: "video_too_long" | "character_video_unreadable"; message: string } {
3456
+ const limit = VIDEO_CHARACTER_CLIP_DURATION_LIMITS[provider]
3457
+ if (!limit) return { ok: true }
3458
+ if (durationsSec.some((d) => !Number.isFinite(d) || d <= 0)) {
3459
+ return {
3460
+ ok: false,
3461
+ code: "character_video_unreadable",
3462
+ message:
3463
+ `A character's video could not be measured, and it must be ${limit.minSec}–${limit.maxSec} seconds long. ` +
3464
+ "Check that the link is a playable video file anyone can open, and run again. Nothing was charged.",
3465
+ }
3466
+ }
3467
+ const offender = durationsSec.find((d) => d < limit.minSec || d > limit.maxSec)
3468
+ if (offender === undefined) return { ok: true }
3469
+ // The measured length, rounded UP to hundredths, so a clip just past the
3470
+ // bound never reads as inside it (8.03 s, never "8.0 s").
3471
+ const shown = (Math.ceil(offender * 100 - 1e-9) / 100).toFixed(2)
3472
+ return {
3473
+ ok: false,
3474
+ code: "video_too_long",
3475
+ message:
3476
+ `A character's video must be between ${limit.minSec} and ${limit.maxSec} seconds — one is ${shown} s. ` +
3477
+ `Use a single-shot clip of that length (a Trim Video node upstream works) and run again.`,
3478
+ }
3479
+ }
3480
+
3323
3481
  /**
3324
3482
  * Validate probed reference-video durations against the provider's limits.
3325
3483
  *
@@ -4492,7 +4650,8 @@ export const VIDEO_DURATION_TIERS: Record<string, Array<{ maxSeconds: number; su
4492
4650
  // The length tiers of the earlier Seedance Extend rows
4493
4651
  // (`seedance-2-extend:<tier>:<res>`). No extend is priced on them any more —
4494
4652
  // each Seedance extend provider has a row per second (`tailExtendCreditId`)
4495
- // — but the rows stay, and so do their tiers.
4653
+ // — and the rows themselves were removed (migration 648); the tiers stay,
4654
+ // unread, as part of this published table.
4496
4655
  "seedance-2-extend": [
4497
4656
  { maxSeconds: 4, suffix: "4s" },
4498
4657
  { maxSeconds: 8, suffix: "8s" },