@nodaro/shared 3.24.0 → 3.26.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 (50) hide show
  1. package/dist/index.cjs +1086 -257
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +531 -97
  4. package/dist/index.d.ts +531 -97
  5. package/dist/index.js +1034 -258
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/__tests__/condition-variables.test.ts +12 -0
  9. package/src/__tests__/content-recipe-ideas.test.ts +9 -4
  10. package/src/__tests__/credit-identifiers.test.ts +31 -6
  11. package/src/__tests__/dialogue-capabilities.test.ts +3 -2
  12. package/src/__tests__/edit-plan-minute-ids.test.ts +82 -0
  13. package/src/__tests__/image-model-roles.test.ts +57 -0
  14. package/src/__tests__/image-ref-limit.test.ts +1 -0
  15. package/src/__tests__/json-kinds.test.ts +179 -0
  16. package/src/__tests__/llm-models.test.ts +136 -37
  17. package/src/__tests__/lone-media-url.test.ts +78 -0
  18. package/src/__tests__/presentation-utils.test.ts +1 -0
  19. package/src/__tests__/preview-gate.test.ts +2 -2
  20. package/src/__tests__/pricing-default-duration.test.ts +56 -15
  21. package/src/__tests__/private-host.test.ts +24 -0
  22. package/src/__tests__/prompt-length-limits.test.ts +2 -0
  23. package/src/__tests__/render-nodes.test.ts +22 -3
  24. package/src/__tests__/tts-capabilities.test.ts +61 -1
  25. package/src/__tests__/video-link-input.test.ts +148 -0
  26. package/src/__tests__/video-link-needs.test.ts +67 -0
  27. package/src/__tests__/video-request-normalize.test.ts +18 -3
  28. package/src/condition-variables.ts +3 -1
  29. package/src/content-recipe-ideas.ts +5 -2
  30. package/src/credit-identifiers.ts +48 -37
  31. package/src/edit-plan-contract.ts +67 -1
  32. package/src/fan-out-rows.ts +2 -2
  33. package/src/image-model-roles.ts +62 -0
  34. package/src/index.ts +59 -1
  35. package/src/json-kinds.ts +188 -0
  36. package/src/llm-models.ts +348 -23
  37. package/src/lone-media-url.ts +57 -0
  38. package/src/model-catalog.ts +160 -13
  39. package/src/model-constants.ts +79 -43
  40. package/src/node-default-mappings.ts +4 -0
  41. package/src/pipeline-types.ts +13 -2
  42. package/src/presentation-utils.ts +8 -1
  43. package/src/private-host.ts +91 -0
  44. package/src/producer-types.ts +3 -0
  45. package/src/render-nodes.ts +12 -1
  46. package/src/scene-node-types.ts +17 -5
  47. package/src/settings-input.ts +2 -1
  48. package/src/social-post-readers.ts +37 -0
  49. package/src/video-link.ts +238 -0
  50. 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
@@ -274,21 +282,21 @@ export interface ModelRecommendation {
274
282
 
275
283
  export const MODEL_RECOMMENDATIONS: readonly ModelRecommendation[] = [
276
284
  // image
277
- { intent: "best for typography / logos / text-heavy", modelIds: ["nano-banana-pro", "gpt-image-2"], note: "Nano Banana Pro for diagrams / complex text; GPT Image 2 for logos and short copy." },
285
+ { intent: "best for typography / logos / text-heavy", modelIds: ["gpt-image-2", "gpt-image-2-5-flare"], note: "GPT Image 2 for exact copy, labels and non-Latin text; GPT Image 2.5 Flare is close and faster." },
278
286
  // Notes name the RANKING, not the price — the price sits in the generated
279
287
  // table directly below them and in `pricing`, so restating it here just
280
288
  // creates a copy that rots (this one said "1 credit" long after it was 2).
281
289
  { intent: "cheapest realistic image", modelIds: ["z-image", "qwen", "imagen4-fast"], note: "Z-Image is the cheapest. Qwen / Imagen4 Fast for slightly higher quality." },
282
- { intent: "highest fidelity image", modelIds: ["nano-banana-pro", "imagen4-ultra", "flux-flex"], note: "Pick by family preference; all three are premium tiers." },
283
- { intent: "image edit / restyle", modelIds: ["flux-kontext", "ideogram-remix", "seedream-5-pro-i2i"], note: "Flux Kontext preserves identity; Ideogram Remix is character-aware; Seedream 5 Pro for instruction-based edits (5 Lite is the budget option)." },
284
- { intent: "highest-resolution image", modelIds: ["topaz-image-upscale", "nano-banana-pro", "gpt-image-2"], note: "Generate at the model's top tier, then Topaz upscale 4x (Topaz's only lever is the 1x/2x/4x factor)." },
290
+ { intent: "highest fidelity image", modelIds: ["gpt-image-2", "gpt-image-2-5-sunburst", "imagen4-ultra"], note: "GPT Image 2 for characters and identity; GPT Image 2.5 Sunburst for wide or in-between ratios GPT Image 2 can't draw." },
291
+ { intent: "image edit / restyle", modelIds: ["gpt-image-2-5-flare-i2i", "gpt-image-2-i2i", "seedream-5-pro-i2i"], note: "GPT Image 2.5 Flare keeps pose, framing and product detail; GPT Image 2 i2i for identity-critical edits; Seedream 5 Pro for instruction-based edits." },
292
+ { intent: "highest-resolution image", modelIds: ["topaz-image-upscale", "gpt-image-2", "gpt-image-2-5-sunburst"], note: "Generate at the model's top tier, then Topaz upscale 4x (Topaz's only lever is the 1x/2x/4x factor)." },
285
293
  { intent: "background removal / cutout", modelIds: ["recraft-remove-bg"], note: "Cheap, no prompt needed." },
286
294
  // video
287
295
  { intent: "best cinematic video", modelIds: ["veo3", "kling-3.0", "seedance-2"], note: "VEO 3.1 Quality for premium narrative; Kling 3.0 for music-synced motion; Seedance 2 for reference-driven consistency." },
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",
@@ -421,7 +453,6 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
421
453
  { identifier: "nano-banana-pro", credits: 45, note: "1K / 2K" },
422
454
  { identifier: "nano-banana-pro:4K", credits: 60, note: "4K" },
423
455
  ],
424
- featured: true,
425
456
  },
426
457
  "nano-banana-edit": {
427
458
  id: "nano-banana-edit",
@@ -659,6 +690,7 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
659
690
  { identifier: "gpt-image-2:4K", credits: 60, note: "4K" },
660
691
  ],
661
692
  safetyFilter: { stochastic: true, fallback: "nano-banana-pro" },
693
+ featured: true,
662
694
  },
663
695
  "gpt-image-2-i2i": {
664
696
  id: "gpt-image-2-i2i",
@@ -981,6 +1013,40 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
981
1013
  { identifier: "seedream-5-pro-i2i:high", credits: 60, note: "high / 2K" },
982
1014
  ],
983
1015
  },
1016
+ // Seedream 5 Flash — fast, low-cost Seedream 5. Its lever is KIE's `size`
1017
+ // (1K / 1.5K / 2K), NOT the siblings' `quality`: declared as `resolutions`
1018
+ // (the KIE config renames it to `size` on the wire). Flat price at every
1019
+ // offered size. 1.5K is not offered yet: no other image model or route enum
1020
+ // carries it, and its price has not been confirmed.
1021
+ // See: docs.kie.ai/market/seedream/5-flash-text-to-image.md
1022
+ "seedream-5-flash": {
1023
+ id: "seedream-5-flash",
1024
+ kind: "image",
1025
+ modes: ["t2i"] as const,
1026
+ family: "Bytedance",
1027
+ label: "Seedream 5 Flash",
1028
+ series: "Seedream",
1029
+ description: "Fast, low-cost Seedream 5 — quick generations at 1K or 2K, same price at either size.",
1030
+ useCases: ["realistic", "drafts", "iteration"],
1031
+ features: ["reference-image"],
1032
+ aspectRatios: SEEDREAM_RATIOS,
1033
+ resolutions: ["1K", "2K"],
1034
+ pricing: [{ identifier: "seedream-5-flash", credits: 10, note: "1K / 2K flat" }],
1035
+ },
1036
+ "seedream-5-flash-i2i": {
1037
+ id: "seedream-5-flash-i2i",
1038
+ kind: "image",
1039
+ modes: ["i2i"] as const,
1040
+ family: "Bytedance",
1041
+ label: "Seedream 5 Flash (I2I)",
1042
+ series: "Seedream",
1043
+ description: "Image-to-image with Seedream 5 Flash — fast edits from up to 10 input images at 1K or 2K, same price at either size.",
1044
+ useCases: ["edit", "iteration"],
1045
+ features: ["reference-image"],
1046
+ aspectRatios: SEEDREAM_RATIOS,
1047
+ resolutions: ["1K", "2K"],
1048
+ pricing: [{ identifier: "seedream-5-flash-i2i", credits: 10, note: "1K / 2K flat" }],
1049
+ },
984
1050
 
985
1051
  // ── Alibaba Qwen ──
986
1052
  "qwen": {
@@ -1201,6 +1267,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1201
1267
  useCases: ["realistic", "motion", "narrative"],
1202
1268
  features: ["end-frame"],
1203
1269
  durations: [5],
1270
+ defaultDuration: 5,
1204
1271
  pricing: [{ identifier: "minimax", credits: 143, note: "5s, 1080p" }],
1205
1272
  },
1206
1273
  // MiniMax Hailuo 3 (KIE "minimax-h3") — t2v / i2v (first and/or last frame) /
@@ -1226,6 +1293,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1226
1293
  features: ["end-frame", "audio", "reference-image", "video-reference"],
1227
1294
  aspectRatios: VIDEO_RATIOS_SEEDANCE_2,
1228
1295
  durations: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1296
+ defaultDuration: 6,
1229
1297
  // First entry = default (the UI dropdown + fail-safe snap use opts[0], and
1230
1298
  // 2K is the KIE-side default). Uppercase values are the exact KIE wire enum.
1231
1299
  resolutions: ["2K", "768P"],
@@ -1251,6 +1319,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1251
1319
  description: "Hailuo 2.3 Pro — newer Hailuo with 768P / 1080P resolutions.",
1252
1320
  useCases: ["realistic", "motion"],
1253
1321
  durations: [6, 10],
1322
+ defaultDuration: 6,
1254
1323
  resolutions: ["768P", "1080P"],
1255
1324
  pricing: [
1256
1325
  { identifier: "hailuo-2.3-pro", credits: 200, note: "10s default" },
@@ -1270,6 +1339,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1270
1339
  description: "Cheaper Hailuo 2.3 tier — good baseline quality.",
1271
1340
  useCases: ["realistic", "cheap"],
1272
1341
  durations: [6, 10],
1342
+ defaultDuration: 6,
1273
1343
  pricing: [
1274
1344
  { identifier: "hailuo-2.3", credits: 75, note: "6s default" },
1275
1345
  { identifier: "hailuo-2.3:6s", credits: 80, note: "6s" },
@@ -1287,6 +1357,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1287
1357
  useCases: ["cheap", "motion"],
1288
1358
  features: ["end-frame"],
1289
1359
  durations: [6, 10],
1360
+ defaultDuration: 6,
1290
1361
  resolutions: ["512P", "768P"],
1291
1362
  pricing: [
1292
1363
  { identifier: "hailuo-standard", credits: 75, note: "6s default" },
@@ -1315,6 +1386,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1315
1386
  // `veo3_lite` DO serve it and keep the flag.
1316
1387
  features: ["end-frame", "audio"],
1317
1388
  durations: [4, 6, 8],
1389
+ defaultDuration: 8,
1318
1390
  aspectRatios: VIDEO_RATIOS_HV,
1319
1391
  // 720p (default) + 1080p inline. 4K generates the base at 1080p then chains
1320
1392
  // KIE's /api/v1/veo/get-4k-video endpoint (worker handleImageToVideo / handleTextToVideo).
@@ -1336,6 +1408,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1336
1408
  useCases: ["cinematic", "fast", "general"],
1337
1409
  features: ["end-frame", "audio", "reference-image"],
1338
1410
  durations: [4, 6, 8],
1411
+ defaultDuration: 8,
1339
1412
  aspectRatios: VIDEO_RATIOS_HV,
1340
1413
  resolutions: ["720p", "1080p", "4k"],
1341
1414
  pricing: [
@@ -1356,6 +1429,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1356
1429
  useCases: ["cinematic", "cheap", "high-volume"],
1357
1430
  features: ["end-frame", "audio", "reference-image"],
1358
1431
  durations: [4, 6, 8],
1432
+ defaultDuration: 8,
1359
1433
  aspectRatios: VIDEO_RATIOS_HV,
1360
1434
  resolutions: ["720p", "1080p", "4k"],
1361
1435
  pricing: [
@@ -1378,6 +1452,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1378
1452
  aspectRatios: VIDEO_RATIOS_HV,
1379
1453
  resolutions: ["720p", "1080p", "4k"],
1380
1454
  durations: [4, 6, 8, 10],
1455
+ defaultDuration: 8,
1381
1456
  pricing: [
1382
1457
  { identifier: "gemini-omni-video", credits: 315, note: "default — 720p/1080p 4s" },
1383
1458
  { identifier: "gemini-omni-video:4", credits: 230, note: "720p/1080p 4s" },
@@ -1413,6 +1488,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1413
1488
  aspectRatios: VIDEO_RATIOS_HV,
1414
1489
  resolutions: ["720p", "1080p", "4k"],
1415
1490
  durations: [4, 6, 8, 10],
1491
+ defaultDuration: 8,
1416
1492
  pricing: [
1417
1493
  { identifier: "gemini-omni-flash", credits: 270, note: "default — 8s 720p/1080p (the credit builder's duration fallback)" },
1418
1494
  { identifier: "gemini-omni-flash:4", credits: 160, note: "720p/1080p 4s" },
@@ -1441,6 +1517,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1441
1517
  features: ["audio"],
1442
1518
  aspectRatios: VIDEO_RATIOS_HVS,
1443
1519
  durations: [5, 10],
1520
+ defaultDuration: 5,
1444
1521
  pricing: [
1445
1522
  { identifier: "kling", credits: 280, note: "10s no audio default" },
1446
1523
  { identifier: "kling:5s", credits: 138, note: "5s no audio" },
@@ -1460,6 +1537,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1460
1537
  useCases: ["fast", "motion", "cheap"],
1461
1538
  features: ["end-frame"],
1462
1539
  durations: [5, 10],
1540
+ defaultDuration: 5,
1463
1541
  pricing: [
1464
1542
  { identifier: "kling-turbo", credits: 125, note: "5s default" },
1465
1543
  { identifier: "kling-turbo:5s", credits: 110 },
@@ -1477,6 +1555,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1477
1555
  useCases: ["premium", "narrative", "cinematic"],
1478
1556
  features: ["end-frame", "audio"],
1479
1557
  durations: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1558
+ defaultDuration: 5,
1480
1559
  resolutions: ["720P", "1080P"],
1481
1560
  pricing: [
1482
1561
  { identifier: "kling-3.0", credits: 500, note: "5s 1080p with audio" },
@@ -1499,6 +1578,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1499
1578
  description: "Master tier I2V — strong cinematic quality.",
1500
1579
  useCases: ["cinematic", "premium"],
1501
1580
  durations: [5, 10],
1581
+ defaultDuration: 5,
1502
1582
  pricing: [
1503
1583
  { identifier: "kling-master", credits: 400, note: "5s default" },
1504
1584
  { identifier: "kling-master:5s", credits: 400 },
@@ -1516,6 +1596,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1516
1596
  useCases: ["motion", "cinematic", "reference"],
1517
1597
  features: ["end-frame", "reference-image"],
1518
1598
  durations: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1599
+ defaultDuration: 5,
1519
1600
  resolutions: ["720p", "1080p"],
1520
1601
  aspectRatios: VIDEO_RATIOS_HVS,
1521
1602
  pricing: [
@@ -1538,6 +1619,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1538
1619
  description: "Grok image-to-video — stylized motion. Up to 15s.",
1539
1620
  useCases: ["stylized", "motion"],
1540
1621
  durations: [6, 10],
1622
+ defaultDuration: 6,
1541
1623
  resolutions: ["480p", "720p"],
1542
1624
  pricing: [
1543
1625
  { identifier: "grok-i2v", credits: 150, note: "6s default" },
@@ -1566,6 +1648,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1566
1648
  useCases: ["stylized", "motion"],
1567
1649
  aspectRatios: ["16:9", "9:16", "1:1", "4:3", "3:4"],
1568
1650
  durations: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1651
+ defaultDuration: 8,
1569
1652
  resolutions: ["480p", "720p"],
1570
1653
  pricing: [
1571
1654
  { identifier: "grok-imagine-video-1.5", credits: 295, note: "default 8s 480p — see :Ns:res variants" },
@@ -1588,6 +1671,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1588
1671
  useCases: ["motion", "narrative"],
1589
1672
  features: ["end-frame"],
1590
1673
  durations: [4, 8, 12],
1674
+ defaultDuration: 8,
1591
1675
  resolutions: ["480p", "720p", "1080p"],
1592
1676
  pricing: [
1593
1677
  { identifier: "seedance", credits: 250, note: "8s default" },
@@ -1609,6 +1693,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1609
1693
  features: ["end-frame", "audio", "reference-image", "video-reference"],
1610
1694
  aspectRatios: VIDEO_RATIOS_SEEDANCE_2,
1611
1695
  durations: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1696
+ defaultDuration: 8,
1612
1697
  autoDuration: true,
1613
1698
  resolutions: ["480p", "720p", "1080p", "4k"],
1614
1699
  pricing: [
@@ -1635,6 +1720,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1635
1720
  features: ["end-frame", "audio", "reference-image", "video-reference"],
1636
1721
  aspectRatios: VIDEO_RATIOS_SEEDANCE_2,
1637
1722
  durations: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1723
+ defaultDuration: 8,
1638
1724
  autoDuration: true,
1639
1725
  resolutions: ["480p", "720p"],
1640
1726
  pricing: [
@@ -1657,6 +1743,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1657
1743
  features: ["end-frame", "audio", "reference-image", "video-reference"],
1658
1744
  aspectRatios: VIDEO_RATIOS_SEEDANCE_2,
1659
1745
  durations: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1746
+ defaultDuration: 8,
1660
1747
  autoDuration: true,
1661
1748
  resolutions: ["480p", "720p"],
1662
1749
  pricing: [
@@ -1685,6 +1772,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1685
1772
  features: ["end-frame", "audio", "reference-image", "video-reference"],
1686
1773
  aspectRatios: VIDEO_RATIOS_SEEDANCE_2,
1687
1774
  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],
1775
+ defaultDuration: 8,
1688
1776
  autoDuration: true,
1689
1777
  resolutions: ["480p", "720p", "1080p"],
1690
1778
  pricing: [
@@ -1727,6 +1815,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1727
1815
  features: ["end-frame", "audio", "reference-image"],
1728
1816
  aspectRatios: VIDEO_RATIOS_WAN_3,
1729
1817
  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],
1818
+ defaultDuration: 5,
1730
1819
  resolutions: ["480p", "720p", "1080p"],
1731
1820
  pricing: [
1732
1821
  { identifier: "wan-3", credits: 200, note: "default 5s 720p — see :Ns:res variants for exact" },
@@ -1752,6 +1841,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1752
1841
  features: ["end-frame", "audio", "reference-image"],
1753
1842
  aspectRatios: VIDEO_RATIOS_WAN_3,
1754
1843
  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],
1844
+ defaultDuration: 5,
1755
1845
  resolutions: ["480p", "720p", "1080p"],
1756
1846
  pricing: [
1757
1847
  { identifier: "wan-3-prime", credits: 320, note: "default 5s 720p — see :Ns:res variants for exact" },
@@ -1774,6 +1864,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1774
1864
  description: "Wan 2.6 image-to-video — 5/10/15s at 720p/1080p.",
1775
1865
  useCases: ["motion", "narrative"],
1776
1866
  durations: [5, 10, 15],
1867
+ defaultDuration: 5,
1777
1868
  resolutions: ["720p", "1080p"],
1778
1869
  pricing: [
1779
1870
  { identifier: "wan-i2v", credits: 175, note: "5s 720p default" },
@@ -1793,6 +1884,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1793
1884
  useCases: ["cheap", "fast"],
1794
1885
  aspectRatios: VIDEO_RATIOS_HVS,
1795
1886
  durations: [5],
1887
+ defaultDuration: 5,
1796
1888
  resolutions: ["480p", "720p"],
1797
1889
  // Different KIE endpoints (i2v vs t2v) → different costs under
1798
1890
  // composite ids. Route picks endpoint based on whether image was supplied.
@@ -1813,6 +1905,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1813
1905
  description: "Wan 2.6 — text-to-video and video-to-video under a single id.",
1814
1906
  useCases: ["v2v", "t2v", "restyle"],
1815
1907
  durations: [5],
1908
+ defaultDuration: 5,
1816
1909
  resolutions: ["720p", "1080p"],
1817
1910
  pricing: [
1818
1911
  { identifier: "wan", credits: 175, note: "v2v 5s 720p" },
@@ -1888,6 +1981,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1888
1981
  description: "Wan 2.7 image-to-video — 2–15s at 720p/1080p, supports start+end frame.",
1889
1982
  useCases: ["motion", "narrative"],
1890
1983
  durations: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1984
+ defaultDuration: 5,
1891
1985
  resolutions: ["720p", "1080p"],
1892
1986
  features: ["end-frame"],
1893
1987
  pricing: [
@@ -1905,6 +1999,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1905
1999
  useCases: ["motion", "narrative"],
1906
2000
  aspectRatios: VIDEO_RATIOS_HVS345,
1907
2001
  durations: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
2002
+ defaultDuration: 5,
1908
2003
  resolutions: ["720p", "1080p"],
1909
2004
  pricing: [
1910
2005
  { identifier: "wan-2.7-t2v", credits: 188, note: "5s 720p default" },
@@ -1931,6 +2026,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1931
2026
  aspectRatios: ["16:9", "9:16"] as const,
1932
2027
  resolutions: ["1080p", "2k", "4k"] as const,
1933
2028
  durations: [6, 8, 10],
2029
+ defaultDuration: 6,
1934
2030
  pricing: [
1935
2031
  { identifier: "ltx-2.3-pro", credits: 240, note: "default 1080p 6s" },
1936
2032
  { identifier: "ltx-2.3-pro:1080p:6s", credits: 240 },
@@ -1962,6 +2058,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1962
2058
  // in credit-identifiers.ts is the per-band authority and snaps a 2k/4k
1963
2059
  // request back onto 6/8/10s, so the reservation is always a real tier).
1964
2060
  durations: [6, 8, 10, 12, 14, 16, 18, 20],
2061
+ defaultDuration: 6,
1965
2062
  pricing: [
1966
2063
  { identifier: "ltx-2.3-fast", credits: 180, note: "default 1080p 6s" },
1967
2064
  { identifier: "ltx-2.3-fast:1080p:6s", credits: 180 },
@@ -1993,6 +2090,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1993
2090
  useCases: ["motion", "creative"],
1994
2091
  aspectRatios: VIDEO_RATIOS_HAPPYHORSE_11,
1995
2092
  durations: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
2093
+ defaultDuration: 5,
1996
2094
  resolutions: ["720p", "1080p"],
1997
2095
  pricing: [
1998
2096
  { identifier: "happyhorse", credits: 282, note: "5s 720p default — per-second: ~5.7 cr/s @720p, ~7.3 cr/s @1080p" },
@@ -2008,6 +2106,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2008
2106
  description: "HappyHorse 1.1 image-to-video — 3–15s at 720p/1080p, aspect ratio inferred from input image, per-second pricing.",
2009
2107
  useCases: ["motion", "creative"],
2010
2108
  durations: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
2109
+ defaultDuration: 5,
2011
2110
  resolutions: ["720p", "1080p"],
2012
2111
  pricing: [
2013
2112
  { identifier: "happyhorse-i2v", credits: 282, note: "5s 720p default — per-second: ~5.7 cr/s @720p, ~7.3 cr/s @1080p" },
@@ -2024,6 +2123,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2024
2123
  useCases: ["motion", "reference"],
2025
2124
  aspectRatios: VIDEO_RATIOS_HAPPYHORSE_11,
2026
2125
  durations: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
2126
+ defaultDuration: 5,
2027
2127
  resolutions: ["720p", "1080p"],
2028
2128
  features: ["reference-image"],
2029
2129
  pricing: [
@@ -2057,6 +2157,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2057
2157
  features: ["end-frame"],
2058
2158
  aspectRatios: VIDEO_RATIOS_HVS,
2059
2159
  durations: [5, 10],
2160
+ defaultDuration: 5,
2060
2161
  resolutions: ["480p", "720p", "1080p"],
2061
2162
  pricing: [{ identifier: "bytedance-lite", credits: 57 }],
2062
2163
  },
@@ -2071,6 +2172,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2071
2172
  useCases: ["motion", "narrative"],
2072
2173
  aspectRatios: VIDEO_RATIOS_HVS,
2073
2174
  durations: [5, 10],
2175
+ defaultDuration: 5,
2074
2176
  resolutions: ["480p", "720p", "1080p"],
2075
2177
  pricing: [{ identifier: "bytedance-pro", credits: 175 }],
2076
2178
  },
@@ -2084,6 +2186,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2084
2186
  description: "Faster Bytedance Pro variant.",
2085
2187
  useCases: ["fast", "motion"],
2086
2188
  durations: [5, 10],
2189
+ defaultDuration: 5,
2087
2190
  resolutions: ["720p", "1080p"],
2088
2191
  pricing: [{ identifier: "bytedance-pro-fast", credits: 90 }],
2089
2192
  },
@@ -2105,6 +2208,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2105
2208
  description: "Runway Gen-3 routed through KIE. 5/10s at 720p/1080p.",
2106
2209
  useCases: ["motion", "narrative"],
2107
2210
  durations: [5, 10],
2211
+ defaultDuration: 5,
2108
2212
  resolutions: ["720p", "1080p"],
2109
2213
  pricing: [{ identifier: "runway-kie", credits: 30, note: "5s 720p" }],
2110
2214
  },
@@ -2156,6 +2260,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2156
2260
  description: "Extend ANY video: generates the continuation (audio included) and trim-stitches it into one seamless clip.",
2157
2261
  useCases: ["extend"],
2158
2262
  durations: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
2263
+ defaultDuration: 8,
2159
2264
  resolutions: ["480p", "720p", "1080p"],
2160
2265
  pricing: [
2161
2266
  { identifier: "seedance-2-extend", credits: 530, note: "default 8s 720p (ref-mode 50 + 3 stitch) — see :NsR variants" },
@@ -2506,14 +2611,26 @@ const TTS_LANGS_V3 = [
2506
2611
  const TTS_LEVERS_V2 = ["stability", "similarity", "style", "speed", "speakerBoost"] as const
2507
2612
  /**
2508
2613
  * 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.
2614
+ * the live probe's answer lands in one place. Measured 2026-10-06: a
2615
+ * 10,000-character v4 dialogue returned 200, voiced its last line and finished
2616
+ * whole in 130 s, well inside the funnel's 300 s timeout
2617
+ * (`DIALOGUE_GENERATION_TIMEOUT_MS`); decided 2026-10-07 to raise the cap to
2618
+ * that number, twice v3 dialogue's 5,000. Length pricing charges
2619
+ * `min(total, cap)`, so the same unit rows reach 10,000 characters without a
2620
+ * new row. ElevenLabs recommends ≤ 2,000 for quality on either model.
2515
2621
  */
2516
- const DIALOGUE_V4_MAX_CHARS = 5000
2622
+ const DIALOGUE_V4_MAX_CHARS = 10000
2623
+ /**
2624
+ * ElevenLabs v4 Turbo's per-request character cap — ONE constant, so a change
2625
+ * of the owner's rule lands in one place. The vendor declares 10,000, the same
2626
+ * as v4 (`maximum_text_length_per_request`, measured 2026-10-07); live, both a
2627
+ * 10,000- and a 10,001-character request returned 200 (the vendor accepts over
2628
+ * its declared figure), so the platform clamps at the declared figure — the
2629
+ * smaller of the two. Decided 2026-10-07: the model takes that whole cap because
2630
+ * it ships priced per started 100 characters. An instance that still prices
2631
+ * speech flat charges the flat row for any length (the Text to Speech docs say so).
2632
+ */
2633
+ const V4_TURBO_MAX_CHARS = 10000
2517
2634
 
2518
2635
  const AUDIO_MODELS: Record<string, ModelCatalogEntry> = {
2519
2636
  // ── ElevenLabs TTS ──
@@ -2574,6 +2691,36 @@ const AUDIO_MODELS: Record<string, ModelCatalogEntry> = {
2574
2691
  languages: TTS_LANGS_V3,
2575
2692
  },
2576
2693
  },
2694
+ "elevenlabs-v4-turbo": {
2695
+ id: "elevenlabs-v4-turbo",
2696
+ kind: "audio",
2697
+ modes: ["tts"] as const,
2698
+ family: "ElevenLabs",
2699
+ label: "ElevenLabs v4 Turbo",
2700
+ series: "ElevenLabs",
2701
+ 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.",
2702
+ useCases: ["tts", "voice-over", "narration", "expressive", "fast"],
2703
+ features: ["audio-tags", "voice-cloning"],
2704
+ // Flat per request at parity with Turbo v2.5 (what a run costs where length
2705
+ // pricing is off); per started 100 characters at Turbo's rate where it is on
2706
+ // (decided 2026-10-06).
2707
+ pricing: [
2708
+ { identifier: "elevenlabs-v4-turbo", credits: 15 },
2709
+ { identifier: "elevenlabs-v4-turbo:per-100-chars", credits: 2, note: SPEECH_UNIT_PRICE_NOTE },
2710
+ ],
2711
+ tts: {
2712
+ // Every value below was measured 2026-10-07 from live calls to eleven_v4_turbo.
2713
+ audioTags: true, // measured 2026-10-07: a tagged line → 200; Scribe hears no tag word spoken and lists [chuckles] as an audio event
2714
+ ssmlBreaks: false,
2715
+ levers: ["stability", "similarity"], // measured 2026-10-07: /v1/models can_use_style / can_use_speaker_boost both false, as v4; stability + similarity_boost → 200
2716
+ languageCode: true, // measured 2026-10-07: language_code "he" with Hebrew text → 200
2717
+ timestamps: true, // measured 2026-10-07: /with-timestamps answers 200 at the same character cost as the plain call
2718
+ stitching: true, // measured 2026-10-07: previous_text / next_text → 200, at the same character cost (context not billed)
2719
+ maxChars: V4_TURBO_MAX_CHARS,
2720
+ // The curated picker, the same 46 as v4 and v3 (the model lists 85; widening is its own change).
2721
+ languages: TTS_LANGS_V3, // measured 2026-10-07: all 46 present in the model's 85-language list
2722
+ },
2723
+ },
2577
2724
  "elevenlabs-turbo": {
2578
2725
  id: "elevenlabs-turbo",
2579
2726
  kind: "audio",