@runapi.ai/kling 0.2.8 → 0.2.10
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 +66 -14
- package/dist/index.d.ts +66 -14
- package/dist/index.js +644 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +650 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -4
- package/skills/kling/README.md +6 -1
- package/skills/kling/SKILL.md +7 -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,31 +5,38 @@ 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';
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type KlingImageToVideoModel = 'kling-v2.5-turbo-image-to-video-pro' | 'kling-v2.1-pro' | 'kling-v2.1-standard' | 'kling-v2.1-master-image-to-video';
|
|
8
|
+
type KlingTextToVideoModel = 'kling-3.0' | 'kling-v2.6' | 'kling-v3-turbo-text-to-video' | 'kling-v2.5-turbo-text-to-video-pro' | 'kling-v2.1-master-text-to-video';
|
|
9
|
+
/** Earlier V2 image-to-video variants. V2.5 turbo and V2.1 pro support last-frame image control. */
|
|
10
|
+
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';
|
|
11
|
+
type KlingImageToVideoModel = KlingV2ImageToVideoModel | 'kling-v2.6' | 'kling-v3-turbo-image-to-video';
|
|
13
12
|
/** Output resolution for text-to-video. 4k is highest quality but slowest. */
|
|
14
13
|
type KlingTextToVideoOutputResolution = '720p' | '1080p' | '4k';
|
|
14
|
+
type KlingV3TurboOutputResolution = '720p' | '1080p';
|
|
15
15
|
type KlingAspectRatio = '16:9' | '9:16' | '1:1';
|
|
16
16
|
/** Duration in seconds. Range varies by model: 3-15 for kling-3.0, 5 or 10 for V2.x. */
|
|
17
17
|
type KlingDuration = number;
|
|
18
|
+
type KlingV26Mode = 'std' | 'pro';
|
|
18
19
|
/** A single shot in a multi-shot text-to-video sequence. */
|
|
19
20
|
interface MultiPromptItem {
|
|
20
21
|
prompt: string;
|
|
21
22
|
duration_seconds: number;
|
|
22
23
|
}
|
|
23
|
-
/** Named
|
|
24
|
+
/** Named element (character, object, style) with reference image, video, or audio materials for generation consistency. */
|
|
24
25
|
interface KlingElement {
|
|
25
26
|
/** Element identifier used for prompt referencing. */
|
|
26
27
|
name: string;
|
|
27
28
|
/** Description of the element's visual characteristics. */
|
|
28
29
|
description: string;
|
|
29
|
-
/** Image URLs providing visual reference for the element. */
|
|
30
|
+
/** Image or video URLs providing visual reference for the element. */
|
|
30
31
|
element_input_urls?: string[];
|
|
31
|
-
/** Video URLs providing motion
|
|
32
|
+
/** Video URLs providing motion reference for the element. */
|
|
32
33
|
element_input_video_urls?: string[];
|
|
34
|
+
/** Audio URLs providing voice or sound reference for the element. */
|
|
35
|
+
element_input_audio_urls?: string[];
|
|
36
|
+
/** Start time in milliseconds for video element capture. */
|
|
37
|
+
start_time?: number;
|
|
38
|
+
/** End time in milliseconds for video element capture; must be 3000-8000 ms after start_time. */
|
|
39
|
+
end_time?: number;
|
|
33
40
|
}
|
|
34
41
|
interface Kling3TextToVideoCommonParams {
|
|
35
42
|
model: 'kling-3.0';
|
|
@@ -87,13 +94,34 @@ interface V21MasterTextToVideoParams {
|
|
|
87
94
|
cfg_scale?: number;
|
|
88
95
|
callback_url?: string;
|
|
89
96
|
}
|
|
97
|
+
/** V3 Turbo text-to-video: prompt-driven 3-15 second clips at 720p or 1080p. */
|
|
98
|
+
interface V3TurboTextToVideoParams {
|
|
99
|
+
model: 'kling-v3-turbo-text-to-video';
|
|
100
|
+
prompt: string;
|
|
101
|
+
/** Duration in seconds (3-15). */
|
|
102
|
+
duration_seconds?: KlingDuration;
|
|
103
|
+
aspect_ratio?: KlingAspectRatio;
|
|
104
|
+
output_resolution?: KlingV3TurboOutputResolution;
|
|
105
|
+
callback_url?: string;
|
|
106
|
+
}
|
|
107
|
+
/** Kling 2.6 text-to-video with standard/pro quality modes and optional sound in pro mode. */
|
|
108
|
+
interface KlingV26TextToVideoParams {
|
|
109
|
+
model: 'kling-v2.6';
|
|
110
|
+
prompt: string;
|
|
111
|
+
mode?: KlingV26Mode;
|
|
112
|
+
duration_seconds?: 5 | 10;
|
|
113
|
+
/** Generate synchronized audio; true requires mode pro. */
|
|
114
|
+
enable_sound?: boolean;
|
|
115
|
+
aspect_ratio?: KlingAspectRatio;
|
|
116
|
+
callback_url?: string;
|
|
117
|
+
}
|
|
90
118
|
/**
|
|
91
|
-
*
|
|
119
|
+
* Earlier V2 image-to-video parameters. A first-frame image is required; the model
|
|
92
120
|
* animates it into video guided by the text prompt. last_frame_image_url is supported
|
|
93
|
-
* on V2.5 turbo and V2.1 pro
|
|
121
|
+
* on V2.5 turbo and V2.1 pro.
|
|
94
122
|
*/
|
|
95
|
-
interface
|
|
96
|
-
model:
|
|
123
|
+
interface V2ImageToVideoParams {
|
|
124
|
+
model: KlingV2ImageToVideoModel;
|
|
97
125
|
/** Video motion description prompt. */
|
|
98
126
|
prompt: string;
|
|
99
127
|
/** Source image URL used as the video's opening frame. */
|
|
@@ -105,7 +133,31 @@ interface ImageToVideoParams {
|
|
|
105
133
|
last_frame_image_url?: string;
|
|
106
134
|
callback_url?: string;
|
|
107
135
|
}
|
|
108
|
-
|
|
136
|
+
/** V3 Turbo image-to-video: animate one first-frame image at 720p or 1080p. */
|
|
137
|
+
interface V3TurboImageToVideoParams {
|
|
138
|
+
model: 'kling-v3-turbo-image-to-video';
|
|
139
|
+
prompt: string;
|
|
140
|
+
first_frame_image_url: string;
|
|
141
|
+
duration_seconds?: KlingDuration;
|
|
142
|
+
output_resolution?: KlingV3TurboOutputResolution;
|
|
143
|
+
callback_url?: string;
|
|
144
|
+
}
|
|
145
|
+
/** Kling 2.6 image-to-video with optional sound and final-frame control in pro mode. */
|
|
146
|
+
interface KlingV26ImageToVideoParams {
|
|
147
|
+
model: 'kling-v2.6';
|
|
148
|
+
prompt: string;
|
|
149
|
+
first_frame_image_url: string;
|
|
150
|
+
/** Final frame URL; requires mode pro and duration_seconds 5. */
|
|
151
|
+
last_frame_image_url?: string;
|
|
152
|
+
mode?: KlingV26Mode;
|
|
153
|
+
duration_seconds?: 5 | 10;
|
|
154
|
+
/** Generate synchronized audio; true requires mode pro. */
|
|
155
|
+
enable_sound?: boolean;
|
|
156
|
+
aspect_ratio?: KlingAspectRatio;
|
|
157
|
+
callback_url?: string;
|
|
158
|
+
}
|
|
159
|
+
type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | KlingV26TextToVideoParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams | V3TurboTextToVideoParams;
|
|
160
|
+
type ImageToVideoParams = V2ImageToVideoParams | KlingV26ImageToVideoParams | V3TurboImageToVideoParams;
|
|
109
161
|
interface AsyncTaskResponse {
|
|
110
162
|
id: string;
|
|
111
163
|
status: AsyncTaskStatus;
|
|
@@ -321,4 +373,4 @@ declare class KlingClient extends BaseClient {
|
|
|
321
373
|
constructor(options?: ClientOptions);
|
|
322
374
|
}
|
|
323
375
|
|
|
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 };
|
|
376
|
+
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 KlingV26ImageToVideoParams, type KlingV26Mode, type KlingV26TextToVideoParams, 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,31 +5,38 @@ 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';
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type KlingImageToVideoModel = 'kling-v2.5-turbo-image-to-video-pro' | 'kling-v2.1-pro' | 'kling-v2.1-standard' | 'kling-v2.1-master-image-to-video';
|
|
8
|
+
type KlingTextToVideoModel = 'kling-3.0' | 'kling-v2.6' | 'kling-v3-turbo-text-to-video' | 'kling-v2.5-turbo-text-to-video-pro' | 'kling-v2.1-master-text-to-video';
|
|
9
|
+
/** Earlier V2 image-to-video variants. V2.5 turbo and V2.1 pro support last-frame image control. */
|
|
10
|
+
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';
|
|
11
|
+
type KlingImageToVideoModel = KlingV2ImageToVideoModel | 'kling-v2.6' | 'kling-v3-turbo-image-to-video';
|
|
13
12
|
/** Output resolution for text-to-video. 4k is highest quality but slowest. */
|
|
14
13
|
type KlingTextToVideoOutputResolution = '720p' | '1080p' | '4k';
|
|
14
|
+
type KlingV3TurboOutputResolution = '720p' | '1080p';
|
|
15
15
|
type KlingAspectRatio = '16:9' | '9:16' | '1:1';
|
|
16
16
|
/** Duration in seconds. Range varies by model: 3-15 for kling-3.0, 5 or 10 for V2.x. */
|
|
17
17
|
type KlingDuration = number;
|
|
18
|
+
type KlingV26Mode = 'std' | 'pro';
|
|
18
19
|
/** A single shot in a multi-shot text-to-video sequence. */
|
|
19
20
|
interface MultiPromptItem {
|
|
20
21
|
prompt: string;
|
|
21
22
|
duration_seconds: number;
|
|
22
23
|
}
|
|
23
|
-
/** Named
|
|
24
|
+
/** Named element (character, object, style) with reference image, video, or audio materials for generation consistency. */
|
|
24
25
|
interface KlingElement {
|
|
25
26
|
/** Element identifier used for prompt referencing. */
|
|
26
27
|
name: string;
|
|
27
28
|
/** Description of the element's visual characteristics. */
|
|
28
29
|
description: string;
|
|
29
|
-
/** Image URLs providing visual reference for the element. */
|
|
30
|
+
/** Image or video URLs providing visual reference for the element. */
|
|
30
31
|
element_input_urls?: string[];
|
|
31
|
-
/** Video URLs providing motion
|
|
32
|
+
/** Video URLs providing motion reference for the element. */
|
|
32
33
|
element_input_video_urls?: string[];
|
|
34
|
+
/** Audio URLs providing voice or sound reference for the element. */
|
|
35
|
+
element_input_audio_urls?: string[];
|
|
36
|
+
/** Start time in milliseconds for video element capture. */
|
|
37
|
+
start_time?: number;
|
|
38
|
+
/** End time in milliseconds for video element capture; must be 3000-8000 ms after start_time. */
|
|
39
|
+
end_time?: number;
|
|
33
40
|
}
|
|
34
41
|
interface Kling3TextToVideoCommonParams {
|
|
35
42
|
model: 'kling-3.0';
|
|
@@ -87,13 +94,34 @@ interface V21MasterTextToVideoParams {
|
|
|
87
94
|
cfg_scale?: number;
|
|
88
95
|
callback_url?: string;
|
|
89
96
|
}
|
|
97
|
+
/** V3 Turbo text-to-video: prompt-driven 3-15 second clips at 720p or 1080p. */
|
|
98
|
+
interface V3TurboTextToVideoParams {
|
|
99
|
+
model: 'kling-v3-turbo-text-to-video';
|
|
100
|
+
prompt: string;
|
|
101
|
+
/** Duration in seconds (3-15). */
|
|
102
|
+
duration_seconds?: KlingDuration;
|
|
103
|
+
aspect_ratio?: KlingAspectRatio;
|
|
104
|
+
output_resolution?: KlingV3TurboOutputResolution;
|
|
105
|
+
callback_url?: string;
|
|
106
|
+
}
|
|
107
|
+
/** Kling 2.6 text-to-video with standard/pro quality modes and optional sound in pro mode. */
|
|
108
|
+
interface KlingV26TextToVideoParams {
|
|
109
|
+
model: 'kling-v2.6';
|
|
110
|
+
prompt: string;
|
|
111
|
+
mode?: KlingV26Mode;
|
|
112
|
+
duration_seconds?: 5 | 10;
|
|
113
|
+
/** Generate synchronized audio; true requires mode pro. */
|
|
114
|
+
enable_sound?: boolean;
|
|
115
|
+
aspect_ratio?: KlingAspectRatio;
|
|
116
|
+
callback_url?: string;
|
|
117
|
+
}
|
|
90
118
|
/**
|
|
91
|
-
*
|
|
119
|
+
* Earlier V2 image-to-video parameters. A first-frame image is required; the model
|
|
92
120
|
* animates it into video guided by the text prompt. last_frame_image_url is supported
|
|
93
|
-
* on V2.5 turbo and V2.1 pro
|
|
121
|
+
* on V2.5 turbo and V2.1 pro.
|
|
94
122
|
*/
|
|
95
|
-
interface
|
|
96
|
-
model:
|
|
123
|
+
interface V2ImageToVideoParams {
|
|
124
|
+
model: KlingV2ImageToVideoModel;
|
|
97
125
|
/** Video motion description prompt. */
|
|
98
126
|
prompt: string;
|
|
99
127
|
/** Source image URL used as the video's opening frame. */
|
|
@@ -105,7 +133,31 @@ interface ImageToVideoParams {
|
|
|
105
133
|
last_frame_image_url?: string;
|
|
106
134
|
callback_url?: string;
|
|
107
135
|
}
|
|
108
|
-
|
|
136
|
+
/** V3 Turbo image-to-video: animate one first-frame image at 720p or 1080p. */
|
|
137
|
+
interface V3TurboImageToVideoParams {
|
|
138
|
+
model: 'kling-v3-turbo-image-to-video';
|
|
139
|
+
prompt: string;
|
|
140
|
+
first_frame_image_url: string;
|
|
141
|
+
duration_seconds?: KlingDuration;
|
|
142
|
+
output_resolution?: KlingV3TurboOutputResolution;
|
|
143
|
+
callback_url?: string;
|
|
144
|
+
}
|
|
145
|
+
/** Kling 2.6 image-to-video with optional sound and final-frame control in pro mode. */
|
|
146
|
+
interface KlingV26ImageToVideoParams {
|
|
147
|
+
model: 'kling-v2.6';
|
|
148
|
+
prompt: string;
|
|
149
|
+
first_frame_image_url: string;
|
|
150
|
+
/** Final frame URL; requires mode pro and duration_seconds 5. */
|
|
151
|
+
last_frame_image_url?: string;
|
|
152
|
+
mode?: KlingV26Mode;
|
|
153
|
+
duration_seconds?: 5 | 10;
|
|
154
|
+
/** Generate synchronized audio; true requires mode pro. */
|
|
155
|
+
enable_sound?: boolean;
|
|
156
|
+
aspect_ratio?: KlingAspectRatio;
|
|
157
|
+
callback_url?: string;
|
|
158
|
+
}
|
|
159
|
+
type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | KlingV26TextToVideoParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams | V3TurboTextToVideoParams;
|
|
160
|
+
type ImageToVideoParams = V2ImageToVideoParams | KlingV26ImageToVideoParams | V3TurboImageToVideoParams;
|
|
109
161
|
interface AsyncTaskResponse {
|
|
110
162
|
id: string;
|
|
111
163
|
status: AsyncTaskStatus;
|
|
@@ -321,4 +373,4 @@ declare class KlingClient extends BaseClient {
|
|
|
321
373
|
constructor(options?: ClientOptions);
|
|
322
374
|
}
|
|
323
375
|
|
|
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 };
|
|
376
|
+
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 KlingV26ImageToVideoParams, type KlingV26Mode, type KlingV26TextToVideoParams, 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 };
|