@runapi.ai/kling 0.2.8 → 0.2.9
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 +6 -6
- package/dist/index.d.mts +37 -9
- package/dist/index.d.ts +37 -9
- package/dist/index.js +494 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +500 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -4
- package/skills/kling/README.md +3 -1
- package/skills/kling/SKILL.md +5 -0
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Kling
|
|
1
|
+
# Kling API JavaScript SDK for RunAPI
|
|
2
2
|
|
|
3
|
-
The
|
|
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
|
|
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.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -16,10 +16,10 @@ npm install @runapi.ai/kling
|
|
|
16
16
|
import { KlingClient } from '@runapi.ai/kling';
|
|
17
17
|
|
|
18
18
|
const client = new KlingClient();
|
|
19
|
-
const task = await client.
|
|
19
|
+
const task = await client.textToVideo.create({
|
|
20
20
|
// Pass the Kling JSON request body from https://runapi.ai/docs#kling.
|
|
21
21
|
});
|
|
22
|
-
const status = await client.
|
|
22
|
+
const status = await client.textToVideo.get(task.id);
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
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.
|
|
@@ -28,7 +28,7 @@ RunAPI-generated file URLs are temporary. Download and store generated images, v
|
|
|
28
28
|
|
|
29
29
|
## Language notes
|
|
30
30
|
|
|
31
|
-
Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building video applications. The available resources
|
|
31
|
+
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.
|
|
32
32
|
|
|
33
33
|
## Links
|
|
34
34
|
|
package/dist/index.d.mts
CHANGED
|
@@ -5,13 +5,15 @@ export { AuthenticationError, InsufficientCreditsError, NetworkError, NotFoundEr
|
|
|
5
5
|
* Text-to-video model variants. kling-3.0 supports multi-shot, sound, first/last frame images,
|
|
6
6
|
* and Kling elements. V2.x models support negative prompts and cfg_scale instead.
|
|
7
7
|
*/
|
|
8
|
-
type KlingTextToVideoModel = 'kling-3.0' | 'kling-v2.5-turbo-text-to-video-pro' | 'kling-v2.1-master-text-to-video';
|
|
8
|
+
type KlingTextToVideoModel = 'kling-3.0' | 'kling-v3-turbo-text-to-video' | 'kling-v2.5-turbo-text-to-video-pro' | 'kling-v2.1-master-text-to-video';
|
|
9
9
|
/**
|
|
10
10
|
* Image-to-video model variants. V2.5 turbo and V2.1 pro support last-frame image control.
|
|
11
11
|
*/
|
|
12
|
-
type
|
|
12
|
+
type KlingV2ImageToVideoModel = 'kling-v2.5-turbo-image-to-video-pro' | 'kling-v2.1-pro' | 'kling-v2.1-standard' | 'kling-v2.1-master-image-to-video';
|
|
13
|
+
type KlingImageToVideoModel = KlingV2ImageToVideoModel | 'kling-v3-turbo-image-to-video';
|
|
13
14
|
/** Output resolution for text-to-video. 4k is highest quality but slowest. */
|
|
14
15
|
type KlingTextToVideoOutputResolution = '720p' | '1080p' | '4k';
|
|
16
|
+
type KlingV3TurboOutputResolution = '720p' | '1080p';
|
|
15
17
|
type KlingAspectRatio = '16:9' | '9:16' | '1:1';
|
|
16
18
|
/** Duration in seconds. Range varies by model: 3-15 for kling-3.0, 5 or 10 for V2.x. */
|
|
17
19
|
type KlingDuration = number;
|
|
@@ -20,16 +22,22 @@ interface MultiPromptItem {
|
|
|
20
22
|
prompt: string;
|
|
21
23
|
duration_seconds: number;
|
|
22
24
|
}
|
|
23
|
-
/** Named
|
|
25
|
+
/** Named element (character, object, style) with reference image, video, or audio materials for generation consistency. */
|
|
24
26
|
interface KlingElement {
|
|
25
27
|
/** Element identifier used for prompt referencing. */
|
|
26
28
|
name: string;
|
|
27
29
|
/** Description of the element's visual characteristics. */
|
|
28
30
|
description: string;
|
|
29
|
-
/** Image URLs providing visual reference for the element. */
|
|
31
|
+
/** Image or video URLs providing visual reference for the element. */
|
|
30
32
|
element_input_urls?: string[];
|
|
31
|
-
/** Video URLs providing motion
|
|
33
|
+
/** Video URLs providing motion reference for the element. */
|
|
32
34
|
element_input_video_urls?: string[];
|
|
35
|
+
/** Audio URLs providing voice or sound reference for the element. */
|
|
36
|
+
element_input_audio_urls?: string[];
|
|
37
|
+
/** Start time in milliseconds for video element capture. */
|
|
38
|
+
start_time?: number;
|
|
39
|
+
/** End time in milliseconds for video element capture; must be 3000-8000 ms after start_time. */
|
|
40
|
+
end_time?: number;
|
|
33
41
|
}
|
|
34
42
|
interface Kling3TextToVideoCommonParams {
|
|
35
43
|
model: 'kling-3.0';
|
|
@@ -87,13 +95,23 @@ interface V21MasterTextToVideoParams {
|
|
|
87
95
|
cfg_scale?: number;
|
|
88
96
|
callback_url?: string;
|
|
89
97
|
}
|
|
98
|
+
/** V3 Turbo text-to-video: prompt-driven 3-15 second clips at 720p or 1080p. */
|
|
99
|
+
interface V3TurboTextToVideoParams {
|
|
100
|
+
model: 'kling-v3-turbo-text-to-video';
|
|
101
|
+
prompt: string;
|
|
102
|
+
/** Duration in seconds (3-15). */
|
|
103
|
+
duration_seconds?: KlingDuration;
|
|
104
|
+
aspect_ratio?: KlingAspectRatio;
|
|
105
|
+
output_resolution?: KlingV3TurboOutputResolution;
|
|
106
|
+
callback_url?: string;
|
|
107
|
+
}
|
|
90
108
|
/**
|
|
91
109
|
* Image-to-video generation parameters. A first-frame image is required; the model
|
|
92
110
|
* animates it into video guided by the text prompt. last_frame_image_url is supported
|
|
93
111
|
* on V2.5 turbo and V2.1 pro models only.
|
|
94
112
|
*/
|
|
95
|
-
interface
|
|
96
|
-
model:
|
|
113
|
+
interface V2ImageToVideoParams {
|
|
114
|
+
model: KlingV2ImageToVideoModel;
|
|
97
115
|
/** Video motion description prompt. */
|
|
98
116
|
prompt: string;
|
|
99
117
|
/** Source image URL used as the video's opening frame. */
|
|
@@ -105,7 +123,17 @@ interface ImageToVideoParams {
|
|
|
105
123
|
last_frame_image_url?: string;
|
|
106
124
|
callback_url?: string;
|
|
107
125
|
}
|
|
108
|
-
|
|
126
|
+
/** V3 Turbo image-to-video: animate one first-frame image at 720p or 1080p. */
|
|
127
|
+
interface V3TurboImageToVideoParams {
|
|
128
|
+
model: 'kling-v3-turbo-image-to-video';
|
|
129
|
+
prompt: string;
|
|
130
|
+
first_frame_image_url: string;
|
|
131
|
+
duration_seconds?: KlingDuration;
|
|
132
|
+
output_resolution?: KlingV3TurboOutputResolution;
|
|
133
|
+
callback_url?: string;
|
|
134
|
+
}
|
|
135
|
+
type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams | V3TurboTextToVideoParams;
|
|
136
|
+
type ImageToVideoParams = V2ImageToVideoParams | V3TurboImageToVideoParams;
|
|
109
137
|
interface AsyncTaskResponse {
|
|
110
138
|
id: string;
|
|
111
139
|
status: AsyncTaskStatus;
|
|
@@ -321,4 +349,4 @@ declare class KlingClient extends BaseClient {
|
|
|
321
349
|
constructor(options?: ClientOptions);
|
|
322
350
|
}
|
|
323
351
|
|
|
324
|
-
export { type AiAvatarModel, type AiAvatarParams, type AiAvatarResponse, type AsyncTaskResponse, type CompletedAiAvatarResponse, type CompletedImageToVideoResponse, type CompletedMotionControlResponse, type CompletedTextToVideoResponse, type ImageToVideoParams, type ImageToVideoResponse, type Kling3TextToVideoMultiShotParams, type Kling3TextToVideoSingleShotParams, type KlingAspectRatio, KlingClient, type KlingDuration, type KlingElement, type KlingImageToVideoModel, type KlingTextToVideoModel, type KlingTextToVideoOutputResolution, type MotionControlParams, type MotionControlResponse, type MultiPromptItem, type TaskCreateResponse, type TextToVideoParams, type TextToVideoResponse, type V21MasterTextToVideoParams, type V25TurboTextToVideoParams, type VideoMetadata };
|
|
352
|
+
export { type AiAvatarModel, type AiAvatarParams, type AiAvatarResponse, type AsyncTaskResponse, type CompletedAiAvatarResponse, type CompletedImageToVideoResponse, type CompletedMotionControlResponse, type CompletedTextToVideoResponse, type ImageToVideoParams, type ImageToVideoResponse, type Kling3TextToVideoMultiShotParams, type Kling3TextToVideoSingleShotParams, type KlingAspectRatio, KlingClient, type KlingDuration, type KlingElement, type KlingImageToVideoModel, type KlingTextToVideoModel, type KlingTextToVideoOutputResolution, type KlingV2ImageToVideoModel, type KlingV3TurboOutputResolution, type MotionControlParams, type MotionControlResponse, type MultiPromptItem, type TaskCreateResponse, type TextToVideoParams, type TextToVideoResponse, type V21MasterTextToVideoParams, type V25TurboTextToVideoParams, type V2ImageToVideoParams, type V3TurboImageToVideoParams, type V3TurboTextToVideoParams, type VideoMetadata };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,13 +5,15 @@ export { AuthenticationError, InsufficientCreditsError, NetworkError, NotFoundEr
|
|
|
5
5
|
* Text-to-video model variants. kling-3.0 supports multi-shot, sound, first/last frame images,
|
|
6
6
|
* and Kling elements. V2.x models support negative prompts and cfg_scale instead.
|
|
7
7
|
*/
|
|
8
|
-
type KlingTextToVideoModel = 'kling-3.0' | 'kling-v2.5-turbo-text-to-video-pro' | 'kling-v2.1-master-text-to-video';
|
|
8
|
+
type KlingTextToVideoModel = 'kling-3.0' | 'kling-v3-turbo-text-to-video' | 'kling-v2.5-turbo-text-to-video-pro' | 'kling-v2.1-master-text-to-video';
|
|
9
9
|
/**
|
|
10
10
|
* Image-to-video model variants. V2.5 turbo and V2.1 pro support last-frame image control.
|
|
11
11
|
*/
|
|
12
|
-
type
|
|
12
|
+
type KlingV2ImageToVideoModel = 'kling-v2.5-turbo-image-to-video-pro' | 'kling-v2.1-pro' | 'kling-v2.1-standard' | 'kling-v2.1-master-image-to-video';
|
|
13
|
+
type KlingImageToVideoModel = KlingV2ImageToVideoModel | 'kling-v3-turbo-image-to-video';
|
|
13
14
|
/** Output resolution for text-to-video. 4k is highest quality but slowest. */
|
|
14
15
|
type KlingTextToVideoOutputResolution = '720p' | '1080p' | '4k';
|
|
16
|
+
type KlingV3TurboOutputResolution = '720p' | '1080p';
|
|
15
17
|
type KlingAspectRatio = '16:9' | '9:16' | '1:1';
|
|
16
18
|
/** Duration in seconds. Range varies by model: 3-15 for kling-3.0, 5 or 10 for V2.x. */
|
|
17
19
|
type KlingDuration = number;
|
|
@@ -20,16 +22,22 @@ interface MultiPromptItem {
|
|
|
20
22
|
prompt: string;
|
|
21
23
|
duration_seconds: number;
|
|
22
24
|
}
|
|
23
|
-
/** Named
|
|
25
|
+
/** Named element (character, object, style) with reference image, video, or audio materials for generation consistency. */
|
|
24
26
|
interface KlingElement {
|
|
25
27
|
/** Element identifier used for prompt referencing. */
|
|
26
28
|
name: string;
|
|
27
29
|
/** Description of the element's visual characteristics. */
|
|
28
30
|
description: string;
|
|
29
|
-
/** Image URLs providing visual reference for the element. */
|
|
31
|
+
/** Image or video URLs providing visual reference for the element. */
|
|
30
32
|
element_input_urls?: string[];
|
|
31
|
-
/** Video URLs providing motion
|
|
33
|
+
/** Video URLs providing motion reference for the element. */
|
|
32
34
|
element_input_video_urls?: string[];
|
|
35
|
+
/** Audio URLs providing voice or sound reference for the element. */
|
|
36
|
+
element_input_audio_urls?: string[];
|
|
37
|
+
/** Start time in milliseconds for video element capture. */
|
|
38
|
+
start_time?: number;
|
|
39
|
+
/** End time in milliseconds for video element capture; must be 3000-8000 ms after start_time. */
|
|
40
|
+
end_time?: number;
|
|
33
41
|
}
|
|
34
42
|
interface Kling3TextToVideoCommonParams {
|
|
35
43
|
model: 'kling-3.0';
|
|
@@ -87,13 +95,23 @@ interface V21MasterTextToVideoParams {
|
|
|
87
95
|
cfg_scale?: number;
|
|
88
96
|
callback_url?: string;
|
|
89
97
|
}
|
|
98
|
+
/** V3 Turbo text-to-video: prompt-driven 3-15 second clips at 720p or 1080p. */
|
|
99
|
+
interface V3TurboTextToVideoParams {
|
|
100
|
+
model: 'kling-v3-turbo-text-to-video';
|
|
101
|
+
prompt: string;
|
|
102
|
+
/** Duration in seconds (3-15). */
|
|
103
|
+
duration_seconds?: KlingDuration;
|
|
104
|
+
aspect_ratio?: KlingAspectRatio;
|
|
105
|
+
output_resolution?: KlingV3TurboOutputResolution;
|
|
106
|
+
callback_url?: string;
|
|
107
|
+
}
|
|
90
108
|
/**
|
|
91
109
|
* Image-to-video generation parameters. A first-frame image is required; the model
|
|
92
110
|
* animates it into video guided by the text prompt. last_frame_image_url is supported
|
|
93
111
|
* on V2.5 turbo and V2.1 pro models only.
|
|
94
112
|
*/
|
|
95
|
-
interface
|
|
96
|
-
model:
|
|
113
|
+
interface V2ImageToVideoParams {
|
|
114
|
+
model: KlingV2ImageToVideoModel;
|
|
97
115
|
/** Video motion description prompt. */
|
|
98
116
|
prompt: string;
|
|
99
117
|
/** Source image URL used as the video's opening frame. */
|
|
@@ -105,7 +123,17 @@ interface ImageToVideoParams {
|
|
|
105
123
|
last_frame_image_url?: string;
|
|
106
124
|
callback_url?: string;
|
|
107
125
|
}
|
|
108
|
-
|
|
126
|
+
/** V3 Turbo image-to-video: animate one first-frame image at 720p or 1080p. */
|
|
127
|
+
interface V3TurboImageToVideoParams {
|
|
128
|
+
model: 'kling-v3-turbo-image-to-video';
|
|
129
|
+
prompt: string;
|
|
130
|
+
first_frame_image_url: string;
|
|
131
|
+
duration_seconds?: KlingDuration;
|
|
132
|
+
output_resolution?: KlingV3TurboOutputResolution;
|
|
133
|
+
callback_url?: string;
|
|
134
|
+
}
|
|
135
|
+
type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams | V3TurboTextToVideoParams;
|
|
136
|
+
type ImageToVideoParams = V2ImageToVideoParams | V3TurboImageToVideoParams;
|
|
109
137
|
interface AsyncTaskResponse {
|
|
110
138
|
id: string;
|
|
111
139
|
status: AsyncTaskStatus;
|
|
@@ -321,4 +349,4 @@ declare class KlingClient extends BaseClient {
|
|
|
321
349
|
constructor(options?: ClientOptions);
|
|
322
350
|
}
|
|
323
351
|
|
|
324
|
-
export { type AiAvatarModel, type AiAvatarParams, type AiAvatarResponse, type AsyncTaskResponse, type CompletedAiAvatarResponse, type CompletedImageToVideoResponse, type CompletedMotionControlResponse, type CompletedTextToVideoResponse, type ImageToVideoParams, type ImageToVideoResponse, type Kling3TextToVideoMultiShotParams, type Kling3TextToVideoSingleShotParams, type KlingAspectRatio, KlingClient, type KlingDuration, type KlingElement, type KlingImageToVideoModel, type KlingTextToVideoModel, type KlingTextToVideoOutputResolution, type MotionControlParams, type MotionControlResponse, type MultiPromptItem, type TaskCreateResponse, type TextToVideoParams, type TextToVideoResponse, type V21MasterTextToVideoParams, type V25TurboTextToVideoParams, type VideoMetadata };
|
|
352
|
+
export { type AiAvatarModel, type AiAvatarParams, type AiAvatarResponse, type AsyncTaskResponse, type CompletedAiAvatarResponse, type CompletedImageToVideoResponse, type CompletedMotionControlResponse, type CompletedTextToVideoResponse, type ImageToVideoParams, type ImageToVideoResponse, type Kling3TextToVideoMultiShotParams, type Kling3TextToVideoSingleShotParams, type KlingAspectRatio, KlingClient, type KlingDuration, type KlingElement, type KlingImageToVideoModel, type KlingTextToVideoModel, type KlingTextToVideoOutputResolution, type KlingV2ImageToVideoModel, type KlingV3TurboOutputResolution, type MotionControlParams, type MotionControlResponse, type MultiPromptItem, type TaskCreateResponse, type TextToVideoParams, type TextToVideoResponse, type V21MasterTextToVideoParams, type V25TurboTextToVideoParams, type V2ImageToVideoParams, type V3TurboImageToVideoParams, type V3TurboTextToVideoParams, type VideoMetadata };
|