@nodaro/shared 3.23.0 → 3.25.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 (39) hide show
  1. package/dist/index.cjs +625 -151
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +389 -48
  4. package/dist/index.d.ts +389 -48
  5. package/dist/index.js +582 -152
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/__tests__/credit-identifiers.test.ts +19 -6
  9. package/src/__tests__/dialogue-capabilities.test.ts +3 -2
  10. package/src/__tests__/edit-plan-minute-ids.test.ts +82 -0
  11. package/src/__tests__/json-kinds.test.ts +179 -0
  12. package/src/__tests__/presentation-utils.test.ts +1 -0
  13. package/src/__tests__/preview-gate.test.ts +2 -2
  14. package/src/__tests__/pricing-default-duration.test.ts +56 -15
  15. package/src/__tests__/private-host.test.ts +24 -0
  16. package/src/__tests__/render-nodes.test.ts +22 -3
  17. package/src/__tests__/tts-capabilities.test.ts +61 -1
  18. package/src/__tests__/video-link-input.test.ts +148 -0
  19. package/src/__tests__/video-link-needs.test.ts +67 -0
  20. package/src/__tests__/video-request-normalize.test.ts +18 -3
  21. package/src/collections.ts +20 -0
  22. package/src/credit-identifiers.ts +48 -37
  23. package/src/edit-plan-contract.ts +67 -1
  24. package/src/fan-out-rows.ts +2 -2
  25. package/src/handle-aliases.ts +29 -26
  26. package/src/index.ts +46 -1
  27. package/src/json-kinds.ts +188 -0
  28. package/src/model-catalog.ts +121 -8
  29. package/src/model-constants.ts +68 -42
  30. package/src/node-default-mappings.ts +1 -0
  31. package/src/pipeline-types.ts +13 -2
  32. package/src/presentation-utils.ts +8 -1
  33. package/src/private-host.ts +91 -0
  34. package/src/producer-types.ts +3 -0
  35. package/src/render-nodes.ts +12 -1
  36. package/src/scene-node-types.ts +17 -5
  37. package/src/social-post-readers.ts +37 -0
  38. package/src/video-link.ts +238 -0
  39. package/src/voices.ts +16 -9
@@ -220,6 +220,14 @@ export interface ModelCatalogEntry {
220
220
  unlistedResolutionRendersAs?: string
221
221
  qualities?: readonly string[]
222
222
  durations?: readonly number[]
223
+ /**
224
+ * The length (seconds) this model renders when the request names no duration
225
+ * — a capability fact, and the length an unset duration is CHARGED at
226
+ * (`pricedOutputDurationSec`). A member of `durations`. REQUIRED on every
227
+ * video model priced by length (`pricing-default-duration-sync.test.ts`), and
228
+ * where the KIE config pins `extraParams.duration` it must equal that pin.
229
+ */
230
+ defaultDuration?: number
223
231
  /**
224
232
  * The model accepts an AUTO duration (`duration: -1`, see
225
233
  * `VIDEO_DURATION_AUTO`): it picks the clip length itself — the source clip's
@@ -288,7 +296,7 @@ export const MODEL_RECOMMENDATIONS: readonly ModelRecommendation[] = [
288
296
  { intent: "cheap batch video clips", modelIds: ["veo3.1", "wan-turbo", "bytedance-lite"], note: "VEO 3.1 Fast is the best price/quality balance with native audio." },
289
297
  { 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]." },
290
298
  { 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." },
291
- { intent: "voice over / narration", modelIds: ["elevenlabs-v4", "elevenlabs-v3", "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. Turbo is cheaper for plain narration." },
299
+ { 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." },
292
300
  { intent: "lip-sync a portrait to audio", modelIds: ["kling-avatar-pro", "kling-avatar", "infinitalk"], note: "Pro for best mouth shape; InfiniTalk for resolution control." },
293
301
  { intent: "transcription / captions", modelIds: ["elevenlabs-stt", "incredibly-fast-whisper", "whisper"], note: "Captions need WORD timestamps: ElevenLabs STT (always) or Incredibly Fast Whisper. Plain Whisper returns phrase segments only." },
294
302
  { 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." },
@@ -304,6 +312,10 @@ const NANO_BANANA_RATIOS = ["1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "
304
312
  // nano-banana-2-lite). Kept separate so the wider set can't leak to the
305
313
  // rest of the family.
306
314
  const NANO_BANANA_2_LITE_RATIOS = ["auto", "1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "4:5", "5:4", "21:9", "4:1", "1:4", "8:1", "1:8"] as const
315
+ // Nano Banana 2.1 — its own documented enum, the same fifteen ratios as Lite
316
+ // (docs.kie.ai/market/google/nanobanana-2-1). Declared separately so a change to
317
+ // either model's set cannot silently move the other.
318
+ const NANO_BANANA_2_1_RATIOS = ["auto", "1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "4:5", "5:4", "21:9", "4:1", "1:4", "8:1", "1:8"] as const
307
319
  // Note: these arrays are synchronized with the frontend's
308
320
  // `model-options.ts` constants of the same names. The frontend now imports
309
321
  // them via the `getAspectRatioOptions(modelId)` helper; if you update one
@@ -389,6 +401,26 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
389
401
  { identifier: "nano-banana-2:4K", credits: 50, note: "4K" },
390
402
  ],
391
403
  },
404
+ "nano-banana-2-1": {
405
+ id: "nano-banana-2-1",
406
+ kind: "image",
407
+ // Single id for both modes, like nano-banana-2: optional input images via
408
+ // image_input (up to 10) on the one endpoint.
409
+ modes: ["t2i", "i2i"] as const,
410
+ family: "Google",
411
+ label: "Nano Banana 2.1",
412
+ series: "Nano Banana",
413
+ description: "Google's high-efficiency image model for generation and editing — sharper quality, prompt adherence, character consistency and text rendering, up to 10 references and 4K output.",
414
+ useCases: ["realistic", "character", "typography", "high-res"],
415
+ features: ["reference-image"],
416
+ aspectRatios: NANO_BANANA_2_1_RATIOS,
417
+ resolutions: ["1K", "2K", "4K"],
418
+ pricing: [
419
+ { identifier: "nano-banana-2-1", credits: 10, note: "1K default" },
420
+ { identifier: "nano-banana-2-1:2K", credits: 20, note: "2K" },
421
+ { identifier: "nano-banana-2-1:4K", credits: 30, note: "4K" },
422
+ ],
423
+ },
392
424
  "nano-banana-2-lite": {
393
425
  id: "nano-banana-2-lite",
394
426
  kind: "image",
@@ -1201,6 +1233,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1201
1233
  useCases: ["realistic", "motion", "narrative"],
1202
1234
  features: ["end-frame"],
1203
1235
  durations: [5],
1236
+ defaultDuration: 5,
1204
1237
  pricing: [{ identifier: "minimax", credits: 143, note: "5s, 1080p" }],
1205
1238
  },
1206
1239
  // MiniMax Hailuo 3 (KIE "minimax-h3") — t2v / i2v (first and/or last frame) /
@@ -1226,6 +1259,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1226
1259
  features: ["end-frame", "audio", "reference-image", "video-reference"],
1227
1260
  aspectRatios: VIDEO_RATIOS_SEEDANCE_2,
1228
1261
  durations: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1262
+ defaultDuration: 6,
1229
1263
  // First entry = default (the UI dropdown + fail-safe snap use opts[0], and
1230
1264
  // 2K is the KIE-side default). Uppercase values are the exact KIE wire enum.
1231
1265
  resolutions: ["2K", "768P"],
@@ -1251,6 +1285,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1251
1285
  description: "Hailuo 2.3 Pro — newer Hailuo with 768P / 1080P resolutions.",
1252
1286
  useCases: ["realistic", "motion"],
1253
1287
  durations: [6, 10],
1288
+ defaultDuration: 6,
1254
1289
  resolutions: ["768P", "1080P"],
1255
1290
  pricing: [
1256
1291
  { identifier: "hailuo-2.3-pro", credits: 200, note: "10s default" },
@@ -1270,6 +1305,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1270
1305
  description: "Cheaper Hailuo 2.3 tier — good baseline quality.",
1271
1306
  useCases: ["realistic", "cheap"],
1272
1307
  durations: [6, 10],
1308
+ defaultDuration: 6,
1273
1309
  pricing: [
1274
1310
  { identifier: "hailuo-2.3", credits: 75, note: "6s default" },
1275
1311
  { identifier: "hailuo-2.3:6s", credits: 80, note: "6s" },
@@ -1287,6 +1323,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1287
1323
  useCases: ["cheap", "motion"],
1288
1324
  features: ["end-frame"],
1289
1325
  durations: [6, 10],
1326
+ defaultDuration: 6,
1290
1327
  resolutions: ["512P", "768P"],
1291
1328
  pricing: [
1292
1329
  { identifier: "hailuo-standard", credits: 75, note: "6s default" },
@@ -1315,6 +1352,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1315
1352
  // `veo3_lite` DO serve it and keep the flag.
1316
1353
  features: ["end-frame", "audio"],
1317
1354
  durations: [4, 6, 8],
1355
+ defaultDuration: 8,
1318
1356
  aspectRatios: VIDEO_RATIOS_HV,
1319
1357
  // 720p (default) + 1080p inline. 4K generates the base at 1080p then chains
1320
1358
  // KIE's /api/v1/veo/get-4k-video endpoint (worker handleImageToVideo / handleTextToVideo).
@@ -1336,6 +1374,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1336
1374
  useCases: ["cinematic", "fast", "general"],
1337
1375
  features: ["end-frame", "audio", "reference-image"],
1338
1376
  durations: [4, 6, 8],
1377
+ defaultDuration: 8,
1339
1378
  aspectRatios: VIDEO_RATIOS_HV,
1340
1379
  resolutions: ["720p", "1080p", "4k"],
1341
1380
  pricing: [
@@ -1356,6 +1395,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1356
1395
  useCases: ["cinematic", "cheap", "high-volume"],
1357
1396
  features: ["end-frame", "audio", "reference-image"],
1358
1397
  durations: [4, 6, 8],
1398
+ defaultDuration: 8,
1359
1399
  aspectRatios: VIDEO_RATIOS_HV,
1360
1400
  resolutions: ["720p", "1080p", "4k"],
1361
1401
  pricing: [
@@ -1378,6 +1418,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1378
1418
  aspectRatios: VIDEO_RATIOS_HV,
1379
1419
  resolutions: ["720p", "1080p", "4k"],
1380
1420
  durations: [4, 6, 8, 10],
1421
+ defaultDuration: 8,
1381
1422
  pricing: [
1382
1423
  { identifier: "gemini-omni-video", credits: 315, note: "default — 720p/1080p 4s" },
1383
1424
  { identifier: "gemini-omni-video:4", credits: 230, note: "720p/1080p 4s" },
@@ -1413,6 +1454,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1413
1454
  aspectRatios: VIDEO_RATIOS_HV,
1414
1455
  resolutions: ["720p", "1080p", "4k"],
1415
1456
  durations: [4, 6, 8, 10],
1457
+ defaultDuration: 8,
1416
1458
  pricing: [
1417
1459
  { identifier: "gemini-omni-flash", credits: 270, note: "default — 8s 720p/1080p (the credit builder's duration fallback)" },
1418
1460
  { identifier: "gemini-omni-flash:4", credits: 160, note: "720p/1080p 4s" },
@@ -1441,6 +1483,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1441
1483
  features: ["audio"],
1442
1484
  aspectRatios: VIDEO_RATIOS_HVS,
1443
1485
  durations: [5, 10],
1486
+ defaultDuration: 5,
1444
1487
  pricing: [
1445
1488
  { identifier: "kling", credits: 280, note: "10s no audio default" },
1446
1489
  { identifier: "kling:5s", credits: 138, note: "5s no audio" },
@@ -1460,6 +1503,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1460
1503
  useCases: ["fast", "motion", "cheap"],
1461
1504
  features: ["end-frame"],
1462
1505
  durations: [5, 10],
1506
+ defaultDuration: 5,
1463
1507
  pricing: [
1464
1508
  { identifier: "kling-turbo", credits: 125, note: "5s default" },
1465
1509
  { identifier: "kling-turbo:5s", credits: 110 },
@@ -1477,6 +1521,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1477
1521
  useCases: ["premium", "narrative", "cinematic"],
1478
1522
  features: ["end-frame", "audio"],
1479
1523
  durations: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1524
+ defaultDuration: 5,
1480
1525
  resolutions: ["720P", "1080P"],
1481
1526
  pricing: [
1482
1527
  { identifier: "kling-3.0", credits: 500, note: "5s 1080p with audio" },
@@ -1499,6 +1544,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1499
1544
  description: "Master tier I2V — strong cinematic quality.",
1500
1545
  useCases: ["cinematic", "premium"],
1501
1546
  durations: [5, 10],
1547
+ defaultDuration: 5,
1502
1548
  pricing: [
1503
1549
  { identifier: "kling-master", credits: 400, note: "5s default" },
1504
1550
  { identifier: "kling-master:5s", credits: 400 },
@@ -1516,6 +1562,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1516
1562
  useCases: ["motion", "cinematic", "reference"],
1517
1563
  features: ["end-frame", "reference-image"],
1518
1564
  durations: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1565
+ defaultDuration: 5,
1519
1566
  resolutions: ["720p", "1080p"],
1520
1567
  aspectRatios: VIDEO_RATIOS_HVS,
1521
1568
  pricing: [
@@ -1538,6 +1585,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1538
1585
  description: "Grok image-to-video — stylized motion. Up to 15s.",
1539
1586
  useCases: ["stylized", "motion"],
1540
1587
  durations: [6, 10],
1588
+ defaultDuration: 6,
1541
1589
  resolutions: ["480p", "720p"],
1542
1590
  pricing: [
1543
1591
  { identifier: "grok-i2v", credits: 150, note: "6s default" },
@@ -1566,6 +1614,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1566
1614
  useCases: ["stylized", "motion"],
1567
1615
  aspectRatios: ["16:9", "9:16", "1:1", "4:3", "3:4"],
1568
1616
  durations: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1617
+ defaultDuration: 8,
1569
1618
  resolutions: ["480p", "720p"],
1570
1619
  pricing: [
1571
1620
  { identifier: "grok-imagine-video-1.5", credits: 295, note: "default 8s 480p — see :Ns:res variants" },
@@ -1588,6 +1637,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1588
1637
  useCases: ["motion", "narrative"],
1589
1638
  features: ["end-frame"],
1590
1639
  durations: [4, 8, 12],
1640
+ defaultDuration: 8,
1591
1641
  resolutions: ["480p", "720p", "1080p"],
1592
1642
  pricing: [
1593
1643
  { identifier: "seedance", credits: 250, note: "8s default" },
@@ -1609,6 +1659,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1609
1659
  features: ["end-frame", "audio", "reference-image", "video-reference"],
1610
1660
  aspectRatios: VIDEO_RATIOS_SEEDANCE_2,
1611
1661
  durations: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1662
+ defaultDuration: 8,
1612
1663
  autoDuration: true,
1613
1664
  resolutions: ["480p", "720p", "1080p", "4k"],
1614
1665
  pricing: [
@@ -1635,6 +1686,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1635
1686
  features: ["end-frame", "audio", "reference-image", "video-reference"],
1636
1687
  aspectRatios: VIDEO_RATIOS_SEEDANCE_2,
1637
1688
  durations: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1689
+ defaultDuration: 8,
1638
1690
  autoDuration: true,
1639
1691
  resolutions: ["480p", "720p"],
1640
1692
  pricing: [
@@ -1657,6 +1709,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1657
1709
  features: ["end-frame", "audio", "reference-image", "video-reference"],
1658
1710
  aspectRatios: VIDEO_RATIOS_SEEDANCE_2,
1659
1711
  durations: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1712
+ defaultDuration: 8,
1660
1713
  autoDuration: true,
1661
1714
  resolutions: ["480p", "720p"],
1662
1715
  pricing: [
@@ -1685,6 +1738,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1685
1738
  features: ["end-frame", "audio", "reference-image", "video-reference"],
1686
1739
  aspectRatios: VIDEO_RATIOS_SEEDANCE_2,
1687
1740
  durations: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],
1741
+ defaultDuration: 8,
1688
1742
  autoDuration: true,
1689
1743
  resolutions: ["480p", "720p", "1080p"],
1690
1744
  pricing: [
@@ -1727,6 +1781,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1727
1781
  features: ["end-frame", "audio", "reference-image"],
1728
1782
  aspectRatios: VIDEO_RATIOS_WAN_3,
1729
1783
  durations: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],
1784
+ defaultDuration: 5,
1730
1785
  resolutions: ["480p", "720p", "1080p"],
1731
1786
  pricing: [
1732
1787
  { identifier: "wan-3", credits: 200, note: "default 5s 720p — see :Ns:res variants for exact" },
@@ -1752,6 +1807,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1752
1807
  features: ["end-frame", "audio", "reference-image"],
1753
1808
  aspectRatios: VIDEO_RATIOS_WAN_3,
1754
1809
  durations: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],
1810
+ defaultDuration: 5,
1755
1811
  resolutions: ["480p", "720p", "1080p"],
1756
1812
  pricing: [
1757
1813
  { identifier: "wan-3-prime", credits: 320, note: "default 5s 720p — see :Ns:res variants for exact" },
@@ -1774,6 +1830,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1774
1830
  description: "Wan 2.6 image-to-video — 5/10/15s at 720p/1080p.",
1775
1831
  useCases: ["motion", "narrative"],
1776
1832
  durations: [5, 10, 15],
1833
+ defaultDuration: 5,
1777
1834
  resolutions: ["720p", "1080p"],
1778
1835
  pricing: [
1779
1836
  { identifier: "wan-i2v", credits: 175, note: "5s 720p default" },
@@ -1793,6 +1850,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1793
1850
  useCases: ["cheap", "fast"],
1794
1851
  aspectRatios: VIDEO_RATIOS_HVS,
1795
1852
  durations: [5],
1853
+ defaultDuration: 5,
1796
1854
  resolutions: ["480p", "720p"],
1797
1855
  // Different KIE endpoints (i2v vs t2v) → different costs under
1798
1856
  // composite ids. Route picks endpoint based on whether image was supplied.
@@ -1813,6 +1871,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1813
1871
  description: "Wan 2.6 — text-to-video and video-to-video under a single id.",
1814
1872
  useCases: ["v2v", "t2v", "restyle"],
1815
1873
  durations: [5],
1874
+ defaultDuration: 5,
1816
1875
  resolutions: ["720p", "1080p"],
1817
1876
  pricing: [
1818
1877
  { identifier: "wan", credits: 175, note: "v2v 5s 720p" },
@@ -1888,6 +1947,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1888
1947
  description: "Wan 2.7 image-to-video — 2–15s at 720p/1080p, supports start+end frame.",
1889
1948
  useCases: ["motion", "narrative"],
1890
1949
  durations: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1950
+ defaultDuration: 5,
1891
1951
  resolutions: ["720p", "1080p"],
1892
1952
  features: ["end-frame"],
1893
1953
  pricing: [
@@ -1905,6 +1965,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1905
1965
  useCases: ["motion", "narrative"],
1906
1966
  aspectRatios: VIDEO_RATIOS_HVS345,
1907
1967
  durations: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1968
+ defaultDuration: 5,
1908
1969
  resolutions: ["720p", "1080p"],
1909
1970
  pricing: [
1910
1971
  { identifier: "wan-2.7-t2v", credits: 188, note: "5s 720p default" },
@@ -1931,6 +1992,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1931
1992
  aspectRatios: ["16:9", "9:16"] as const,
1932
1993
  resolutions: ["1080p", "2k", "4k"] as const,
1933
1994
  durations: [6, 8, 10],
1995
+ defaultDuration: 6,
1934
1996
  pricing: [
1935
1997
  { identifier: "ltx-2.3-pro", credits: 240, note: "default 1080p 6s" },
1936
1998
  { identifier: "ltx-2.3-pro:1080p:6s", credits: 240 },
@@ -1962,6 +2024,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1962
2024
  // in credit-identifiers.ts is the per-band authority and snaps a 2k/4k
1963
2025
  // request back onto 6/8/10s, so the reservation is always a real tier).
1964
2026
  durations: [6, 8, 10, 12, 14, 16, 18, 20],
2027
+ defaultDuration: 6,
1965
2028
  pricing: [
1966
2029
  { identifier: "ltx-2.3-fast", credits: 180, note: "default 1080p 6s" },
1967
2030
  { identifier: "ltx-2.3-fast:1080p:6s", credits: 180 },
@@ -1993,6 +2056,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1993
2056
  useCases: ["motion", "creative"],
1994
2057
  aspectRatios: VIDEO_RATIOS_HAPPYHORSE_11,
1995
2058
  durations: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
2059
+ defaultDuration: 5,
1996
2060
  resolutions: ["720p", "1080p"],
1997
2061
  pricing: [
1998
2062
  { identifier: "happyhorse", credits: 282, note: "5s 720p default — per-second: ~5.7 cr/s @720p, ~7.3 cr/s @1080p" },
@@ -2008,6 +2072,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2008
2072
  description: "HappyHorse 1.1 image-to-video — 3–15s at 720p/1080p, aspect ratio inferred from input image, per-second pricing.",
2009
2073
  useCases: ["motion", "creative"],
2010
2074
  durations: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
2075
+ defaultDuration: 5,
2011
2076
  resolutions: ["720p", "1080p"],
2012
2077
  pricing: [
2013
2078
  { identifier: "happyhorse-i2v", credits: 282, note: "5s 720p default — per-second: ~5.7 cr/s @720p, ~7.3 cr/s @1080p" },
@@ -2024,6 +2089,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2024
2089
  useCases: ["motion", "reference"],
2025
2090
  aspectRatios: VIDEO_RATIOS_HAPPYHORSE_11,
2026
2091
  durations: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
2092
+ defaultDuration: 5,
2027
2093
  resolutions: ["720p", "1080p"],
2028
2094
  features: ["reference-image"],
2029
2095
  pricing: [
@@ -2057,6 +2123,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2057
2123
  features: ["end-frame"],
2058
2124
  aspectRatios: VIDEO_RATIOS_HVS,
2059
2125
  durations: [5, 10],
2126
+ defaultDuration: 5,
2060
2127
  resolutions: ["480p", "720p", "1080p"],
2061
2128
  pricing: [{ identifier: "bytedance-lite", credits: 57 }],
2062
2129
  },
@@ -2071,6 +2138,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2071
2138
  useCases: ["motion", "narrative"],
2072
2139
  aspectRatios: VIDEO_RATIOS_HVS,
2073
2140
  durations: [5, 10],
2141
+ defaultDuration: 5,
2074
2142
  resolutions: ["480p", "720p", "1080p"],
2075
2143
  pricing: [{ identifier: "bytedance-pro", credits: 175 }],
2076
2144
  },
@@ -2084,6 +2152,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2084
2152
  description: "Faster Bytedance Pro variant.",
2085
2153
  useCases: ["fast", "motion"],
2086
2154
  durations: [5, 10],
2155
+ defaultDuration: 5,
2087
2156
  resolutions: ["720p", "1080p"],
2088
2157
  pricing: [{ identifier: "bytedance-pro-fast", credits: 90 }],
2089
2158
  },
@@ -2105,6 +2174,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2105
2174
  description: "Runway Gen-3 routed through KIE. 5/10s at 720p/1080p.",
2106
2175
  useCases: ["motion", "narrative"],
2107
2176
  durations: [5, 10],
2177
+ defaultDuration: 5,
2108
2178
  resolutions: ["720p", "1080p"],
2109
2179
  pricing: [{ identifier: "runway-kie", credits: 30, note: "5s 720p" }],
2110
2180
  },
@@ -2156,6 +2226,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2156
2226
  description: "Extend ANY video: generates the continuation (audio included) and trim-stitches it into one seamless clip.",
2157
2227
  useCases: ["extend"],
2158
2228
  durations: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
2229
+ defaultDuration: 8,
2159
2230
  resolutions: ["480p", "720p", "1080p"],
2160
2231
  pricing: [
2161
2232
  { identifier: "seedance-2-extend", credits: 530, note: "default 8s 720p (ref-mode 50 + 3 stitch) — see :NsR variants" },
@@ -2506,14 +2577,26 @@ const TTS_LANGS_V3 = [
2506
2577
  const TTS_LEVERS_V2 = ["stability", "similarity", "style", "speed", "speakerBoost"] as const
2507
2578
  /**
2508
2579
  * ElevenLabs Dialogue v4's total-character cap across lines — ONE constant, so
2509
- * the live probe's answer lands in one place. Rule (decided 2026-10-06): the
2510
- * largest of 2,500 / 5,000 that returned 200, voiced its last line and finished
2511
- * well inside the funnel's timeout in a live check of v4 dialogue above 2,000
2512
- * characters; never above 5,000 (parity with v3 dialogue) without a separate
2513
- * decision. Written at parity until that check reports; ElevenLabs recommends
2514
- * ≤ 2,000 for quality on either model.
2580
+ * the live probe's answer lands in one place. Measured 2026-10-06: a
2581
+ * 10,000-character v4 dialogue returned 200, voiced its last line and finished
2582
+ * whole in 130 s, well inside the funnel's 300 s timeout
2583
+ * (`DIALOGUE_GENERATION_TIMEOUT_MS`); decided 2026-10-07 to raise the cap to
2584
+ * that number, twice v3 dialogue's 5,000. Length pricing charges
2585
+ * `min(total, cap)`, so the same unit rows reach 10,000 characters without a
2586
+ * new row. ElevenLabs recommends ≤ 2,000 for quality on either model.
2587
+ */
2588
+ const DIALOGUE_V4_MAX_CHARS = 10000
2589
+ /**
2590
+ * ElevenLabs v4 Turbo's per-request character cap — ONE constant, so a change
2591
+ * of the owner's rule lands in one place. The vendor declares 10,000, the same
2592
+ * as v4 (`maximum_text_length_per_request`, measured 2026-10-07); live, both a
2593
+ * 10,000- and a 10,001-character request returned 200 (the vendor accepts over
2594
+ * its declared figure), so the platform clamps at the declared figure — the
2595
+ * smaller of the two. Decided 2026-10-07: the model takes that whole cap because
2596
+ * it ships priced per started 100 characters. An instance that still prices
2597
+ * speech flat charges the flat row for any length (the Text to Speech docs say so).
2515
2598
  */
2516
- const DIALOGUE_V4_MAX_CHARS = 5000
2599
+ const V4_TURBO_MAX_CHARS = 10000
2517
2600
 
2518
2601
  const AUDIO_MODELS: Record<string, ModelCatalogEntry> = {
2519
2602
  // ── ElevenLabs TTS ──
@@ -2574,6 +2657,36 @@ const AUDIO_MODELS: Record<string, ModelCatalogEntry> = {
2574
2657
  languages: TTS_LANGS_V3,
2575
2658
  },
2576
2659
  },
2660
+ "elevenlabs-v4-turbo": {
2661
+ id: "elevenlabs-v4-turbo",
2662
+ kind: "audio",
2663
+ modes: ["tts"] as const,
2664
+ family: "ElevenLabs",
2665
+ label: "ElevenLabs v4 Turbo",
2666
+ series: "ElevenLabs",
2667
+ description: "Faster, cheaper ElevenLabs v4 at lower fidelity — [audio tags], stability and similarity control, at Turbo's credit price. Prefer v4 when quality matters. Direct API.",
2668
+ useCases: ["tts", "voice-over", "narration", "expressive", "fast"],
2669
+ features: ["audio-tags", "voice-cloning"],
2670
+ // Flat per request at parity with Turbo v2.5 (what a run costs where length
2671
+ // pricing is off); per started 100 characters at Turbo's rate where it is on
2672
+ // (decided 2026-10-06).
2673
+ pricing: [
2674
+ { identifier: "elevenlabs-v4-turbo", credits: 15 },
2675
+ { identifier: "elevenlabs-v4-turbo:per-100-chars", credits: 2, note: SPEECH_UNIT_PRICE_NOTE },
2676
+ ],
2677
+ tts: {
2678
+ // Every value below was measured 2026-10-07 from live calls to eleven_v4_turbo.
2679
+ audioTags: true, // measured 2026-10-07: a tagged line → 200; Scribe hears no tag word spoken and lists [chuckles] as an audio event
2680
+ ssmlBreaks: false,
2681
+ levers: ["stability", "similarity"], // measured 2026-10-07: /v1/models can_use_style / can_use_speaker_boost both false, as v4; stability + similarity_boost → 200
2682
+ languageCode: true, // measured 2026-10-07: language_code "he" with Hebrew text → 200
2683
+ timestamps: true, // measured 2026-10-07: /with-timestamps answers 200 at the same character cost as the plain call
2684
+ stitching: true, // measured 2026-10-07: previous_text / next_text → 200, at the same character cost (context not billed)
2685
+ maxChars: V4_TURBO_MAX_CHARS,
2686
+ // The curated picker, the same 46 as v4 and v3 (the model lists 85; widening is its own change).
2687
+ languages: TTS_LANGS_V3, // measured 2026-10-07: all 46 present in the model's 85-language list
2688
+ },
2689
+ },
2577
2690
  "elevenlabs-turbo": {
2578
2691
  id: "elevenlabs-turbo",
2579
2692
  kind: "audio",
@@ -78,6 +78,7 @@ export const MAX_IMAGE_PROMPT_CHARS_BY_PROVIDER: Record<string, number> = {
78
78
  // ── higher than the 5000 default ──
79
79
  "nano-banana-2": 20000, // docs.kie.ai/market/google/nano-banana-2
80
80
  "nano-banana-2-lite": 20000, // docs.kie.ai/market/google/nano-banana-2-lite
81
+ "nano-banana-2-1": 20000, // docs.kie.ai/market/google/nanobanana-2-1
81
82
  "nano-banana-pro": 20000, // docs.kie.ai/market/google/pro-image-to-image
82
83
  "gpt-image-2-i2i": 20000, // docs.kie.ai/market/gpt/gpt-image-2-image-to-image
83
84
  // GPT Image 2.5 — all four lanes document a 20000-char prompt ceiling.
@@ -490,6 +491,7 @@ export const MODELS_WITH_REFERENCE_IMAGE_SUPPORT = new Set([
490
491
  "nano-banana-pro",
491
492
  "nano-banana-2",
492
493
  "nano-banana-2-lite",
494
+ "nano-banana-2-1",
493
495
  // T2I providers that auto-route to their i2i sibling when refs are attached
494
496
  "gpt-image",
495
497
  "gpt-image-2",
@@ -576,6 +578,7 @@ export const REF_IMAGE_MAX_LIMITS: Record<string, number> = {
576
578
  "nano-banana-pro": 8,
577
579
  "nano-banana-2": 4,
578
580
  "nano-banana-2-lite": 10,
581
+ "nano-banana-2-1": 10,
579
582
  "wan-2.7": 9,
580
583
  // grok-2 reference chain consumes exactly one image (segment-map input).
581
584
  "grok-2-i2i": 1,
@@ -655,6 +658,7 @@ export const VARIABLE_PRICING_MODELS: Record<string, "quality" | "resolution" |
655
658
  "gpt-image-2-5-sunburst-i2i": "resolution",
656
659
  "nano-banana-pro": "resolution",
657
660
  "nano-banana-2": "resolution",
661
+ "nano-banana-2-1": "resolution",
658
662
  "flux": "resolution",
659
663
  "flux-flex": "resolution",
660
664
  "flux-i2i": "resolution",
@@ -683,6 +687,7 @@ export const TWO_K_RESOLUTION_PROVIDERS = new Set(["flux", "flux-pro-i2i", "flux
683
687
  // Models where both 2K and 4K resolutions trigger composite credit identifiers (1K is base)
684
688
  export const RESOLUTION_2K_4K_TIERED_PROVIDERS = new Set([
685
689
  "nano-banana-2",
690
+ "nano-banana-2-1",
686
691
  "gpt-image-2",
687
692
  "gpt-image-2-i2i",
688
693
  "gpt-image-2-5-flare",
@@ -712,6 +717,7 @@ export const IMAGE_GEN_PROVIDERS = [
712
717
  "nano-banana-pro",
713
718
  "nano-banana-2",
714
719
  "nano-banana-2-lite",
720
+ "nano-banana-2-1",
715
721
  "grok",
716
722
  "grok-2",
717
723
  "gpt-image",
@@ -743,6 +749,7 @@ export const IMAGE_I2I_PROVIDERS = [
743
749
  "nano-banana",
744
750
  "nano-banana-2",
745
751
  "nano-banana-2-lite",
752
+ "nano-banana-2-1",
746
753
  "nano-banana-pro",
747
754
  "grok-i2i",
748
755
  "flux-i2i",
@@ -1216,6 +1223,7 @@ export type MotionTransferProviderType = typeof MOTION_TRANSFER_PROVIDERS[number
1216
1223
  export const TTS_PROVIDERS = [
1217
1224
  "elevenlabs-v3",
1218
1225
  "elevenlabs-v4",
1226
+ "elevenlabs-v4-turbo",
1219
1227
  "elevenlabs-turbo",
1220
1228
  "elevenlabs-multilingual",
1221
1229
  "elevenlabs",
@@ -1519,6 +1527,7 @@ export const IMAGE_MASK_MODE: Record<ImageGenProvider, ImageMaskMode> = {
1519
1527
  "nano-banana-pro": "prompt",
1520
1528
  "nano-banana-2": "prompt",
1521
1529
  "nano-banana-2-lite": "prompt",
1530
+ "nano-banana-2-1": "prompt",
1522
1531
  "gpt-image": "prompt",
1523
1532
  "gpt-image-2": "prompt",
1524
1533
  "gpt-image-2-5-flare": "prompt",
@@ -2703,57 +2712,74 @@ export const VIDEO_VARIABLE_PRICING: Record<string, "duration" | "duration+audio
2703
2712
  }
2704
2713
 
2705
2714
  /**
2706
- * Duration assumed for PRICING when a request names a provider but omits
2707
- * `duration` — MUST match the provider's KIE-side default (`extraParams.duration`
2708
- * in backend kie/models.ts) so an intent-less request reserves what it will
2709
- * actually render. Providers absent here use the historical global 5s fallback,
2710
- * which is only safe when their duration TIERS snap 5 up to (or past) the model
2711
- * default (e.g. seedance-2's 4/8/12/15 ladder snaps 5 → the 8s tier = its 8s
2712
- * default). minimax-h3 prices per-second (every 4-15s tier seeded), so a 5s
2713
- * fallback would under-reserve its 6s default render.
2714
- */
2715
- export const PRICING_DEFAULT_DURATION_SEC: Record<string, number> = {
2716
- "minimax-h3": 6,
2717
- // KIE renders 8s when `duration` is omitted (kie/models.ts extraParams), and
2718
- // Seedance 2.5 prices one tier per second across 4–30s, so the 5s fallback
2719
- // billed a 5s tier against an 8s render — and under-reserved every
2720
- // reference-video run's output seconds by three (#1397).
2721
- "seedance-2-5": 8,
2722
- // Same shape: KIE renders 8s by default and the ladder is priced per second,
2723
- // so the 5s fallback billed a 5s tier against an 8s render (caught by the
2724
- // render-default ↔ priced-tier invariant in
2725
- // backend/src/providers/__tests__/pricing-default-duration-sync.test.ts).
2726
- "grok-imagine-video-1.5": 8,
2727
- }
2728
-
2729
- /**
2730
- * The output seconds a request is PRICED at: the requested duration when the
2731
- * caller gave one, else the provider's own default render length
2732
- * ({@link PRICING_DEFAULT_DURATION_SEC}), else the historical 5s fallback.
2733
- *
2734
- * The ONE source for `buildVideoCreditModelIdentifier`'s tier AND for every
2735
- * dynamic reservation that scales by output seconds (the Seedance 2 and
2736
- * MiniMax Hailuo 3 reference-video overrides on both the route and the DAG
2737
- * lane) — a literal `?? 5` in any of those places re-opens the gap this map
2738
- * closes.
2715
+ * @deprecated Read {@link pricedOutputDurationSec} (or the catalog's
2716
+ * `defaultDuration`). Kept only as a derived view of `MODEL_CATALOG` for
2717
+ * consumers of the published package that imported the old hand-kept map; no
2718
+ * pricing path reads it (`pricing-default-duration-guard.test.ts` fails the
2719
+ * build if one does).
2720
+ */
2721
+ export const PRICING_DEFAULT_DURATION_SEC: Readonly<Record<string, number>> = Object.freeze(
2722
+ Object.fromEntries(
2723
+ Object.values(MODEL_CATALOG)
2724
+ .filter((e) => e.kind === "video" && typeof e.defaultDuration === "number")
2725
+ .map((e) => [e.id, e.defaultDuration as number]),
2726
+ ),
2727
+ )
2728
+
2729
+ /**
2730
+ * The legal length nearest to `requested` — ties go to the earlier (shorter)
2731
+ * entry of the list. This is the SAME rule every video runner snaps a request
2732
+ * with (`snapToAllowedDuration` delegates here), so the length a request is
2733
+ * priced at and the length it renders can never be two different numbers.
2734
+ */
2735
+ export function snapToNearestDuration(requested: number, allowed: readonly number[] | undefined): number {
2736
+ if (!allowed || allowed.length === 0) return requested
2737
+ if (allowed.includes(requested)) return requested
2738
+ return allowed.reduce((best, d) => (Math.abs(d - requested) < Math.abs(best - requested) ? d : best))
2739
+ }
2740
+
2741
+ /**
2742
+ * The length a model renders when the request names none, from the model
2743
+ * catalog (`defaultDuration`); else its shortest legal length; else 5 for an id
2744
+ * the catalog does not list. A video model that is priced by length MUST
2745
+ * declare `defaultDuration` (`pricing-default-duration-sync.test.ts`).
2746
+ */
2747
+ export function videoDefaultDurationSec(provider: string): number {
2748
+ const entry = MODEL_CATALOG[provider]
2749
+ if (typeof entry?.defaultDuration === "number") return entry.defaultDuration
2750
+ const shortest = entry?.durations?.length ? Math.min(...entry.durations) : undefined
2751
+ return shortest ?? 5
2752
+ }
2753
+
2754
+ /**
2755
+ * The output seconds a video request is CHARGED at — the ONE funnel every
2756
+ * price path reads (the credit identifier's tier, the run reservation and
2757
+ * commit, the editor and server estimates, the Seedance and MiniMax
2758
+ * reference-video reservations and the Loop Trim refund).
2759
+ *
2760
+ * - no duration (or an unusable one) → the model's own default render length
2761
+ * (`MODEL_CATALOG[provider].defaultDuration`), never a global 5;
2762
+ * - a duration the model does not offer → the nearest one it does
2763
+ * ({@link snapToNearestDuration}, the runners' own rule), because that is the
2764
+ * length it renders;
2765
+ * - AUTO (`VIDEO_DURATION_AUTO`) → the model's longest clip: the model picks
2766
+ * the length, `commit_credits` refunds a surplus but never collects a
2767
+ * deficit, and the delivered clip is measured at settle time
2768
+ * (lib/seedance2-ref-video-settle.ts).
2769
+ *
2770
+ * A literal `?? 5` (or `?? 8`) at any pricing site re-opens the gap this closes;
2771
+ * `pricing-default-duration-guard.test.ts` fails the build on one.
2739
2772
  */
2740
2773
  export function pricedOutputDurationSec(provider: string, requested: number | string | undefined): number {
2741
- const fallback = PRICING_DEFAULT_DURATION_SEC[provider] ?? 5
2774
+ const fallback = videoDefaultDurationSec(provider)
2742
2775
  const parsed = typeof requested === "string" ? parseInt(requested, 10) : requested
2743
2776
  if (parsed === undefined || Number.isNaN(parsed)) return fallback
2744
- // AUTO (`VIDEO_DURATION_AUTO`): the model picks the length, so the only
2745
- // safe price is the LONGEST it can render — `commit_credits` refunds a surplus
2746
- // but never collects a deficit, and the delivered clip is measured at settle
2747
- // time (lib/seedance2-ref-video-settle.ts). Living HERE, the one source every
2748
- // tier and every scaled reservation reads, a new pricing call site reserves
2749
- // the ceiling by default instead of having to remember to. Any other
2750
- // non-positive value is nonsense and prices at the render default.
2751
2777
  if (parsed <= 0) {
2752
2778
  return isAutoVideoDuration(parsed) && supportsAutoVideoDuration(provider)
2753
2779
  ? maxVideoDurationSec(provider) ?? fallback
2754
2780
  : fallback
2755
2781
  }
2756
- return parsed
2782
+ return snapToNearestDuration(parsed, MODEL_CATALOG[provider]?.durations)
2757
2783
  }
2758
2784
 
2759
2785
  /** Models that accept `VIDEO_DURATION_AUTO` — a catalog capability (docs.kie.ai:
@@ -161,6 +161,7 @@ const QUALITY_MAP: Record<string, QualityMapping> = {
161
161
  // Image gen — resolution-style (1K/2K/4K)
162
162
  "nano-banana-pro": { field: "resolution", values: { low: "1K", mid: "2K", high: "4K" } },
163
163
  "nano-banana-2": { field: "resolution", values: { low: "1K", mid: "2K", high: "4K" } },
164
+ "nano-banana-2-1": { field: "resolution", values: { low: "1K", mid: "2K", high: "4K" } },
164
165
  "flux": { field: "resolution", values: { low: "1K", mid: "2K", high: "2K" } },
165
166
  "flux-flex": { field: "resolution", values: { low: "1K", mid: "2K", high: "2K" } },
166
167
  "flux-i2i": { field: "resolution", values: { low: "1K", mid: "2K", high: "2K" } },