@acedatacloud/sdk 2026.629.0 → 2026.716.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/dist/index.d.mts +47 -26
- package/dist/index.d.ts +47 -26
- package/dist/index.js +166 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +166 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +7 -1
- package/src/resources/kling.ts +218 -39
- package/src/resources/veo.ts +3 -3
package/dist/index.mjs
CHANGED
|
@@ -856,12 +856,148 @@ var Veo = class {
|
|
|
856
856
|
};
|
|
857
857
|
|
|
858
858
|
// src/resources/kling.ts
|
|
859
|
+
var KLING_MODELS = [
|
|
860
|
+
"kling-v1",
|
|
861
|
+
"kling-v1-6",
|
|
862
|
+
"kling-v2-master",
|
|
863
|
+
"kling-v2-1-master",
|
|
864
|
+
"kling-v2-5-turbo",
|
|
865
|
+
"kling-v2-6",
|
|
866
|
+
"kling-v3",
|
|
867
|
+
"kling-v3-omni",
|
|
868
|
+
"kling-o1"
|
|
869
|
+
];
|
|
870
|
+
function isHttpUrl(value) {
|
|
871
|
+
try {
|
|
872
|
+
const url = new URL(value);
|
|
873
|
+
return url.protocol === "http:" || url.protocol === "https:";
|
|
874
|
+
} catch {
|
|
875
|
+
return false;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
function validateGenerateOptions(opts) {
|
|
879
|
+
if (!KLING_MODELS.includes(opts.model)) {
|
|
880
|
+
throw new Error(`model must be one of: ${KLING_MODELS.join(", ")}`);
|
|
881
|
+
}
|
|
882
|
+
const isV3 = opts.model === "kling-v3" || opts.model === "kling-v3-omni";
|
|
883
|
+
const hasReferences = Boolean(opts.imageList?.length || opts.videoList?.length);
|
|
884
|
+
if (opts.imageList !== void 0 && opts.imageList.length === 0) {
|
|
885
|
+
throw new Error("imageList must be non-empty or omitted");
|
|
886
|
+
}
|
|
887
|
+
if (opts.videoList !== void 0 && opts.videoList.length === 0) {
|
|
888
|
+
throw new Error("videoList must be non-empty or omitted");
|
|
889
|
+
}
|
|
890
|
+
if ((opts.action === "text2video" || opts.action === "image2video") && !opts.prompt) {
|
|
891
|
+
throw new Error("prompt is required for text2video and image2video");
|
|
892
|
+
}
|
|
893
|
+
if (opts.action === "image2video" && !opts.startImageUrl) {
|
|
894
|
+
throw new Error("startImageUrl is required for image2video");
|
|
895
|
+
}
|
|
896
|
+
if (opts.action === "extend" && !opts.videoId) {
|
|
897
|
+
throw new Error("videoId is required for extend");
|
|
898
|
+
}
|
|
899
|
+
if (opts.endImageUrl && !opts.startImageUrl) {
|
|
900
|
+
throw new Error("startImageUrl is required with endImageUrl");
|
|
901
|
+
}
|
|
902
|
+
if (opts.startImageUrl && !isHttpUrl(opts.startImageUrl)) {
|
|
903
|
+
throw new Error("startImageUrl must be an HTTP URL");
|
|
904
|
+
}
|
|
905
|
+
if (opts.endImageUrl && !isHttpUrl(opts.endImageUrl)) {
|
|
906
|
+
throw new Error("endImageUrl must be an HTTP URL");
|
|
907
|
+
}
|
|
908
|
+
if (opts.callbackUrl && !isHttpUrl(opts.callbackUrl)) {
|
|
909
|
+
throw new Error("callbackUrl must be an HTTP URL");
|
|
910
|
+
}
|
|
911
|
+
if (opts.cfgScale !== void 0 && (opts.cfgScale < 0 || opts.cfgScale > 1)) {
|
|
912
|
+
throw new Error("cfgScale must be between 0 and 1");
|
|
913
|
+
}
|
|
914
|
+
if (opts.duration !== void 0 && !Number.isInteger(opts.duration)) {
|
|
915
|
+
throw new Error("duration must be an integer");
|
|
916
|
+
}
|
|
917
|
+
if (isV3 && opts.duration !== void 0 && (opts.duration < 3 || opts.duration > 15)) {
|
|
918
|
+
throw new Error("Kling V3 duration must be between 3 and 15 seconds");
|
|
919
|
+
}
|
|
920
|
+
if (!isV3 && opts.model !== "kling-o1" && opts.duration !== void 0 && ![5, 10].includes(opts.duration)) {
|
|
921
|
+
throw new Error("This Kling model supports only 5- or 10-second generation");
|
|
922
|
+
}
|
|
923
|
+
if (opts.model === "kling-o1" && opts.duration !== void 0 && opts.duration !== 5) {
|
|
924
|
+
throw new Error("kling-o1 supports only 5-second generation");
|
|
925
|
+
}
|
|
926
|
+
if (opts.model === "kling-o1" && opts.mode !== void 0 && !["std", "pro"].includes(opts.mode)) {
|
|
927
|
+
throw new Error("kling-o1 supports only std and pro modes");
|
|
928
|
+
}
|
|
929
|
+
if (opts.mode === "4k" && !isV3) {
|
|
930
|
+
throw new Error("4k mode requires kling-v3 or kling-v3-omni");
|
|
931
|
+
}
|
|
932
|
+
if (opts.action === "extend" && !["kling-v1", "kling-v1-6", "kling-v2-5-turbo"].includes(opts.model)) {
|
|
933
|
+
throw new Error("extend requires kling-v1, kling-v1-6, or kling-v2-5-turbo");
|
|
934
|
+
}
|
|
935
|
+
if (opts.action === "extend" && hasReferences) {
|
|
936
|
+
throw new Error("imageList and videoList are not supported with extend");
|
|
937
|
+
}
|
|
938
|
+
if (hasReferences && opts.model !== "kling-o1" && opts.model !== "kling-v3-omni") {
|
|
939
|
+
throw new Error("Omni references require kling-o1 or kling-v3-omni");
|
|
940
|
+
}
|
|
941
|
+
if (hasReferences && opts.mode === "4k") {
|
|
942
|
+
throw new Error("4k cannot be combined with Omni references");
|
|
943
|
+
}
|
|
944
|
+
if ((opts.model === "kling-o1" || hasReferences) && (opts.negativePrompt !== void 0 || opts.cameraControl !== void 0 || opts.cfgScale !== void 0)) {
|
|
945
|
+
throw new Error("Kling O1 and Omni references do not support negativePrompt, cameraControl, or cfgScale");
|
|
946
|
+
}
|
|
947
|
+
if (opts.model === "kling-o1" && opts.generateAudio) {
|
|
948
|
+
throw new Error("kling-o1 does not support generateAudio");
|
|
949
|
+
}
|
|
950
|
+
if (opts.generateAudio && !isV3 && opts.model !== "kling-v2-6") {
|
|
951
|
+
throw new Error("generateAudio requires a V3 model or kling-v2-6 pro mode");
|
|
952
|
+
}
|
|
953
|
+
if (opts.generateAudio && opts.model === "kling-v2-6" && opts.mode !== "pro") {
|
|
954
|
+
throw new Error("kling-v2-6 supports generateAudio only in pro mode");
|
|
955
|
+
}
|
|
956
|
+
if (opts.generateAudio && opts.videoList?.length) {
|
|
957
|
+
throw new Error("generateAudio cannot be used with videoList");
|
|
958
|
+
}
|
|
959
|
+
if (opts.videoList && (opts.videoList.length === 0 || opts.videoList.length > 1)) {
|
|
960
|
+
throw new Error("videoList must contain exactly one reference video");
|
|
961
|
+
}
|
|
962
|
+
for (const image of opts.imageList ?? []) {
|
|
963
|
+
if (!isHttpUrl(image.imageUrl)) throw new Error("Every reference image requires an HTTP imageUrl");
|
|
964
|
+
if (image.type !== void 0 && !["first_frame", "end_frame"].includes(image.type)) {
|
|
965
|
+
throw new Error("Reference image type must be first_frame or end_frame");
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
for (const video of opts.videoList ?? []) {
|
|
969
|
+
if (!isHttpUrl(video.videoUrl)) throw new Error("Every reference video requires an HTTP videoUrl");
|
|
970
|
+
if (video.referType !== void 0 && !["base", "feature"].includes(video.referType)) {
|
|
971
|
+
throw new Error("Reference video referType must be base or feature");
|
|
972
|
+
}
|
|
973
|
+
if (video.keepOriginalSound !== void 0 && !["yes", "no"].includes(video.keepOriginalSound)) {
|
|
974
|
+
throw new Error("Reference video keepOriginalSound must be yes or no");
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
const firstFrames = Number(Boolean(opts.startImageUrl)) + (opts.imageList ?? []).filter((item) => item.type === "first_frame").length;
|
|
978
|
+
const endFrames = Number(Boolean(opts.endImageUrl)) + (opts.imageList ?? []).filter((item) => item.type === "end_frame").length;
|
|
979
|
+
if (firstFrames > 1 || endFrames > 1) {
|
|
980
|
+
throw new Error("Only one first frame and one end frame are allowed");
|
|
981
|
+
}
|
|
982
|
+
if (endFrames > 0 && firstFrames === 0) {
|
|
983
|
+
throw new Error("A first frame is required with an end frame");
|
|
984
|
+
}
|
|
985
|
+
if ((opts.videoList?.[0]?.referType ?? "base") === "base" && opts.videoList?.length && (firstFrames > 0 || endFrames > 0)) {
|
|
986
|
+
throw new Error("A base reference video cannot be combined with first or end frames");
|
|
987
|
+
}
|
|
988
|
+
const imageCount = (opts.imageList?.length ?? 0) + Number(Boolean(opts.startImageUrl)) + Number(Boolean(opts.endImageUrl));
|
|
989
|
+
const imageLimit = opts.videoList?.length ? 4 : 7;
|
|
990
|
+
if (imageCount > imageLimit) {
|
|
991
|
+
throw new Error(`Reference images cannot exceed ${imageLimit} for this request`);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
859
994
|
var Kling = class {
|
|
860
995
|
constructor(transport) {
|
|
861
996
|
this.transport = transport;
|
|
862
997
|
}
|
|
863
998
|
transport;
|
|
864
999
|
async generate(opts) {
|
|
1000
|
+
validateGenerateOptions(opts);
|
|
865
1001
|
const {
|
|
866
1002
|
action,
|
|
867
1003
|
mode,
|
|
@@ -873,15 +1009,16 @@ var Kling = class {
|
|
|
873
1009
|
cfgScale,
|
|
874
1010
|
aspectRatio,
|
|
875
1011
|
callbackUrl,
|
|
1012
|
+
async: asyncMode,
|
|
1013
|
+
timeout,
|
|
876
1014
|
endImageUrl,
|
|
877
1015
|
cameraControl,
|
|
878
|
-
|
|
1016
|
+
imageList,
|
|
879
1017
|
videoList,
|
|
880
1018
|
negativePrompt,
|
|
881
|
-
startImageUrl
|
|
882
|
-
...rest
|
|
1019
|
+
startImageUrl
|
|
883
1020
|
} = opts;
|
|
884
|
-
const body = { action
|
|
1021
|
+
const body = { action };
|
|
885
1022
|
if (mode !== void 0) body.mode = mode;
|
|
886
1023
|
if (model !== void 0) body.model = model;
|
|
887
1024
|
if (prompt !== void 0) body.prompt = prompt;
|
|
@@ -891,26 +1028,46 @@ var Kling = class {
|
|
|
891
1028
|
if (cfgScale !== void 0) body.cfg_scale = cfgScale;
|
|
892
1029
|
if (aspectRatio !== void 0) body.aspect_ratio = aspectRatio;
|
|
893
1030
|
if (callbackUrl !== void 0) body.callback_url = callbackUrl;
|
|
1031
|
+
if (asyncMode !== void 0) body.async = asyncMode;
|
|
1032
|
+
if (timeout !== void 0) body.timeout = timeout;
|
|
894
1033
|
if (endImageUrl !== void 0) body.end_image_url = endImageUrl;
|
|
895
1034
|
if (cameraControl !== void 0) body.camera_control = cameraControl;
|
|
896
|
-
if (
|
|
897
|
-
|
|
1035
|
+
if (imageList !== void 0) {
|
|
1036
|
+
body.image_list = imageList.map(({ imageUrl, type }) => ({ image_url: imageUrl, ...type ? { type } : {} }));
|
|
1037
|
+
}
|
|
1038
|
+
if (videoList !== void 0) {
|
|
1039
|
+
body.video_list = videoList.map(({ videoUrl, referType, keepOriginalSound }) => ({
|
|
1040
|
+
video_url: videoUrl,
|
|
1041
|
+
...referType ? { refer_type: referType } : {},
|
|
1042
|
+
...keepOriginalSound ? { keep_original_sound: keepOriginalSound } : {}
|
|
1043
|
+
}));
|
|
1044
|
+
}
|
|
898
1045
|
if (negativePrompt !== void 0) body.negative_prompt = negativePrompt;
|
|
899
1046
|
if (startImageUrl !== void 0) body.start_image_url = startImageUrl;
|
|
900
1047
|
return this.transport.request("POST", "/kling/videos", { json: body });
|
|
901
1048
|
}
|
|
902
1049
|
async motion(opts) {
|
|
903
|
-
const { mode, imageUrl, videoUrl, characterOrientation, keepOriginalSound, prompt, callbackUrl
|
|
1050
|
+
const { mode, imageUrl, videoUrl, characterOrientation, keepOriginalSound, prompt, callbackUrl } = opts;
|
|
1051
|
+
if (!["std", "pro"].includes(mode)) throw new Error("mode must be std or pro");
|
|
1052
|
+
if (!isHttpUrl(imageUrl)) throw new Error("imageUrl must be an HTTP URL");
|
|
1053
|
+
if (!isHttpUrl(videoUrl)) throw new Error("videoUrl must be an HTTP URL");
|
|
1054
|
+
if (!["image", "video"].includes(characterOrientation)) {
|
|
1055
|
+
throw new Error("characterOrientation must be image or video");
|
|
1056
|
+
}
|
|
1057
|
+
if (keepOriginalSound !== void 0 && !["yes", "no"].includes(keepOriginalSound)) {
|
|
1058
|
+
throw new Error("keepOriginalSound must be yes or no");
|
|
1059
|
+
}
|
|
1060
|
+
if (callbackUrl && !isHttpUrl(callbackUrl)) throw new Error("callbackUrl must be an HTTP URL");
|
|
904
1061
|
const body = {
|
|
905
1062
|
mode,
|
|
906
1063
|
image_url: imageUrl,
|
|
907
1064
|
video_url: videoUrl,
|
|
908
|
-
character_orientation: characterOrientation
|
|
909
|
-
...rest
|
|
1065
|
+
character_orientation: characterOrientation
|
|
910
1066
|
};
|
|
911
1067
|
if (keepOriginalSound !== void 0) body.keep_original_sound = keepOriginalSound;
|
|
912
1068
|
if (prompt !== void 0) body.prompt = prompt;
|
|
913
1069
|
if (callbackUrl !== void 0) body.callback_url = callbackUrl;
|
|
1070
|
+
if (opts.async !== void 0) body.async = opts.async;
|
|
914
1071
|
return this.transport.request("POST", "/kling/motion", { json: body });
|
|
915
1072
|
}
|
|
916
1073
|
};
|