@runapi.ai/kling 0.2.9 → 0.2.11
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 +107 -18
- package/dist/index.d.ts +107 -18
- package/dist/index.js +326 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +312 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/skills/kling/README.md +5 -0
- package/skills/kling/SKILL.md +4 -0
package/dist/index.js
CHANGED
|
@@ -20,23 +20,23 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
AuthenticationError: () =>
|
|
24
|
-
InsufficientCreditsError: () =>
|
|
23
|
+
AuthenticationError: () => import_core7.AuthenticationError,
|
|
24
|
+
InsufficientCreditsError: () => import_core7.InsufficientCreditsError,
|
|
25
25
|
KlingClient: () => KlingClient,
|
|
26
|
-
NetworkError: () =>
|
|
27
|
-
NotFoundError: () =>
|
|
28
|
-
RateLimitError: () =>
|
|
29
|
-
RunApiError: () =>
|
|
30
|
-
ServiceUnavailableError: () =>
|
|
31
|
-
TaskFailedError: () =>
|
|
32
|
-
TaskTimeoutError: () =>
|
|
33
|
-
TimeoutError: () =>
|
|
34
|
-
ValidationError: () =>
|
|
26
|
+
NetworkError: () => import_core7.NetworkError,
|
|
27
|
+
NotFoundError: () => import_core7.NotFoundError,
|
|
28
|
+
RateLimitError: () => import_core7.RateLimitError,
|
|
29
|
+
RunApiError: () => import_core7.RunApiError,
|
|
30
|
+
ServiceUnavailableError: () => import_core7.ServiceUnavailableError,
|
|
31
|
+
TaskFailedError: () => import_core7.TaskFailedError,
|
|
32
|
+
TaskTimeoutError: () => import_core7.TaskTimeoutError,
|
|
33
|
+
TimeoutError: () => import_core7.TimeoutError,
|
|
34
|
+
ValidationError: () => import_core7.ValidationError
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
37
|
|
|
38
38
|
// src/client.ts
|
|
39
|
-
var
|
|
39
|
+
var import_core6 = require("@runapi.ai/core");
|
|
40
40
|
|
|
41
41
|
// src/resources/text-to-video.ts
|
|
42
42
|
var import_core = require("@runapi.ai/core");
|
|
@@ -110,12 +110,44 @@ var contract = {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
|
+
"extend-video": {
|
|
114
|
+
"models": [
|
|
115
|
+
"kling-v2.5-turbo-image-to-video-pro",
|
|
116
|
+
"kling-v2.5-turbo-text-to-video-pro"
|
|
117
|
+
],
|
|
118
|
+
"fields_by_model": {
|
|
119
|
+
"kling-v2.5-turbo-image-to-video-pro": {
|
|
120
|
+
"mode": {
|
|
121
|
+
"enum": [
|
|
122
|
+
"std",
|
|
123
|
+
"pro"
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
"source_task_id": {
|
|
127
|
+
"required": true
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"kling-v2.5-turbo-text-to-video-pro": {
|
|
131
|
+
"mode": {
|
|
132
|
+
"enum": [
|
|
133
|
+
"std",
|
|
134
|
+
"pro"
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
"source_task_id": {
|
|
138
|
+
"required": true
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
113
143
|
"image-to-video": {
|
|
114
144
|
"models": [
|
|
115
145
|
"kling-v2.1-master-image-to-video",
|
|
116
146
|
"kling-v2.1-pro",
|
|
117
147
|
"kling-v2.1-standard",
|
|
118
148
|
"kling-v2.5-turbo-image-to-video-pro",
|
|
149
|
+
"kling-v2.6",
|
|
150
|
+
"kling-v3-omni",
|
|
119
151
|
"kling-v3-turbo-image-to-video"
|
|
120
152
|
],
|
|
121
153
|
"fields_by_model": {
|
|
@@ -191,6 +223,86 @@ var contract = {
|
|
|
191
223
|
"required": true
|
|
192
224
|
}
|
|
193
225
|
},
|
|
226
|
+
"kling-v2.6": {
|
|
227
|
+
"aspect_ratio": {
|
|
228
|
+
"enum": [
|
|
229
|
+
"16:9",
|
|
230
|
+
"9:16",
|
|
231
|
+
"1:1"
|
|
232
|
+
]
|
|
233
|
+
},
|
|
234
|
+
"duration_seconds": {
|
|
235
|
+
"enum": [
|
|
236
|
+
5,
|
|
237
|
+
10
|
|
238
|
+
],
|
|
239
|
+
"type": "integer"
|
|
240
|
+
},
|
|
241
|
+
"first_frame_image_url": {
|
|
242
|
+
"required": true
|
|
243
|
+
},
|
|
244
|
+
"mode": {
|
|
245
|
+
"enum": [
|
|
246
|
+
"std",
|
|
247
|
+
"pro"
|
|
248
|
+
]
|
|
249
|
+
},
|
|
250
|
+
"model": {
|
|
251
|
+
"required": true
|
|
252
|
+
},
|
|
253
|
+
"prompt": {
|
|
254
|
+
"required": true,
|
|
255
|
+
"min": 1,
|
|
256
|
+
"max": 2500,
|
|
257
|
+
"length": true
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
"kling-v3-omni": {
|
|
261
|
+
"aspect_ratio": {
|
|
262
|
+
"enum": [
|
|
263
|
+
"16:9",
|
|
264
|
+
"9:16",
|
|
265
|
+
"1:1"
|
|
266
|
+
]
|
|
267
|
+
},
|
|
268
|
+
"duration_seconds": {
|
|
269
|
+
"enum": [
|
|
270
|
+
3,
|
|
271
|
+
4,
|
|
272
|
+
5,
|
|
273
|
+
6,
|
|
274
|
+
7,
|
|
275
|
+
8,
|
|
276
|
+
9,
|
|
277
|
+
10,
|
|
278
|
+
11,
|
|
279
|
+
12,
|
|
280
|
+
13,
|
|
281
|
+
14,
|
|
282
|
+
15
|
|
283
|
+
],
|
|
284
|
+
"type": "integer"
|
|
285
|
+
},
|
|
286
|
+
"first_frame_image_url": {
|
|
287
|
+
"required": true
|
|
288
|
+
},
|
|
289
|
+
"model": {
|
|
290
|
+
"required": true
|
|
291
|
+
},
|
|
292
|
+
"output_resolution": {
|
|
293
|
+
"enum": [
|
|
294
|
+
"720p",
|
|
295
|
+
"1080p",
|
|
296
|
+
"4k"
|
|
297
|
+
]
|
|
298
|
+
},
|
|
299
|
+
"prompt": {
|
|
300
|
+
"required": true,
|
|
301
|
+
"min": 1,
|
|
302
|
+
"max": 2500,
|
|
303
|
+
"length": true
|
|
304
|
+
}
|
|
305
|
+
},
|
|
194
306
|
"kling-v3-turbo-image-to-video": {
|
|
195
307
|
"duration_seconds": {
|
|
196
308
|
"enum": [
|
|
@@ -236,7 +348,8 @@ var contract = {
|
|
|
236
348
|
"model": "kling-v2.1-master-image-to-video"
|
|
237
349
|
},
|
|
238
350
|
"forbidden": [
|
|
239
|
-
"output_resolution"
|
|
351
|
+
"output_resolution",
|
|
352
|
+
"enable_sound"
|
|
240
353
|
]
|
|
241
354
|
},
|
|
242
355
|
{
|
|
@@ -244,7 +357,8 @@ var contract = {
|
|
|
244
357
|
"model": "kling-v2.1-pro"
|
|
245
358
|
},
|
|
246
359
|
"forbidden": [
|
|
247
|
-
"output_resolution"
|
|
360
|
+
"output_resolution",
|
|
361
|
+
"enable_sound"
|
|
248
362
|
]
|
|
249
363
|
},
|
|
250
364
|
{
|
|
@@ -252,7 +366,8 @@ var contract = {
|
|
|
252
366
|
"model": "kling-v2.1-standard"
|
|
253
367
|
},
|
|
254
368
|
"forbidden": [
|
|
255
|
-
"output_resolution"
|
|
369
|
+
"output_resolution",
|
|
370
|
+
"enable_sound"
|
|
256
371
|
]
|
|
257
372
|
},
|
|
258
373
|
{
|
|
@@ -260,7 +375,27 @@ var contract = {
|
|
|
260
375
|
"model": "kling-v2.5-turbo-image-to-video-pro"
|
|
261
376
|
},
|
|
262
377
|
"forbidden": [
|
|
263
|
-
"output_resolution"
|
|
378
|
+
"output_resolution",
|
|
379
|
+
"enable_sound"
|
|
380
|
+
]
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
"when": {
|
|
384
|
+
"model": "kling-v2.6"
|
|
385
|
+
},
|
|
386
|
+
"forbidden": [
|
|
387
|
+
"output_resolution",
|
|
388
|
+
"negative_prompt",
|
|
389
|
+
"cfg_scale"
|
|
390
|
+
]
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
"when": {
|
|
394
|
+
"model": "kling-v3-omni"
|
|
395
|
+
},
|
|
396
|
+
"forbidden": [
|
|
397
|
+
"negative_prompt",
|
|
398
|
+
"cfg_scale"
|
|
264
399
|
]
|
|
265
400
|
},
|
|
266
401
|
{
|
|
@@ -268,6 +403,7 @@ var contract = {
|
|
|
268
403
|
"model": "kling-v3-turbo-image-to-video"
|
|
269
404
|
},
|
|
270
405
|
"forbidden": [
|
|
406
|
+
"enable_sound",
|
|
271
407
|
"aspect_ratio",
|
|
272
408
|
"negative_prompt",
|
|
273
409
|
"cfg_scale",
|
|
@@ -317,6 +453,8 @@ var contract = {
|
|
|
317
453
|
"kling-3.0",
|
|
318
454
|
"kling-v2.1-master-text-to-video",
|
|
319
455
|
"kling-v2.5-turbo-text-to-video-pro",
|
|
456
|
+
"kling-v2.6",
|
|
457
|
+
"kling-v3-omni",
|
|
320
458
|
"kling-v3-turbo-text-to-video"
|
|
321
459
|
],
|
|
322
460
|
"fields_by_model": {
|
|
@@ -395,6 +533,80 @@ var contract = {
|
|
|
395
533
|
"required": true
|
|
396
534
|
}
|
|
397
535
|
},
|
|
536
|
+
"kling-v2.6": {
|
|
537
|
+
"aspect_ratio": {
|
|
538
|
+
"enum": [
|
|
539
|
+
"16:9",
|
|
540
|
+
"9:16",
|
|
541
|
+
"1:1"
|
|
542
|
+
]
|
|
543
|
+
},
|
|
544
|
+
"duration_seconds": {
|
|
545
|
+
"enum": [
|
|
546
|
+
5,
|
|
547
|
+
10
|
|
548
|
+
],
|
|
549
|
+
"type": "integer"
|
|
550
|
+
},
|
|
551
|
+
"mode": {
|
|
552
|
+
"enum": [
|
|
553
|
+
"std",
|
|
554
|
+
"pro"
|
|
555
|
+
]
|
|
556
|
+
},
|
|
557
|
+
"model": {
|
|
558
|
+
"required": true
|
|
559
|
+
},
|
|
560
|
+
"prompt": {
|
|
561
|
+
"required": true,
|
|
562
|
+
"min": 1,
|
|
563
|
+
"max": 2500,
|
|
564
|
+
"length": true
|
|
565
|
+
}
|
|
566
|
+
},
|
|
567
|
+
"kling-v3-omni": {
|
|
568
|
+
"aspect_ratio": {
|
|
569
|
+
"enum": [
|
|
570
|
+
"16:9",
|
|
571
|
+
"9:16",
|
|
572
|
+
"1:1"
|
|
573
|
+
]
|
|
574
|
+
},
|
|
575
|
+
"duration_seconds": {
|
|
576
|
+
"enum": [
|
|
577
|
+
3,
|
|
578
|
+
4,
|
|
579
|
+
5,
|
|
580
|
+
6,
|
|
581
|
+
7,
|
|
582
|
+
8,
|
|
583
|
+
9,
|
|
584
|
+
10,
|
|
585
|
+
11,
|
|
586
|
+
12,
|
|
587
|
+
13,
|
|
588
|
+
14,
|
|
589
|
+
15
|
|
590
|
+
],
|
|
591
|
+
"type": "integer"
|
|
592
|
+
},
|
|
593
|
+
"model": {
|
|
594
|
+
"required": true
|
|
595
|
+
},
|
|
596
|
+
"output_resolution": {
|
|
597
|
+
"enum": [
|
|
598
|
+
"720p",
|
|
599
|
+
"1080p",
|
|
600
|
+
"4k"
|
|
601
|
+
]
|
|
602
|
+
},
|
|
603
|
+
"prompt": {
|
|
604
|
+
"required": true,
|
|
605
|
+
"min": 1,
|
|
606
|
+
"max": 2500,
|
|
607
|
+
"length": true
|
|
608
|
+
}
|
|
609
|
+
},
|
|
398
610
|
"kling-v3-turbo-text-to-video": {
|
|
399
611
|
"aspect_ratio": {
|
|
400
612
|
"enum": [
|
|
@@ -439,6 +651,43 @@ var contract = {
|
|
|
439
651
|
}
|
|
440
652
|
},
|
|
441
653
|
"rules": [
|
|
654
|
+
{
|
|
655
|
+
"when": {
|
|
656
|
+
"model": "kling-v2.5-turbo-text-to-video-pro"
|
|
657
|
+
},
|
|
658
|
+
"forbidden": [
|
|
659
|
+
"mode"
|
|
660
|
+
]
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
"when": {
|
|
664
|
+
"model": "kling-v2.6"
|
|
665
|
+
},
|
|
666
|
+
"forbidden": [
|
|
667
|
+
"output_resolution",
|
|
668
|
+
"negative_prompt",
|
|
669
|
+
"cfg_scale",
|
|
670
|
+
"multi_shots",
|
|
671
|
+
"multi_prompt",
|
|
672
|
+
"first_frame_image_url",
|
|
673
|
+
"last_frame_image_url",
|
|
674
|
+
"kling_elements"
|
|
675
|
+
]
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
"when": {
|
|
679
|
+
"model": "kling-v3-omni"
|
|
680
|
+
},
|
|
681
|
+
"forbidden": [
|
|
682
|
+
"negative_prompt",
|
|
683
|
+
"cfg_scale",
|
|
684
|
+
"multi_shots",
|
|
685
|
+
"multi_prompt",
|
|
686
|
+
"first_frame_image_url",
|
|
687
|
+
"last_frame_image_url",
|
|
688
|
+
"kling_elements"
|
|
689
|
+
]
|
|
690
|
+
},
|
|
442
691
|
{
|
|
443
692
|
"when": {
|
|
444
693
|
"model": "kling-v3-turbo-text-to-video"
|
|
@@ -460,6 +709,7 @@ var contract = {
|
|
|
460
709
|
|
|
461
710
|
// src/resources/text-to-video.ts
|
|
462
711
|
var ENDPOINT = "/api/v1/kling/text_to_video";
|
|
712
|
+
var V26_MODEL = "kling-v2.6";
|
|
463
713
|
var V3_TURBO_MODEL = "kling-v3-turbo-text-to-video";
|
|
464
714
|
var V3_TURBO_UNSUPPORTED_FIELDS = [
|
|
465
715
|
"enable_sound",
|
|
@@ -500,6 +750,7 @@ var TextToVideo = class {
|
|
|
500
750
|
const body = (0, import_core.compactParams)(params);
|
|
501
751
|
rejectUnsupportedV3TurboFields(body);
|
|
502
752
|
(0, import_core.validateParams)(contract["text-to-video"], body);
|
|
753
|
+
validateV26Params(body);
|
|
503
754
|
return this.http.request("POST", ENDPOINT, {
|
|
504
755
|
body,
|
|
505
756
|
...options
|
|
@@ -517,6 +768,12 @@ var TextToVideo = class {
|
|
|
517
768
|
});
|
|
518
769
|
}
|
|
519
770
|
};
|
|
771
|
+
function validateV26Params(body) {
|
|
772
|
+
if (body.model !== V26_MODEL) return;
|
|
773
|
+
if (body.enable_sound === true && body.mode !== "pro") {
|
|
774
|
+
throw new import_core.ValidationError(`enable_sound requires mode pro for ${V26_MODEL}`);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
520
777
|
function rejectUnsupportedV3TurboFields(body) {
|
|
521
778
|
if (body.model !== V3_TURBO_MODEL) return;
|
|
522
779
|
const field = V3_TURBO_UNSUPPORTED_FIELDS.find((candidate) => fieldPresent(body, candidate));
|
|
@@ -544,6 +801,8 @@ function presentValue(value) {
|
|
|
544
801
|
var import_core2 = require("@runapi.ai/core");
|
|
545
802
|
var import_internal2 = require("@runapi.ai/core/internal");
|
|
546
803
|
var ENDPOINT2 = "/api/v1/kling/image_to_video";
|
|
804
|
+
var V26_MODEL2 = "kling-v2.6";
|
|
805
|
+
var V3_OMNI_MODEL = "kling-v3-omni";
|
|
547
806
|
var V3_TURBO_MODEL2 = "kling-v3-turbo-image-to-video";
|
|
548
807
|
var V3_TURBO_UNSUPPORTED_FIELDS2 = [
|
|
549
808
|
"aspect_ratio",
|
|
@@ -580,6 +839,8 @@ var ImageToVideo = class {
|
|
|
580
839
|
const body = (0, import_core2.compactParams)(params);
|
|
581
840
|
rejectUnsupportedV3TurboFields2(body);
|
|
582
841
|
(0, import_core2.validateParams)(contract["image-to-video"], body);
|
|
842
|
+
validateV26Params2(body);
|
|
843
|
+
validateV3OmniFields(body);
|
|
583
844
|
return this.http.request("POST", ENDPOINT2, {
|
|
584
845
|
body,
|
|
585
846
|
...options
|
|
@@ -597,6 +858,25 @@ var ImageToVideo = class {
|
|
|
597
858
|
});
|
|
598
859
|
}
|
|
599
860
|
};
|
|
861
|
+
function validateV26Params2(body) {
|
|
862
|
+
if (body.model !== V26_MODEL2) return;
|
|
863
|
+
if (body.enable_sound === true && body.mode !== "pro") {
|
|
864
|
+
throw new import_core2.ValidationError(`enable_sound requires mode pro for ${V26_MODEL2}`);
|
|
865
|
+
}
|
|
866
|
+
if (!fieldPresent2(body, "last_frame_image_url")) return;
|
|
867
|
+
if (body.mode !== "pro") {
|
|
868
|
+
throw new import_core2.ValidationError(`last_frame_image_url requires mode pro for ${V26_MODEL2}`);
|
|
869
|
+
}
|
|
870
|
+
if (body.duration_seconds !== void 0 && body.duration_seconds !== 5) {
|
|
871
|
+
throw new import_core2.ValidationError(`last_frame_image_url requires duration_seconds 5 for ${V26_MODEL2}`);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
function validateV3OmniFields(body) {
|
|
875
|
+
if (body.model !== V3_OMNI_MODEL || !fieldPresent2(body, "last_frame_image_url")) return;
|
|
876
|
+
if ((body.duration_seconds ?? 5) !== 5) {
|
|
877
|
+
throw new import_core2.ValidationError(`last_frame_image_url requires duration_seconds 5 for ${V3_OMNI_MODEL}`);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
600
880
|
function rejectUnsupportedV3TurboFields2(body) {
|
|
601
881
|
if (body.model !== V3_TURBO_MODEL2) return;
|
|
602
882
|
const field = V3_TURBO_UNSUPPORTED_FIELDS2.find((candidate) => fieldPresent2(body, candidate));
|
|
@@ -720,8 +1000,34 @@ var MotionControl = class {
|
|
|
720
1000
|
}
|
|
721
1001
|
};
|
|
722
1002
|
|
|
1003
|
+
// src/resources/extend-video.ts
|
|
1004
|
+
var import_core5 = require("@runapi.ai/core");
|
|
1005
|
+
var import_internal5 = require("@runapi.ai/core/internal");
|
|
1006
|
+
var ENDPOINT5 = "/api/v1/kling/extend_video";
|
|
1007
|
+
var ExtendVideo = class {
|
|
1008
|
+
constructor(http) {
|
|
1009
|
+
this.http = http;
|
|
1010
|
+
}
|
|
1011
|
+
http;
|
|
1012
|
+
async run(params, options) {
|
|
1013
|
+
const { id } = await this.create(params, options);
|
|
1014
|
+
return (0, import_internal5.pollUntilComplete)(() => this.get(id, options), {
|
|
1015
|
+
maxWaitMs: options?.maxWaitMs,
|
|
1016
|
+
pollIntervalMs: options?.pollIntervalMs
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
async create(params, options) {
|
|
1020
|
+
const body = (0, import_core5.compactParams)(params);
|
|
1021
|
+
(0, import_core5.validateParams)(contract["extend-video"], body);
|
|
1022
|
+
return this.http.request("POST", ENDPOINT5, { body, ...options });
|
|
1023
|
+
}
|
|
1024
|
+
async get(id, options) {
|
|
1025
|
+
return this.http.request("GET", `${ENDPOINT5}/${id}`, { ...options });
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
|
|
723
1029
|
// src/client.ts
|
|
724
|
-
var KlingClient = class extends
|
|
1030
|
+
var KlingClient = class extends import_core6.BaseClient {
|
|
725
1031
|
/** Text-to-video generation with multi-shot, sound, and Kling elements support on kling-3.0. */
|
|
726
1032
|
textToVideo;
|
|
727
1033
|
/** Image-to-video animation from a first-frame image guided by a text prompt. */
|
|
@@ -730,17 +1036,19 @@ var KlingClient = class extends import_core5.BaseClient {
|
|
|
730
1036
|
aiAvatar;
|
|
731
1037
|
/** Transfer motion from a reference video onto a subject image. */
|
|
732
1038
|
motionControl;
|
|
1039
|
+
extendVideo;
|
|
733
1040
|
constructor(options = {}) {
|
|
734
1041
|
super(options);
|
|
735
1042
|
this.textToVideo = new TextToVideo(this.http);
|
|
736
1043
|
this.imageToVideo = new ImageToVideo(this.http);
|
|
737
1044
|
this.aiAvatar = new AiAvatar(this.http);
|
|
738
1045
|
this.motionControl = new MotionControl(this.http);
|
|
1046
|
+
this.extendVideo = new ExtendVideo(this.http);
|
|
739
1047
|
}
|
|
740
1048
|
};
|
|
741
1049
|
|
|
742
1050
|
// src/index.ts
|
|
743
|
-
var
|
|
1051
|
+
var import_core7 = require("@runapi.ai/core");
|
|
744
1052
|
// Annotate the CommonJS export names for ESM import in node:
|
|
745
1053
|
0 && (module.exports = {
|
|
746
1054
|
AuthenticationError,
|