@runapi.ai/kling 0.2.10 → 0.2.12

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.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: () => import_core6.AuthenticationError,
24
- InsufficientCreditsError: () => import_core6.InsufficientCreditsError,
23
+ AuthenticationError: () => import_core7.AuthenticationError,
24
+ InsufficientCreditsError: () => import_core7.InsufficientCreditsError,
25
25
  KlingClient: () => KlingClient,
26
- NetworkError: () => import_core6.NetworkError,
27
- NotFoundError: () => import_core6.NotFoundError,
28
- RateLimitError: () => import_core6.RateLimitError,
29
- RunApiError: () => import_core6.RunApiError,
30
- ServiceUnavailableError: () => import_core6.ServiceUnavailableError,
31
- TaskFailedError: () => import_core6.TaskFailedError,
32
- TaskTimeoutError: () => import_core6.TaskTimeoutError,
33
- TimeoutError: () => import_core6.TimeoutError,
34
- ValidationError: () => import_core6.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 import_core5 = require("@runapi.ai/core");
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,6 +110,36 @@ 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",
@@ -117,6 +147,7 @@ var contract = {
117
147
  "kling-v2.1-standard",
118
148
  "kling-v2.5-turbo-image-to-video-pro",
119
149
  "kling-v2.6",
150
+ "kling-v3-omni",
120
151
  "kling-v3-turbo-image-to-video"
121
152
  ],
122
153
  "fields_by_model": {
@@ -226,6 +257,52 @@ var contract = {
226
257
  "length": true
227
258
  }
228
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
+ },
229
306
  "kling-v3-turbo-image-to-video": {
230
307
  "duration_seconds": {
231
308
  "enum": [
@@ -272,7 +349,6 @@ var contract = {
272
349
  },
273
350
  "forbidden": [
274
351
  "output_resolution",
275
- "mode",
276
352
  "enable_sound"
277
353
  ]
278
354
  },
@@ -282,7 +358,6 @@ var contract = {
282
358
  },
283
359
  "forbidden": [
284
360
  "output_resolution",
285
- "mode",
286
361
  "enable_sound"
287
362
  ]
288
363
  },
@@ -292,7 +367,6 @@ var contract = {
292
367
  },
293
368
  "forbidden": [
294
369
  "output_resolution",
295
- "mode",
296
370
  "enable_sound"
297
371
  ]
298
372
  },
@@ -302,7 +376,6 @@ var contract = {
302
376
  },
303
377
  "forbidden": [
304
378
  "output_resolution",
305
- "mode",
306
379
  "enable_sound"
307
380
  ]
308
381
  },
@@ -316,12 +389,20 @@ var contract = {
316
389
  "cfg_scale"
317
390
  ]
318
391
  },
392
+ {
393
+ "when": {
394
+ "model": "kling-v3-omni"
395
+ },
396
+ "forbidden": [
397
+ "negative_prompt",
398
+ "cfg_scale"
399
+ ]
400
+ },
319
401
  {
320
402
  "when": {
321
403
  "model": "kling-v3-turbo-image-to-video"
322
404
  },
323
405
  "forbidden": [
324
- "mode",
325
406
  "enable_sound",
326
407
  "aspect_ratio",
327
408
  "negative_prompt",
@@ -333,7 +414,8 @@ var contract = {
333
414
  },
334
415
  "motion-control": {
335
416
  "models": [
336
- "kling-3.0"
417
+ "kling-3.0",
418
+ "kling-v2.6"
337
419
  ],
338
420
  "fields_by_model": {
339
421
  "kling-3.0": {
@@ -364,8 +446,47 @@ var contract = {
364
446
  "source_image_url": {
365
447
  "required": true
366
448
  }
449
+ },
450
+ "kling-v2.6": {
451
+ "character_orientation": {
452
+ "enum": [
453
+ "video",
454
+ "image"
455
+ ],
456
+ "required": true
457
+ },
458
+ "model": {
459
+ "required": true
460
+ },
461
+ "output_resolution": {
462
+ "enum": [
463
+ "720p",
464
+ "1080p"
465
+ ],
466
+ "required": true
467
+ },
468
+ "prompt": {
469
+ "max": 2500,
470
+ "length": true
471
+ },
472
+ "reference_video_url": {
473
+ "required": true
474
+ },
475
+ "source_image_url": {
476
+ "required": true
477
+ }
367
478
  }
368
- }
479
+ },
480
+ "rules": [
481
+ {
482
+ "when": {
483
+ "model": "kling-v2.6"
484
+ },
485
+ "forbidden": [
486
+ "background_source"
487
+ ]
488
+ }
489
+ ]
369
490
  },
370
491
  "text-to-video": {
371
492
  "models": [
@@ -373,6 +494,7 @@ var contract = {
373
494
  "kling-v2.1-master-text-to-video",
374
495
  "kling-v2.5-turbo-text-to-video-pro",
375
496
  "kling-v2.6",
497
+ "kling-v3-omni",
376
498
  "kling-v3-turbo-text-to-video"
377
499
  ],
378
500
  "fields_by_model": {
@@ -482,6 +604,49 @@ var contract = {
482
604
  "length": true
483
605
  }
484
606
  },
607
+ "kling-v3-omni": {
608
+ "aspect_ratio": {
609
+ "enum": [
610
+ "16:9",
611
+ "9:16",
612
+ "1:1"
613
+ ]
614
+ },
615
+ "duration_seconds": {
616
+ "enum": [
617
+ 3,
618
+ 4,
619
+ 5,
620
+ 6,
621
+ 7,
622
+ 8,
623
+ 9,
624
+ 10,
625
+ 11,
626
+ 12,
627
+ 13,
628
+ 14,
629
+ 15
630
+ ],
631
+ "type": "integer"
632
+ },
633
+ "model": {
634
+ "required": true
635
+ },
636
+ "output_resolution": {
637
+ "enum": [
638
+ "720p",
639
+ "1080p",
640
+ "4k"
641
+ ]
642
+ },
643
+ "prompt": {
644
+ "required": true,
645
+ "min": 1,
646
+ "max": 2500,
647
+ "length": true
648
+ }
649
+ },
485
650
  "kling-v3-turbo-text-to-video": {
486
651
  "aspect_ratio": {
487
652
  "enum": [
@@ -528,15 +693,7 @@ var contract = {
528
693
  "rules": [
529
694
  {
530
695
  "when": {
531
- "model": "kling-3.0"
532
- },
533
- "forbidden": [
534
- "mode"
535
- ]
536
- },
537
- {
538
- "when": {
539
- "model": "kling-v2.1-master-text-to-video"
696
+ "model": "kling-v2.5-turbo-text-to-video-pro"
540
697
  },
541
698
  "forbidden": [
542
699
  "mode"
@@ -544,18 +701,24 @@ var contract = {
544
701
  },
545
702
  {
546
703
  "when": {
547
- "model": "kling-v2.5-turbo-text-to-video-pro"
704
+ "model": "kling-v2.6"
548
705
  },
549
706
  "forbidden": [
550
- "mode"
707
+ "output_resolution",
708
+ "negative_prompt",
709
+ "cfg_scale",
710
+ "multi_shots",
711
+ "multi_prompt",
712
+ "first_frame_image_url",
713
+ "last_frame_image_url",
714
+ "kling_elements"
551
715
  ]
552
716
  },
553
717
  {
554
718
  "when": {
555
- "model": "kling-v2.6"
719
+ "model": "kling-v3-omni"
556
720
  },
557
721
  "forbidden": [
558
- "output_resolution",
559
722
  "negative_prompt",
560
723
  "cfg_scale",
561
724
  "multi_shots",
@@ -570,7 +733,6 @@ var contract = {
570
733
  "model": "kling-v3-turbo-text-to-video"
571
734
  },
572
735
  "forbidden": [
573
- "mode",
574
736
  "enable_sound",
575
737
  "negative_prompt",
576
738
  "cfg_scale",
@@ -680,6 +842,7 @@ var import_core2 = require("@runapi.ai/core");
680
842
  var import_internal2 = require("@runapi.ai/core/internal");
681
843
  var ENDPOINT2 = "/api/v1/kling/image_to_video";
682
844
  var V26_MODEL2 = "kling-v2.6";
845
+ var V3_OMNI_MODEL = "kling-v3-omni";
683
846
  var V3_TURBO_MODEL2 = "kling-v3-turbo-image-to-video";
684
847
  var V3_TURBO_UNSUPPORTED_FIELDS2 = [
685
848
  "aspect_ratio",
@@ -717,6 +880,7 @@ var ImageToVideo = class {
717
880
  rejectUnsupportedV3TurboFields2(body);
718
881
  (0, import_core2.validateParams)(contract["image-to-video"], body);
719
882
  validateV26Params2(body);
883
+ validateV3OmniFields(body);
720
884
  return this.http.request("POST", ENDPOINT2, {
721
885
  body,
722
886
  ...options
@@ -747,6 +911,12 @@ function validateV26Params2(body) {
747
911
  throw new import_core2.ValidationError(`last_frame_image_url requires duration_seconds 5 for ${V26_MODEL2}`);
748
912
  }
749
913
  }
914
+ function validateV3OmniFields(body) {
915
+ if (body.model !== V3_OMNI_MODEL || !fieldPresent2(body, "last_frame_image_url")) return;
916
+ if ((body.duration_seconds ?? 5) !== 5) {
917
+ throw new import_core2.ValidationError(`last_frame_image_url requires duration_seconds 5 for ${V3_OMNI_MODEL}`);
918
+ }
919
+ }
750
920
  function rejectUnsupportedV3TurboFields2(body) {
751
921
  if (body.model !== V3_TURBO_MODEL2) return;
752
922
  const field = V3_TURBO_UNSUPPORTED_FIELDS2.find((candidate) => fieldPresent2(body, candidate));
@@ -870,8 +1040,34 @@ var MotionControl = class {
870
1040
  }
871
1041
  };
872
1042
 
1043
+ // src/resources/extend-video.ts
1044
+ var import_core5 = require("@runapi.ai/core");
1045
+ var import_internal5 = require("@runapi.ai/core/internal");
1046
+ var ENDPOINT5 = "/api/v1/kling/extend_video";
1047
+ var ExtendVideo = class {
1048
+ constructor(http) {
1049
+ this.http = http;
1050
+ }
1051
+ http;
1052
+ async run(params, options) {
1053
+ const { id } = await this.create(params, options);
1054
+ return (0, import_internal5.pollUntilComplete)(() => this.get(id, options), {
1055
+ maxWaitMs: options?.maxWaitMs,
1056
+ pollIntervalMs: options?.pollIntervalMs
1057
+ });
1058
+ }
1059
+ async create(params, options) {
1060
+ const body = (0, import_core5.compactParams)(params);
1061
+ (0, import_core5.validateParams)(contract["extend-video"], body);
1062
+ return this.http.request("POST", ENDPOINT5, { body, ...options });
1063
+ }
1064
+ async get(id, options) {
1065
+ return this.http.request("GET", `${ENDPOINT5}/${id}`, { ...options });
1066
+ }
1067
+ };
1068
+
873
1069
  // src/client.ts
874
- var KlingClient = class extends import_core5.BaseClient {
1070
+ var KlingClient = class extends import_core6.BaseClient {
875
1071
  /** Text-to-video generation with multi-shot, sound, and Kling elements support on kling-3.0. */
876
1072
  textToVideo;
877
1073
  /** Image-to-video animation from a first-frame image guided by a text prompt. */
@@ -880,17 +1076,19 @@ var KlingClient = class extends import_core5.BaseClient {
880
1076
  aiAvatar;
881
1077
  /** Transfer motion from a reference video onto a subject image. */
882
1078
  motionControl;
1079
+ extendVideo;
883
1080
  constructor(options = {}) {
884
1081
  super(options);
885
1082
  this.textToVideo = new TextToVideo(this.http);
886
1083
  this.imageToVideo = new ImageToVideo(this.http);
887
1084
  this.aiAvatar = new AiAvatar(this.http);
888
1085
  this.motionControl = new MotionControl(this.http);
1086
+ this.extendVideo = new ExtendVideo(this.http);
889
1087
  }
890
1088
  };
891
1089
 
892
1090
  // src/index.ts
893
- var import_core6 = require("@runapi.ai/core");
1091
+ var import_core7 = require("@runapi.ai/core");
894
1092
  // Annotate the CommonJS export names for ESM import in node:
895
1093
  0 && (module.exports = {
896
1094
  AuthenticationError,