@runapi.ai/kling 0.2.12 → 0.3.0
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/README.md +26 -5
- package/dist/index.d.mts +92 -6
- package/dist/index.d.ts +92 -6
- package/dist/index.js +879 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +854 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/skills/kling/README.md +5 -2
- package/skills/kling/SKILL.md +78 -47
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: () =>
|
|
24
|
-
InsufficientCreditsError: () =>
|
|
23
|
+
AuthenticationError: () => import_core9.AuthenticationError,
|
|
24
|
+
InsufficientCreditsError: () => import_core9.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_core9.NetworkError,
|
|
27
|
+
NotFoundError: () => import_core9.NotFoundError,
|
|
28
|
+
RateLimitError: () => import_core9.RateLimitError,
|
|
29
|
+
RunApiError: () => import_core9.RunApiError,
|
|
30
|
+
ServiceUnavailableError: () => import_core9.ServiceUnavailableError,
|
|
31
|
+
TaskFailedError: () => import_core9.TaskFailedError,
|
|
32
|
+
TaskTimeoutError: () => import_core9.TaskTimeoutError,
|
|
33
|
+
TimeoutError: () => import_core9.TimeoutError,
|
|
34
|
+
ValidationError: () => import_core9.ValidationError
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
37
|
|
|
38
38
|
// src/client.ts
|
|
39
|
-
var
|
|
39
|
+
var import_core8 = require("@runapi.ai/core");
|
|
40
40
|
|
|
41
41
|
// src/resources/text-to-video.ts
|
|
42
|
-
var
|
|
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
|
|
@@ -110,6 +110,370 @@ var contract = {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
|
+
"edit-video": {
|
|
114
|
+
"models": [
|
|
115
|
+
"kling-v3-omni-edit",
|
|
116
|
+
"kling-v3-omni-reference"
|
|
117
|
+
],
|
|
118
|
+
"fields_by_model": {
|
|
119
|
+
"kling-v3-omni-edit": {
|
|
120
|
+
"aspect_ratio": {
|
|
121
|
+
"enum": [
|
|
122
|
+
"auto",
|
|
123
|
+
"16:9",
|
|
124
|
+
"9:16",
|
|
125
|
+
"1:1"
|
|
126
|
+
]
|
|
127
|
+
},
|
|
128
|
+
"duration_seconds": {
|
|
129
|
+
"enum": [
|
|
130
|
+
3,
|
|
131
|
+
4,
|
|
132
|
+
5,
|
|
133
|
+
6,
|
|
134
|
+
7,
|
|
135
|
+
8,
|
|
136
|
+
9,
|
|
137
|
+
10,
|
|
138
|
+
11,
|
|
139
|
+
12,
|
|
140
|
+
13,
|
|
141
|
+
14,
|
|
142
|
+
15
|
|
143
|
+
],
|
|
144
|
+
"type": "integer"
|
|
145
|
+
},
|
|
146
|
+
"model": {
|
|
147
|
+
"required": true
|
|
148
|
+
},
|
|
149
|
+
"output_resolution": {
|
|
150
|
+
"enum": [
|
|
151
|
+
"720p",
|
|
152
|
+
"1080p",
|
|
153
|
+
"4k"
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
"prompt": {
|
|
157
|
+
"required": true,
|
|
158
|
+
"min": 1,
|
|
159
|
+
"max": 2500,
|
|
160
|
+
"length": true
|
|
161
|
+
},
|
|
162
|
+
"reference_image_urls": {
|
|
163
|
+
"min_items": 1,
|
|
164
|
+
"max_items": 4
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
"kling-v3-omni-reference": {
|
|
168
|
+
"aspect_ratio": {
|
|
169
|
+
"enum": [
|
|
170
|
+
"auto",
|
|
171
|
+
"16:9",
|
|
172
|
+
"9:16",
|
|
173
|
+
"1:1"
|
|
174
|
+
]
|
|
175
|
+
},
|
|
176
|
+
"duration_seconds": {
|
|
177
|
+
"enum": [
|
|
178
|
+
3,
|
|
179
|
+
4,
|
|
180
|
+
5,
|
|
181
|
+
6,
|
|
182
|
+
7,
|
|
183
|
+
8,
|
|
184
|
+
9,
|
|
185
|
+
10,
|
|
186
|
+
11,
|
|
187
|
+
12,
|
|
188
|
+
13,
|
|
189
|
+
14,
|
|
190
|
+
15
|
|
191
|
+
],
|
|
192
|
+
"type": "integer"
|
|
193
|
+
},
|
|
194
|
+
"model": {
|
|
195
|
+
"required": true
|
|
196
|
+
},
|
|
197
|
+
"output_resolution": {
|
|
198
|
+
"enum": [
|
|
199
|
+
"720p",
|
|
200
|
+
"1080p",
|
|
201
|
+
"4k"
|
|
202
|
+
]
|
|
203
|
+
},
|
|
204
|
+
"prompt": {
|
|
205
|
+
"required": true,
|
|
206
|
+
"min": 1,
|
|
207
|
+
"max": 2500,
|
|
208
|
+
"length": true
|
|
209
|
+
},
|
|
210
|
+
"reference_image_urls": {
|
|
211
|
+
"min_items": 1,
|
|
212
|
+
"max_items": 4
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
"rules": [
|
|
217
|
+
{
|
|
218
|
+
"when": {
|
|
219
|
+
"model": "kling-v3-omni-edit",
|
|
220
|
+
"source_task_id": {
|
|
221
|
+
"present": false
|
|
222
|
+
},
|
|
223
|
+
"source_video_url": {
|
|
224
|
+
"present": false
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
"required_any": [
|
|
228
|
+
"source_video_url",
|
|
229
|
+
"source_task_id"
|
|
230
|
+
]
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"when": {
|
|
234
|
+
"model": "kling-v3-omni-edit",
|
|
235
|
+
"source_video_url": {
|
|
236
|
+
"present": true
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
"forbidden": [
|
|
240
|
+
"source_task_id"
|
|
241
|
+
]
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"when": {
|
|
245
|
+
"model": "kling-v3-omni-edit",
|
|
246
|
+
"source_task_id": {
|
|
247
|
+
"present": true
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
"forbidden": [
|
|
251
|
+
"source_video_url"
|
|
252
|
+
]
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"enum": {
|
|
256
|
+
"aspect_ratio": [
|
|
257
|
+
"auto"
|
|
258
|
+
],
|
|
259
|
+
"duration_seconds": [
|
|
260
|
+
5
|
|
261
|
+
]
|
|
262
|
+
},
|
|
263
|
+
"when": {
|
|
264
|
+
"model": "kling-v3-omni-edit",
|
|
265
|
+
"source_video_url": {
|
|
266
|
+
"present": true
|
|
267
|
+
},
|
|
268
|
+
"reference_image_urls": {
|
|
269
|
+
"present": false
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
"required": [
|
|
273
|
+
"aspect_ratio"
|
|
274
|
+
]
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"enum": {
|
|
278
|
+
"aspect_ratio": [
|
|
279
|
+
"auto"
|
|
280
|
+
],
|
|
281
|
+
"duration_seconds": [
|
|
282
|
+
5
|
|
283
|
+
]
|
|
284
|
+
},
|
|
285
|
+
"when": {
|
|
286
|
+
"model": "kling-v3-omni-edit",
|
|
287
|
+
"source_task_id": {
|
|
288
|
+
"present": true
|
|
289
|
+
},
|
|
290
|
+
"reference_image_urls": {
|
|
291
|
+
"present": false
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
"required": [
|
|
295
|
+
"aspect_ratio"
|
|
296
|
+
]
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"enum": {
|
|
300
|
+
"aspect_ratio": [
|
|
301
|
+
"16:9",
|
|
302
|
+
"9:16",
|
|
303
|
+
"1:1"
|
|
304
|
+
]
|
|
305
|
+
},
|
|
306
|
+
"when": {
|
|
307
|
+
"model": "kling-v3-omni-edit",
|
|
308
|
+
"source_video_url": {
|
|
309
|
+
"present": true
|
|
310
|
+
},
|
|
311
|
+
"reference_image_urls": {
|
|
312
|
+
"present": true
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
"required": [
|
|
316
|
+
"aspect_ratio"
|
|
317
|
+
]
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"enum": {
|
|
321
|
+
"aspect_ratio": [
|
|
322
|
+
"16:9",
|
|
323
|
+
"9:16",
|
|
324
|
+
"1:1"
|
|
325
|
+
]
|
|
326
|
+
},
|
|
327
|
+
"when": {
|
|
328
|
+
"model": "kling-v3-omni-edit",
|
|
329
|
+
"source_task_id": {
|
|
330
|
+
"present": true
|
|
331
|
+
},
|
|
332
|
+
"reference_image_urls": {
|
|
333
|
+
"present": true
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
"required": [
|
|
337
|
+
"aspect_ratio"
|
|
338
|
+
]
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"when": {
|
|
342
|
+
"model": "kling-v3-omni-reference",
|
|
343
|
+
"source_task_id": {
|
|
344
|
+
"present": false
|
|
345
|
+
},
|
|
346
|
+
"source_video_url": {
|
|
347
|
+
"present": false
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
"required_any": [
|
|
351
|
+
"source_video_url",
|
|
352
|
+
"source_task_id"
|
|
353
|
+
]
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"when": {
|
|
357
|
+
"model": "kling-v3-omni-reference",
|
|
358
|
+
"source_video_url": {
|
|
359
|
+
"present": true
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
"forbidden": [
|
|
363
|
+
"source_task_id"
|
|
364
|
+
]
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
"when": {
|
|
368
|
+
"model": "kling-v3-omni-reference",
|
|
369
|
+
"source_task_id": {
|
|
370
|
+
"present": true
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
"forbidden": [
|
|
374
|
+
"source_video_url"
|
|
375
|
+
]
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
"enum": {
|
|
379
|
+
"aspect_ratio": [
|
|
380
|
+
"auto"
|
|
381
|
+
],
|
|
382
|
+
"enable_sound": [
|
|
383
|
+
false
|
|
384
|
+
],
|
|
385
|
+
"duration_seconds": [
|
|
386
|
+
5
|
|
387
|
+
]
|
|
388
|
+
},
|
|
389
|
+
"when": {
|
|
390
|
+
"model": "kling-v3-omni-reference",
|
|
391
|
+
"source_video_url": {
|
|
392
|
+
"present": true
|
|
393
|
+
},
|
|
394
|
+
"reference_image_urls": {
|
|
395
|
+
"present": false
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
"required": [
|
|
399
|
+
"aspect_ratio"
|
|
400
|
+
]
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
"enum": {
|
|
404
|
+
"aspect_ratio": [
|
|
405
|
+
"auto"
|
|
406
|
+
],
|
|
407
|
+
"enable_sound": [
|
|
408
|
+
false
|
|
409
|
+
],
|
|
410
|
+
"duration_seconds": [
|
|
411
|
+
5
|
|
412
|
+
]
|
|
413
|
+
},
|
|
414
|
+
"when": {
|
|
415
|
+
"model": "kling-v3-omni-reference",
|
|
416
|
+
"source_task_id": {
|
|
417
|
+
"present": true
|
|
418
|
+
},
|
|
419
|
+
"reference_image_urls": {
|
|
420
|
+
"present": false
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
"required": [
|
|
424
|
+
"aspect_ratio"
|
|
425
|
+
]
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
"enum": {
|
|
429
|
+
"aspect_ratio": [
|
|
430
|
+
"16:9",
|
|
431
|
+
"9:16",
|
|
432
|
+
"1:1"
|
|
433
|
+
],
|
|
434
|
+
"enable_sound": [
|
|
435
|
+
false
|
|
436
|
+
]
|
|
437
|
+
},
|
|
438
|
+
"when": {
|
|
439
|
+
"model": "kling-v3-omni-reference",
|
|
440
|
+
"source_video_url": {
|
|
441
|
+
"present": true
|
|
442
|
+
},
|
|
443
|
+
"reference_image_urls": {
|
|
444
|
+
"present": true
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
"required": [
|
|
448
|
+
"aspect_ratio"
|
|
449
|
+
]
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
"enum": {
|
|
453
|
+
"aspect_ratio": [
|
|
454
|
+
"16:9",
|
|
455
|
+
"9:16",
|
|
456
|
+
"1:1"
|
|
457
|
+
],
|
|
458
|
+
"enable_sound": [
|
|
459
|
+
false
|
|
460
|
+
]
|
|
461
|
+
},
|
|
462
|
+
"when": {
|
|
463
|
+
"model": "kling-v3-omni-reference",
|
|
464
|
+
"source_task_id": {
|
|
465
|
+
"present": true
|
|
466
|
+
},
|
|
467
|
+
"reference_image_urls": {
|
|
468
|
+
"present": true
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
"required": [
|
|
472
|
+
"aspect_ratio"
|
|
473
|
+
]
|
|
474
|
+
}
|
|
475
|
+
]
|
|
476
|
+
},
|
|
113
477
|
"extend-video": {
|
|
114
478
|
"models": [
|
|
115
479
|
"kling-v2.5-turbo-image-to-video-pro",
|
|
@@ -142,6 +506,7 @@ var contract = {
|
|
|
142
506
|
},
|
|
143
507
|
"image-to-video": {
|
|
144
508
|
"models": [
|
|
509
|
+
"kling-o1",
|
|
145
510
|
"kling-v2.1-master-image-to-video",
|
|
146
511
|
"kling-v2.1-pro",
|
|
147
512
|
"kling-v2.1-standard",
|
|
@@ -151,6 +516,49 @@ var contract = {
|
|
|
151
516
|
"kling-v3-turbo-image-to-video"
|
|
152
517
|
],
|
|
153
518
|
"fields_by_model": {
|
|
519
|
+
"kling-o1": {
|
|
520
|
+
"aspect_ratio": {
|
|
521
|
+
"enum": [
|
|
522
|
+
"16:9",
|
|
523
|
+
"9:16",
|
|
524
|
+
"1:1"
|
|
525
|
+
]
|
|
526
|
+
},
|
|
527
|
+
"duration_seconds": {
|
|
528
|
+
"enum": [
|
|
529
|
+
5
|
|
530
|
+
],
|
|
531
|
+
"type": "integer"
|
|
532
|
+
},
|
|
533
|
+
"first_frame_image_url": {
|
|
534
|
+
"required": true
|
|
535
|
+
},
|
|
536
|
+
"mode": {
|
|
537
|
+
"enum": [
|
|
538
|
+
"std",
|
|
539
|
+
"pro"
|
|
540
|
+
]
|
|
541
|
+
},
|
|
542
|
+
"model": {
|
|
543
|
+
"required": true
|
|
544
|
+
},
|
|
545
|
+
"prompt": {
|
|
546
|
+
"required": true,
|
|
547
|
+
"min": 1,
|
|
548
|
+
"max": 2500,
|
|
549
|
+
"length": true
|
|
550
|
+
},
|
|
551
|
+
"reference_image_urls": {
|
|
552
|
+
"min_items": 1,
|
|
553
|
+
"max_items": 7
|
|
554
|
+
},
|
|
555
|
+
"reference_video_type": {
|
|
556
|
+
"enum": [
|
|
557
|
+
"base",
|
|
558
|
+
"feature"
|
|
559
|
+
]
|
|
560
|
+
}
|
|
561
|
+
},
|
|
154
562
|
"kling-v2.1-master-image-to-video": {
|
|
155
563
|
"duration_seconds": {
|
|
156
564
|
"enum": [
|
|
@@ -343,13 +751,27 @@ var contract = {
|
|
|
343
751
|
}
|
|
344
752
|
},
|
|
345
753
|
"rules": [
|
|
754
|
+
{
|
|
755
|
+
"when": {
|
|
756
|
+
"model": "kling-o1"
|
|
757
|
+
},
|
|
758
|
+
"forbidden": [
|
|
759
|
+
"output_resolution",
|
|
760
|
+
"negative_prompt",
|
|
761
|
+
"cfg_scale"
|
|
762
|
+
]
|
|
763
|
+
},
|
|
346
764
|
{
|
|
347
765
|
"when": {
|
|
348
766
|
"model": "kling-v2.1-master-image-to-video"
|
|
349
767
|
},
|
|
350
768
|
"forbidden": [
|
|
351
769
|
"output_resolution",
|
|
352
|
-
"enable_sound"
|
|
770
|
+
"enable_sound",
|
|
771
|
+
"reference_image_urls",
|
|
772
|
+
"reference_video_url",
|
|
773
|
+
"reference_video_type",
|
|
774
|
+
"preserve_reference_video_audio"
|
|
353
775
|
]
|
|
354
776
|
},
|
|
355
777
|
{
|
|
@@ -358,7 +780,11 @@ var contract = {
|
|
|
358
780
|
},
|
|
359
781
|
"forbidden": [
|
|
360
782
|
"output_resolution",
|
|
361
|
-
"enable_sound"
|
|
783
|
+
"enable_sound",
|
|
784
|
+
"reference_image_urls",
|
|
785
|
+
"reference_video_url",
|
|
786
|
+
"reference_video_type",
|
|
787
|
+
"preserve_reference_video_audio"
|
|
362
788
|
]
|
|
363
789
|
},
|
|
364
790
|
{
|
|
@@ -367,7 +793,11 @@ var contract = {
|
|
|
367
793
|
},
|
|
368
794
|
"forbidden": [
|
|
369
795
|
"output_resolution",
|
|
370
|
-
"enable_sound"
|
|
796
|
+
"enable_sound",
|
|
797
|
+
"reference_image_urls",
|
|
798
|
+
"reference_video_url",
|
|
799
|
+
"reference_video_type",
|
|
800
|
+
"preserve_reference_video_audio"
|
|
371
801
|
]
|
|
372
802
|
},
|
|
373
803
|
{
|
|
@@ -376,7 +806,11 @@ var contract = {
|
|
|
376
806
|
},
|
|
377
807
|
"forbidden": [
|
|
378
808
|
"output_resolution",
|
|
379
|
-
"enable_sound"
|
|
809
|
+
"enable_sound",
|
|
810
|
+
"reference_image_urls",
|
|
811
|
+
"reference_video_url",
|
|
812
|
+
"reference_video_type",
|
|
813
|
+
"preserve_reference_video_audio"
|
|
380
814
|
]
|
|
381
815
|
},
|
|
382
816
|
{
|
|
@@ -386,7 +820,11 @@ var contract = {
|
|
|
386
820
|
"forbidden": [
|
|
387
821
|
"output_resolution",
|
|
388
822
|
"negative_prompt",
|
|
389
|
-
"cfg_scale"
|
|
823
|
+
"cfg_scale",
|
|
824
|
+
"reference_image_urls",
|
|
825
|
+
"reference_video_url",
|
|
826
|
+
"reference_video_type",
|
|
827
|
+
"preserve_reference_video_audio"
|
|
390
828
|
]
|
|
391
829
|
},
|
|
392
830
|
{
|
|
@@ -395,7 +833,11 @@ var contract = {
|
|
|
395
833
|
},
|
|
396
834
|
"forbidden": [
|
|
397
835
|
"negative_prompt",
|
|
398
|
-
"cfg_scale"
|
|
836
|
+
"cfg_scale",
|
|
837
|
+
"reference_image_urls",
|
|
838
|
+
"reference_video_url",
|
|
839
|
+
"reference_video_type",
|
|
840
|
+
"preserve_reference_video_audio"
|
|
399
841
|
]
|
|
400
842
|
},
|
|
401
843
|
{
|
|
@@ -407,7 +849,11 @@ var contract = {
|
|
|
407
849
|
"aspect_ratio",
|
|
408
850
|
"negative_prompt",
|
|
409
851
|
"cfg_scale",
|
|
410
|
-
"last_frame_image_url"
|
|
852
|
+
"last_frame_image_url",
|
|
853
|
+
"reference_image_urls",
|
|
854
|
+
"reference_video_url",
|
|
855
|
+
"reference_video_type",
|
|
856
|
+
"preserve_reference_video_audio"
|
|
411
857
|
]
|
|
412
858
|
}
|
|
413
859
|
]
|
|
@@ -491,10 +937,12 @@ var contract = {
|
|
|
491
937
|
"text-to-video": {
|
|
492
938
|
"models": [
|
|
493
939
|
"kling-3.0",
|
|
940
|
+
"kling-o1",
|
|
494
941
|
"kling-v2.1-master-text-to-video",
|
|
495
942
|
"kling-v2.5-turbo-text-to-video-pro",
|
|
496
943
|
"kling-v2.6",
|
|
497
944
|
"kling-v3-omni",
|
|
945
|
+
"kling-v3-omni-reference",
|
|
498
946
|
"kling-v3-turbo-text-to-video"
|
|
499
947
|
],
|
|
500
948
|
"fields_by_model": {
|
|
@@ -535,6 +983,46 @@ var contract = {
|
|
|
535
983
|
]
|
|
536
984
|
}
|
|
537
985
|
},
|
|
986
|
+
"kling-o1": {
|
|
987
|
+
"aspect_ratio": {
|
|
988
|
+
"enum": [
|
|
989
|
+
"16:9",
|
|
990
|
+
"9:16",
|
|
991
|
+
"1:1"
|
|
992
|
+
]
|
|
993
|
+
},
|
|
994
|
+
"duration_seconds": {
|
|
995
|
+
"enum": [
|
|
996
|
+
5
|
|
997
|
+
],
|
|
998
|
+
"type": "integer"
|
|
999
|
+
},
|
|
1000
|
+
"mode": {
|
|
1001
|
+
"enum": [
|
|
1002
|
+
"std",
|
|
1003
|
+
"pro"
|
|
1004
|
+
]
|
|
1005
|
+
},
|
|
1006
|
+
"model": {
|
|
1007
|
+
"required": true
|
|
1008
|
+
},
|
|
1009
|
+
"prompt": {
|
|
1010
|
+
"required": true,
|
|
1011
|
+
"min": 1,
|
|
1012
|
+
"max": 2500,
|
|
1013
|
+
"length": true
|
|
1014
|
+
},
|
|
1015
|
+
"reference_image_urls": {
|
|
1016
|
+
"min_items": 1,
|
|
1017
|
+
"max_items": 7
|
|
1018
|
+
},
|
|
1019
|
+
"reference_video_type": {
|
|
1020
|
+
"enum": [
|
|
1021
|
+
"base",
|
|
1022
|
+
"feature"
|
|
1023
|
+
]
|
|
1024
|
+
}
|
|
1025
|
+
},
|
|
538
1026
|
"kling-v2.1-master-text-to-video": {
|
|
539
1027
|
"aspect_ratio": {
|
|
540
1028
|
"enum": [
|
|
@@ -647,6 +1135,55 @@ var contract = {
|
|
|
647
1135
|
"length": true
|
|
648
1136
|
}
|
|
649
1137
|
},
|
|
1138
|
+
"kling-v3-omni-reference": {
|
|
1139
|
+
"aspect_ratio": {
|
|
1140
|
+
"enum": [
|
|
1141
|
+
"16:9",
|
|
1142
|
+
"9:16",
|
|
1143
|
+
"1:1"
|
|
1144
|
+
],
|
|
1145
|
+
"required": true
|
|
1146
|
+
},
|
|
1147
|
+
"duration_seconds": {
|
|
1148
|
+
"enum": [
|
|
1149
|
+
3,
|
|
1150
|
+
4,
|
|
1151
|
+
5,
|
|
1152
|
+
6,
|
|
1153
|
+
7,
|
|
1154
|
+
8,
|
|
1155
|
+
9,
|
|
1156
|
+
10,
|
|
1157
|
+
11,
|
|
1158
|
+
12,
|
|
1159
|
+
13,
|
|
1160
|
+
14,
|
|
1161
|
+
15
|
|
1162
|
+
],
|
|
1163
|
+
"type": "integer"
|
|
1164
|
+
},
|
|
1165
|
+
"model": {
|
|
1166
|
+
"required": true
|
|
1167
|
+
},
|
|
1168
|
+
"output_resolution": {
|
|
1169
|
+
"enum": [
|
|
1170
|
+
"720p",
|
|
1171
|
+
"1080p",
|
|
1172
|
+
"4k"
|
|
1173
|
+
]
|
|
1174
|
+
},
|
|
1175
|
+
"prompt": {
|
|
1176
|
+
"required": true,
|
|
1177
|
+
"min": 1,
|
|
1178
|
+
"max": 2500,
|
|
1179
|
+
"length": true
|
|
1180
|
+
},
|
|
1181
|
+
"reference_image_urls": {
|
|
1182
|
+
"required": true,
|
|
1183
|
+
"min_items": 1,
|
|
1184
|
+
"max_items": 7
|
|
1185
|
+
}
|
|
1186
|
+
},
|
|
650
1187
|
"kling-v3-turbo-text-to-video": {
|
|
651
1188
|
"aspect_ratio": {
|
|
652
1189
|
"enum": [
|
|
@@ -691,12 +1228,54 @@ var contract = {
|
|
|
691
1228
|
}
|
|
692
1229
|
},
|
|
693
1230
|
"rules": [
|
|
1231
|
+
{
|
|
1232
|
+
"when": {
|
|
1233
|
+
"model": "kling-3.0"
|
|
1234
|
+
},
|
|
1235
|
+
"forbidden": [
|
|
1236
|
+
"reference_image_urls",
|
|
1237
|
+
"reference_video_url",
|
|
1238
|
+
"reference_video_type",
|
|
1239
|
+
"preserve_reference_video_audio"
|
|
1240
|
+
]
|
|
1241
|
+
},
|
|
1242
|
+
{
|
|
1243
|
+
"when": {
|
|
1244
|
+
"model": "kling-o1"
|
|
1245
|
+
},
|
|
1246
|
+
"forbidden": [
|
|
1247
|
+
"output_resolution",
|
|
1248
|
+
"negative_prompt",
|
|
1249
|
+
"cfg_scale",
|
|
1250
|
+
"multi_shots",
|
|
1251
|
+
"multi_prompt",
|
|
1252
|
+
"first_frame_image_url",
|
|
1253
|
+
"last_frame_image_url",
|
|
1254
|
+
"kling_elements"
|
|
1255
|
+
]
|
|
1256
|
+
},
|
|
1257
|
+
{
|
|
1258
|
+
"when": {
|
|
1259
|
+
"model": "kling-v2.1-master-text-to-video"
|
|
1260
|
+
},
|
|
1261
|
+
"forbidden": [
|
|
1262
|
+
"mode",
|
|
1263
|
+
"reference_image_urls",
|
|
1264
|
+
"reference_video_url",
|
|
1265
|
+
"reference_video_type",
|
|
1266
|
+
"preserve_reference_video_audio"
|
|
1267
|
+
]
|
|
1268
|
+
},
|
|
694
1269
|
{
|
|
695
1270
|
"when": {
|
|
696
1271
|
"model": "kling-v2.5-turbo-text-to-video-pro"
|
|
697
1272
|
},
|
|
698
1273
|
"forbidden": [
|
|
699
|
-
"mode"
|
|
1274
|
+
"mode",
|
|
1275
|
+
"reference_image_urls",
|
|
1276
|
+
"reference_video_url",
|
|
1277
|
+
"reference_video_type",
|
|
1278
|
+
"preserve_reference_video_audio"
|
|
700
1279
|
]
|
|
701
1280
|
},
|
|
702
1281
|
{
|
|
@@ -711,7 +1290,11 @@ var contract = {
|
|
|
711
1290
|
"multi_prompt",
|
|
712
1291
|
"first_frame_image_url",
|
|
713
1292
|
"last_frame_image_url",
|
|
714
|
-
"kling_elements"
|
|
1293
|
+
"kling_elements",
|
|
1294
|
+
"reference_image_urls",
|
|
1295
|
+
"reference_video_url",
|
|
1296
|
+
"reference_video_type",
|
|
1297
|
+
"preserve_reference_video_audio"
|
|
715
1298
|
]
|
|
716
1299
|
},
|
|
717
1300
|
{
|
|
@@ -725,7 +1308,11 @@ var contract = {
|
|
|
725
1308
|
"multi_prompt",
|
|
726
1309
|
"first_frame_image_url",
|
|
727
1310
|
"last_frame_image_url",
|
|
728
|
-
"kling_elements"
|
|
1311
|
+
"kling_elements",
|
|
1312
|
+
"reference_image_urls",
|
|
1313
|
+
"reference_video_url",
|
|
1314
|
+
"reference_video_type",
|
|
1315
|
+
"preserve_reference_video_audio"
|
|
729
1316
|
]
|
|
730
1317
|
},
|
|
731
1318
|
{
|
|
@@ -740,13 +1327,227 @@ var contract = {
|
|
|
740
1327
|
"multi_prompt",
|
|
741
1328
|
"first_frame_image_url",
|
|
742
1329
|
"last_frame_image_url",
|
|
743
|
-
"kling_elements"
|
|
1330
|
+
"kling_elements",
|
|
1331
|
+
"reference_image_urls",
|
|
1332
|
+
"reference_video_url",
|
|
1333
|
+
"reference_video_type",
|
|
1334
|
+
"preserve_reference_video_audio"
|
|
744
1335
|
]
|
|
745
1336
|
}
|
|
746
1337
|
]
|
|
747
1338
|
}
|
|
748
1339
|
};
|
|
749
1340
|
|
|
1341
|
+
// src/resources/o1-reference-validation.ts
|
|
1342
|
+
var import_core = require("@runapi.ai/core");
|
|
1343
|
+
var O1_MODEL = "kling-o1";
|
|
1344
|
+
var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([".jpg", ".jpeg", ".png"]);
|
|
1345
|
+
var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set([".mp4", ".mov"]);
|
|
1346
|
+
var BLOCKED_IP_CIDRS = [
|
|
1347
|
+
"0.0.0.0/8",
|
|
1348
|
+
"10.0.0.0/8",
|
|
1349
|
+
"100.64.0.0/10",
|
|
1350
|
+
"127.0.0.0/8",
|
|
1351
|
+
"169.254.0.0/16",
|
|
1352
|
+
"172.16.0.0/12",
|
|
1353
|
+
"192.0.0.0/24",
|
|
1354
|
+
"192.0.2.0/24",
|
|
1355
|
+
"192.88.99.0/24",
|
|
1356
|
+
"192.168.0.0/16",
|
|
1357
|
+
"198.18.0.0/15",
|
|
1358
|
+
"198.51.100.0/24",
|
|
1359
|
+
"203.0.113.0/24",
|
|
1360
|
+
"224.0.0.0/4",
|
|
1361
|
+
"240.0.0.0/4",
|
|
1362
|
+
"255.255.255.255/32",
|
|
1363
|
+
"::/128",
|
|
1364
|
+
"::1/128",
|
|
1365
|
+
"64:ff9b::/96",
|
|
1366
|
+
"64:ff9b:1::/48",
|
|
1367
|
+
"100::/64",
|
|
1368
|
+
"2001::/32",
|
|
1369
|
+
"2001:2::/48",
|
|
1370
|
+
"2001:db8::/32",
|
|
1371
|
+
"2002::/16",
|
|
1372
|
+
"3fff::/20",
|
|
1373
|
+
"fc00::/7",
|
|
1374
|
+
"fe80::/10",
|
|
1375
|
+
"ff00::/8"
|
|
1376
|
+
];
|
|
1377
|
+
var BLOCKED_IP_NETWORKS = BLOCKED_IP_CIDRS.map((cidr) => {
|
|
1378
|
+
const [address, prefixText] = cidr.split("/");
|
|
1379
|
+
const parsed = parseIpLiteral(address);
|
|
1380
|
+
if (!parsed) throw new Error("Invalid blocked IP range: " + cidr);
|
|
1381
|
+
return { ...parsed, prefix: Number(prefixText) };
|
|
1382
|
+
});
|
|
1383
|
+
function validateKlingO1References(body) {
|
|
1384
|
+
if (body.model !== O1_MODEL) return;
|
|
1385
|
+
if (body.enable_sound === true) {
|
|
1386
|
+
throw new import_core.ValidationError(`enable_sound is not supported by ${O1_MODEL}`);
|
|
1387
|
+
}
|
|
1388
|
+
validateFrameUrls(body);
|
|
1389
|
+
if (typeof body.prompt !== "string") {
|
|
1390
|
+
throw new import_core.ValidationError("prompt must be a string");
|
|
1391
|
+
}
|
|
1392
|
+
const prompt = body.prompt;
|
|
1393
|
+
const referenceImages = Array.isArray(body.reference_image_urls) ? body.reference_image_urls : [];
|
|
1394
|
+
if ("reference_video_url" in body && typeof body.reference_video_url !== "string") {
|
|
1395
|
+
throw new import_core.ValidationError("reference_video_url must be a string");
|
|
1396
|
+
}
|
|
1397
|
+
const referenceVideoUrl = body.reference_video_url;
|
|
1398
|
+
if (present(body.last_frame_image_url) && (referenceImages.length > 0 || present(referenceVideoUrl))) {
|
|
1399
|
+
throw new import_core.ValidationError(
|
|
1400
|
+
"last_frame_image_url cannot be combined with reference_image_urls or reference_video_url"
|
|
1401
|
+
);
|
|
1402
|
+
}
|
|
1403
|
+
if (referenceVideoUrl && referenceImages.length > 4) {
|
|
1404
|
+
throw new import_core.ValidationError(
|
|
1405
|
+
"reference_image_urls must contain at most 4 items when reference_video_url is present"
|
|
1406
|
+
);
|
|
1407
|
+
}
|
|
1408
|
+
validateReferenceImages(prompt, referenceImages);
|
|
1409
|
+
validateReferenceVideo(body, prompt, referenceVideoUrl);
|
|
1410
|
+
}
|
|
1411
|
+
function validateFrameUrls(body) {
|
|
1412
|
+
for (const field of ["first_frame_image_url", "last_frame_image_url"]) {
|
|
1413
|
+
const value = body[field];
|
|
1414
|
+
if (typeof value !== "string" || value.length === 0) continue;
|
|
1415
|
+
if (!isPublicHttpUrl(value)) {
|
|
1416
|
+
throw new import_core.ValidationError(`${field} must be a public HTTP or HTTPS URL`);
|
|
1417
|
+
}
|
|
1418
|
+
if (!IMAGE_EXTENSIONS.has(urlExtension(value))) {
|
|
1419
|
+
throw new import_core.ValidationError(`${field} must use a JPG, JPEG, or PNG URL`);
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
function validateReferenceImages(prompt, urls) {
|
|
1424
|
+
urls.forEach((url, index) => {
|
|
1425
|
+
if (typeof url !== "string") {
|
|
1426
|
+
throw new import_core.ValidationError(`reference_image_urls[${index}] must be a string`);
|
|
1427
|
+
}
|
|
1428
|
+
if (!isPublicHttpUrl(url)) {
|
|
1429
|
+
throw new import_core.ValidationError(
|
|
1430
|
+
`reference_image_urls[${index}] must be a public HTTP or HTTPS URL`
|
|
1431
|
+
);
|
|
1432
|
+
}
|
|
1433
|
+
if (!IMAGE_EXTENSIONS.has(urlExtension(url))) {
|
|
1434
|
+
throw new import_core.ValidationError(
|
|
1435
|
+
`reference_image_urls[${index}] must use a JPG, JPEG, or PNG URL`
|
|
1436
|
+
);
|
|
1437
|
+
}
|
|
1438
|
+
const marker = `<<<image_${index + 1}>>>`;
|
|
1439
|
+
if (!prompt.includes(marker)) {
|
|
1440
|
+
throw new import_core.ValidationError(
|
|
1441
|
+
`prompt must reference reference_image_urls[${index}] as ${marker}`
|
|
1442
|
+
);
|
|
1443
|
+
}
|
|
1444
|
+
});
|
|
1445
|
+
for (const match of prompt.matchAll(/<<<image_(\d+)>>>/g)) {
|
|
1446
|
+
const index = Number(match[1]);
|
|
1447
|
+
if (index < 1 || index > urls.length) {
|
|
1448
|
+
throw new import_core.ValidationError(`prompt references missing image_${index}`);
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
function validateReferenceVideo(body, prompt, referenceVideoUrl) {
|
|
1453
|
+
if (!referenceVideoUrl) {
|
|
1454
|
+
if ("reference_video_type" in body) {
|
|
1455
|
+
throw new import_core.ValidationError("reference_video_type requires reference_video_url");
|
|
1456
|
+
}
|
|
1457
|
+
if ("preserve_reference_video_audio" in body) {
|
|
1458
|
+
throw new import_core.ValidationError("preserve_reference_video_audio requires reference_video_url");
|
|
1459
|
+
}
|
|
1460
|
+
const missingMarker = prompt.match(/<<<video_([^>]+)>>>/);
|
|
1461
|
+
if (missingMarker) {
|
|
1462
|
+
throw new import_core.ValidationError(`prompt references missing video_${missingMarker[1]}`);
|
|
1463
|
+
}
|
|
1464
|
+
return;
|
|
1465
|
+
}
|
|
1466
|
+
if (!isPublicHttpUrl(referenceVideoUrl)) {
|
|
1467
|
+
throw new import_core.ValidationError("reference_video_url must be a public HTTP or HTTPS URL");
|
|
1468
|
+
}
|
|
1469
|
+
if (!VIDEO_EXTENSIONS.has(urlExtension(referenceVideoUrl))) {
|
|
1470
|
+
throw new import_core.ValidationError("reference_video_url must use an MP4 or MOV URL");
|
|
1471
|
+
}
|
|
1472
|
+
if (!prompt.includes("<<<video_1>>>")) {
|
|
1473
|
+
throw new import_core.ValidationError("prompt must reference reference_video_url as <<<video_1>>>");
|
|
1474
|
+
}
|
|
1475
|
+
for (const match of prompt.matchAll(/<<<video_([^>]+)>>>/g)) {
|
|
1476
|
+
if (match[1] !== "1") {
|
|
1477
|
+
throw new import_core.ValidationError("prompt may only reference video_1");
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
const referenceVideoType = body.reference_video_type ?? "base";
|
|
1481
|
+
if (referenceVideoType === "base" && (present(body.first_frame_image_url) || present(body.last_frame_image_url))) {
|
|
1482
|
+
throw new import_core.ValidationError(
|
|
1483
|
+
"reference_video_type base cannot be combined with first_frame_image_url or last_frame_image_url"
|
|
1484
|
+
);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
function present(value) {
|
|
1488
|
+
return typeof value === "string" ? value.trim().length > 0 : value !== void 0 && value !== null;
|
|
1489
|
+
}
|
|
1490
|
+
function urlExtension(value) {
|
|
1491
|
+
try {
|
|
1492
|
+
const path = new URL(value).pathname;
|
|
1493
|
+
const dot = path.lastIndexOf(".");
|
|
1494
|
+
return dot >= 0 ? path.slice(dot).toLowerCase() : "";
|
|
1495
|
+
} catch {
|
|
1496
|
+
return "";
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
function isPublicHttpUrl(value) {
|
|
1500
|
+
try {
|
|
1501
|
+
const url = new URL(value);
|
|
1502
|
+
return (url.protocol === "http:" || url.protocol === "https:") && url.hostname.length > 0 && url.username.length === 0 && url.password.length === 0 && !isBlockedHost(url.hostname);
|
|
1503
|
+
} catch {
|
|
1504
|
+
return false;
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
function isBlockedHost(hostname) {
|
|
1508
|
+
const host = hostname.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");
|
|
1509
|
+
if (host === "localhost" || host.endsWith(".localhost")) return true;
|
|
1510
|
+
const parsed = parseIpLiteral(host);
|
|
1511
|
+
if (!parsed) return false;
|
|
1512
|
+
return BLOCKED_IP_NETWORKS.some((network) => {
|
|
1513
|
+
if (network.bits !== parsed.bits) return false;
|
|
1514
|
+
const shift = BigInt(parsed.bits - network.prefix);
|
|
1515
|
+
return parsed.value >> shift === network.value >> shift;
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
function parseIpLiteral(value) {
|
|
1519
|
+
const ipv4 = parseIpv4(value);
|
|
1520
|
+
if (ipv4 !== void 0) return { bits: 32, value: ipv4 };
|
|
1521
|
+
if (!value.includes(":")) return void 0;
|
|
1522
|
+
const halves = value.toLowerCase().split("::");
|
|
1523
|
+
if (halves.length > 2) return void 0;
|
|
1524
|
+
const head = parseIpv6Half(halves[0]);
|
|
1525
|
+
const tail = parseIpv6Half(halves[1] ?? "");
|
|
1526
|
+
if (!head || !tail) return void 0;
|
|
1527
|
+
const compressed = halves.length === 2;
|
|
1528
|
+
const missing = 8 - head.length - tail.length;
|
|
1529
|
+
if (!compressed && missing !== 0 || compressed && missing < 1) return void 0;
|
|
1530
|
+
const segments = [...head, ...Array(missing).fill(0), ...tail];
|
|
1531
|
+
const address = segments.reduce((result, segment) => result << 16n | BigInt(segment), 0n);
|
|
1532
|
+
if (address >> 32n === 0xffffn) {
|
|
1533
|
+
return { bits: 32, value: address & 0xffffffffn };
|
|
1534
|
+
}
|
|
1535
|
+
return { bits: 128, value: address };
|
|
1536
|
+
}
|
|
1537
|
+
function parseIpv4(value) {
|
|
1538
|
+
const parts = value.split(".");
|
|
1539
|
+
if (parts.length !== 4 || parts.some((part) => !/^\d+$/.test(part))) return void 0;
|
|
1540
|
+
const octets = parts.map(Number);
|
|
1541
|
+
if (octets.some((octet) => octet < 0 || octet > 255)) return void 0;
|
|
1542
|
+
return octets.reduce((result, octet) => result << 8n | BigInt(octet), 0n);
|
|
1543
|
+
}
|
|
1544
|
+
function parseIpv6Half(value) {
|
|
1545
|
+
if (value === "") return [];
|
|
1546
|
+
const parts = value.split(":");
|
|
1547
|
+
if (parts.some((part) => !/^[0-9a-f]{1,4}$/.test(part))) return void 0;
|
|
1548
|
+
return parts.map((part) => Number.parseInt(part, 16));
|
|
1549
|
+
}
|
|
1550
|
+
|
|
750
1551
|
// src/resources/text-to-video.ts
|
|
751
1552
|
var ENDPOINT = "/api/v1/kling/text_to_video";
|
|
752
1553
|
var V26_MODEL = "kling-v2.6";
|
|
@@ -787,10 +1588,11 @@ var TextToVideo = class {
|
|
|
787
1588
|
* @returns The task creation result with id.
|
|
788
1589
|
*/
|
|
789
1590
|
async create(params, options) {
|
|
790
|
-
const body = (0,
|
|
1591
|
+
const body = (0, import_core2.compactParams)(params);
|
|
791
1592
|
rejectUnsupportedV3TurboFields(body);
|
|
792
|
-
(0,
|
|
1593
|
+
(0, import_core2.validateParams)(contract["text-to-video"], body);
|
|
793
1594
|
validateV26Params(body);
|
|
1595
|
+
validateKlingO1References(body);
|
|
794
1596
|
return this.http.request("POST", ENDPOINT, {
|
|
795
1597
|
body,
|
|
796
1598
|
...options
|
|
@@ -811,14 +1613,14 @@ var TextToVideo = class {
|
|
|
811
1613
|
function validateV26Params(body) {
|
|
812
1614
|
if (body.model !== V26_MODEL) return;
|
|
813
1615
|
if (body.enable_sound === true && body.mode !== "pro") {
|
|
814
|
-
throw new
|
|
1616
|
+
throw new import_core2.ValidationError(`enable_sound requires mode pro for ${V26_MODEL}`);
|
|
815
1617
|
}
|
|
816
1618
|
}
|
|
817
1619
|
function rejectUnsupportedV3TurboFields(body) {
|
|
818
1620
|
if (body.model !== V3_TURBO_MODEL) return;
|
|
819
1621
|
const field = V3_TURBO_UNSUPPORTED_FIELDS.find((candidate) => fieldPresent(body, candidate));
|
|
820
1622
|
if (field) {
|
|
821
|
-
throw new
|
|
1623
|
+
throw new import_core2.ValidationError(`${field} is not supported by ${V3_TURBO_MODEL}`);
|
|
822
1624
|
}
|
|
823
1625
|
}
|
|
824
1626
|
function fieldPresent(params, field) {
|
|
@@ -838,7 +1640,7 @@ function presentValue(value) {
|
|
|
838
1640
|
}
|
|
839
1641
|
|
|
840
1642
|
// src/resources/image-to-video.ts
|
|
841
|
-
var
|
|
1643
|
+
var import_core3 = require("@runapi.ai/core");
|
|
842
1644
|
var import_internal2 = require("@runapi.ai/core/internal");
|
|
843
1645
|
var ENDPOINT2 = "/api/v1/kling/image_to_video";
|
|
844
1646
|
var V26_MODEL2 = "kling-v2.6";
|
|
@@ -876,11 +1678,12 @@ var ImageToVideo = class {
|
|
|
876
1678
|
* @returns The task creation result with id.
|
|
877
1679
|
*/
|
|
878
1680
|
async create(params, options) {
|
|
879
|
-
const body = (0,
|
|
1681
|
+
const body = (0, import_core3.compactParams)(params);
|
|
880
1682
|
rejectUnsupportedV3TurboFields2(body);
|
|
881
|
-
(0,
|
|
1683
|
+
(0, import_core3.validateParams)(contract["image-to-video"], body);
|
|
882
1684
|
validateV26Params2(body);
|
|
883
1685
|
validateV3OmniFields(body);
|
|
1686
|
+
validateKlingO1References(body);
|
|
884
1687
|
return this.http.request("POST", ENDPOINT2, {
|
|
885
1688
|
body,
|
|
886
1689
|
...options
|
|
@@ -901,27 +1704,27 @@ var ImageToVideo = class {
|
|
|
901
1704
|
function validateV26Params2(body) {
|
|
902
1705
|
if (body.model !== V26_MODEL2) return;
|
|
903
1706
|
if (body.enable_sound === true && body.mode !== "pro") {
|
|
904
|
-
throw new
|
|
1707
|
+
throw new import_core3.ValidationError(`enable_sound requires mode pro for ${V26_MODEL2}`);
|
|
905
1708
|
}
|
|
906
1709
|
if (!fieldPresent2(body, "last_frame_image_url")) return;
|
|
907
1710
|
if (body.mode !== "pro") {
|
|
908
|
-
throw new
|
|
1711
|
+
throw new import_core3.ValidationError(`last_frame_image_url requires mode pro for ${V26_MODEL2}`);
|
|
909
1712
|
}
|
|
910
1713
|
if (body.duration_seconds !== void 0 && body.duration_seconds !== 5) {
|
|
911
|
-
throw new
|
|
1714
|
+
throw new import_core3.ValidationError(`last_frame_image_url requires duration_seconds 5 for ${V26_MODEL2}`);
|
|
912
1715
|
}
|
|
913
1716
|
}
|
|
914
1717
|
function validateV3OmniFields(body) {
|
|
915
1718
|
if (body.model !== V3_OMNI_MODEL || !fieldPresent2(body, "last_frame_image_url")) return;
|
|
916
1719
|
if ((body.duration_seconds ?? 5) !== 5) {
|
|
917
|
-
throw new
|
|
1720
|
+
throw new import_core3.ValidationError(`last_frame_image_url requires duration_seconds 5 for ${V3_OMNI_MODEL}`);
|
|
918
1721
|
}
|
|
919
1722
|
}
|
|
920
1723
|
function rejectUnsupportedV3TurboFields2(body) {
|
|
921
1724
|
if (body.model !== V3_TURBO_MODEL2) return;
|
|
922
1725
|
const field = V3_TURBO_UNSUPPORTED_FIELDS2.find((candidate) => fieldPresent2(body, candidate));
|
|
923
1726
|
if (field) {
|
|
924
|
-
throw new
|
|
1727
|
+
throw new import_core3.ValidationError(`${field} is not supported by ${V3_TURBO_MODEL2}`);
|
|
925
1728
|
}
|
|
926
1729
|
}
|
|
927
1730
|
function fieldPresent2(params, field) {
|
|
@@ -941,7 +1744,7 @@ function presentValue2(value) {
|
|
|
941
1744
|
}
|
|
942
1745
|
|
|
943
1746
|
// src/resources/ai-avatar.ts
|
|
944
|
-
var
|
|
1747
|
+
var import_core4 = require("@runapi.ai/core");
|
|
945
1748
|
var import_internal3 = require("@runapi.ai/core/internal");
|
|
946
1749
|
var ENDPOINT3 = "/api/v1/kling/ai_avatar";
|
|
947
1750
|
var AiAvatar = class {
|
|
@@ -970,8 +1773,8 @@ var AiAvatar = class {
|
|
|
970
1773
|
* @returns The task creation result with id.
|
|
971
1774
|
*/
|
|
972
1775
|
async create(params, options) {
|
|
973
|
-
const body = (0,
|
|
974
|
-
(0,
|
|
1776
|
+
const body = (0, import_core4.compactParams)(params);
|
|
1777
|
+
(0, import_core4.validateParams)(contract["avatar"], body);
|
|
975
1778
|
return this.http.request("POST", ENDPOINT3, {
|
|
976
1779
|
body,
|
|
977
1780
|
...options
|
|
@@ -991,7 +1794,7 @@ var AiAvatar = class {
|
|
|
991
1794
|
};
|
|
992
1795
|
|
|
993
1796
|
// src/resources/motion-control.ts
|
|
994
|
-
var
|
|
1797
|
+
var import_core5 = require("@runapi.ai/core");
|
|
995
1798
|
var import_internal4 = require("@runapi.ai/core/internal");
|
|
996
1799
|
var ENDPOINT4 = "/api/v1/kling/motion_control";
|
|
997
1800
|
var MotionControl = class {
|
|
@@ -1020,8 +1823,8 @@ var MotionControl = class {
|
|
|
1020
1823
|
* @returns The task creation result with id.
|
|
1021
1824
|
*/
|
|
1022
1825
|
async create(params, options) {
|
|
1023
|
-
const body = (0,
|
|
1024
|
-
(0,
|
|
1826
|
+
const body = (0, import_core5.compactParams)(params);
|
|
1827
|
+
(0, import_core5.validateParams)(contract["motion-control"], body);
|
|
1025
1828
|
return this.http.request("POST", ENDPOINT4, {
|
|
1026
1829
|
body,
|
|
1027
1830
|
...options
|
|
@@ -1041,7 +1844,7 @@ var MotionControl = class {
|
|
|
1041
1844
|
};
|
|
1042
1845
|
|
|
1043
1846
|
// src/resources/extend-video.ts
|
|
1044
|
-
var
|
|
1847
|
+
var import_core6 = require("@runapi.ai/core");
|
|
1045
1848
|
var import_internal5 = require("@runapi.ai/core/internal");
|
|
1046
1849
|
var ENDPOINT5 = "/api/v1/kling/extend_video";
|
|
1047
1850
|
var ExtendVideo = class {
|
|
@@ -1057,8 +1860,8 @@ var ExtendVideo = class {
|
|
|
1057
1860
|
});
|
|
1058
1861
|
}
|
|
1059
1862
|
async create(params, options) {
|
|
1060
|
-
const body = (0,
|
|
1061
|
-
(0,
|
|
1863
|
+
const body = (0, import_core6.compactParams)(params);
|
|
1864
|
+
(0, import_core6.validateParams)(contract["extend-video"], body);
|
|
1062
1865
|
return this.http.request("POST", ENDPOINT5, { body, ...options });
|
|
1063
1866
|
}
|
|
1064
1867
|
async get(id, options) {
|
|
@@ -1066,8 +1869,34 @@ var ExtendVideo = class {
|
|
|
1066
1869
|
}
|
|
1067
1870
|
};
|
|
1068
1871
|
|
|
1872
|
+
// src/resources/edit-video.ts
|
|
1873
|
+
var import_core7 = require("@runapi.ai/core");
|
|
1874
|
+
var import_internal6 = require("@runapi.ai/core/internal");
|
|
1875
|
+
var ENDPOINT6 = "/api/v1/kling/edit_video";
|
|
1876
|
+
var EditVideo = class {
|
|
1877
|
+
constructor(http) {
|
|
1878
|
+
this.http = http;
|
|
1879
|
+
}
|
|
1880
|
+
http;
|
|
1881
|
+
async run(params, options) {
|
|
1882
|
+
const { id } = await this.create(params, options);
|
|
1883
|
+
return (0, import_internal6.pollUntilComplete)(() => this.get(id, options), {
|
|
1884
|
+
maxWaitMs: options?.maxWaitMs,
|
|
1885
|
+
pollIntervalMs: options?.pollIntervalMs
|
|
1886
|
+
});
|
|
1887
|
+
}
|
|
1888
|
+
async create(params, options) {
|
|
1889
|
+
const body = (0, import_core7.compactParams)(params);
|
|
1890
|
+
(0, import_core7.validateParams)(contract["edit-video"], body);
|
|
1891
|
+
return this.http.request("POST", ENDPOINT6, { body, ...options });
|
|
1892
|
+
}
|
|
1893
|
+
async get(id, options) {
|
|
1894
|
+
return this.http.request("GET", `${ENDPOINT6}/${id}`, { ...options });
|
|
1895
|
+
}
|
|
1896
|
+
};
|
|
1897
|
+
|
|
1069
1898
|
// src/client.ts
|
|
1070
|
-
var KlingClient = class extends
|
|
1899
|
+
var KlingClient = class extends import_core8.BaseClient {
|
|
1071
1900
|
/** Text-to-video generation with multi-shot, sound, and Kling elements support on kling-3.0. */
|
|
1072
1901
|
textToVideo;
|
|
1073
1902
|
/** Image-to-video animation from a first-frame image guided by a text prompt. */
|
|
@@ -1077,6 +1906,8 @@ var KlingClient = class extends import_core6.BaseClient {
|
|
|
1077
1906
|
/** Transfer motion from a reference video onto a subject image. */
|
|
1078
1907
|
motionControl;
|
|
1079
1908
|
extendVideo;
|
|
1909
|
+
/** Edit a source video with the selected Kling v3 Omni model. */
|
|
1910
|
+
editVideo;
|
|
1080
1911
|
constructor(options = {}) {
|
|
1081
1912
|
super(options);
|
|
1082
1913
|
this.textToVideo = new TextToVideo(this.http);
|
|
@@ -1084,11 +1915,12 @@ var KlingClient = class extends import_core6.BaseClient {
|
|
|
1084
1915
|
this.aiAvatar = new AiAvatar(this.http);
|
|
1085
1916
|
this.motionControl = new MotionControl(this.http);
|
|
1086
1917
|
this.extendVideo = new ExtendVideo(this.http);
|
|
1918
|
+
this.editVideo = new EditVideo(this.http);
|
|
1087
1919
|
}
|
|
1088
1920
|
};
|
|
1089
1921
|
|
|
1090
1922
|
// src/index.ts
|
|
1091
|
-
var
|
|
1923
|
+
var import_core9 = require("@runapi.ai/core");
|
|
1092
1924
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1093
1925
|
0 && (module.exports = {
|
|
1094
1926
|
AuthenticationError,
|