@picsart/ai-sdk 5.26.0 → 5.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +0 -10
- package/index.js +163 -132
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -534,7 +534,6 @@ type ModelInputById = {
|
|
|
534
534
|
};
|
|
535
535
|
"kling-motion-control": {
|
|
536
536
|
prompt?: string;
|
|
537
|
-
resolution?: "720p" | "1080p";
|
|
538
537
|
renderingSpeed?: "std" | "pro";
|
|
539
538
|
characterOrientation?: "image" | "video";
|
|
540
539
|
keepOriginalSound?: "yes" | "no";
|
|
@@ -543,7 +542,6 @@ type ModelInputById = {
|
|
|
543
542
|
};
|
|
544
543
|
"kling-motion-control-v3": {
|
|
545
544
|
prompt?: string;
|
|
546
|
-
resolution?: "720p" | "1080p";
|
|
547
545
|
renderingSpeed?: "std" | "pro";
|
|
548
546
|
characterOrientation?: "image" | "video";
|
|
549
547
|
keepOriginalSound?: "yes" | "no";
|
|
@@ -575,8 +573,6 @@ type ModelInputById = {
|
|
|
575
573
|
count?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
576
574
|
negativePrompt?: string;
|
|
577
575
|
imageUrls?: string[];
|
|
578
|
-
imageWeight?: number;
|
|
579
|
-
humanFidelity?: number;
|
|
580
576
|
};
|
|
581
577
|
"kling-v2-6": {
|
|
582
578
|
prompt: string;
|
|
@@ -586,8 +582,6 @@ type ModelInputById = {
|
|
|
586
582
|
endFrame?: string;
|
|
587
583
|
negativePrompt?: string;
|
|
588
584
|
generateAudio?: boolean;
|
|
589
|
-
cfgScale?: number;
|
|
590
|
-
renderingSpeed?: "std" | "pro";
|
|
591
585
|
};
|
|
592
586
|
"kling-v2a": {
|
|
593
587
|
videoUrl: string;
|
|
@@ -613,7 +607,6 @@ type ModelInputById = {
|
|
|
613
607
|
elementList?: Array<{
|
|
614
608
|
element_id: string;
|
|
615
609
|
}>;
|
|
616
|
-
staticMask?: string;
|
|
617
610
|
renderingSpeed?: "std" | "pro" | "4k";
|
|
618
611
|
};
|
|
619
612
|
"kling-v3-omni": {
|
|
@@ -621,7 +614,6 @@ type ModelInputById = {
|
|
|
621
614
|
aspectRatio?: "16:9" | "9:16" | "1:1";
|
|
622
615
|
duration?: 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15;
|
|
623
616
|
resolution?: "720p" | "1080p" | "4k";
|
|
624
|
-
renderingSpeed?: "std" | "pro";
|
|
625
617
|
generateAudio?: boolean;
|
|
626
618
|
startFrame?: string;
|
|
627
619
|
endFrame?: string;
|
|
@@ -647,7 +639,6 @@ type ModelInputById = {
|
|
|
647
639
|
negativePrompt?: string;
|
|
648
640
|
resolution?: "720p" | "1080p";
|
|
649
641
|
startFrame?: string;
|
|
650
|
-
staticMask?: string;
|
|
651
642
|
};
|
|
652
643
|
"kling-video-effects": {
|
|
653
644
|
templateId?: string;
|
|
@@ -657,7 +648,6 @@ type ModelInputById = {
|
|
|
657
648
|
prompt: string;
|
|
658
649
|
aspectRatio?: "16:9" | "9:16" | "1:1";
|
|
659
650
|
duration?: 5 | 10;
|
|
660
|
-
resolution?: "720p" | "1080p";
|
|
661
651
|
renderingSpeed?: "std" | "pro";
|
|
662
652
|
generateAudio?: boolean;
|
|
663
653
|
};
|
package/index.js
CHANGED
|
@@ -1377,12 +1377,6 @@ var paramPresets = {
|
|
|
1377
1377
|
var feat = (label, variant) => ({ label, variant });
|
|
1378
1378
|
|
|
1379
1379
|
// src/vendors/catalog/kling/params.ts
|
|
1380
|
-
var klingHumanFidelity = {
|
|
1381
|
-
humanFidelity: {
|
|
1382
|
-
label: "Face Fidelity",
|
|
1383
|
-
descriptor: { kind: "range", min: 0, max: 1, step: 0.05, default: 0.45 }
|
|
1384
|
-
}
|
|
1385
|
-
};
|
|
1386
1380
|
var klingCharacterOrientation = {
|
|
1387
1381
|
characterOrientation: {
|
|
1388
1382
|
label: "Character Orientation",
|
|
@@ -1473,11 +1467,6 @@ var klingV3AdvancedParams = {
|
|
|
1473
1467
|
element_id: { kind: "text" }
|
|
1474
1468
|
}
|
|
1475
1469
|
}
|
|
1476
|
-
},
|
|
1477
|
-
staticMask: {
|
|
1478
|
-
label: "Static Mask",
|
|
1479
|
-
category: "reference",
|
|
1480
|
-
descriptor: { kind: "file", accept: "image" }
|
|
1481
1470
|
}
|
|
1482
1471
|
};
|
|
1483
1472
|
var klingOmniAdvancedParams = {
|
|
@@ -1580,12 +1569,7 @@ var klingV3TurboVideoBase = {
|
|
|
1580
1569
|
...params.duration(V3_DURATIONS, 5),
|
|
1581
1570
|
...params.negativePrompt(),
|
|
1582
1571
|
...params.resolution(["720p", "1080p"], "720p"),
|
|
1583
|
-
...params.startFrame("Start Frame")
|
|
1584
|
-
staticMask: {
|
|
1585
|
-
label: "Static Mask",
|
|
1586
|
-
category: "reference",
|
|
1587
|
-
descriptor: { kind: "file", accept: "image" }
|
|
1588
|
-
}
|
|
1572
|
+
...params.startFrame("Start Frame")
|
|
1589
1573
|
}
|
|
1590
1574
|
};
|
|
1591
1575
|
var klingV26VideoBase = {
|
|
@@ -1602,9 +1586,7 @@ var klingV26VideoBase = {
|
|
|
1602
1586
|
...paramPresets.videoStartEndWithAudio({
|
|
1603
1587
|
durations: V26_DURATIONS,
|
|
1604
1588
|
defaultDuration: 5
|
|
1605
|
-
})
|
|
1606
|
-
...params.cfgScale(0, 1, 0.5, 0.1),
|
|
1607
|
-
...params.renderingSpeed([{ id: "std", label: "Standard" }, { id: "pro", label: "Pro" }], "std")
|
|
1589
|
+
})
|
|
1608
1590
|
}
|
|
1609
1591
|
};
|
|
1610
1592
|
var { MODELS } = defineModels("kling", [
|
|
@@ -1620,11 +1602,15 @@ var { MODELS } = defineModels("kling", [
|
|
|
1620
1602
|
badge: ["popular", "premium"],
|
|
1621
1603
|
description: "Long-form video up to 15s with native audio and start/end frame control.",
|
|
1622
1604
|
constraints: [
|
|
1623
|
-
{ when: { renderingSpeed: { is: "std" } }, then: { endFrame: { disabled: true, reason: "End frame requires Pro or 4K mode." } } },
|
|
1624
1605
|
// Backend: `voice_list` requires `sound=on`. Two rules because the
|
|
1625
1606
|
// `is` operator does not match an unset value (see core/constraints.ts).
|
|
1626
1607
|
{ when: { generateAudio: { is: false } }, then: { voiceList: { disabled: true, reason: "Voice references require generated audio." } } },
|
|
1627
|
-
{ when: { generateAudio: { exists: false } }, then: { voiceList: { disabled: true, reason: "Voice references require generated audio." } } }
|
|
1608
|
+
{ when: { generateAudio: { exists: false } }, then: { voiceList: { disabled: true, reason: "Voice references require generated audio." } } },
|
|
1609
|
+
// Vendor: first/end frames are unsupported in multi-shot mode.
|
|
1610
|
+
{ when: { multiShot: { is: true } }, then: {
|
|
1611
|
+
startFrame: { disabled: true, reason: "Frames are unavailable in multi-shot mode." },
|
|
1612
|
+
endFrame: { disabled: true, reason: "Frames are unavailable in multi-shot mode." }
|
|
1613
|
+
} }
|
|
1628
1614
|
]
|
|
1629
1615
|
},
|
|
1630
1616
|
// ── Video: Kling V3 Turbo (resolution-tiered T2V + I2V) ───────────
|
|
@@ -1647,7 +1633,7 @@ var { MODELS } = defineModels("kling", [
|
|
|
1647
1633
|
modelId: "kling-v2-6",
|
|
1648
1634
|
addedAt: "2026-02-11",
|
|
1649
1635
|
estimatedTime: 60,
|
|
1650
|
-
description: "Mature pipeline with audio
|
|
1636
|
+
description: "Mature pipeline with audio and pro-tier rendering."
|
|
1651
1637
|
},
|
|
1652
1638
|
// ── Video: Kling Omni ─────────────────────────────────────────────
|
|
1653
1639
|
{
|
|
@@ -1670,14 +1656,14 @@ var { MODELS } = defineModels("kling", [
|
|
|
1670
1656
|
...params.prompt({ maxLength: 2500 }),
|
|
1671
1657
|
...params.aspectRatio(["16:9", "9:16", "1:1"]),
|
|
1672
1658
|
...params.duration(V3_DURATIONS, 5),
|
|
1659
|
+
// Quality tier maps straight to the wire `mode`: 720p→std, 1080p→pro, 4k→4k.
|
|
1673
1660
|
...params.resolution(["720p", "1080p", "4k"], "720p"),
|
|
1674
|
-
...params.renderingSpeed([{ id: "std", label: "Standard" }, { id: "pro", label: "Pro" }], "std"),
|
|
1675
1661
|
...params.generateAudio(false),
|
|
1676
1662
|
...params.startFrame("First Frame"),
|
|
1677
1663
|
...params.endFrame("End Frame"),
|
|
1678
|
-
//
|
|
1679
|
-
//
|
|
1680
|
-
...params.imageInput(
|
|
1664
|
+
// Vendor cap: reference images + frames + multi-image elements ≤ 7
|
|
1665
|
+
// (4 when a reference video is supplied).
|
|
1666
|
+
...params.imageInput(7, "Reference Images"),
|
|
1681
1667
|
...params.videoInput("Reference Video", "reference", false),
|
|
1682
1668
|
...klingOmniReferType,
|
|
1683
1669
|
...klingKeepOriginalSound,
|
|
@@ -1689,6 +1675,15 @@ var { MODELS } = defineModels("kling", [
|
|
|
1689
1675
|
{ when: { videoUrl: { exists: true } }, then: {
|
|
1690
1676
|
resolution: { allowed: ["720p", "1080p"], reason: "4K output is unavailable with a reference video." },
|
|
1691
1677
|
generateAudio: { disabled: true, reason: "Kling disables generated sound when a reference video is supplied." }
|
|
1678
|
+
} },
|
|
1679
|
+
// Vendor: an end frame requires a first frame.
|
|
1680
|
+
{ when: { startFrame: { exists: false } }, then: { endFrame: { disabled: true, reason: "End frame requires a first frame." } } },
|
|
1681
|
+
// Vendor: base-video editing cannot be combined with frames or multi-shot.
|
|
1682
|
+
{ when: { referType: { is: "base" }, videoUrl: { exists: true } }, then: {
|
|
1683
|
+
startFrame: { disabled: true, reason: "Base video editing cannot be combined with frames." },
|
|
1684
|
+
endFrame: { disabled: true, reason: "Base video editing cannot be combined with frames." },
|
|
1685
|
+
multiShot: { disabled: true, reason: "Base video editing does not support multi-shot." },
|
|
1686
|
+
multiPrompt: { disabled: true, reason: "Base video editing does not support multi-shot." }
|
|
1692
1687
|
} }
|
|
1693
1688
|
]
|
|
1694
1689
|
},
|
|
@@ -1714,7 +1709,6 @@ var { MODELS } = defineModels("kling", [
|
|
|
1714
1709
|
...params.prompt({ maxLength: 2500 }),
|
|
1715
1710
|
...params.aspectRatio(["16:9", "9:16", "1:1"]),
|
|
1716
1711
|
...params.duration([5, 10], 5),
|
|
1717
|
-
...params.resolution(["720p", "1080p"], "720p"),
|
|
1718
1712
|
...params.renderingSpeed([{ id: "std", label: "Standard" }, { id: "pro", label: "Pro" }], "std"),
|
|
1719
1713
|
...params.generateAudio(false)
|
|
1720
1714
|
}
|
|
@@ -1733,7 +1727,6 @@ var { MODELS } = defineModels("kling", [
|
|
|
1733
1727
|
features: [feat("Image + Video", "input"), feat("Motion Transfer", "characteristic"), feat("V3", "resolution")],
|
|
1734
1728
|
paramConfig: {
|
|
1735
1729
|
...params.prompt({ required: false, maxLength: 2500 }),
|
|
1736
|
-
...params.resolution(["720p", "1080p"], "720p"),
|
|
1737
1730
|
...params.renderingSpeed([{ id: "std", label: "Standard" }, { id: "pro", label: "Pro" }], "std"),
|
|
1738
1731
|
...klingCharacterOrientation,
|
|
1739
1732
|
...klingKeepOriginalSound,
|
|
@@ -1754,7 +1747,6 @@ var { MODELS } = defineModels("kling", [
|
|
|
1754
1747
|
features: [feat("Image + Video", "input"), feat("Motion Transfer", "characteristic"), feat("2.6", "resolution")],
|
|
1755
1748
|
paramConfig: {
|
|
1756
1749
|
...params.prompt({ required: false, maxLength: 2500 }),
|
|
1757
|
-
...params.resolution(["720p", "1080p"], "720p"),
|
|
1758
1750
|
...params.renderingSpeed([{ id: "std", label: "Standard" }, { id: "pro", label: "Pro" }], "std"),
|
|
1759
1751
|
...klingCharacterOrientation,
|
|
1760
1752
|
...klingKeepOriginalSound,
|
|
@@ -1777,10 +1769,10 @@ var { MODELS } = defineModels("kling", [
|
|
|
1777
1769
|
...params.prompt({ required: false, maxLength: 2500 }),
|
|
1778
1770
|
...params.renderingSpeed([{ id: "std", label: "Standard" }, { id: "pro", label: "Pro" }], "std"),
|
|
1779
1771
|
...params.imageInput(1, "Face Portrait", true),
|
|
1780
|
-
//
|
|
1781
|
-
//
|
|
1782
|
-
//
|
|
1783
|
-
//
|
|
1772
|
+
// Vendor: exactly ONE of sound_file / audio_id. The UI path keeps the
|
|
1773
|
+
// audio file required; audio_id stays an additive alternative for raw
|
|
1774
|
+
// API callers. The builder never emits both keys (file wins) and the
|
|
1775
|
+
// worker enforces the XOR for un-typed callers.
|
|
1784
1776
|
...params.audioInput("Speech Audio", true),
|
|
1785
1777
|
audioId: {
|
|
1786
1778
|
label: "TTS Audio ID",
|
|
@@ -1846,10 +1838,12 @@ var { MODELS } = defineModels("kling", [
|
|
|
1846
1838
|
...params.aspectRatio(KLING_IMAGE_AR),
|
|
1847
1839
|
...params.count([1, 2, 3, 4, 5, 6, 7, 8, 9]),
|
|
1848
1840
|
...params.negativePrompt(),
|
|
1849
|
-
...params.imageInput(1, "Restyle Image")
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1841
|
+
...params.imageInput(1, "Restyle Image")
|
|
1842
|
+
},
|
|
1843
|
+
constraints: [
|
|
1844
|
+
// Vendor: negative prompts are not supported in image-to-image mode.
|
|
1845
|
+
{ when: { imageUrls: { exists: true } }, then: { negativePrompt: { disabled: true, reason: "Negative prompt is ignored in image-to-image mode." } } }
|
|
1846
|
+
]
|
|
1853
1847
|
},
|
|
1854
1848
|
// ── Image: Multi-Image-to-Image ─────────────────────────────────
|
|
1855
1849
|
{
|
|
@@ -1919,13 +1913,20 @@ var { MODELS } = defineModels("kling", [
|
|
|
1919
1913
|
default: "image_refer"
|
|
1920
1914
|
}
|
|
1921
1915
|
},
|
|
1922
|
-
|
|
1916
|
+
// Vendor: image_refer requires a frontal image + 1-3 extra angles
|
|
1917
|
+
// (min 2 uploads total — the builder enforces the minimum).
|
|
1918
|
+
...params.imageInput(4, "Reference Images (1st = frontal, plus 1-3 angles)", false),
|
|
1923
1919
|
...params.videoInput("Reference Video", "reference", false),
|
|
1924
1920
|
elementVoiceId: {
|
|
1925
|
-
label: "Voice ID (
|
|
1921
|
+
label: "Voice ID (character/humanoid elements)",
|
|
1926
1922
|
descriptor: { kind: "text" }
|
|
1927
1923
|
}
|
|
1928
|
-
}
|
|
1924
|
+
},
|
|
1925
|
+
constraints: [
|
|
1926
|
+
{ when: { referenceType: { is: "video_refer" } }, then: { imageUrls: { disabled: true, reason: "Video reference uses the reference video, not images." } } },
|
|
1927
|
+
{ when: { referenceType: { is: "image_refer" } }, then: { videoUrl: { disabled: true, reason: "Image reference uses reference images, not a video." } } },
|
|
1928
|
+
{ when: { referenceType: { exists: false } }, then: { videoUrl: { disabled: true, reason: "Image reference uses reference images, not a video." } } }
|
|
1929
|
+
]
|
|
1929
1930
|
},
|
|
1930
1931
|
{
|
|
1931
1932
|
id: "kling-video-effects",
|
|
@@ -1936,7 +1937,7 @@ var { MODELS } = defineModels("kling", [
|
|
|
1936
1937
|
mode: "video",
|
|
1937
1938
|
inputType: "i2v",
|
|
1938
1939
|
badge: ["new"],
|
|
1939
|
-
description: "Apply
|
|
1940
|
+
description: "Apply curated Kling visual effects to photos \u2014 single or dual-image scenes.",
|
|
1940
1941
|
features: [feat("Image Input", "input"), feat("Video Effects", "characteristic")],
|
|
1941
1942
|
paramConfig: {
|
|
1942
1943
|
...params.catalog("templateId", {
|
|
@@ -1944,7 +1945,8 @@ var { MODELS } = defineModels("kling", [
|
|
|
1944
1945
|
source: { workflow: "kling/v1/catalog/templates" },
|
|
1945
1946
|
default: "korean_baseball"
|
|
1946
1947
|
}),
|
|
1947
|
-
|
|
1948
|
+
// Vendor: ≥300px per side (10MB / aspect-ratio checks stay vendor-side).
|
|
1949
|
+
...params.imageInput(2, "Effect Images", true, "reference", { minSidePixels: 300 })
|
|
1948
1950
|
}
|
|
1949
1951
|
},
|
|
1950
1952
|
// ── Audio ─────────────────────────────────────────────────────────
|
|
@@ -1974,21 +1976,96 @@ var { MODELS } = defineModels("kling", [
|
|
|
1974
1976
|
description: "Extract or generate a matching audio track from an uploaded video.",
|
|
1975
1977
|
features: [feat("Video Input", "input")],
|
|
1976
1978
|
paramConfig: {
|
|
1977
|
-
|
|
1979
|
+
// Vendor: .mp4/.mov only, ≤100MB, 3.0-20.0s — duration and size are
|
|
1980
|
+
// enforced at upload; the 3s floor and container check stay vendor-side.
|
|
1981
|
+
...params.videoInput("Source Video (3-20s, \u2264100MB)", "reference", true, 20, void 0, 100 * 1024 * 1024)
|
|
1978
1982
|
}
|
|
1979
1983
|
}
|
|
1980
1984
|
]);
|
|
1981
1985
|
|
|
1986
|
+
// src/core/catalogs.ts
|
|
1987
|
+
var metaString = (item, key) => {
|
|
1988
|
+
const v = item.meta?.[key];
|
|
1989
|
+
return typeof v === "string" ? v : void 0;
|
|
1990
|
+
};
|
|
1991
|
+
function toVoiceOption(item, provider) {
|
|
1992
|
+
return {
|
|
1993
|
+
id: item.id,
|
|
1994
|
+
name: item.name,
|
|
1995
|
+
description: item.description ?? "",
|
|
1996
|
+
tags: item.tags,
|
|
1997
|
+
provider,
|
|
1998
|
+
previewUrl: item.preview?.audioUrl
|
|
1999
|
+
};
|
|
2000
|
+
}
|
|
2001
|
+
function toAvatarOption(item, provider) {
|
|
2002
|
+
return {
|
|
2003
|
+
id: item.id,
|
|
2004
|
+
name: item.name,
|
|
2005
|
+
description: item.description ?? "",
|
|
2006
|
+
tags: item.tags,
|
|
2007
|
+
provider,
|
|
2008
|
+
previewImageUrl: item.preview?.imageUrl,
|
|
2009
|
+
previewVideoUrl: item.preview?.videoUrl,
|
|
2010
|
+
gender: metaString(item, "gender"),
|
|
2011
|
+
defaultVoiceId: metaString(item, "defaultVoiceId")
|
|
2012
|
+
};
|
|
2013
|
+
}
|
|
2014
|
+
var registry = /* @__PURE__ */ new Map();
|
|
2015
|
+
var keyOf = (s) => `${s.workflow} ${s.modelId ?? ""}`;
|
|
2016
|
+
var OPTION_ADAPTERS = {
|
|
2017
|
+
voiceId: toVoiceOption,
|
|
2018
|
+
videoId: toAvatarOption
|
|
2019
|
+
};
|
|
2020
|
+
function installHydratedCatalog(source, paramKey, items, provider, version) {
|
|
2021
|
+
const adapt = OPTION_ADAPTERS[paramKey];
|
|
2022
|
+
registry.set(keyOf(source), {
|
|
2023
|
+
paramKey,
|
|
2024
|
+
items,
|
|
2025
|
+
options: items.map((i) => ({ id: i.id, label: i.name })),
|
|
2026
|
+
catalogOptions: adapt ? items.map((i) => adapt(i, provider)) : items,
|
|
2027
|
+
version
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
function getHydratedCatalog(source) {
|
|
2031
|
+
return registry.get(keyOf(source));
|
|
2032
|
+
}
|
|
2033
|
+
function getHydratedVoices() {
|
|
2034
|
+
const out = [];
|
|
2035
|
+
for (const c of registry.values()) {
|
|
2036
|
+
if (c.paramKey === "voiceId") out.push(...c.catalogOptions);
|
|
2037
|
+
}
|
|
2038
|
+
return out;
|
|
2039
|
+
}
|
|
2040
|
+
|
|
1982
2041
|
// src/vendors/catalog/kling/payloads.ts
|
|
2042
|
+
function assertMultiPrompt(multiPrompt, totalDuration, model) {
|
|
2043
|
+
if (!multiPrompt?.length || multiPrompt.length > 6) {
|
|
2044
|
+
throw new ApiError(`${model}: multi-shot mode requires 1-6 storyboard entries in multiPrompt.`, { status: 400, code: "validation_error" });
|
|
2045
|
+
}
|
|
2046
|
+
const durations = multiPrompt.map((s) => Number(s.duration));
|
|
2047
|
+
if (durations.some((d) => !Number.isFinite(d) || d < 1 || d > totalDuration)) {
|
|
2048
|
+
throw new ApiError(`${model}: each storyboard duration must be between 1 and the total duration (${totalDuration}s).`, { status: 400, code: "validation_error" });
|
|
2049
|
+
}
|
|
2050
|
+
const sum = durations.reduce((a, b) => a + b, 0);
|
|
2051
|
+
if (sum !== totalDuration) {
|
|
2052
|
+
throw new ApiError(`${model}: storyboard durations must add up to the total duration (${sum}s \u2260 ${totalDuration}s).`, { status: 400, code: "validation_error" });
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
1983
2055
|
var buildKlingV3Payload = (defaultMode = "std") => (input) => {
|
|
1984
|
-
const hasEndFrame = !!(input.startFrame && input.endFrame
|
|
1985
|
-
const hasSound = !!input.generateAudio
|
|
1986
|
-
const mode =
|
|
2056
|
+
const hasEndFrame = !!(input.startFrame && input.endFrame);
|
|
2057
|
+
const hasSound = !!input.generateAudio;
|
|
2058
|
+
const mode = input.renderingSpeed ?? defaultMode;
|
|
2059
|
+
const totalDuration = input.duration ?? 5;
|
|
2060
|
+
if (input.multiShot && (input.shotType ?? "customize") !== "intelligence") {
|
|
2061
|
+
assertMultiPrompt(input.multiPrompt, totalDuration, "Kling V3");
|
|
2062
|
+
}
|
|
2063
|
+
const voiceList = hasSound && input.startFrame ? input.voiceList : void 0;
|
|
1987
2064
|
return {
|
|
1988
2065
|
...input.multiShot ? {} : { prompt: input.prompt },
|
|
1989
2066
|
aspect_ratio: input.aspectRatio ?? "16:9",
|
|
1990
2067
|
// String(n) is just `string`; wire expects '3'|'5'|...|'15'. Narrowing cast.
|
|
1991
|
-
duration: String(
|
|
2068
|
+
duration: String(totalDuration),
|
|
1992
2069
|
model_name: "kling-v3",
|
|
1993
2070
|
...input.startFrame ? { image: input.startFrame } : {},
|
|
1994
2071
|
...hasEndFrame ? { image_tail: input.endFrame } : {},
|
|
@@ -1998,26 +2075,25 @@ var buildKlingV3Payload = (defaultMode = "std") => (input) => {
|
|
|
1998
2075
|
...input.multiShot != null ? { multi_shot: input.multiShot } : {},
|
|
1999
2076
|
...input.shotType ? { shot_type: input.shotType } : {},
|
|
2000
2077
|
...input.multiPrompt ? { multi_prompt: input.multiPrompt } : {},
|
|
2001
|
-
// voice_list and
|
|
2002
|
-
//
|
|
2003
|
-
...
|
|
2004
|
-
...input.startFrame && input.elementList && !
|
|
2005
|
-
...input.startFrame && input.staticMask ? { static_mask: input.staticMask } : {}
|
|
2078
|
+
// voice_list requires sound 'on' and exists only on the I2V spec;
|
|
2079
|
+
// element_list is I2V-only and mutex with voice_list (voice_list wins).
|
|
2080
|
+
...voiceList ? { voice_list: voiceList } : {},
|
|
2081
|
+
...input.startFrame && input.elementList && !voiceList ? { element_list: input.elementList } : {}
|
|
2006
2082
|
};
|
|
2007
2083
|
};
|
|
2008
2084
|
var buildKlingV3TurboPayload = (input) => ({
|
|
2009
|
-
prompt:
|
|
2085
|
+
// Cap the folded string at the declared 2500-char prompt limit: the prompt
|
|
2086
|
+
// alone passed validation, so trimming can only ever hit the negative tail.
|
|
2087
|
+
prompt: input.negativePrompt ? `${input.prompt}. Avoid: ${input.negativePrompt}`.slice(0, 2500) : input.prompt,
|
|
2010
2088
|
aspect_ratio: input.aspectRatio ?? "16:9",
|
|
2011
2089
|
// String(n) is just `string`; wire expects '3'|'5'|...|'15'. Narrowing cast.
|
|
2012
2090
|
duration: String(input.duration ?? 5),
|
|
2013
2091
|
model_name: "kling-v3-turbo",
|
|
2014
2092
|
resolution: input.resolution ?? "720p",
|
|
2015
|
-
...input.startFrame ? { image: input.startFrame } : {}
|
|
2016
|
-
...input.negativePrompt ? { negative_prompt: input.negativePrompt } : {},
|
|
2017
|
-
...input.startFrame && input.staticMask ? { static_mask: input.staticMask } : {}
|
|
2093
|
+
...input.startFrame ? { image: input.startFrame } : {}
|
|
2018
2094
|
});
|
|
2019
2095
|
var buildKlingV26Payload = (input) => {
|
|
2020
|
-
const hasEndFrame = !!(input.startFrame && input.endFrame
|
|
2096
|
+
const hasEndFrame = !!(input.startFrame && input.endFrame);
|
|
2021
2097
|
const hasSound = !!input.generateAudio && !hasEndFrame;
|
|
2022
2098
|
return {
|
|
2023
2099
|
prompt: input.prompt,
|
|
@@ -2028,8 +2104,7 @@ var buildKlingV26Payload = (input) => {
|
|
|
2028
2104
|
...hasEndFrame ? { image_tail: input.endFrame } : {},
|
|
2029
2105
|
...input.negativePrompt ? { negative_prompt: input.negativePrompt } : {},
|
|
2030
2106
|
...hasSound ? { sound: "on" } : {},
|
|
2031
|
-
mode: "pro"
|
|
2032
|
-
...input.cfgScale !== void 0 ? { cfg_scale: input.cfgScale } : {}
|
|
2107
|
+
mode: "pro"
|
|
2033
2108
|
};
|
|
2034
2109
|
};
|
|
2035
2110
|
var stringElementList = (list) => list?.length ? { element_list: list.map((e) => ({ element_id: String(e.element_id) })) } : {};
|
|
@@ -2046,15 +2121,19 @@ var buildOmniV3 = (input) => {
|
|
|
2046
2121
|
}] : [];
|
|
2047
2122
|
const hasBaseEdit = videoList[0]?.refer_type === "base";
|
|
2048
2123
|
const hasReferenceVideo = videoList.length > 0;
|
|
2049
|
-
const fourK = input.resolution === "4k" && !hasReferenceVideo;
|
|
2050
2124
|
const hasSound = !!input.generateAudio && !hasReferenceVideo;
|
|
2125
|
+
const mode = input.resolution === "4k" ? hasReferenceVideo ? "pro" : "4k" : input.resolution === "1080p" ? "pro" : "std";
|
|
2126
|
+
const totalDuration = input.duration ?? 5;
|
|
2127
|
+
if (input.multiShot && !hasBaseEdit) {
|
|
2128
|
+
assertMultiPrompt(input.multiPrompt, totalDuration, "Kling V3 Omni");
|
|
2129
|
+
}
|
|
2051
2130
|
return {
|
|
2052
2131
|
...input.multiShot ? {} : { prompt: input.prompt },
|
|
2053
2132
|
model_name: "kling-v3-omni",
|
|
2054
2133
|
...hasBaseEdit || input.startFrame ? {} : { aspect_ratio: input.aspectRatio ?? "16:9" },
|
|
2055
2134
|
// String(n) is just `string`; wire expects literal union. Narrowing cast.
|
|
2056
|
-
...hasBaseEdit ? {} : { duration: String(
|
|
2057
|
-
|
|
2135
|
+
...hasBaseEdit ? {} : { duration: String(totalDuration) },
|
|
2136
|
+
mode,
|
|
2058
2137
|
...input.multiShot != null ? { multi_shot: input.multiShot } : {},
|
|
2059
2138
|
...input.shotType ? { shot_type: input.shotType } : {},
|
|
2060
2139
|
...input.multiPrompt ? { multi_prompt: input.multiPrompt } : {},
|
|
@@ -2088,8 +2167,7 @@ var buildMotionControl = (backendModelName) => (input) => ({
|
|
|
2088
2167
|
var buildKlingAvatarPayload = (input) => ({
|
|
2089
2168
|
// imageUrls is typed [string, ...string[]] (required tuple).
|
|
2090
2169
|
image: input.imageUrls[0],
|
|
2091
|
-
...input.audioUrl ? { sound_file: input.audioUrl } : {},
|
|
2092
|
-
...input.audioId ? { audio_id: input.audioId } : {},
|
|
2170
|
+
...input.audioUrl ? { sound_file: input.audioUrl } : input.audioId ? { audio_id: input.audioId } : {},
|
|
2093
2171
|
prompt: input.prompt,
|
|
2094
2172
|
...input.renderingSpeed ? { mode: input.renderingSpeed } : {}
|
|
2095
2173
|
});
|
|
@@ -2108,10 +2186,8 @@ var buildGenerations = (input) => {
|
|
|
2108
2186
|
model_name: "kling-v2-1",
|
|
2109
2187
|
n: input.count ?? 1,
|
|
2110
2188
|
...input.aspectRatio ? { aspect_ratio: input.aspectRatio } : {},
|
|
2111
|
-
...input.negativePrompt ? { negative_prompt: input.negativePrompt } : {},
|
|
2112
|
-
...hasImage ? { image: input.imageUrls[0] } : {}
|
|
2113
|
-
...hasImage && input.imageWeight != null ? { image_fidelity: input.imageWeight / 100 } : {},
|
|
2114
|
-
...input.humanFidelity != null ? { human_fidelity: input.humanFidelity } : {}
|
|
2189
|
+
...input.negativePrompt && !hasImage ? { negative_prompt: input.negativePrompt } : {},
|
|
2190
|
+
...hasImage ? { image: input.imageUrls[0] } : {}
|
|
2115
2191
|
};
|
|
2116
2192
|
};
|
|
2117
2193
|
var buildMultiImage = (input) => ({
|
|
@@ -2125,26 +2201,36 @@ var buildMultiImage = (input) => ({
|
|
|
2125
2201
|
});
|
|
2126
2202
|
var buildKlingElementsPayload = (input) => {
|
|
2127
2203
|
const isVideo = input.referenceType === "video_refer";
|
|
2204
|
+
if (isVideo && !input.videoUrl) {
|
|
2205
|
+
throw new ApiError("Kling Elements: video reference requires a reference video.", { status: 400, code: "validation_error" });
|
|
2206
|
+
}
|
|
2207
|
+
if (!isVideo && (input.imageUrls?.length ?? 0) < 2) {
|
|
2208
|
+
throw new ApiError("Kling Elements: image reference requires at least 2 images \u2014 a frontal image plus 1-3 additional angles.", { status: 400, code: "validation_error" });
|
|
2209
|
+
}
|
|
2128
2210
|
return {
|
|
2129
2211
|
element_name: input.elementName,
|
|
2130
2212
|
element_description: input.elementDescription,
|
|
2131
2213
|
reference_type: input.referenceType ?? "image_refer",
|
|
2132
|
-
...isVideo ?
|
|
2214
|
+
...isVideo ? { element_video_list: { refer_videos: [{ video_url: input.videoUrl }] } } : {
|
|
2133
2215
|
element_image_list: {
|
|
2134
2216
|
frontal_image: input.imageUrls[0],
|
|
2135
|
-
refer_images:
|
|
2217
|
+
refer_images: input.imageUrls.slice(1).map((url) => ({ image_url: url }))
|
|
2136
2218
|
}
|
|
2137
|
-
}
|
|
2219
|
+
},
|
|
2138
2220
|
...input.elementVoiceId ? { element_voice_id: input.elementVoiceId } : {}
|
|
2139
2221
|
};
|
|
2140
2222
|
};
|
|
2141
2223
|
var buildKlingVideoEffectsPayload = (input) => {
|
|
2142
|
-
const
|
|
2224
|
+
const scene = input.templateId ?? input.style;
|
|
2225
|
+
const catalogItem = getHydratedCatalog({ workflow: "kling/v1/catalog/templates" })?.items.find((item) => item.id === scene);
|
|
2226
|
+
const slots = typeof catalogItem?.meta?.imageSlots === "number" ? catalogItem.meta.imageSlots : scene && KLING_DUAL_IMAGE_EFFECTS.has(scene) ? 2 : 1;
|
|
2227
|
+
const uploaded = input.imageUrls?.length ?? 0;
|
|
2228
|
+
if (uploaded < slots) {
|
|
2229
|
+
throw new ApiError(`Kling Video Effects: the "${scene}" effect requires ${slots} image${slots > 1 ? "s" : ""} (got ${uploaded}).`, { status: 400, code: "validation_error" });
|
|
2230
|
+
}
|
|
2143
2231
|
return {
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
effect_scene: input.templateId ?? input.style,
|
|
2147
|
-
...isDualEffect ? { images: input.imageUrls.slice(0, 2) } : input.imageUrls?.[0] ? { image: input.imageUrls[0] } : {}
|
|
2232
|
+
effect_scene: scene,
|
|
2233
|
+
...slots === 2 ? { images: input.imageUrls.slice(0, 2) } : { image: input.imageUrls[0] }
|
|
2148
2234
|
};
|
|
2149
2235
|
};
|
|
2150
2236
|
var buildKlingT2APayload = (input) => ({
|
|
@@ -4531,61 +4617,6 @@ var { MODELS: MODELS14 } = defineModels("seedream", [
|
|
|
4531
4617
|
}
|
|
4532
4618
|
]);
|
|
4533
4619
|
|
|
4534
|
-
// src/core/catalogs.ts
|
|
4535
|
-
var metaString = (item, key) => {
|
|
4536
|
-
const v = item.meta?.[key];
|
|
4537
|
-
return typeof v === "string" ? v : void 0;
|
|
4538
|
-
};
|
|
4539
|
-
function toVoiceOption(item, provider) {
|
|
4540
|
-
return {
|
|
4541
|
-
id: item.id,
|
|
4542
|
-
name: item.name,
|
|
4543
|
-
description: item.description ?? "",
|
|
4544
|
-
tags: item.tags,
|
|
4545
|
-
provider,
|
|
4546
|
-
previewUrl: item.preview?.audioUrl
|
|
4547
|
-
};
|
|
4548
|
-
}
|
|
4549
|
-
function toAvatarOption(item, provider) {
|
|
4550
|
-
return {
|
|
4551
|
-
id: item.id,
|
|
4552
|
-
name: item.name,
|
|
4553
|
-
description: item.description ?? "",
|
|
4554
|
-
tags: item.tags,
|
|
4555
|
-
provider,
|
|
4556
|
-
previewImageUrl: item.preview?.imageUrl,
|
|
4557
|
-
previewVideoUrl: item.preview?.videoUrl,
|
|
4558
|
-
gender: metaString(item, "gender"),
|
|
4559
|
-
defaultVoiceId: metaString(item, "defaultVoiceId")
|
|
4560
|
-
};
|
|
4561
|
-
}
|
|
4562
|
-
var registry = /* @__PURE__ */ new Map();
|
|
4563
|
-
var keyOf = (s) => `${s.workflow} ${s.modelId ?? ""}`;
|
|
4564
|
-
var OPTION_ADAPTERS = {
|
|
4565
|
-
voiceId: toVoiceOption,
|
|
4566
|
-
videoId: toAvatarOption
|
|
4567
|
-
};
|
|
4568
|
-
function installHydratedCatalog(source, paramKey, items, provider, version) {
|
|
4569
|
-
const adapt = OPTION_ADAPTERS[paramKey];
|
|
4570
|
-
registry.set(keyOf(source), {
|
|
4571
|
-
paramKey,
|
|
4572
|
-
items,
|
|
4573
|
-
options: items.map((i) => ({ id: i.id, label: i.name })),
|
|
4574
|
-
catalogOptions: adapt ? items.map((i) => adapt(i, provider)) : items,
|
|
4575
|
-
version
|
|
4576
|
-
});
|
|
4577
|
-
}
|
|
4578
|
-
function getHydratedCatalog(source) {
|
|
4579
|
-
return registry.get(keyOf(source));
|
|
4580
|
-
}
|
|
4581
|
-
function getHydratedVoices() {
|
|
4582
|
-
const out = [];
|
|
4583
|
-
for (const c of registry.values()) {
|
|
4584
|
-
if (c.paramKey === "voiceId") out.push(...c.catalogOptions);
|
|
4585
|
-
}
|
|
4586
|
-
return out;
|
|
4587
|
-
}
|
|
4588
|
-
|
|
4589
4620
|
// src/core/voices.ts
|
|
4590
4621
|
var DEFAULT_VOICE_ID = "JBFqnCBsd6RMkjVDRZzb";
|
|
4591
4622
|
var GEMINI_DEFAULT_VOICE_ID = "Kore";
|