@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.d.mts
CHANGED
|
@@ -502,7 +502,7 @@ declare class Glm {
|
|
|
502
502
|
|
|
503
503
|
/** Veo-specific video generation and editing resources. */
|
|
504
504
|
|
|
505
|
-
type VeoModel = '
|
|
505
|
+
type VeoModel = 'veo3' | 'veo3-fast' | 'veo31-fast' | 'veo31' | 'veo31-fast-ingredients' | (string & {});
|
|
506
506
|
declare class Veo {
|
|
507
507
|
private transport;
|
|
508
508
|
constructor(transport: Transport);
|
|
@@ -512,8 +512,8 @@ declare class Veo {
|
|
|
512
512
|
model?: VeoModel;
|
|
513
513
|
resolution?: '4k' | '1080p' | 'gif';
|
|
514
514
|
videoId?: string;
|
|
515
|
-
translation?:
|
|
516
|
-
aspectRatio?: '
|
|
515
|
+
translation?: boolean;
|
|
516
|
+
aspectRatio?: '16:9' | '9:16';
|
|
517
517
|
imageUrls?: string[];
|
|
518
518
|
callbackUrl?: string;
|
|
519
519
|
async?: boolean;
|
|
@@ -554,30 +554,52 @@ declare class Veo {
|
|
|
554
554
|
|
|
555
555
|
/** Kling-specific video generation resources. */
|
|
556
556
|
|
|
557
|
-
|
|
557
|
+
declare const KLING_MODELS: readonly ["kling-v1", "kling-v1-6", "kling-v2-master", "kling-v2-1-master", "kling-v2-5-turbo", "kling-v2-6", "kling-v3", "kling-v3-omni", "kling-o1"];
|
|
558
|
+
type KlingModel = (typeof KLING_MODELS)[number];
|
|
559
|
+
interface KlingCameraControl {
|
|
560
|
+
type: 'simple' | 'down_back' | 'forward_up' | 'left_turn_forward' | 'right_turn_forward';
|
|
561
|
+
config?: {
|
|
562
|
+
horizontal?: number;
|
|
563
|
+
vertical?: number;
|
|
564
|
+
pan?: number;
|
|
565
|
+
tilt?: number;
|
|
566
|
+
roll?: number;
|
|
567
|
+
zoom?: number;
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
interface KlingReferenceImage {
|
|
571
|
+
imageUrl: string;
|
|
572
|
+
type?: 'first_frame' | 'end_frame';
|
|
573
|
+
}
|
|
574
|
+
interface KlingReferenceVideo {
|
|
575
|
+
videoUrl: string;
|
|
576
|
+
referType?: 'base' | 'feature';
|
|
577
|
+
keepOriginalSound?: 'yes' | 'no';
|
|
578
|
+
}
|
|
579
|
+
interface KlingGenerateOptions {
|
|
580
|
+
action: 'text2video' | 'image2video' | 'extend';
|
|
581
|
+
mode?: 'std' | 'pro' | '4k';
|
|
582
|
+
model: KlingModel;
|
|
583
|
+
prompt?: string;
|
|
584
|
+
duration?: number;
|
|
585
|
+
generateAudio?: boolean;
|
|
586
|
+
videoId?: string;
|
|
587
|
+
cfgScale?: number;
|
|
588
|
+
aspectRatio?: '16:9' | '9:16' | '1:1';
|
|
589
|
+
callbackUrl?: string;
|
|
590
|
+
async?: boolean;
|
|
591
|
+
timeout?: number;
|
|
592
|
+
endImageUrl?: string;
|
|
593
|
+
cameraControl?: KlingCameraControl;
|
|
594
|
+
imageList?: KlingReferenceImage[];
|
|
595
|
+
videoList?: KlingReferenceVideo[];
|
|
596
|
+
negativePrompt?: string;
|
|
597
|
+
startImageUrl?: string;
|
|
598
|
+
}
|
|
558
599
|
declare class Kling {
|
|
559
600
|
private transport;
|
|
560
601
|
constructor(transport: Transport);
|
|
561
|
-
generate(opts:
|
|
562
|
-
action: 'text2video' | 'image2video' | 'extend';
|
|
563
|
-
mode?: 'std' | 'pro' | '4k';
|
|
564
|
-
model?: KlingModel;
|
|
565
|
-
prompt?: string;
|
|
566
|
-
duration?: 5 | 10;
|
|
567
|
-
generateAudio?: boolean;
|
|
568
|
-
videoId?: string;
|
|
569
|
-
cfgScale?: number;
|
|
570
|
-
aspectRatio?: '16:9' | '9:16' | '1:1';
|
|
571
|
-
callbackUrl?: string;
|
|
572
|
-
async?: boolean;
|
|
573
|
-
endImageUrl?: string;
|
|
574
|
-
cameraControl?: string;
|
|
575
|
-
elementList?: unknown[];
|
|
576
|
-
videoList?: unknown[];
|
|
577
|
-
negativePrompt?: string;
|
|
578
|
-
startImageUrl?: string;
|
|
579
|
-
[key: string]: unknown;
|
|
580
|
-
}): Promise<Record<string, unknown>>;
|
|
602
|
+
generate(opts: KlingGenerateOptions): Promise<Record<string, unknown>>;
|
|
581
603
|
motion(opts: {
|
|
582
604
|
mode: 'std' | 'pro';
|
|
583
605
|
imageUrl: string;
|
|
@@ -587,7 +609,6 @@ declare class Kling {
|
|
|
587
609
|
prompt?: string;
|
|
588
610
|
callbackUrl?: string;
|
|
589
611
|
async?: boolean;
|
|
590
|
-
[key: string]: unknown;
|
|
591
612
|
}): Promise<Record<string, unknown>>;
|
|
592
613
|
}
|
|
593
614
|
|
|
@@ -712,4 +733,4 @@ declare class AceDataCloud {
|
|
|
712
733
|
constructor(opts?: AceDataCloudOptions);
|
|
713
734
|
}
|
|
714
735
|
|
|
715
|
-
export { APIError, AceDataCloud, AceDataCloudError, type AceDataCloudOptions, type AiChatModel, type AudioProvider, AuthenticationError, type GlmModel, type ImageProvider, InsufficientBalanceError, type KlingModel, ModerationError, type PaymentHandler, type PaymentHandlerContext, type PaymentHandlerResult, type PaymentRequiredBody, type PaymentRequirement, RateLimitError, ResourceDisabledError, TaskHandle, type TaskHandleOptions, TimeoutError, TokenMismatchError, TransportError, ValidationError, type VeoModel, type VideoProvider };
|
|
736
|
+
export { APIError, AceDataCloud, AceDataCloudError, type AceDataCloudOptions, type AiChatModel, type AudioProvider, AuthenticationError, type GlmModel, type ImageProvider, InsufficientBalanceError, type KlingCameraControl, type KlingGenerateOptions, type KlingModel, type KlingReferenceImage, type KlingReferenceVideo, ModerationError, type PaymentHandler, type PaymentHandlerContext, type PaymentHandlerResult, type PaymentRequiredBody, type PaymentRequirement, RateLimitError, ResourceDisabledError, TaskHandle, type TaskHandleOptions, TimeoutError, TokenMismatchError, TransportError, ValidationError, type VeoModel, type VideoProvider };
|
package/dist/index.d.ts
CHANGED
|
@@ -502,7 +502,7 @@ declare class Glm {
|
|
|
502
502
|
|
|
503
503
|
/** Veo-specific video generation and editing resources. */
|
|
504
504
|
|
|
505
|
-
type VeoModel = '
|
|
505
|
+
type VeoModel = 'veo3' | 'veo3-fast' | 'veo31-fast' | 'veo31' | 'veo31-fast-ingredients' | (string & {});
|
|
506
506
|
declare class Veo {
|
|
507
507
|
private transport;
|
|
508
508
|
constructor(transport: Transport);
|
|
@@ -512,8 +512,8 @@ declare class Veo {
|
|
|
512
512
|
model?: VeoModel;
|
|
513
513
|
resolution?: '4k' | '1080p' | 'gif';
|
|
514
514
|
videoId?: string;
|
|
515
|
-
translation?:
|
|
516
|
-
aspectRatio?: '
|
|
515
|
+
translation?: boolean;
|
|
516
|
+
aspectRatio?: '16:9' | '9:16';
|
|
517
517
|
imageUrls?: string[];
|
|
518
518
|
callbackUrl?: string;
|
|
519
519
|
async?: boolean;
|
|
@@ -554,30 +554,52 @@ declare class Veo {
|
|
|
554
554
|
|
|
555
555
|
/** Kling-specific video generation resources. */
|
|
556
556
|
|
|
557
|
-
|
|
557
|
+
declare const KLING_MODELS: readonly ["kling-v1", "kling-v1-6", "kling-v2-master", "kling-v2-1-master", "kling-v2-5-turbo", "kling-v2-6", "kling-v3", "kling-v3-omni", "kling-o1"];
|
|
558
|
+
type KlingModel = (typeof KLING_MODELS)[number];
|
|
559
|
+
interface KlingCameraControl {
|
|
560
|
+
type: 'simple' | 'down_back' | 'forward_up' | 'left_turn_forward' | 'right_turn_forward';
|
|
561
|
+
config?: {
|
|
562
|
+
horizontal?: number;
|
|
563
|
+
vertical?: number;
|
|
564
|
+
pan?: number;
|
|
565
|
+
tilt?: number;
|
|
566
|
+
roll?: number;
|
|
567
|
+
zoom?: number;
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
interface KlingReferenceImage {
|
|
571
|
+
imageUrl: string;
|
|
572
|
+
type?: 'first_frame' | 'end_frame';
|
|
573
|
+
}
|
|
574
|
+
interface KlingReferenceVideo {
|
|
575
|
+
videoUrl: string;
|
|
576
|
+
referType?: 'base' | 'feature';
|
|
577
|
+
keepOriginalSound?: 'yes' | 'no';
|
|
578
|
+
}
|
|
579
|
+
interface KlingGenerateOptions {
|
|
580
|
+
action: 'text2video' | 'image2video' | 'extend';
|
|
581
|
+
mode?: 'std' | 'pro' | '4k';
|
|
582
|
+
model: KlingModel;
|
|
583
|
+
prompt?: string;
|
|
584
|
+
duration?: number;
|
|
585
|
+
generateAudio?: boolean;
|
|
586
|
+
videoId?: string;
|
|
587
|
+
cfgScale?: number;
|
|
588
|
+
aspectRatio?: '16:9' | '9:16' | '1:1';
|
|
589
|
+
callbackUrl?: string;
|
|
590
|
+
async?: boolean;
|
|
591
|
+
timeout?: number;
|
|
592
|
+
endImageUrl?: string;
|
|
593
|
+
cameraControl?: KlingCameraControl;
|
|
594
|
+
imageList?: KlingReferenceImage[];
|
|
595
|
+
videoList?: KlingReferenceVideo[];
|
|
596
|
+
negativePrompt?: string;
|
|
597
|
+
startImageUrl?: string;
|
|
598
|
+
}
|
|
558
599
|
declare class Kling {
|
|
559
600
|
private transport;
|
|
560
601
|
constructor(transport: Transport);
|
|
561
|
-
generate(opts:
|
|
562
|
-
action: 'text2video' | 'image2video' | 'extend';
|
|
563
|
-
mode?: 'std' | 'pro' | '4k';
|
|
564
|
-
model?: KlingModel;
|
|
565
|
-
prompt?: string;
|
|
566
|
-
duration?: 5 | 10;
|
|
567
|
-
generateAudio?: boolean;
|
|
568
|
-
videoId?: string;
|
|
569
|
-
cfgScale?: number;
|
|
570
|
-
aspectRatio?: '16:9' | '9:16' | '1:1';
|
|
571
|
-
callbackUrl?: string;
|
|
572
|
-
async?: boolean;
|
|
573
|
-
endImageUrl?: string;
|
|
574
|
-
cameraControl?: string;
|
|
575
|
-
elementList?: unknown[];
|
|
576
|
-
videoList?: unknown[];
|
|
577
|
-
negativePrompt?: string;
|
|
578
|
-
startImageUrl?: string;
|
|
579
|
-
[key: string]: unknown;
|
|
580
|
-
}): Promise<Record<string, unknown>>;
|
|
602
|
+
generate(opts: KlingGenerateOptions): Promise<Record<string, unknown>>;
|
|
581
603
|
motion(opts: {
|
|
582
604
|
mode: 'std' | 'pro';
|
|
583
605
|
imageUrl: string;
|
|
@@ -587,7 +609,6 @@ declare class Kling {
|
|
|
587
609
|
prompt?: string;
|
|
588
610
|
callbackUrl?: string;
|
|
589
611
|
async?: boolean;
|
|
590
|
-
[key: string]: unknown;
|
|
591
612
|
}): Promise<Record<string, unknown>>;
|
|
592
613
|
}
|
|
593
614
|
|
|
@@ -712,4 +733,4 @@ declare class AceDataCloud {
|
|
|
712
733
|
constructor(opts?: AceDataCloudOptions);
|
|
713
734
|
}
|
|
714
735
|
|
|
715
|
-
export { APIError, AceDataCloud, AceDataCloudError, type AceDataCloudOptions, type AiChatModel, type AudioProvider, AuthenticationError, type GlmModel, type ImageProvider, InsufficientBalanceError, type KlingModel, ModerationError, type PaymentHandler, type PaymentHandlerContext, type PaymentHandlerResult, type PaymentRequiredBody, type PaymentRequirement, RateLimitError, ResourceDisabledError, TaskHandle, type TaskHandleOptions, TimeoutError, TokenMismatchError, TransportError, ValidationError, type VeoModel, type VideoProvider };
|
|
736
|
+
export { APIError, AceDataCloud, AceDataCloudError, type AceDataCloudOptions, type AiChatModel, type AudioProvider, AuthenticationError, type GlmModel, type ImageProvider, InsufficientBalanceError, type KlingCameraControl, type KlingGenerateOptions, type KlingModel, type KlingReferenceImage, type KlingReferenceVideo, ModerationError, type PaymentHandler, type PaymentHandlerContext, type PaymentHandlerResult, type PaymentRequiredBody, type PaymentRequirement, RateLimitError, ResourceDisabledError, TaskHandle, type TaskHandleOptions, TimeoutError, TokenMismatchError, TransportError, ValidationError, type VeoModel, type VideoProvider };
|
package/dist/index.js
CHANGED
|
@@ -904,12 +904,148 @@ var Veo = class {
|
|
|
904
904
|
};
|
|
905
905
|
|
|
906
906
|
// src/resources/kling.ts
|
|
907
|
+
var KLING_MODELS = [
|
|
908
|
+
"kling-v1",
|
|
909
|
+
"kling-v1-6",
|
|
910
|
+
"kling-v2-master",
|
|
911
|
+
"kling-v2-1-master",
|
|
912
|
+
"kling-v2-5-turbo",
|
|
913
|
+
"kling-v2-6",
|
|
914
|
+
"kling-v3",
|
|
915
|
+
"kling-v3-omni",
|
|
916
|
+
"kling-o1"
|
|
917
|
+
];
|
|
918
|
+
function isHttpUrl(value) {
|
|
919
|
+
try {
|
|
920
|
+
const url = new URL(value);
|
|
921
|
+
return url.protocol === "http:" || url.protocol === "https:";
|
|
922
|
+
} catch {
|
|
923
|
+
return false;
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
function validateGenerateOptions(opts) {
|
|
927
|
+
if (!KLING_MODELS.includes(opts.model)) {
|
|
928
|
+
throw new Error(`model must be one of: ${KLING_MODELS.join(", ")}`);
|
|
929
|
+
}
|
|
930
|
+
const isV3 = opts.model === "kling-v3" || opts.model === "kling-v3-omni";
|
|
931
|
+
const hasReferences = Boolean(opts.imageList?.length || opts.videoList?.length);
|
|
932
|
+
if (opts.imageList !== void 0 && opts.imageList.length === 0) {
|
|
933
|
+
throw new Error("imageList must be non-empty or omitted");
|
|
934
|
+
}
|
|
935
|
+
if (opts.videoList !== void 0 && opts.videoList.length === 0) {
|
|
936
|
+
throw new Error("videoList must be non-empty or omitted");
|
|
937
|
+
}
|
|
938
|
+
if ((opts.action === "text2video" || opts.action === "image2video") && !opts.prompt) {
|
|
939
|
+
throw new Error("prompt is required for text2video and image2video");
|
|
940
|
+
}
|
|
941
|
+
if (opts.action === "image2video" && !opts.startImageUrl) {
|
|
942
|
+
throw new Error("startImageUrl is required for image2video");
|
|
943
|
+
}
|
|
944
|
+
if (opts.action === "extend" && !opts.videoId) {
|
|
945
|
+
throw new Error("videoId is required for extend");
|
|
946
|
+
}
|
|
947
|
+
if (opts.endImageUrl && !opts.startImageUrl) {
|
|
948
|
+
throw new Error("startImageUrl is required with endImageUrl");
|
|
949
|
+
}
|
|
950
|
+
if (opts.startImageUrl && !isHttpUrl(opts.startImageUrl)) {
|
|
951
|
+
throw new Error("startImageUrl must be an HTTP URL");
|
|
952
|
+
}
|
|
953
|
+
if (opts.endImageUrl && !isHttpUrl(opts.endImageUrl)) {
|
|
954
|
+
throw new Error("endImageUrl must be an HTTP URL");
|
|
955
|
+
}
|
|
956
|
+
if (opts.callbackUrl && !isHttpUrl(opts.callbackUrl)) {
|
|
957
|
+
throw new Error("callbackUrl must be an HTTP URL");
|
|
958
|
+
}
|
|
959
|
+
if (opts.cfgScale !== void 0 && (opts.cfgScale < 0 || opts.cfgScale > 1)) {
|
|
960
|
+
throw new Error("cfgScale must be between 0 and 1");
|
|
961
|
+
}
|
|
962
|
+
if (opts.duration !== void 0 && !Number.isInteger(opts.duration)) {
|
|
963
|
+
throw new Error("duration must be an integer");
|
|
964
|
+
}
|
|
965
|
+
if (isV3 && opts.duration !== void 0 && (opts.duration < 3 || opts.duration > 15)) {
|
|
966
|
+
throw new Error("Kling V3 duration must be between 3 and 15 seconds");
|
|
967
|
+
}
|
|
968
|
+
if (!isV3 && opts.model !== "kling-o1" && opts.duration !== void 0 && ![5, 10].includes(opts.duration)) {
|
|
969
|
+
throw new Error("This Kling model supports only 5- or 10-second generation");
|
|
970
|
+
}
|
|
971
|
+
if (opts.model === "kling-o1" && opts.duration !== void 0 && opts.duration !== 5) {
|
|
972
|
+
throw new Error("kling-o1 supports only 5-second generation");
|
|
973
|
+
}
|
|
974
|
+
if (opts.model === "kling-o1" && opts.mode !== void 0 && !["std", "pro"].includes(opts.mode)) {
|
|
975
|
+
throw new Error("kling-o1 supports only std and pro modes");
|
|
976
|
+
}
|
|
977
|
+
if (opts.mode === "4k" && !isV3) {
|
|
978
|
+
throw new Error("4k mode requires kling-v3 or kling-v3-omni");
|
|
979
|
+
}
|
|
980
|
+
if (opts.action === "extend" && !["kling-v1", "kling-v1-6", "kling-v2-5-turbo"].includes(opts.model)) {
|
|
981
|
+
throw new Error("extend requires kling-v1, kling-v1-6, or kling-v2-5-turbo");
|
|
982
|
+
}
|
|
983
|
+
if (opts.action === "extend" && hasReferences) {
|
|
984
|
+
throw new Error("imageList and videoList are not supported with extend");
|
|
985
|
+
}
|
|
986
|
+
if (hasReferences && opts.model !== "kling-o1" && opts.model !== "kling-v3-omni") {
|
|
987
|
+
throw new Error("Omni references require kling-o1 or kling-v3-omni");
|
|
988
|
+
}
|
|
989
|
+
if (hasReferences && opts.mode === "4k") {
|
|
990
|
+
throw new Error("4k cannot be combined with Omni references");
|
|
991
|
+
}
|
|
992
|
+
if ((opts.model === "kling-o1" || hasReferences) && (opts.negativePrompt !== void 0 || opts.cameraControl !== void 0 || opts.cfgScale !== void 0)) {
|
|
993
|
+
throw new Error("Kling O1 and Omni references do not support negativePrompt, cameraControl, or cfgScale");
|
|
994
|
+
}
|
|
995
|
+
if (opts.model === "kling-o1" && opts.generateAudio) {
|
|
996
|
+
throw new Error("kling-o1 does not support generateAudio");
|
|
997
|
+
}
|
|
998
|
+
if (opts.generateAudio && !isV3 && opts.model !== "kling-v2-6") {
|
|
999
|
+
throw new Error("generateAudio requires a V3 model or kling-v2-6 pro mode");
|
|
1000
|
+
}
|
|
1001
|
+
if (opts.generateAudio && opts.model === "kling-v2-6" && opts.mode !== "pro") {
|
|
1002
|
+
throw new Error("kling-v2-6 supports generateAudio only in pro mode");
|
|
1003
|
+
}
|
|
1004
|
+
if (opts.generateAudio && opts.videoList?.length) {
|
|
1005
|
+
throw new Error("generateAudio cannot be used with videoList");
|
|
1006
|
+
}
|
|
1007
|
+
if (opts.videoList && (opts.videoList.length === 0 || opts.videoList.length > 1)) {
|
|
1008
|
+
throw new Error("videoList must contain exactly one reference video");
|
|
1009
|
+
}
|
|
1010
|
+
for (const image of opts.imageList ?? []) {
|
|
1011
|
+
if (!isHttpUrl(image.imageUrl)) throw new Error("Every reference image requires an HTTP imageUrl");
|
|
1012
|
+
if (image.type !== void 0 && !["first_frame", "end_frame"].includes(image.type)) {
|
|
1013
|
+
throw new Error("Reference image type must be first_frame or end_frame");
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
for (const video of opts.videoList ?? []) {
|
|
1017
|
+
if (!isHttpUrl(video.videoUrl)) throw new Error("Every reference video requires an HTTP videoUrl");
|
|
1018
|
+
if (video.referType !== void 0 && !["base", "feature"].includes(video.referType)) {
|
|
1019
|
+
throw new Error("Reference video referType must be base or feature");
|
|
1020
|
+
}
|
|
1021
|
+
if (video.keepOriginalSound !== void 0 && !["yes", "no"].includes(video.keepOriginalSound)) {
|
|
1022
|
+
throw new Error("Reference video keepOriginalSound must be yes or no");
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
const firstFrames = Number(Boolean(opts.startImageUrl)) + (opts.imageList ?? []).filter((item) => item.type === "first_frame").length;
|
|
1026
|
+
const endFrames = Number(Boolean(opts.endImageUrl)) + (opts.imageList ?? []).filter((item) => item.type === "end_frame").length;
|
|
1027
|
+
if (firstFrames > 1 || endFrames > 1) {
|
|
1028
|
+
throw new Error("Only one first frame and one end frame are allowed");
|
|
1029
|
+
}
|
|
1030
|
+
if (endFrames > 0 && firstFrames === 0) {
|
|
1031
|
+
throw new Error("A first frame is required with an end frame");
|
|
1032
|
+
}
|
|
1033
|
+
if ((opts.videoList?.[0]?.referType ?? "base") === "base" && opts.videoList?.length && (firstFrames > 0 || endFrames > 0)) {
|
|
1034
|
+
throw new Error("A base reference video cannot be combined with first or end frames");
|
|
1035
|
+
}
|
|
1036
|
+
const imageCount = (opts.imageList?.length ?? 0) + Number(Boolean(opts.startImageUrl)) + Number(Boolean(opts.endImageUrl));
|
|
1037
|
+
const imageLimit = opts.videoList?.length ? 4 : 7;
|
|
1038
|
+
if (imageCount > imageLimit) {
|
|
1039
|
+
throw new Error(`Reference images cannot exceed ${imageLimit} for this request`);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
907
1042
|
var Kling = class {
|
|
908
1043
|
constructor(transport) {
|
|
909
1044
|
this.transport = transport;
|
|
910
1045
|
}
|
|
911
1046
|
transport;
|
|
912
1047
|
async generate(opts) {
|
|
1048
|
+
validateGenerateOptions(opts);
|
|
913
1049
|
const {
|
|
914
1050
|
action,
|
|
915
1051
|
mode,
|
|
@@ -921,15 +1057,16 @@ var Kling = class {
|
|
|
921
1057
|
cfgScale,
|
|
922
1058
|
aspectRatio,
|
|
923
1059
|
callbackUrl,
|
|
1060
|
+
async: asyncMode,
|
|
1061
|
+
timeout,
|
|
924
1062
|
endImageUrl,
|
|
925
1063
|
cameraControl,
|
|
926
|
-
|
|
1064
|
+
imageList,
|
|
927
1065
|
videoList,
|
|
928
1066
|
negativePrompt,
|
|
929
|
-
startImageUrl
|
|
930
|
-
...rest
|
|
1067
|
+
startImageUrl
|
|
931
1068
|
} = opts;
|
|
932
|
-
const body = { action
|
|
1069
|
+
const body = { action };
|
|
933
1070
|
if (mode !== void 0) body.mode = mode;
|
|
934
1071
|
if (model !== void 0) body.model = model;
|
|
935
1072
|
if (prompt !== void 0) body.prompt = prompt;
|
|
@@ -939,26 +1076,46 @@ var Kling = class {
|
|
|
939
1076
|
if (cfgScale !== void 0) body.cfg_scale = cfgScale;
|
|
940
1077
|
if (aspectRatio !== void 0) body.aspect_ratio = aspectRatio;
|
|
941
1078
|
if (callbackUrl !== void 0) body.callback_url = callbackUrl;
|
|
1079
|
+
if (asyncMode !== void 0) body.async = asyncMode;
|
|
1080
|
+
if (timeout !== void 0) body.timeout = timeout;
|
|
942
1081
|
if (endImageUrl !== void 0) body.end_image_url = endImageUrl;
|
|
943
1082
|
if (cameraControl !== void 0) body.camera_control = cameraControl;
|
|
944
|
-
if (
|
|
945
|
-
|
|
1083
|
+
if (imageList !== void 0) {
|
|
1084
|
+
body.image_list = imageList.map(({ imageUrl, type }) => ({ image_url: imageUrl, ...type ? { type } : {} }));
|
|
1085
|
+
}
|
|
1086
|
+
if (videoList !== void 0) {
|
|
1087
|
+
body.video_list = videoList.map(({ videoUrl, referType, keepOriginalSound }) => ({
|
|
1088
|
+
video_url: videoUrl,
|
|
1089
|
+
...referType ? { refer_type: referType } : {},
|
|
1090
|
+
...keepOriginalSound ? { keep_original_sound: keepOriginalSound } : {}
|
|
1091
|
+
}));
|
|
1092
|
+
}
|
|
946
1093
|
if (negativePrompt !== void 0) body.negative_prompt = negativePrompt;
|
|
947
1094
|
if (startImageUrl !== void 0) body.start_image_url = startImageUrl;
|
|
948
1095
|
return this.transport.request("POST", "/kling/videos", { json: body });
|
|
949
1096
|
}
|
|
950
1097
|
async motion(opts) {
|
|
951
|
-
const { mode, imageUrl, videoUrl, characterOrientation, keepOriginalSound, prompt, callbackUrl
|
|
1098
|
+
const { mode, imageUrl, videoUrl, characterOrientation, keepOriginalSound, prompt, callbackUrl } = opts;
|
|
1099
|
+
if (!["std", "pro"].includes(mode)) throw new Error("mode must be std or pro");
|
|
1100
|
+
if (!isHttpUrl(imageUrl)) throw new Error("imageUrl must be an HTTP URL");
|
|
1101
|
+
if (!isHttpUrl(videoUrl)) throw new Error("videoUrl must be an HTTP URL");
|
|
1102
|
+
if (!["image", "video"].includes(characterOrientation)) {
|
|
1103
|
+
throw new Error("characterOrientation must be image or video");
|
|
1104
|
+
}
|
|
1105
|
+
if (keepOriginalSound !== void 0 && !["yes", "no"].includes(keepOriginalSound)) {
|
|
1106
|
+
throw new Error("keepOriginalSound must be yes or no");
|
|
1107
|
+
}
|
|
1108
|
+
if (callbackUrl && !isHttpUrl(callbackUrl)) throw new Error("callbackUrl must be an HTTP URL");
|
|
952
1109
|
const body = {
|
|
953
1110
|
mode,
|
|
954
1111
|
image_url: imageUrl,
|
|
955
1112
|
video_url: videoUrl,
|
|
956
|
-
character_orientation: characterOrientation
|
|
957
|
-
...rest
|
|
1113
|
+
character_orientation: characterOrientation
|
|
958
1114
|
};
|
|
959
1115
|
if (keepOriginalSound !== void 0) body.keep_original_sound = keepOriginalSound;
|
|
960
1116
|
if (prompt !== void 0) body.prompt = prompt;
|
|
961
1117
|
if (callbackUrl !== void 0) body.callback_url = callbackUrl;
|
|
1118
|
+
if (opts.async !== void 0) body.async = opts.async;
|
|
962
1119
|
return this.transport.request("POST", "/kling/motion", { json: body });
|
|
963
1120
|
}
|
|
964
1121
|
};
|