@runapi.ai/kling 0.2.11 → 0.2.13

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,26 +20,26 @@ 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_core7.AuthenticationError,
24
- InsufficientCreditsError: () => import_core7.InsufficientCreditsError,
23
+ AuthenticationError: () => import_core8.AuthenticationError,
24
+ InsufficientCreditsError: () => import_core8.InsufficientCreditsError,
25
25
  KlingClient: () => KlingClient,
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
26
+ NetworkError: () => import_core8.NetworkError,
27
+ NotFoundError: () => import_core8.NotFoundError,
28
+ RateLimitError: () => import_core8.RateLimitError,
29
+ RunApiError: () => import_core8.RunApiError,
30
+ ServiceUnavailableError: () => import_core8.ServiceUnavailableError,
31
+ TaskFailedError: () => import_core8.TaskFailedError,
32
+ TaskTimeoutError: () => import_core8.TaskTimeoutError,
33
+ TimeoutError: () => import_core8.TimeoutError,
34
+ ValidationError: () => import_core8.ValidationError
35
35
  });
36
36
  module.exports = __toCommonJS(index_exports);
37
37
 
38
38
  // src/client.ts
39
- var import_core6 = require("@runapi.ai/core");
39
+ var import_core7 = require("@runapi.ai/core");
40
40
 
41
41
  // src/resources/text-to-video.ts
42
- var import_core = require("@runapi.ai/core");
42
+ var import_core2 = require("@runapi.ai/core");
43
43
  var import_internal = require("@runapi.ai/core/internal");
44
44
 
45
45
  // src/contract_gen.ts
@@ -142,6 +142,7 @@ var contract = {
142
142
  },
143
143
  "image-to-video": {
144
144
  "models": [
145
+ "kling-o1",
145
146
  "kling-v2.1-master-image-to-video",
146
147
  "kling-v2.1-pro",
147
148
  "kling-v2.1-standard",
@@ -151,6 +152,49 @@ var contract = {
151
152
  "kling-v3-turbo-image-to-video"
152
153
  ],
153
154
  "fields_by_model": {
155
+ "kling-o1": {
156
+ "aspect_ratio": {
157
+ "enum": [
158
+ "16:9",
159
+ "9:16",
160
+ "1:1"
161
+ ]
162
+ },
163
+ "duration_seconds": {
164
+ "enum": [
165
+ 5
166
+ ],
167
+ "type": "integer"
168
+ },
169
+ "first_frame_image_url": {
170
+ "required": true
171
+ },
172
+ "mode": {
173
+ "enum": [
174
+ "std",
175
+ "pro"
176
+ ]
177
+ },
178
+ "model": {
179
+ "required": true
180
+ },
181
+ "prompt": {
182
+ "required": true,
183
+ "min": 1,
184
+ "max": 2500,
185
+ "length": true
186
+ },
187
+ "reference_image_urls": {
188
+ "min_items": 1,
189
+ "max_items": 7
190
+ },
191
+ "reference_video_type": {
192
+ "enum": [
193
+ "base",
194
+ "feature"
195
+ ]
196
+ }
197
+ },
154
198
  "kling-v2.1-master-image-to-video": {
155
199
  "duration_seconds": {
156
200
  "enum": [
@@ -343,13 +387,27 @@ var contract = {
343
387
  }
344
388
  },
345
389
  "rules": [
390
+ {
391
+ "when": {
392
+ "model": "kling-o1"
393
+ },
394
+ "forbidden": [
395
+ "output_resolution",
396
+ "negative_prompt",
397
+ "cfg_scale"
398
+ ]
399
+ },
346
400
  {
347
401
  "when": {
348
402
  "model": "kling-v2.1-master-image-to-video"
349
403
  },
350
404
  "forbidden": [
351
405
  "output_resolution",
352
- "enable_sound"
406
+ "enable_sound",
407
+ "reference_image_urls",
408
+ "reference_video_url",
409
+ "reference_video_type",
410
+ "preserve_reference_video_audio"
353
411
  ]
354
412
  },
355
413
  {
@@ -358,7 +416,11 @@ var contract = {
358
416
  },
359
417
  "forbidden": [
360
418
  "output_resolution",
361
- "enable_sound"
419
+ "enable_sound",
420
+ "reference_image_urls",
421
+ "reference_video_url",
422
+ "reference_video_type",
423
+ "preserve_reference_video_audio"
362
424
  ]
363
425
  },
364
426
  {
@@ -367,7 +429,11 @@ var contract = {
367
429
  },
368
430
  "forbidden": [
369
431
  "output_resolution",
370
- "enable_sound"
432
+ "enable_sound",
433
+ "reference_image_urls",
434
+ "reference_video_url",
435
+ "reference_video_type",
436
+ "preserve_reference_video_audio"
371
437
  ]
372
438
  },
373
439
  {
@@ -376,7 +442,11 @@ var contract = {
376
442
  },
377
443
  "forbidden": [
378
444
  "output_resolution",
379
- "enable_sound"
445
+ "enable_sound",
446
+ "reference_image_urls",
447
+ "reference_video_url",
448
+ "reference_video_type",
449
+ "preserve_reference_video_audio"
380
450
  ]
381
451
  },
382
452
  {
@@ -386,7 +456,11 @@ var contract = {
386
456
  "forbidden": [
387
457
  "output_resolution",
388
458
  "negative_prompt",
389
- "cfg_scale"
459
+ "cfg_scale",
460
+ "reference_image_urls",
461
+ "reference_video_url",
462
+ "reference_video_type",
463
+ "preserve_reference_video_audio"
390
464
  ]
391
465
  },
392
466
  {
@@ -395,7 +469,11 @@ var contract = {
395
469
  },
396
470
  "forbidden": [
397
471
  "negative_prompt",
398
- "cfg_scale"
472
+ "cfg_scale",
473
+ "reference_image_urls",
474
+ "reference_video_url",
475
+ "reference_video_type",
476
+ "preserve_reference_video_audio"
399
477
  ]
400
478
  },
401
479
  {
@@ -407,14 +485,19 @@ var contract = {
407
485
  "aspect_ratio",
408
486
  "negative_prompt",
409
487
  "cfg_scale",
410
- "last_frame_image_url"
488
+ "last_frame_image_url",
489
+ "reference_image_urls",
490
+ "reference_video_url",
491
+ "reference_video_type",
492
+ "preserve_reference_video_audio"
411
493
  ]
412
494
  }
413
495
  ]
414
496
  },
415
497
  "motion-control": {
416
498
  "models": [
417
- "kling-3.0"
499
+ "kling-3.0",
500
+ "kling-v2.6"
418
501
  ],
419
502
  "fields_by_model": {
420
503
  "kling-3.0": {
@@ -445,12 +528,52 @@ var contract = {
445
528
  "source_image_url": {
446
529
  "required": true
447
530
  }
531
+ },
532
+ "kling-v2.6": {
533
+ "character_orientation": {
534
+ "enum": [
535
+ "video",
536
+ "image"
537
+ ],
538
+ "required": true
539
+ },
540
+ "model": {
541
+ "required": true
542
+ },
543
+ "output_resolution": {
544
+ "enum": [
545
+ "720p",
546
+ "1080p"
547
+ ],
548
+ "required": true
549
+ },
550
+ "prompt": {
551
+ "max": 2500,
552
+ "length": true
553
+ },
554
+ "reference_video_url": {
555
+ "required": true
556
+ },
557
+ "source_image_url": {
558
+ "required": true
559
+ }
448
560
  }
449
- }
561
+ },
562
+ "rules": [
563
+ {
564
+ "when": {
565
+ "model": "kling-v2.6"
566
+ },
567
+ "forbidden": [
568
+ "background_source"
569
+ ]
570
+ }
571
+ ]
450
572
  },
451
573
  "text-to-video": {
452
574
  "models": [
453
575
  "kling-3.0",
576
+ "kling-o1",
454
577
  "kling-v2.1-master-text-to-video",
455
578
  "kling-v2.5-turbo-text-to-video-pro",
456
579
  "kling-v2.6",
@@ -495,6 +618,46 @@ var contract = {
495
618
  ]
496
619
  }
497
620
  },
621
+ "kling-o1": {
622
+ "aspect_ratio": {
623
+ "enum": [
624
+ "16:9",
625
+ "9:16",
626
+ "1:1"
627
+ ]
628
+ },
629
+ "duration_seconds": {
630
+ "enum": [
631
+ 5
632
+ ],
633
+ "type": "integer"
634
+ },
635
+ "mode": {
636
+ "enum": [
637
+ "std",
638
+ "pro"
639
+ ]
640
+ },
641
+ "model": {
642
+ "required": true
643
+ },
644
+ "prompt": {
645
+ "required": true,
646
+ "min": 1,
647
+ "max": 2500,
648
+ "length": true
649
+ },
650
+ "reference_image_urls": {
651
+ "min_items": 1,
652
+ "max_items": 7
653
+ },
654
+ "reference_video_type": {
655
+ "enum": [
656
+ "base",
657
+ "feature"
658
+ ]
659
+ }
660
+ },
498
661
  "kling-v2.1-master-text-to-video": {
499
662
  "aspect_ratio": {
500
663
  "enum": [
@@ -651,12 +814,54 @@ var contract = {
651
814
  }
652
815
  },
653
816
  "rules": [
817
+ {
818
+ "when": {
819
+ "model": "kling-3.0"
820
+ },
821
+ "forbidden": [
822
+ "reference_image_urls",
823
+ "reference_video_url",
824
+ "reference_video_type",
825
+ "preserve_reference_video_audio"
826
+ ]
827
+ },
828
+ {
829
+ "when": {
830
+ "model": "kling-o1"
831
+ },
832
+ "forbidden": [
833
+ "output_resolution",
834
+ "negative_prompt",
835
+ "cfg_scale",
836
+ "multi_shots",
837
+ "multi_prompt",
838
+ "first_frame_image_url",
839
+ "last_frame_image_url",
840
+ "kling_elements"
841
+ ]
842
+ },
843
+ {
844
+ "when": {
845
+ "model": "kling-v2.1-master-text-to-video"
846
+ },
847
+ "forbidden": [
848
+ "mode",
849
+ "reference_image_urls",
850
+ "reference_video_url",
851
+ "reference_video_type",
852
+ "preserve_reference_video_audio"
853
+ ]
854
+ },
654
855
  {
655
856
  "when": {
656
857
  "model": "kling-v2.5-turbo-text-to-video-pro"
657
858
  },
658
859
  "forbidden": [
659
- "mode"
860
+ "mode",
861
+ "reference_image_urls",
862
+ "reference_video_url",
863
+ "reference_video_type",
864
+ "preserve_reference_video_audio"
660
865
  ]
661
866
  },
662
867
  {
@@ -671,7 +876,11 @@ var contract = {
671
876
  "multi_prompt",
672
877
  "first_frame_image_url",
673
878
  "last_frame_image_url",
674
- "kling_elements"
879
+ "kling_elements",
880
+ "reference_image_urls",
881
+ "reference_video_url",
882
+ "reference_video_type",
883
+ "preserve_reference_video_audio"
675
884
  ]
676
885
  },
677
886
  {
@@ -685,7 +894,11 @@ var contract = {
685
894
  "multi_prompt",
686
895
  "first_frame_image_url",
687
896
  "last_frame_image_url",
688
- "kling_elements"
897
+ "kling_elements",
898
+ "reference_image_urls",
899
+ "reference_video_url",
900
+ "reference_video_type",
901
+ "preserve_reference_video_audio"
689
902
  ]
690
903
  },
691
904
  {
@@ -700,13 +913,227 @@ var contract = {
700
913
  "multi_prompt",
701
914
  "first_frame_image_url",
702
915
  "last_frame_image_url",
703
- "kling_elements"
916
+ "kling_elements",
917
+ "reference_image_urls",
918
+ "reference_video_url",
919
+ "reference_video_type",
920
+ "preserve_reference_video_audio"
704
921
  ]
705
922
  }
706
923
  ]
707
924
  }
708
925
  };
709
926
 
927
+ // src/resources/o1-reference-validation.ts
928
+ var import_core = require("@runapi.ai/core");
929
+ var O1_MODEL = "kling-o1";
930
+ var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([".jpg", ".jpeg", ".png"]);
931
+ var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set([".mp4", ".mov"]);
932
+ var BLOCKED_IP_CIDRS = [
933
+ "0.0.0.0/8",
934
+ "10.0.0.0/8",
935
+ "100.64.0.0/10",
936
+ "127.0.0.0/8",
937
+ "169.254.0.0/16",
938
+ "172.16.0.0/12",
939
+ "192.0.0.0/24",
940
+ "192.0.2.0/24",
941
+ "192.88.99.0/24",
942
+ "192.168.0.0/16",
943
+ "198.18.0.0/15",
944
+ "198.51.100.0/24",
945
+ "203.0.113.0/24",
946
+ "224.0.0.0/4",
947
+ "240.0.0.0/4",
948
+ "255.255.255.255/32",
949
+ "::/128",
950
+ "::1/128",
951
+ "64:ff9b::/96",
952
+ "64:ff9b:1::/48",
953
+ "100::/64",
954
+ "2001::/32",
955
+ "2001:2::/48",
956
+ "2001:db8::/32",
957
+ "2002::/16",
958
+ "3fff::/20",
959
+ "fc00::/7",
960
+ "fe80::/10",
961
+ "ff00::/8"
962
+ ];
963
+ var BLOCKED_IP_NETWORKS = BLOCKED_IP_CIDRS.map((cidr) => {
964
+ const [address, prefixText] = cidr.split("/");
965
+ const parsed = parseIpLiteral(address);
966
+ if (!parsed) throw new Error("Invalid blocked IP range: " + cidr);
967
+ return { ...parsed, prefix: Number(prefixText) };
968
+ });
969
+ function validateKlingO1References(body) {
970
+ if (body.model !== O1_MODEL) return;
971
+ if (body.enable_sound === true) {
972
+ throw new import_core.ValidationError(`enable_sound is not supported by ${O1_MODEL}`);
973
+ }
974
+ validateFrameUrls(body);
975
+ if (typeof body.prompt !== "string") {
976
+ throw new import_core.ValidationError("prompt must be a string");
977
+ }
978
+ const prompt = body.prompt;
979
+ const referenceImages = Array.isArray(body.reference_image_urls) ? body.reference_image_urls : [];
980
+ if ("reference_video_url" in body && typeof body.reference_video_url !== "string") {
981
+ throw new import_core.ValidationError("reference_video_url must be a string");
982
+ }
983
+ const referenceVideoUrl = body.reference_video_url;
984
+ if (present(body.last_frame_image_url) && (referenceImages.length > 0 || present(referenceVideoUrl))) {
985
+ throw new import_core.ValidationError(
986
+ "last_frame_image_url cannot be combined with reference_image_urls or reference_video_url"
987
+ );
988
+ }
989
+ if (referenceVideoUrl && referenceImages.length > 4) {
990
+ throw new import_core.ValidationError(
991
+ "reference_image_urls must contain at most 4 items when reference_video_url is present"
992
+ );
993
+ }
994
+ validateReferenceImages(prompt, referenceImages);
995
+ validateReferenceVideo(body, prompt, referenceVideoUrl);
996
+ }
997
+ function validateFrameUrls(body) {
998
+ for (const field of ["first_frame_image_url", "last_frame_image_url"]) {
999
+ const value = body[field];
1000
+ if (typeof value !== "string" || value.length === 0) continue;
1001
+ if (!isPublicHttpUrl(value)) {
1002
+ throw new import_core.ValidationError(`${field} must be a public HTTP or HTTPS URL`);
1003
+ }
1004
+ if (!IMAGE_EXTENSIONS.has(urlExtension(value))) {
1005
+ throw new import_core.ValidationError(`${field} must use a JPG, JPEG, or PNG URL`);
1006
+ }
1007
+ }
1008
+ }
1009
+ function validateReferenceImages(prompt, urls) {
1010
+ urls.forEach((url, index) => {
1011
+ if (typeof url !== "string") {
1012
+ throw new import_core.ValidationError(`reference_image_urls[${index}] must be a string`);
1013
+ }
1014
+ if (!isPublicHttpUrl(url)) {
1015
+ throw new import_core.ValidationError(
1016
+ `reference_image_urls[${index}] must be a public HTTP or HTTPS URL`
1017
+ );
1018
+ }
1019
+ if (!IMAGE_EXTENSIONS.has(urlExtension(url))) {
1020
+ throw new import_core.ValidationError(
1021
+ `reference_image_urls[${index}] must use a JPG, JPEG, or PNG URL`
1022
+ );
1023
+ }
1024
+ const marker = `<<<image_${index + 1}>>>`;
1025
+ if (!prompt.includes(marker)) {
1026
+ throw new import_core.ValidationError(
1027
+ `prompt must reference reference_image_urls[${index}] as ${marker}`
1028
+ );
1029
+ }
1030
+ });
1031
+ for (const match of prompt.matchAll(/<<<image_(\d+)>>>/g)) {
1032
+ const index = Number(match[1]);
1033
+ if (index < 1 || index > urls.length) {
1034
+ throw new import_core.ValidationError(`prompt references missing image_${index}`);
1035
+ }
1036
+ }
1037
+ }
1038
+ function validateReferenceVideo(body, prompt, referenceVideoUrl) {
1039
+ if (!referenceVideoUrl) {
1040
+ if ("reference_video_type" in body) {
1041
+ throw new import_core.ValidationError("reference_video_type requires reference_video_url");
1042
+ }
1043
+ if ("preserve_reference_video_audio" in body) {
1044
+ throw new import_core.ValidationError("preserve_reference_video_audio requires reference_video_url");
1045
+ }
1046
+ const missingMarker = prompt.match(/<<<video_([^>]+)>>>/);
1047
+ if (missingMarker) {
1048
+ throw new import_core.ValidationError(`prompt references missing video_${missingMarker[1]}`);
1049
+ }
1050
+ return;
1051
+ }
1052
+ if (!isPublicHttpUrl(referenceVideoUrl)) {
1053
+ throw new import_core.ValidationError("reference_video_url must be a public HTTP or HTTPS URL");
1054
+ }
1055
+ if (!VIDEO_EXTENSIONS.has(urlExtension(referenceVideoUrl))) {
1056
+ throw new import_core.ValidationError("reference_video_url must use an MP4 or MOV URL");
1057
+ }
1058
+ if (!prompt.includes("<<<video_1>>>")) {
1059
+ throw new import_core.ValidationError("prompt must reference reference_video_url as <<<video_1>>>");
1060
+ }
1061
+ for (const match of prompt.matchAll(/<<<video_([^>]+)>>>/g)) {
1062
+ if (match[1] !== "1") {
1063
+ throw new import_core.ValidationError("prompt may only reference video_1");
1064
+ }
1065
+ }
1066
+ const referenceVideoType = body.reference_video_type ?? "base";
1067
+ if (referenceVideoType === "base" && (present(body.first_frame_image_url) || present(body.last_frame_image_url))) {
1068
+ throw new import_core.ValidationError(
1069
+ "reference_video_type base cannot be combined with first_frame_image_url or last_frame_image_url"
1070
+ );
1071
+ }
1072
+ }
1073
+ function present(value) {
1074
+ return typeof value === "string" ? value.trim().length > 0 : value !== void 0 && value !== null;
1075
+ }
1076
+ function urlExtension(value) {
1077
+ try {
1078
+ const path = new URL(value).pathname;
1079
+ const dot = path.lastIndexOf(".");
1080
+ return dot >= 0 ? path.slice(dot).toLowerCase() : "";
1081
+ } catch {
1082
+ return "";
1083
+ }
1084
+ }
1085
+ function isPublicHttpUrl(value) {
1086
+ try {
1087
+ const url = new URL(value);
1088
+ return (url.protocol === "http:" || url.protocol === "https:") && url.hostname.length > 0 && url.username.length === 0 && url.password.length === 0 && !isBlockedHost(url.hostname);
1089
+ } catch {
1090
+ return false;
1091
+ }
1092
+ }
1093
+ function isBlockedHost(hostname) {
1094
+ const host = hostname.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");
1095
+ if (host === "localhost" || host.endsWith(".localhost")) return true;
1096
+ const parsed = parseIpLiteral(host);
1097
+ if (!parsed) return false;
1098
+ return BLOCKED_IP_NETWORKS.some((network) => {
1099
+ if (network.bits !== parsed.bits) return false;
1100
+ const shift = BigInt(parsed.bits - network.prefix);
1101
+ return parsed.value >> shift === network.value >> shift;
1102
+ });
1103
+ }
1104
+ function parseIpLiteral(value) {
1105
+ const ipv4 = parseIpv4(value);
1106
+ if (ipv4 !== void 0) return { bits: 32, value: ipv4 };
1107
+ if (!value.includes(":")) return void 0;
1108
+ const halves = value.toLowerCase().split("::");
1109
+ if (halves.length > 2) return void 0;
1110
+ const head = parseIpv6Half(halves[0]);
1111
+ const tail = parseIpv6Half(halves[1] ?? "");
1112
+ if (!head || !tail) return void 0;
1113
+ const compressed = halves.length === 2;
1114
+ const missing = 8 - head.length - tail.length;
1115
+ if (!compressed && missing !== 0 || compressed && missing < 1) return void 0;
1116
+ const segments = [...head, ...Array(missing).fill(0), ...tail];
1117
+ const address = segments.reduce((result, segment) => result << 16n | BigInt(segment), 0n);
1118
+ if (address >> 32n === 0xffffn) {
1119
+ return { bits: 32, value: address & 0xffffffffn };
1120
+ }
1121
+ return { bits: 128, value: address };
1122
+ }
1123
+ function parseIpv4(value) {
1124
+ const parts = value.split(".");
1125
+ if (parts.length !== 4 || parts.some((part) => !/^\d+$/.test(part))) return void 0;
1126
+ const octets = parts.map(Number);
1127
+ if (octets.some((octet) => octet < 0 || octet > 255)) return void 0;
1128
+ return octets.reduce((result, octet) => result << 8n | BigInt(octet), 0n);
1129
+ }
1130
+ function parseIpv6Half(value) {
1131
+ if (value === "") return [];
1132
+ const parts = value.split(":");
1133
+ if (parts.some((part) => !/^[0-9a-f]{1,4}$/.test(part))) return void 0;
1134
+ return parts.map((part) => Number.parseInt(part, 16));
1135
+ }
1136
+
710
1137
  // src/resources/text-to-video.ts
711
1138
  var ENDPOINT = "/api/v1/kling/text_to_video";
712
1139
  var V26_MODEL = "kling-v2.6";
@@ -747,10 +1174,11 @@ var TextToVideo = class {
747
1174
  * @returns The task creation result with id.
748
1175
  */
749
1176
  async create(params, options) {
750
- const body = (0, import_core.compactParams)(params);
1177
+ const body = (0, import_core2.compactParams)(params);
751
1178
  rejectUnsupportedV3TurboFields(body);
752
- (0, import_core.validateParams)(contract["text-to-video"], body);
1179
+ (0, import_core2.validateParams)(contract["text-to-video"], body);
753
1180
  validateV26Params(body);
1181
+ validateKlingO1References(body);
754
1182
  return this.http.request("POST", ENDPOINT, {
755
1183
  body,
756
1184
  ...options
@@ -771,14 +1199,14 @@ var TextToVideo = class {
771
1199
  function validateV26Params(body) {
772
1200
  if (body.model !== V26_MODEL) return;
773
1201
  if (body.enable_sound === true && body.mode !== "pro") {
774
- throw new import_core.ValidationError(`enable_sound requires mode pro for ${V26_MODEL}`);
1202
+ throw new import_core2.ValidationError(`enable_sound requires mode pro for ${V26_MODEL}`);
775
1203
  }
776
1204
  }
777
1205
  function rejectUnsupportedV3TurboFields(body) {
778
1206
  if (body.model !== V3_TURBO_MODEL) return;
779
1207
  const field = V3_TURBO_UNSUPPORTED_FIELDS.find((candidate) => fieldPresent(body, candidate));
780
1208
  if (field) {
781
- throw new import_core.ValidationError(`${field} is not supported by ${V3_TURBO_MODEL}`);
1209
+ throw new import_core2.ValidationError(`${field} is not supported by ${V3_TURBO_MODEL}`);
782
1210
  }
783
1211
  }
784
1212
  function fieldPresent(params, field) {
@@ -798,7 +1226,7 @@ function presentValue(value) {
798
1226
  }
799
1227
 
800
1228
  // src/resources/image-to-video.ts
801
- var import_core2 = require("@runapi.ai/core");
1229
+ var import_core3 = require("@runapi.ai/core");
802
1230
  var import_internal2 = require("@runapi.ai/core/internal");
803
1231
  var ENDPOINT2 = "/api/v1/kling/image_to_video";
804
1232
  var V26_MODEL2 = "kling-v2.6";
@@ -836,11 +1264,12 @@ var ImageToVideo = class {
836
1264
  * @returns The task creation result with id.
837
1265
  */
838
1266
  async create(params, options) {
839
- const body = (0, import_core2.compactParams)(params);
1267
+ const body = (0, import_core3.compactParams)(params);
840
1268
  rejectUnsupportedV3TurboFields2(body);
841
- (0, import_core2.validateParams)(contract["image-to-video"], body);
1269
+ (0, import_core3.validateParams)(contract["image-to-video"], body);
842
1270
  validateV26Params2(body);
843
1271
  validateV3OmniFields(body);
1272
+ validateKlingO1References(body);
844
1273
  return this.http.request("POST", ENDPOINT2, {
845
1274
  body,
846
1275
  ...options
@@ -861,27 +1290,27 @@ var ImageToVideo = class {
861
1290
  function validateV26Params2(body) {
862
1291
  if (body.model !== V26_MODEL2) return;
863
1292
  if (body.enable_sound === true && body.mode !== "pro") {
864
- throw new import_core2.ValidationError(`enable_sound requires mode pro for ${V26_MODEL2}`);
1293
+ throw new import_core3.ValidationError(`enable_sound requires mode pro for ${V26_MODEL2}`);
865
1294
  }
866
1295
  if (!fieldPresent2(body, "last_frame_image_url")) return;
867
1296
  if (body.mode !== "pro") {
868
- throw new import_core2.ValidationError(`last_frame_image_url requires mode pro for ${V26_MODEL2}`);
1297
+ throw new import_core3.ValidationError(`last_frame_image_url requires mode pro for ${V26_MODEL2}`);
869
1298
  }
870
1299
  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}`);
1300
+ throw new import_core3.ValidationError(`last_frame_image_url requires duration_seconds 5 for ${V26_MODEL2}`);
872
1301
  }
873
1302
  }
874
1303
  function validateV3OmniFields(body) {
875
1304
  if (body.model !== V3_OMNI_MODEL || !fieldPresent2(body, "last_frame_image_url")) return;
876
1305
  if ((body.duration_seconds ?? 5) !== 5) {
877
- throw new import_core2.ValidationError(`last_frame_image_url requires duration_seconds 5 for ${V3_OMNI_MODEL}`);
1306
+ throw new import_core3.ValidationError(`last_frame_image_url requires duration_seconds 5 for ${V3_OMNI_MODEL}`);
878
1307
  }
879
1308
  }
880
1309
  function rejectUnsupportedV3TurboFields2(body) {
881
1310
  if (body.model !== V3_TURBO_MODEL2) return;
882
1311
  const field = V3_TURBO_UNSUPPORTED_FIELDS2.find((candidate) => fieldPresent2(body, candidate));
883
1312
  if (field) {
884
- throw new import_core2.ValidationError(`${field} is not supported by ${V3_TURBO_MODEL2}`);
1313
+ throw new import_core3.ValidationError(`${field} is not supported by ${V3_TURBO_MODEL2}`);
885
1314
  }
886
1315
  }
887
1316
  function fieldPresent2(params, field) {
@@ -901,7 +1330,7 @@ function presentValue2(value) {
901
1330
  }
902
1331
 
903
1332
  // src/resources/ai-avatar.ts
904
- var import_core3 = require("@runapi.ai/core");
1333
+ var import_core4 = require("@runapi.ai/core");
905
1334
  var import_internal3 = require("@runapi.ai/core/internal");
906
1335
  var ENDPOINT3 = "/api/v1/kling/ai_avatar";
907
1336
  var AiAvatar = class {
@@ -930,8 +1359,8 @@ var AiAvatar = class {
930
1359
  * @returns The task creation result with id.
931
1360
  */
932
1361
  async create(params, options) {
933
- const body = (0, import_core3.compactParams)(params);
934
- (0, import_core3.validateParams)(contract["avatar"], body);
1362
+ const body = (0, import_core4.compactParams)(params);
1363
+ (0, import_core4.validateParams)(contract["avatar"], body);
935
1364
  return this.http.request("POST", ENDPOINT3, {
936
1365
  body,
937
1366
  ...options
@@ -951,7 +1380,7 @@ var AiAvatar = class {
951
1380
  };
952
1381
 
953
1382
  // src/resources/motion-control.ts
954
- var import_core4 = require("@runapi.ai/core");
1383
+ var import_core5 = require("@runapi.ai/core");
955
1384
  var import_internal4 = require("@runapi.ai/core/internal");
956
1385
  var ENDPOINT4 = "/api/v1/kling/motion_control";
957
1386
  var MotionControl = class {
@@ -980,8 +1409,8 @@ var MotionControl = class {
980
1409
  * @returns The task creation result with id.
981
1410
  */
982
1411
  async create(params, options) {
983
- const body = (0, import_core4.compactParams)(params);
984
- (0, import_core4.validateParams)(contract["motion-control"], body);
1412
+ const body = (0, import_core5.compactParams)(params);
1413
+ (0, import_core5.validateParams)(contract["motion-control"], body);
985
1414
  return this.http.request("POST", ENDPOINT4, {
986
1415
  body,
987
1416
  ...options
@@ -1001,7 +1430,7 @@ var MotionControl = class {
1001
1430
  };
1002
1431
 
1003
1432
  // src/resources/extend-video.ts
1004
- var import_core5 = require("@runapi.ai/core");
1433
+ var import_core6 = require("@runapi.ai/core");
1005
1434
  var import_internal5 = require("@runapi.ai/core/internal");
1006
1435
  var ENDPOINT5 = "/api/v1/kling/extend_video";
1007
1436
  var ExtendVideo = class {
@@ -1017,8 +1446,8 @@ var ExtendVideo = class {
1017
1446
  });
1018
1447
  }
1019
1448
  async create(params, options) {
1020
- const body = (0, import_core5.compactParams)(params);
1021
- (0, import_core5.validateParams)(contract["extend-video"], body);
1449
+ const body = (0, import_core6.compactParams)(params);
1450
+ (0, import_core6.validateParams)(contract["extend-video"], body);
1022
1451
  return this.http.request("POST", ENDPOINT5, { body, ...options });
1023
1452
  }
1024
1453
  async get(id, options) {
@@ -1027,7 +1456,7 @@ var ExtendVideo = class {
1027
1456
  };
1028
1457
 
1029
1458
  // src/client.ts
1030
- var KlingClient = class extends import_core6.BaseClient {
1459
+ var KlingClient = class extends import_core7.BaseClient {
1031
1460
  /** Text-to-video generation with multi-shot, sound, and Kling elements support on kling-3.0. */
1032
1461
  textToVideo;
1033
1462
  /** Image-to-video animation from a first-frame image guided by a text prompt. */
@@ -1048,7 +1477,7 @@ var KlingClient = class extends import_core6.BaseClient {
1048
1477
  };
1049
1478
 
1050
1479
  // src/index.ts
1051
- var import_core7 = require("@runapi.ai/core");
1480
+ var import_core8 = require("@runapi.ai/core");
1052
1481
  // Annotate the CommonJS export names for ESM import in node:
1053
1482
  0 && (module.exports = {
1054
1483
  AuthenticationError,