@runapi.ai/kling 0.2.13 → 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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The Kling JavaScript SDK is the language-specific package for Kling on RunAPI. Use this package for video generation, animation, and video editing workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in JavaScript.
4
4
 
5
- This README is the JavaScript package guide inside the public `kling-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/kling; for API reference, use https://runapi.ai/docs#kling; for SDK docs, use https://runapi.ai/docs#sdk-kling.
5
+ This README is the JavaScript package guide inside the public `kling-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/kling; for API reference, use https://runapi.ai/docs/api/kling/text-to-video; for SDK docs, use https://runapi.ai/docs/resources/sdks.
6
6
 
7
7
  ## Install
8
8
 
@@ -17,7 +17,7 @@ import { KlingClient } from '@runapi.ai/kling';
17
17
 
18
18
  const client = new KlingClient();
19
19
  const task = await client.textToVideo.create({
20
- // Pass the Kling JSON request body from https://runapi.ai/docs#kling.
20
+ // Pass the Kling JSON request body from https://runapi.ai/docs/api/kling/text-to-video.
21
21
  });
22
22
  const status = await client.textToVideo.get(task.id);
23
23
  ```
@@ -39,19 +39,23 @@ const result = await client.textToVideo.run({
39
39
 
40
40
  Number reference images in prompt order as `<<<image_1>>>`, `<<<image_2>>>`, and so on; the optional video is `<<<video_1>>>`. With a video, send at most four images. Do not combine `last_frame_image_url` with reference images or a reference video. A `feature` reference video may be used with the required first frame; `base` cannot be combined with frame inputs. O1 requests are five seconds and keep sound disabled. Pricing and limits: https://runapi.ai/models/kling/o1.
41
41
 
42
+ ## Kling V3 Omni source-video editing
43
+
44
+ Use `kling-v3-omni-reference` with `textToVideo` for image-only reference inputs. For a source video, use `editVideo` with either `kling-v3-omni-reference` or `kling-v3-omni-edit`. The reference model keeps sound disabled for source-video requests.
45
+
42
46
  Use `create` when you want to submit a task and return quickly, `get` when you need the latest task state, and `run` when a script should create and poll until completion. In web request handlers, prefer `create` plus webhook or later `get` polling so a worker is not held open.
43
47
 
44
48
  RunAPI-generated file URLs are temporary. Download and store generated images, videos, audio, or other files in your own durable storage within 7 days; do not treat returned URLs as long-term assets.
45
49
 
46
50
  ## Language notes
47
51
 
48
- Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building video applications. The available resources are `textToVideo`, `imageToVideo`, `aiAvatar`, and `motionControl`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
52
+ Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building video applications. The available resources are `textToVideo`, `editVideo`, `imageToVideo`, `aiAvatar`, and `motionControl`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
49
53
 
50
54
  ## Links
51
55
 
52
56
  - Model page: https://runapi.ai/models/kling
53
- - SDK docs: https://runapi.ai/docs#sdk-kling
54
- - Product docs: https://runapi.ai/docs#kling
57
+ - SDK docs: https://runapi.ai/docs/resources/sdks
58
+ - Product docs: https://runapi.ai/docs/api/kling/text-to-video
55
59
  - Pricing and rate limits: https://runapi.ai/models/kling/3.0
56
60
  - Provider comparison: https://runapi.ai/providers/kuaishou
57
61
  - Full catalog: https://runapi.ai/models
package/dist/index.d.mts CHANGED
@@ -9,6 +9,7 @@ declare const modelValues: {
9
9
  readonly KLING_V2_5_TURBO_TEXT_TO_VIDEO_PRO: "kling-v2.5-turbo-text-to-video-pro";
10
10
  readonly KLING_V2_6: "kling-v2.6";
11
11
  readonly KLING_V3_OMNI: "kling-v3-omni";
12
+ readonly KLING_V3_OMNI_REFERENCE: "kling-v3-omni-reference";
12
13
  readonly KLING_V3_TURBO_TEXT_TO_VIDEO: "kling-v3-turbo-text-to-video";
13
14
  };
14
15
  readonly imageToVideo: {
@@ -21,6 +22,10 @@ declare const modelValues: {
21
22
  readonly KLING_V3_OMNI: "kling-v3-omni";
22
23
  readonly KLING_V3_TURBO_IMAGE_TO_VIDEO: "kling-v3-turbo-image-to-video";
23
24
  };
25
+ readonly editVideo: {
26
+ readonly KLING_V3_OMNI_EDIT: "kling-v3-omni-edit";
27
+ readonly KLING_V3_OMNI_REFERENCE: "kling-v3-omni-reference";
28
+ };
24
29
  readonly avatar: {
25
30
  readonly KLING_AI_AVATAR_PRO: "kling-ai-avatar-pro";
26
31
  readonly KLING_AI_AVATAR_STANDARD: "kling-ai-avatar-standard";
@@ -41,6 +46,8 @@ type KlingTextToVideoModel = (typeof modelValues.textToVideo)[keyof typeof model
41
46
  /** Earlier V2 image-to-video variants. V2.5 turbo and V2.1 pro support last-frame image control. */
42
47
  type KlingV2ImageToVideoModel = (typeof modelValues.imageToVideo.KLING_V2_5_TURBO_IMAGE_TO_VIDEO_PRO) | (typeof modelValues.imageToVideo.KLING_V2_1_PRO) | (typeof modelValues.imageToVideo.KLING_V2_1_STANDARD) | (typeof modelValues.imageToVideo.KLING_V2_1_MASTER_IMAGE_TO_VIDEO);
43
48
  type KlingImageToVideoModel = (typeof modelValues.imageToVideo)[keyof typeof modelValues.imageToVideo];
49
+ /** Model variants for source-video editing. */
50
+ type KlingEditVideoModel = (typeof modelValues.editVideo)[keyof typeof modelValues.editVideo];
44
51
  /** Output resolution for text-to-video. 4k is highest quality but slowest. */
45
52
  type KlingTextToVideoOutputResolution = '720p' | '1080p' | '4k';
46
53
  type KlingV3TurboOutputResolution = '720p' | '1080p';
@@ -178,6 +185,17 @@ interface V3OmniTextToVideoParams {
178
185
  aspect_ratio?: KlingAspectRatio;
179
186
  callback_url?: string;
180
187
  }
188
+ /** Kling v3 Omni reference generation from one to seven reference images. */
189
+ interface V3OmniReferenceTextToVideoParams {
190
+ model: (typeof modelValues.textToVideo.KLING_V3_OMNI_REFERENCE);
191
+ prompt: string;
192
+ reference_image_urls: string[];
193
+ duration_seconds?: KlingDuration;
194
+ output_resolution?: KlingTextToVideoOutputResolution;
195
+ aspect_ratio: KlingAspectRatio;
196
+ enable_sound?: boolean;
197
+ callback_url?: string;
198
+ }
181
199
  /**
182
200
  * Earlier V2 image-to-video parameters. A first-frame image is required; the model
183
201
  * animates it into video guided by the text prompt. last_frame_image_url is supported
@@ -245,7 +263,7 @@ interface V3OmniImageToVideoParams {
245
263
  aspect_ratio?: KlingAspectRatio;
246
264
  callback_url?: string;
247
265
  }
248
- type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | KlingV26TextToVideoParams | KlingO1TextToVideoParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams | V3TurboTextToVideoParams | V3OmniTextToVideoParams;
266
+ type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | KlingV26TextToVideoParams | KlingO1TextToVideoParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams | V3TurboTextToVideoParams | V3OmniTextToVideoParams | V3OmniReferenceTextToVideoParams;
249
267
  type ImageToVideoParams = V2ImageToVideoParams | KlingV26ImageToVideoParams | KlingO1ImageToVideoParams | V3TurboImageToVideoParams | V3OmniImageToVideoParams;
250
268
  /** Continue a completed Kling V2.5 Turbo video task. */
251
269
  interface KlingExtendVideoParams {
@@ -254,6 +272,28 @@ interface KlingExtendVideoParams {
254
272
  prompt?: string;
255
273
  callback_url?: string;
256
274
  }
275
+ /** Parameters for Kling v3 Omni source-video editing. */
276
+ interface EditVideoParams {
277
+ model: KlingEditVideoModel;
278
+ /** Video description prompt. */
279
+ prompt: string;
280
+ /** Caller-owned source video URL. Mutually exclusive with source_task_id. */
281
+ source_video_url?: string;
282
+ /** Completed compatible RunAPI task ID. Mutually exclusive with source_video_url. */
283
+ source_task_id?: string;
284
+ /** Ordered reference image URLs. */
285
+ reference_image_urls?: string[];
286
+ /** Output duration in seconds. Source-only requests use five seconds. */
287
+ duration_seconds?: KlingDuration;
288
+ /** Output resolution. */
289
+ output_resolution?: KlingTextToVideoOutputResolution;
290
+ /** Output aspect ratio. Source-only requests use auto. */
291
+ aspect_ratio?: KlingAspectRatio | 'auto';
292
+ /** Enable synchronized sound generation. */
293
+ enable_sound?: boolean;
294
+ /** URL for completion callback notifications. */
295
+ callback_url?: string;
296
+ }
257
297
  interface AsyncTaskResponse extends TaskResponse {
258
298
  id: string;
259
299
  status: AsyncTaskStatus;
@@ -460,6 +500,14 @@ declare class ExtendVideo {
460
500
  get(id: string, options?: RequestOptions): Promise<TextToVideoResponse>;
461
501
  }
462
502
 
503
+ declare class EditVideo {
504
+ private readonly http;
505
+ constructor(http: HttpClient);
506
+ run(params: EditVideoParams, options?: RequestOptions & PollingOptions): Promise<TextToVideoResponse>;
507
+ create(params: EditVideoParams, options?: RequestOptions): Promise<TaskCreateResponse>;
508
+ get(id: string, options?: RequestOptions): Promise<TextToVideoResponse>;
509
+ }
510
+
463
511
  /**
464
512
  * Kling video generation, AI avatar lip-sync, and motion control API client.
465
513
  *
@@ -483,7 +531,9 @@ declare class KlingClient extends BaseClient {
483
531
  /** Transfer motion from a reference video onto a subject image. */
484
532
  readonly motionControl: MotionControl;
485
533
  readonly extendVideo: ExtendVideo;
534
+ /** Edit a source video with the selected Kling v3 Omni model. */
535
+ readonly editVideo: EditVideo;
486
536
  constructor(options?: ClientOptions);
487
537
  }
488
538
 
489
- export { type AiAvatarModel, type AiAvatarParams, type AiAvatarResponse, type AsyncTaskResponse, type CompletedAiAvatarResponse, type CompletedImageToVideoResponse, type CompletedMotionControlResponse, type CompletedTextToVideoResponse, type ImageToVideoParams, type ImageToVideoResponse, type Kling3MotionControlParams, type Kling3TextToVideoMultiShotParams, type Kling3TextToVideoSingleShotParams, type KlingAspectRatio, KlingClient, type KlingDuration, type KlingElement, type KlingExtendVideoParams, type KlingImageToVideoModel, type KlingO1ImageToVideoParams, type KlingO1ReferenceVideoType, type KlingO1TextToVideoParams, type KlingTextToVideoModel, type KlingTextToVideoOutputResolution, type KlingV26ImageToVideoParams, type KlingV26Mode, type KlingV26MotionControlParams, type KlingV26TextToVideoParams, type KlingV2ImageToVideoModel, type KlingV3TurboOutputResolution, type MotionControlModel, type MotionControlParams, type MotionControlResponse, type MultiPromptItem, type TaskCreateResponse, type TextToVideoParams, type TextToVideoResponse, type V21MasterTextToVideoParams, type V25TurboTextToVideoParams, type V2ImageToVideoParams, type V3OmniImageToVideoParams, type V3OmniTextToVideoParams, type V3TurboImageToVideoParams, type V3TurboTextToVideoParams, type VideoMetadata };
539
+ export { type AiAvatarModel, type AiAvatarParams, type AiAvatarResponse, type AsyncTaskResponse, type CompletedAiAvatarResponse, type CompletedImageToVideoResponse, type CompletedMotionControlResponse, type CompletedTextToVideoResponse, type EditVideoParams, type ImageToVideoParams, type ImageToVideoResponse, type Kling3MotionControlParams, type Kling3TextToVideoMultiShotParams, type Kling3TextToVideoSingleShotParams, type KlingAspectRatio, KlingClient, type KlingDuration, type KlingEditVideoModel, type KlingElement, type KlingExtendVideoParams, type KlingImageToVideoModel, type KlingO1ImageToVideoParams, type KlingO1ReferenceVideoType, type KlingO1TextToVideoParams, type KlingTextToVideoModel, type KlingTextToVideoOutputResolution, type KlingV26ImageToVideoParams, type KlingV26Mode, type KlingV26MotionControlParams, type KlingV26TextToVideoParams, type KlingV2ImageToVideoModel, type KlingV3TurboOutputResolution, type MotionControlModel, type MotionControlParams, type MotionControlResponse, type MultiPromptItem, type TaskCreateResponse, type TextToVideoParams, type TextToVideoResponse, type V21MasterTextToVideoParams, type V25TurboTextToVideoParams, type V2ImageToVideoParams, type V3OmniImageToVideoParams, type V3OmniReferenceTextToVideoParams, type V3OmniTextToVideoParams, type V3TurboImageToVideoParams, type V3TurboTextToVideoParams, type VideoMetadata };
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ declare const modelValues: {
9
9
  readonly KLING_V2_5_TURBO_TEXT_TO_VIDEO_PRO: "kling-v2.5-turbo-text-to-video-pro";
10
10
  readonly KLING_V2_6: "kling-v2.6";
11
11
  readonly KLING_V3_OMNI: "kling-v3-omni";
12
+ readonly KLING_V3_OMNI_REFERENCE: "kling-v3-omni-reference";
12
13
  readonly KLING_V3_TURBO_TEXT_TO_VIDEO: "kling-v3-turbo-text-to-video";
13
14
  };
14
15
  readonly imageToVideo: {
@@ -21,6 +22,10 @@ declare const modelValues: {
21
22
  readonly KLING_V3_OMNI: "kling-v3-omni";
22
23
  readonly KLING_V3_TURBO_IMAGE_TO_VIDEO: "kling-v3-turbo-image-to-video";
23
24
  };
25
+ readonly editVideo: {
26
+ readonly KLING_V3_OMNI_EDIT: "kling-v3-omni-edit";
27
+ readonly KLING_V3_OMNI_REFERENCE: "kling-v3-omni-reference";
28
+ };
24
29
  readonly avatar: {
25
30
  readonly KLING_AI_AVATAR_PRO: "kling-ai-avatar-pro";
26
31
  readonly KLING_AI_AVATAR_STANDARD: "kling-ai-avatar-standard";
@@ -41,6 +46,8 @@ type KlingTextToVideoModel = (typeof modelValues.textToVideo)[keyof typeof model
41
46
  /** Earlier V2 image-to-video variants. V2.5 turbo and V2.1 pro support last-frame image control. */
42
47
  type KlingV2ImageToVideoModel = (typeof modelValues.imageToVideo.KLING_V2_5_TURBO_IMAGE_TO_VIDEO_PRO) | (typeof modelValues.imageToVideo.KLING_V2_1_PRO) | (typeof modelValues.imageToVideo.KLING_V2_1_STANDARD) | (typeof modelValues.imageToVideo.KLING_V2_1_MASTER_IMAGE_TO_VIDEO);
43
48
  type KlingImageToVideoModel = (typeof modelValues.imageToVideo)[keyof typeof modelValues.imageToVideo];
49
+ /** Model variants for source-video editing. */
50
+ type KlingEditVideoModel = (typeof modelValues.editVideo)[keyof typeof modelValues.editVideo];
44
51
  /** Output resolution for text-to-video. 4k is highest quality but slowest. */
45
52
  type KlingTextToVideoOutputResolution = '720p' | '1080p' | '4k';
46
53
  type KlingV3TurboOutputResolution = '720p' | '1080p';
@@ -178,6 +185,17 @@ interface V3OmniTextToVideoParams {
178
185
  aspect_ratio?: KlingAspectRatio;
179
186
  callback_url?: string;
180
187
  }
188
+ /** Kling v3 Omni reference generation from one to seven reference images. */
189
+ interface V3OmniReferenceTextToVideoParams {
190
+ model: (typeof modelValues.textToVideo.KLING_V3_OMNI_REFERENCE);
191
+ prompt: string;
192
+ reference_image_urls: string[];
193
+ duration_seconds?: KlingDuration;
194
+ output_resolution?: KlingTextToVideoOutputResolution;
195
+ aspect_ratio: KlingAspectRatio;
196
+ enable_sound?: boolean;
197
+ callback_url?: string;
198
+ }
181
199
  /**
182
200
  * Earlier V2 image-to-video parameters. A first-frame image is required; the model
183
201
  * animates it into video guided by the text prompt. last_frame_image_url is supported
@@ -245,7 +263,7 @@ interface V3OmniImageToVideoParams {
245
263
  aspect_ratio?: KlingAspectRatio;
246
264
  callback_url?: string;
247
265
  }
248
- type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | KlingV26TextToVideoParams | KlingO1TextToVideoParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams | V3TurboTextToVideoParams | V3OmniTextToVideoParams;
266
+ type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | KlingV26TextToVideoParams | KlingO1TextToVideoParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams | V3TurboTextToVideoParams | V3OmniTextToVideoParams | V3OmniReferenceTextToVideoParams;
249
267
  type ImageToVideoParams = V2ImageToVideoParams | KlingV26ImageToVideoParams | KlingO1ImageToVideoParams | V3TurboImageToVideoParams | V3OmniImageToVideoParams;
250
268
  /** Continue a completed Kling V2.5 Turbo video task. */
251
269
  interface KlingExtendVideoParams {
@@ -254,6 +272,28 @@ interface KlingExtendVideoParams {
254
272
  prompt?: string;
255
273
  callback_url?: string;
256
274
  }
275
+ /** Parameters for Kling v3 Omni source-video editing. */
276
+ interface EditVideoParams {
277
+ model: KlingEditVideoModel;
278
+ /** Video description prompt. */
279
+ prompt: string;
280
+ /** Caller-owned source video URL. Mutually exclusive with source_task_id. */
281
+ source_video_url?: string;
282
+ /** Completed compatible RunAPI task ID. Mutually exclusive with source_video_url. */
283
+ source_task_id?: string;
284
+ /** Ordered reference image URLs. */
285
+ reference_image_urls?: string[];
286
+ /** Output duration in seconds. Source-only requests use five seconds. */
287
+ duration_seconds?: KlingDuration;
288
+ /** Output resolution. */
289
+ output_resolution?: KlingTextToVideoOutputResolution;
290
+ /** Output aspect ratio. Source-only requests use auto. */
291
+ aspect_ratio?: KlingAspectRatio | 'auto';
292
+ /** Enable synchronized sound generation. */
293
+ enable_sound?: boolean;
294
+ /** URL for completion callback notifications. */
295
+ callback_url?: string;
296
+ }
257
297
  interface AsyncTaskResponse extends TaskResponse {
258
298
  id: string;
259
299
  status: AsyncTaskStatus;
@@ -460,6 +500,14 @@ declare class ExtendVideo {
460
500
  get(id: string, options?: RequestOptions): Promise<TextToVideoResponse>;
461
501
  }
462
502
 
503
+ declare class EditVideo {
504
+ private readonly http;
505
+ constructor(http: HttpClient);
506
+ run(params: EditVideoParams, options?: RequestOptions & PollingOptions): Promise<TextToVideoResponse>;
507
+ create(params: EditVideoParams, options?: RequestOptions): Promise<TaskCreateResponse>;
508
+ get(id: string, options?: RequestOptions): Promise<TextToVideoResponse>;
509
+ }
510
+
463
511
  /**
464
512
  * Kling video generation, AI avatar lip-sync, and motion control API client.
465
513
  *
@@ -483,7 +531,9 @@ declare class KlingClient extends BaseClient {
483
531
  /** Transfer motion from a reference video onto a subject image. */
484
532
  readonly motionControl: MotionControl;
485
533
  readonly extendVideo: ExtendVideo;
534
+ /** Edit a source video with the selected Kling v3 Omni model. */
535
+ readonly editVideo: EditVideo;
486
536
  constructor(options?: ClientOptions);
487
537
  }
488
538
 
489
- export { type AiAvatarModel, type AiAvatarParams, type AiAvatarResponse, type AsyncTaskResponse, type CompletedAiAvatarResponse, type CompletedImageToVideoResponse, type CompletedMotionControlResponse, type CompletedTextToVideoResponse, type ImageToVideoParams, type ImageToVideoResponse, type Kling3MotionControlParams, type Kling3TextToVideoMultiShotParams, type Kling3TextToVideoSingleShotParams, type KlingAspectRatio, KlingClient, type KlingDuration, type KlingElement, type KlingExtendVideoParams, type KlingImageToVideoModel, type KlingO1ImageToVideoParams, type KlingO1ReferenceVideoType, type KlingO1TextToVideoParams, type KlingTextToVideoModel, type KlingTextToVideoOutputResolution, type KlingV26ImageToVideoParams, type KlingV26Mode, type KlingV26MotionControlParams, type KlingV26TextToVideoParams, type KlingV2ImageToVideoModel, type KlingV3TurboOutputResolution, type MotionControlModel, type MotionControlParams, type MotionControlResponse, type MultiPromptItem, type TaskCreateResponse, type TextToVideoParams, type TextToVideoResponse, type V21MasterTextToVideoParams, type V25TurboTextToVideoParams, type V2ImageToVideoParams, type V3OmniImageToVideoParams, type V3OmniTextToVideoParams, type V3TurboImageToVideoParams, type V3TurboTextToVideoParams, type VideoMetadata };
539
+ export { type AiAvatarModel, type AiAvatarParams, type AiAvatarResponse, type AsyncTaskResponse, type CompletedAiAvatarResponse, type CompletedImageToVideoResponse, type CompletedMotionControlResponse, type CompletedTextToVideoResponse, type EditVideoParams, type ImageToVideoParams, type ImageToVideoResponse, type Kling3MotionControlParams, type Kling3TextToVideoMultiShotParams, type Kling3TextToVideoSingleShotParams, type KlingAspectRatio, KlingClient, type KlingDuration, type KlingEditVideoModel, type KlingElement, type KlingExtendVideoParams, type KlingImageToVideoModel, type KlingO1ImageToVideoParams, type KlingO1ReferenceVideoType, type KlingO1TextToVideoParams, type KlingTextToVideoModel, type KlingTextToVideoOutputResolution, type KlingV26ImageToVideoParams, type KlingV26Mode, type KlingV26MotionControlParams, type KlingV26TextToVideoParams, type KlingV2ImageToVideoModel, type KlingV3TurboOutputResolution, type MotionControlModel, type MotionControlParams, type MotionControlResponse, type MultiPromptItem, type TaskCreateResponse, type TextToVideoParams, type TextToVideoResponse, type V21MasterTextToVideoParams, type V25TurboTextToVideoParams, type V2ImageToVideoParams, type V3OmniImageToVideoParams, type V3OmniReferenceTextToVideoParams, type V3OmniTextToVideoParams, type V3TurboImageToVideoParams, type V3TurboTextToVideoParams, type VideoMetadata };