@runapi.ai/kling 0.2.1 → 0.2.7
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 +2 -2
- package/dist/index.d.mts +35 -24
- package/dist/index.d.ts +35 -24
- package/package.json +2 -2
- package/skills/kling/README.md +41 -2
- package/skills/kling/SKILL.md +60 -221
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Kling AI API JavaScript SDK for RunAPI
|
|
2
2
|
|
|
3
|
-
The kling ai api JavaScript SDK is the language-specific package for Kling on RunAPI. Use this kling ai api package for text-to-video, image-to-video, video
|
|
3
|
+
The kling ai api JavaScript SDK is the language-specific package for Kling on RunAPI. Use this kling ai api package for text-to-video, image-to-video, video editing, and animation flows when your application needs JSON request bodies, task status lookup, and consistent RunAPI errors in JavaScript.
|
|
4
4
|
|
|
5
5
|
This kling ai api 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
|
|
|
@@ -26,7 +26,7 @@ Use `create` when you want to submit a task and return quickly, `get` when you n
|
|
|
26
26
|
|
|
27
27
|
## Language notes
|
|
28
28
|
|
|
29
|
-
Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building video applications. The available resources include
|
|
29
|
+
Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building video applications. The available resources include text-to-video, image-to-video, AI avatars, V2.1/V2.5 video variants, and motion controls. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
|
|
30
30
|
|
|
31
31
|
## Links
|
|
32
32
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, ClientOptions } from '@runapi.ai/core';
|
|
2
2
|
export { AuthenticationError, InsufficientCreditsError, NetworkError, NotFoundError, RateLimitError, RunApiError, ServiceUnavailableError, TaskFailedError, TaskTimeoutError, TimeoutError, ValidationError } from '@runapi.ai/core';
|
|
3
3
|
|
|
4
|
-
type KlingTextToVideoModel = 'kling-3.0' | 'kling-v2.5-turbo-text-to-video-pro';
|
|
5
|
-
type KlingImageToVideoModel = 'kling-v2.5-turbo-image-to-video-pro';
|
|
6
|
-
type
|
|
4
|
+
type KlingTextToVideoModel = 'kling-3.0' | 'kling-v2.5-turbo-text-to-video-pro' | 'kling-v2.1-master-text-to-video';
|
|
5
|
+
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';
|
|
6
|
+
type KlingTextToVideoOutputResolution = '720p' | '1080p' | '4k';
|
|
7
7
|
type KlingAspectRatio = '16:9' | '9:16' | '1:1';
|
|
8
|
-
type KlingDuration =
|
|
8
|
+
type KlingDuration = number;
|
|
9
9
|
/** A single shot in a multi-shot text-to-video sequence. */
|
|
10
10
|
interface MultiPromptItem {
|
|
11
11
|
prompt: string;
|
|
12
|
-
|
|
12
|
+
duration_seconds: number;
|
|
13
13
|
}
|
|
14
14
|
/** Element reference for subject/style guidance. */
|
|
15
15
|
interface KlingElement {
|
|
@@ -20,42 +20,53 @@ interface KlingElement {
|
|
|
20
20
|
}
|
|
21
21
|
interface Kling3TextToVideoCommonParams {
|
|
22
22
|
model: 'kling-3.0';
|
|
23
|
-
|
|
23
|
+
duration_seconds?: KlingDuration;
|
|
24
24
|
aspect_ratio?: KlingAspectRatio;
|
|
25
|
-
|
|
25
|
+
output_resolution?: KlingTextToVideoOutputResolution;
|
|
26
26
|
kling_elements?: KlingElement[];
|
|
27
27
|
callback_url?: string;
|
|
28
28
|
}
|
|
29
29
|
interface Kling3TextToVideoSingleShotParams extends Kling3TextToVideoCommonParams {
|
|
30
30
|
prompt: string;
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
enable_sound?: boolean;
|
|
32
|
+
first_frame_image_url?: string;
|
|
33
|
+
last_frame_image_url?: string;
|
|
33
34
|
}
|
|
34
35
|
interface Kling3TextToVideoMultiShotParams extends Kling3TextToVideoCommonParams {
|
|
35
36
|
multi_shots: true;
|
|
36
|
-
|
|
37
|
+
enable_sound: true;
|
|
37
38
|
multi_prompt: MultiPromptItem[];
|
|
38
|
-
|
|
39
|
+
first_frame_image_url?: string;
|
|
39
40
|
}
|
|
40
41
|
interface V25TurboTextToVideoParams {
|
|
41
42
|
model: 'kling-v2.5-turbo-text-to-video-pro';
|
|
42
43
|
prompt: string;
|
|
43
|
-
|
|
44
|
+
duration_seconds?: 5 | 10;
|
|
45
|
+
aspect_ratio?: KlingAspectRatio;
|
|
46
|
+
negative_prompt?: string;
|
|
47
|
+
cfg_scale?: number;
|
|
48
|
+
callback_url?: string;
|
|
49
|
+
}
|
|
50
|
+
interface V21MasterTextToVideoParams {
|
|
51
|
+
model: 'kling-v2.1-master-text-to-video';
|
|
52
|
+
prompt: string;
|
|
53
|
+
duration_seconds?: 5 | 10;
|
|
44
54
|
aspect_ratio?: KlingAspectRatio;
|
|
45
55
|
negative_prompt?: string;
|
|
46
56
|
cfg_scale?: number;
|
|
47
57
|
callback_url?: string;
|
|
48
58
|
}
|
|
49
59
|
interface ImageToVideoParams {
|
|
50
|
-
model:
|
|
60
|
+
model: KlingImageToVideoModel;
|
|
51
61
|
prompt: string;
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
first_frame_image_url: string;
|
|
63
|
+
duration_seconds?: 5 | 10;
|
|
54
64
|
negative_prompt?: string;
|
|
55
65
|
cfg_scale?: number;
|
|
66
|
+
last_frame_image_url?: string;
|
|
56
67
|
callback_url?: string;
|
|
57
68
|
}
|
|
58
|
-
type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | V25TurboTextToVideoParams;
|
|
69
|
+
type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams;
|
|
59
70
|
interface AsyncTaskResponse {
|
|
60
71
|
id: string;
|
|
61
72
|
status: AsyncTaskStatus;
|
|
@@ -76,11 +87,11 @@ interface ImageToVideoResponse extends AsyncTaskResponse {
|
|
|
76
87
|
error?: string;
|
|
77
88
|
[key: string]: unknown;
|
|
78
89
|
}
|
|
79
|
-
type AiAvatarModel = 'kling-ai-avatar-pro' | 'kling-ai-avatar-standard';
|
|
90
|
+
type AiAvatarModel = 'kling-ai-avatar-pro' | 'kling-ai-avatar-standard' | 'kling-ai-avatar-v1-pro' | 'kling-v1-avatar-standard';
|
|
80
91
|
interface AiAvatarParams {
|
|
81
92
|
model: AiAvatarModel;
|
|
82
|
-
|
|
83
|
-
|
|
93
|
+
source_image_url: string;
|
|
94
|
+
source_audio_url: string;
|
|
84
95
|
prompt: string;
|
|
85
96
|
callback_url?: string;
|
|
86
97
|
}
|
|
@@ -91,12 +102,12 @@ interface AiAvatarResponse extends AsyncTaskResponse {
|
|
|
91
102
|
}
|
|
92
103
|
interface MotionControlParams {
|
|
93
104
|
model: 'kling-3.0';
|
|
94
|
-
|
|
95
|
-
|
|
105
|
+
source_image_url: string;
|
|
106
|
+
reference_video_url: string;
|
|
96
107
|
prompt?: string;
|
|
97
|
-
|
|
108
|
+
output_resolution?: '720p' | '1080p';
|
|
98
109
|
character_orientation?: 'video' | 'image';
|
|
99
|
-
background_source?: '
|
|
110
|
+
background_source?: 'video' | 'image';
|
|
100
111
|
callback_url?: string;
|
|
101
112
|
}
|
|
102
113
|
interface MotionControlResponse extends AsyncTaskResponse {
|
|
@@ -166,4 +177,4 @@ declare class KlingClient {
|
|
|
166
177
|
constructor(options?: ClientOptions);
|
|
167
178
|
}
|
|
168
179
|
|
|
169
|
-
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
|
|
180
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, ClientOptions } from '@runapi.ai/core';
|
|
2
2
|
export { AuthenticationError, InsufficientCreditsError, NetworkError, NotFoundError, RateLimitError, RunApiError, ServiceUnavailableError, TaskFailedError, TaskTimeoutError, TimeoutError, ValidationError } from '@runapi.ai/core';
|
|
3
3
|
|
|
4
|
-
type KlingTextToVideoModel = 'kling-3.0' | 'kling-v2.5-turbo-text-to-video-pro';
|
|
5
|
-
type KlingImageToVideoModel = 'kling-v2.5-turbo-image-to-video-pro';
|
|
6
|
-
type
|
|
4
|
+
type KlingTextToVideoModel = 'kling-3.0' | 'kling-v2.5-turbo-text-to-video-pro' | 'kling-v2.1-master-text-to-video';
|
|
5
|
+
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';
|
|
6
|
+
type KlingTextToVideoOutputResolution = '720p' | '1080p' | '4k';
|
|
7
7
|
type KlingAspectRatio = '16:9' | '9:16' | '1:1';
|
|
8
|
-
type KlingDuration =
|
|
8
|
+
type KlingDuration = number;
|
|
9
9
|
/** A single shot in a multi-shot text-to-video sequence. */
|
|
10
10
|
interface MultiPromptItem {
|
|
11
11
|
prompt: string;
|
|
12
|
-
|
|
12
|
+
duration_seconds: number;
|
|
13
13
|
}
|
|
14
14
|
/** Element reference for subject/style guidance. */
|
|
15
15
|
interface KlingElement {
|
|
@@ -20,42 +20,53 @@ interface KlingElement {
|
|
|
20
20
|
}
|
|
21
21
|
interface Kling3TextToVideoCommonParams {
|
|
22
22
|
model: 'kling-3.0';
|
|
23
|
-
|
|
23
|
+
duration_seconds?: KlingDuration;
|
|
24
24
|
aspect_ratio?: KlingAspectRatio;
|
|
25
|
-
|
|
25
|
+
output_resolution?: KlingTextToVideoOutputResolution;
|
|
26
26
|
kling_elements?: KlingElement[];
|
|
27
27
|
callback_url?: string;
|
|
28
28
|
}
|
|
29
29
|
interface Kling3TextToVideoSingleShotParams extends Kling3TextToVideoCommonParams {
|
|
30
30
|
prompt: string;
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
enable_sound?: boolean;
|
|
32
|
+
first_frame_image_url?: string;
|
|
33
|
+
last_frame_image_url?: string;
|
|
33
34
|
}
|
|
34
35
|
interface Kling3TextToVideoMultiShotParams extends Kling3TextToVideoCommonParams {
|
|
35
36
|
multi_shots: true;
|
|
36
|
-
|
|
37
|
+
enable_sound: true;
|
|
37
38
|
multi_prompt: MultiPromptItem[];
|
|
38
|
-
|
|
39
|
+
first_frame_image_url?: string;
|
|
39
40
|
}
|
|
40
41
|
interface V25TurboTextToVideoParams {
|
|
41
42
|
model: 'kling-v2.5-turbo-text-to-video-pro';
|
|
42
43
|
prompt: string;
|
|
43
|
-
|
|
44
|
+
duration_seconds?: 5 | 10;
|
|
45
|
+
aspect_ratio?: KlingAspectRatio;
|
|
46
|
+
negative_prompt?: string;
|
|
47
|
+
cfg_scale?: number;
|
|
48
|
+
callback_url?: string;
|
|
49
|
+
}
|
|
50
|
+
interface V21MasterTextToVideoParams {
|
|
51
|
+
model: 'kling-v2.1-master-text-to-video';
|
|
52
|
+
prompt: string;
|
|
53
|
+
duration_seconds?: 5 | 10;
|
|
44
54
|
aspect_ratio?: KlingAspectRatio;
|
|
45
55
|
negative_prompt?: string;
|
|
46
56
|
cfg_scale?: number;
|
|
47
57
|
callback_url?: string;
|
|
48
58
|
}
|
|
49
59
|
interface ImageToVideoParams {
|
|
50
|
-
model:
|
|
60
|
+
model: KlingImageToVideoModel;
|
|
51
61
|
prompt: string;
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
first_frame_image_url: string;
|
|
63
|
+
duration_seconds?: 5 | 10;
|
|
54
64
|
negative_prompt?: string;
|
|
55
65
|
cfg_scale?: number;
|
|
66
|
+
last_frame_image_url?: string;
|
|
56
67
|
callback_url?: string;
|
|
57
68
|
}
|
|
58
|
-
type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | V25TurboTextToVideoParams;
|
|
69
|
+
type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams;
|
|
59
70
|
interface AsyncTaskResponse {
|
|
60
71
|
id: string;
|
|
61
72
|
status: AsyncTaskStatus;
|
|
@@ -76,11 +87,11 @@ interface ImageToVideoResponse extends AsyncTaskResponse {
|
|
|
76
87
|
error?: string;
|
|
77
88
|
[key: string]: unknown;
|
|
78
89
|
}
|
|
79
|
-
type AiAvatarModel = 'kling-ai-avatar-pro' | 'kling-ai-avatar-standard';
|
|
90
|
+
type AiAvatarModel = 'kling-ai-avatar-pro' | 'kling-ai-avatar-standard' | 'kling-ai-avatar-v1-pro' | 'kling-v1-avatar-standard';
|
|
80
91
|
interface AiAvatarParams {
|
|
81
92
|
model: AiAvatarModel;
|
|
82
|
-
|
|
83
|
-
|
|
93
|
+
source_image_url: string;
|
|
94
|
+
source_audio_url: string;
|
|
84
95
|
prompt: string;
|
|
85
96
|
callback_url?: string;
|
|
86
97
|
}
|
|
@@ -91,12 +102,12 @@ interface AiAvatarResponse extends AsyncTaskResponse {
|
|
|
91
102
|
}
|
|
92
103
|
interface MotionControlParams {
|
|
93
104
|
model: 'kling-3.0';
|
|
94
|
-
|
|
95
|
-
|
|
105
|
+
source_image_url: string;
|
|
106
|
+
reference_video_url: string;
|
|
96
107
|
prompt?: string;
|
|
97
|
-
|
|
108
|
+
output_resolution?: '720p' | '1080p';
|
|
98
109
|
character_orientation?: 'video' | 'image';
|
|
99
|
-
background_source?: '
|
|
110
|
+
background_source?: 'video' | 'image';
|
|
100
111
|
callback_url?: string;
|
|
101
112
|
}
|
|
102
113
|
interface MotionControlResponse extends AsyncTaskResponse {
|
|
@@ -166,4 +177,4 @@ declare class KlingClient {
|
|
|
166
177
|
constructor(options?: ClientOptions);
|
|
167
178
|
}
|
|
168
179
|
|
|
169
|
-
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
|
|
180
|
+
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runapi.ai/kling",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "RunAPI Kling SDK for JavaScript, Ruby, and Go",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"clean": "rm -rf dist"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@runapi.ai/core": "^0.2.
|
|
31
|
+
"@runapi.ai/core": "^0.2.5"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^20.0.0",
|
package/skills/kling/README.md
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://github.com/runapi-ai/kling">
|
|
3
|
+
<h3 align="center">Kling AI API Skill for RunAPI</h3>
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
Install this agent skill, inspect Kling fields, then run jobs through the RunAPI CLI.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://runapi.ai/models/kling"><strong>Model Reference</strong></a> · <a href="https://github.com/runapi-ai/cli"><strong>CLI</strong></a> · <a href="https://github.com/runapi-ai/kling-sdk"><strong>SDK</strong></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<div align="center">
|
|
16
|
+
|
|
17
|
+
[](https://www.skills.sh/runapi-ai/kling/kling)
|
|
18
|
+
[](https://clawhub.ai/runapi-ai/runapi-kling)
|
|
19
|
+
[](https://github.com/runapi-ai/kling/blob/main/LICENSE)
|
|
20
|
+
|
|
21
|
+
</div>
|
|
22
|
+
<br/>
|
|
2
23
|
|
|
3
24
|
Generate video, AI avatars, and motion-controlled clips with the Kling SDK. This skill helps Claude Code, Codex, Gemini CLI, Cursor, and 50+ agents integrate Kling through RunAPI.
|
|
4
25
|
|
|
@@ -10,7 +31,18 @@ The canonical agent file is `skills/kling/SKILL.md`.
|
|
|
10
31
|
npx skills add runapi-ai/kling -g
|
|
11
32
|
```
|
|
12
33
|
|
|
13
|
-
Or
|
|
34
|
+
Or paste this prompt to your AI agent:
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
Install the kling skill for me:
|
|
38
|
+
|
|
39
|
+
1. Clone https://github.com/runapi-ai/kling
|
|
40
|
+
2. Copy the skills/kling/ directory into your
|
|
41
|
+
user-level skills directory (e.g. ~/.claude/skills/
|
|
42
|
+
for Claude Code, ~/.codex/skills/ for Codex).
|
|
43
|
+
3. Verify that SKILL.md is present.
|
|
44
|
+
4. Confirm the install path when done.
|
|
45
|
+
```
|
|
14
46
|
|
|
15
47
|
## Quick example
|
|
16
48
|
|
|
@@ -21,6 +53,7 @@ const client = new KlingClient();
|
|
|
21
53
|
const result = await client.textToVideo.run({
|
|
22
54
|
model: 'kling-3.0',
|
|
23
55
|
prompt: 'A cat walking through a sunlit garden',
|
|
56
|
+
output_resolution: '4k',
|
|
24
57
|
});
|
|
25
58
|
const url = result.videos[0].url;
|
|
26
59
|
```
|
|
@@ -40,6 +73,12 @@ const url = result.videos[0].url;
|
|
|
40
73
|
- [Kling 3.0](https://runapi.ai/models/kling/3.0)
|
|
41
74
|
- [AI avatar pro](https://runapi.ai/models/kling/ai-avatar-pro)
|
|
42
75
|
- [AI avatar standard](https://runapi.ai/models/kling/ai-avatar-standard)
|
|
76
|
+
- [AI avatar v1 pro](https://runapi.ai/models/kling/ai-avatar-v1-pro)
|
|
77
|
+
- [V1 avatar standard](https://runapi.ai/models/kling/v1-avatar-standard)
|
|
78
|
+
- [V2.1 pro](https://runapi.ai/models/kling/v2.1-pro)
|
|
79
|
+
- [V2.1 standard](https://runapi.ai/models/kling/v2.1-standard)
|
|
80
|
+
- [V2.1 master text to video](https://runapi.ai/models/kling/v2.1-master-text-to-video)
|
|
81
|
+
- [V2.1 master image to video](https://runapi.ai/models/kling/v2.1-master-image-to-video)
|
|
43
82
|
- [V2.5 turbo text to video pro](https://runapi.ai/models/kling/v2.5-turbo-text-to-video-pro)
|
|
44
83
|
- [V2.5 turbo image to video pro](https://runapi.ai/models/kling/v2.5-turbo-image-to-video-pro)
|
|
45
84
|
|
package/skills/kling/SKILL.md
CHANGED
|
@@ -1,248 +1,87 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: kling
|
|
3
|
-
description: Generate
|
|
4
|
-
documentation: https://runapi.ai/models/kling
|
|
5
|
-
provider_page: https://runapi.ai/providers/kuaishou
|
|
6
|
-
catalog: https://runapi.ai/models
|
|
3
|
+
description: Generate and edit video with Kling through RunAPI. Use when the user asks an agent to create, edit, or transform video with Kling. Default to the RunAPI CLI for one-off generation; use SDKs only when the user is integrating RunAPI into an app or backend.
|
|
4
|
+
documentation: https://runapi.ai/models/kling.md
|
|
5
|
+
provider_page: https://runapi.ai/providers/kuaishou.md
|
|
6
|
+
catalog: https://runapi.ai/models.md
|
|
7
|
+
metadata:
|
|
8
|
+
openclaw:
|
|
9
|
+
homepage: https://runapi.ai/models/kling
|
|
10
|
+
requires:
|
|
11
|
+
bins:
|
|
12
|
+
- runapi
|
|
13
|
+
install:
|
|
14
|
+
- kind: brew
|
|
15
|
+
formula: runapi-ai/tap/runapi
|
|
16
|
+
bins:
|
|
17
|
+
- runapi
|
|
18
|
+
envVars:
|
|
19
|
+
- name: RUNAPI_API_KEY
|
|
20
|
+
required: false
|
|
21
|
+
description: Optional RunAPI API key; agents should prefer environment auth or saved CLI config. Browser login is interactive fallback only.
|
|
7
22
|
---
|
|
8
|
-
# @runapi.ai/kling — RunAPI.ai Kling video generation
|
|
9
23
|
|
|
10
|
-
|
|
24
|
+
# Kling on RunAPI
|
|
11
25
|
|
|
12
|
-
|
|
26
|
+
Generate and edit video with Kling through RunAPI. The default path for one-off agent tasks is the `runapi` CLI; SDKs are for application integration.
|
|
13
27
|
|
|
14
|
-
|
|
28
|
+
## Routing decision
|
|
15
29
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Set your API key in the environment:
|
|
21
|
-
|
|
22
|
-
```dotenv
|
|
23
|
-
# .env
|
|
24
|
-
RUNAPI_API_KEY=runapi_xxx # get one at https://runapi.ai/settings/api_keys
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
```ts
|
|
28
|
-
import { KlingClient } from '@runapi.ai/kling';
|
|
29
|
-
|
|
30
|
-
// The SDK reads RUNAPI_API_KEY from the environment automatically.
|
|
31
|
-
const client = new KlingClient();
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Pass `{ apiKey }` explicitly if you manage secrets differently. `baseUrl` defaults to `https://runapi.ai`; override only for local development.
|
|
35
|
-
|
|
36
|
-
## Core recipe — text to video
|
|
37
|
-
|
|
38
|
-
```ts
|
|
39
|
-
const result = await client.textToVideo.run({
|
|
40
|
-
model: 'kling-3.0',
|
|
41
|
-
prompt: 'A cat walking through a sunlit garden',
|
|
42
|
-
aspect_ratio: '16:9',
|
|
43
|
-
duration: '5',
|
|
44
|
-
mode: 'pro',
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const url = result.videos[0].url;
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
`run()` creates the task, auto-polls, and resolves only when the task completes — `videos[0].url` is guaranteed on the resolved value. On failure it throws `TaskFailedError`; on polling timeout it throws `TaskTimeoutError`. Use `run()` for scripts and short-lived processes. For request handlers, split it:
|
|
51
|
-
|
|
52
|
-
```ts
|
|
53
|
-
const { id } = await client.textToVideo.create({ model: 'kling-3.0', prompt: '...' });
|
|
54
|
-
// return 202 immediately; fetch later:
|
|
55
|
-
const status = await client.textToVideo.get(id);
|
|
56
|
-
if (status.status === 'completed') { /* ... */ }
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Do not hold a web worker open waiting on `run()`. Split + webhook is the production pattern.
|
|
60
|
-
|
|
61
|
-
`run()` polls every 2 s for up to 15 min by default. Tune when needed:
|
|
62
|
-
|
|
63
|
-
```ts
|
|
64
|
-
await client.textToVideo.run(params, { maxWaitMs: 30 * 60_000, pollIntervalMs: 5_000 });
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
If `TaskTimeoutError` fires, the task is still running server-side — resume with `textToVideo.get(id)` or finish via webhook.
|
|
68
|
-
|
|
69
|
-
## Image to video and multi-shot
|
|
70
|
-
|
|
71
|
-
Attach `image_urls` to animate a still frame. For multi-scene output, use `multi_shots: true` with per-shot prompts:
|
|
72
|
-
|
|
73
|
-
```ts
|
|
74
|
-
// Image to video
|
|
75
|
-
await client.textToVideo.run({
|
|
76
|
-
model: 'kling-3.0',
|
|
77
|
-
prompt: 'The dog starts running',
|
|
78
|
-
image_urls: ['https://cdn.example.com/dog.jpg'],
|
|
79
|
-
aspect_ratio: '16:9',
|
|
80
|
-
sound: true,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// Multi-shot (audio is always on for multi-shot)
|
|
84
|
-
await client.textToVideo.run({
|
|
85
|
-
model: 'kling-3.0',
|
|
86
|
-
multi_shots: true,
|
|
87
|
-
sound: true,
|
|
88
|
-
aspect_ratio: '16:9',
|
|
89
|
-
multi_prompt: [
|
|
90
|
-
{ prompt: 'Wide shot of a waterfall', duration: 4 },
|
|
91
|
-
{ prompt: 'Camera pans to a rainbow above', duration: 6 },
|
|
92
|
-
],
|
|
93
|
-
});
|
|
94
|
-
```
|
|
30
|
+
- One-off generation, editing, or transformation for the user → use the **CLI path** with the `runapi` binary.
|
|
31
|
+
- Building an app, backend, worker, library, or production codebase → use the **SDK integration path**.
|
|
95
32
|
|
|
96
|
-
##
|
|
97
|
-
|
|
98
|
-
Use the canonical text-to-video and image-to-video resources for the faster v2.5 Turbo variants:
|
|
99
|
-
|
|
100
|
-
```ts
|
|
101
|
-
// Text-to-video
|
|
102
|
-
await client.textToVideo.run({
|
|
103
|
-
model: 'kling-v2.5-turbo-text-to-video-pro',
|
|
104
|
-
prompt: 'A neon-lit alley at night, rain falling',
|
|
105
|
-
aspect_ratio: '9:16',
|
|
106
|
-
duration: '5',
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
// Image-to-video
|
|
110
|
-
await client.imageToVideo.run({
|
|
111
|
-
model: 'kling-v2.5-turbo-image-to-video-pro',
|
|
112
|
-
image_url: 'https://cdn.example.com/frame.jpg',
|
|
113
|
-
prompt: 'The character walks forward slowly',
|
|
114
|
-
duration: '10',
|
|
115
|
-
});
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
## AI avatars — talking-head video
|
|
33
|
+
## CLI path
|
|
119
34
|
|
|
120
|
-
|
|
35
|
+
The `runapi` binary is the runtime dependency. Run `runapi auth status` first. For agents and headless runs, prefer `RUNAPI_API_KEY` or import it into saved config with `printf '%s' "$RUNAPI_API_KEY" | runapi auth import-token --token -`. Use `runapi login` only when the user explicitly wants interactive browser auth.
|
|
121
36
|
|
|
122
|
-
|
|
123
|
-
const avatar = await client.aiAvatar.run({
|
|
124
|
-
model: 'kling-ai-avatar-pro',
|
|
125
|
-
image_url: 'https://cdn.example.com/headshot.jpg',
|
|
126
|
-
audio_url: 'https://cdn.example.com/voiceover.mp3',
|
|
127
|
-
prompt: 'Warm lighting, relaxed posture',
|
|
128
|
-
});
|
|
37
|
+
Inspect the available commands and request fields with CLI help:
|
|
129
38
|
|
|
130
|
-
|
|
39
|
+
```shell
|
|
40
|
+
runapi kling --help
|
|
41
|
+
runapi kling text-to-video --help
|
|
131
42
|
```
|
|
132
43
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
Pass one or more driving videos plus one or more input images:
|
|
44
|
+
Run a one-off task (synchronous — polls until the task completes):
|
|
136
45
|
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
model: 'kling-3.0',
|
|
140
|
-
input_urls: ['https://cdn.example.com/person.jpg'],
|
|
141
|
-
video_urls: ['https://cdn.example.com/dance.mp4'],
|
|
142
|
-
prompt: 'Match the dance motion exactly',
|
|
143
|
-
mode: '1080p',
|
|
144
|
-
character_orientation: 'image',
|
|
145
|
-
background_source: 'input_image',
|
|
146
|
-
});
|
|
46
|
+
```shell
|
|
47
|
+
runapi kling text-to-video --input-file request.json
|
|
147
48
|
```
|
|
148
49
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
| Resource | `model` values |
|
|
152
|
-
|---|---|
|
|
153
|
-
| `textToVideo` | `kling-3.0`, `kling-v2.5-turbo-text-to-video-pro` |
|
|
154
|
-
| `imageToVideo` | `kling-v2.5-turbo-image-to-video-pro` |
|
|
155
|
-
| `aiAvatar` | `kling-ai-avatar-pro`, `kling-ai-avatar-standard` |
|
|
156
|
-
| `motionControl` | `kling-3.0` |
|
|
157
|
-
|
|
158
|
-
Exact credit costs per model are shown at https://runapi.ai/pricing and in the dashboard — do not hardcode prices in application code.
|
|
159
|
-
|
|
160
|
-
## Callbacks (webhooks)
|
|
50
|
+
Submit asynchronously and poll separately:
|
|
161
51
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
await client.textToVideo.create({
|
|
166
|
-
model: 'kling-3.0',
|
|
167
|
-
prompt: '...',
|
|
168
|
-
callback_url: 'https://your.app/webhooks/runapi/kling',
|
|
169
|
-
});
|
|
52
|
+
```shell
|
|
53
|
+
runapi kling text-to-video --async --input-file request.json
|
|
54
|
+
runapi wait <task-id> --service kling --action text-to-video
|
|
170
55
|
```
|
|
171
56
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
```ts
|
|
175
|
-
{ id: string; status: 'completed' | 'failed'; videos?: { url: string }[]; error?: string }
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
**Always verify the signature before trusting the body.** RunAPI signs every callback with your account's Callback Secret (rotate at `/accounts/callback_secret`). Headers:
|
|
179
|
-
|
|
180
|
-
- `X-Callback-Id` — UUID, store to make handler idempotent
|
|
181
|
-
- `X-Callback-Timestamp` — unix seconds, reject if `|now - ts| > 300`
|
|
182
|
-
- `X-Callback-Signature` — base64 HMAC-SHA256 over `` `${id}.${ts}.${rawBody}` `` using the base64-decoded secret
|
|
183
|
-
|
|
184
|
-
```ts
|
|
185
|
-
import crypto from 'node:crypto';
|
|
186
|
-
|
|
187
|
-
function verify(raw: string, id: string, ts: string, sig: string, secret: string) {
|
|
188
|
-
const key = Buffer.from(secret, 'base64');
|
|
189
|
-
const mac = crypto.createHmac('sha256', key)
|
|
190
|
-
.update(`${id}.${ts}.${raw}`)
|
|
191
|
-
.digest('base64');
|
|
192
|
-
return crypto.timingSafeEqual(Buffer.from(mac), Buffer.from(sig));
|
|
193
|
-
}
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
Reply `2xx` within 10s; any non-2xx triggers retries.
|
|
197
|
-
|
|
198
|
-
## Errors
|
|
199
|
-
|
|
200
|
-
All errors are re-exported from `@runapi.ai/core`. Always `instanceof` — never string-match messages.
|
|
201
|
-
|
|
202
|
-
| Error | Status | Action |
|
|
203
|
-
|---|---|---|
|
|
204
|
-
| `AuthenticationError` | 401 | abort; surface "reconnect your API key" |
|
|
205
|
-
| `InsufficientCreditsError` | 402 | prompt user to top up at runapi.ai/billing |
|
|
206
|
-
| `ValidationError` | 400 / 422 | fix params; do not retry |
|
|
207
|
-
| `RateLimitError` | 429 | sleep `err.retryAfterMs`, then retry |
|
|
208
|
-
| `ServiceUnavailableError` | 503 / 455 | retry with backoff; transient service issue |
|
|
209
|
-
| `TaskFailedError` | — | show `err.details` to user; do not auto-retry |
|
|
210
|
-
| `TaskTimeoutError` | — | re-poll with `<resource>.get(id)` |
|
|
211
|
-
|
|
212
|
-
```ts
|
|
213
|
-
import { InsufficientCreditsError, TaskFailedError } from '@runapi.ai/kling';
|
|
214
|
-
|
|
215
|
-
try {
|
|
216
|
-
await client.textToVideo.run({ model: 'kling-3.0', prompt: '...' });
|
|
217
|
-
} catch (err) {
|
|
218
|
-
if (err instanceof InsufficientCreditsError) { /* surface top-up CTA */ }
|
|
219
|
-
else if (err instanceof TaskFailedError) { /* show err.details */ }
|
|
220
|
-
else throw err;
|
|
221
|
-
}
|
|
222
|
-
```
|
|
57
|
+
Available commands: `text-to-video`, `avatar`, `image-to-video`, `motion-control`.
|
|
223
58
|
|
|
224
|
-
|
|
59
|
+
For Kling 3.0 text-to-video requests, keep `model: "kling-3.0"` and choose `output_resolution: "720p"`, `"1080p"`, or `"4k"` as needed.
|
|
225
60
|
|
|
226
|
-
|
|
227
|
-
- Multi-shot mode requires `multi_shots: true` **and** `sound: true` — audio cannot be disabled.
|
|
228
|
-
- `image_urls` accepts at most 1 image in multi-shot mode.
|
|
229
|
-
- Motion controls expect both `input_urls` (images) and `video_urls` (driving motion); each is an array.
|
|
230
|
-
- `duration` is a string (`'3'` to `'15'`), not a number — matching the wire format.
|
|
231
|
-
- `callback_url` must be reachable from the public internet. `localhost` / `127.0.0.1` URLs will never fire — use a tunnel (cloudflared, ngrok, tailscale funnel) when developing locally.
|
|
61
|
+
## SDK integration path
|
|
232
62
|
|
|
233
|
-
|
|
63
|
+
When integrating Kling into an app, backend, worker, or library — not for one-off tasks — use a RunAPI SDK package:
|
|
234
64
|
|
|
235
|
-
|
|
65
|
+
- JavaScript / TypeScript: `@runapi.ai/kling`
|
|
66
|
+
- Ruby: `runapi-kling`
|
|
67
|
+
- Go: `github.com/runapi-ai/kling-sdk/go`
|
|
236
68
|
|
|
237
|
-
##
|
|
69
|
+
## References
|
|
238
70
|
|
|
239
|
-
|
|
71
|
+
- Model overview, pricing, and rate limits: https://runapi.ai/models/kling.md
|
|
72
|
+
- Provider comparison: https://runapi.ai/providers/kuaishou.md
|
|
73
|
+
- Full model catalog: https://runapi.ai/models.md
|
|
240
74
|
|
|
241
|
-
|
|
242
|
-
- [Kling 3.0](https://runapi.ai/models/kling/3.0)
|
|
243
|
-
- [AI avatar pro](https://runapi.ai/models/kling/ai-avatar-pro)
|
|
244
|
-
- [AI avatar standard](https://runapi.ai/models/kling/ai-avatar-standard)
|
|
245
|
-
- [V2.5 turbo text to video pro](https://runapi.ai/models/kling/v2.5-turbo-text-to-video-pro)
|
|
246
|
-
- [V2.5 turbo image to video pro](https://runapi.ai/models/kling/v2.5-turbo-image-to-video-pro)
|
|
75
|
+
## Variants
|
|
247
76
|
|
|
248
|
-
|
|
77
|
+
- [Kling 3.0](https://runapi.ai/models/kling/3.0.md)
|
|
78
|
+
- [AI avatar pro](https://runapi.ai/models/kling/ai-avatar-pro.md)
|
|
79
|
+
- [AI avatar standard](https://runapi.ai/models/kling/ai-avatar-standard.md)
|
|
80
|
+
- [AI avatar v1 pro](https://runapi.ai/models/kling/ai-avatar-v1-pro.md)
|
|
81
|
+
- [V1 avatar standard](https://runapi.ai/models/kling/v1-avatar-standard.md)
|
|
82
|
+
- [V2.1 pro](https://runapi.ai/models/kling/v2.1-pro.md)
|
|
83
|
+
- [V2.1 standard](https://runapi.ai/models/kling/v2.1-standard.md)
|
|
84
|
+
- [V2.1 master text to video](https://runapi.ai/models/kling/v2.1-master-text-to-video.md)
|
|
85
|
+
- [V2.1 master image to video](https://runapi.ai/models/kling/v2.1-master-image-to-video.md)
|
|
86
|
+
- [V2.5 turbo text to video pro](https://runapi.ai/models/kling/v2.5-turbo-text-to-video-pro.md)
|
|
87
|
+
- [V2.5 turbo image to video pro](https://runapi.ai/models/kling/v2.5-turbo-image-to-video-pro.md)
|