@runapi.ai/kling 0.2.1 → 0.2.4
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/package.json +2 -2
- package/skills/kling/README.md +34 -2
- package/skills/kling/SKILL.md +53 -221
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runapi.ai/kling",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
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.4"
|
|
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
|
|
package/skills/kling/SKILL.md
CHANGED
|
@@ -1,248 +1,80 @@
|
|
|
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 actions 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 actions: `text-to-video`, `avatar`, `image-to-video`, `motion-control`.
|
|
223
58
|
|
|
224
|
-
##
|
|
59
|
+
## SDK integration path
|
|
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
|
+
When integrating Kling into an app, backend, worker, or library — not for one-off tasks — use a RunAPI SDK package:
|
|
232
62
|
|
|
233
|
-
|
|
63
|
+
- JavaScript / TypeScript: `@runapi.ai/kling`
|
|
64
|
+
- Ruby: `runapi-kling`
|
|
65
|
+
- Go: `github.com/runapi-ai/kling-sdk/go`
|
|
234
66
|
|
|
235
|
-
|
|
67
|
+
## References
|
|
236
68
|
|
|
237
|
-
|
|
69
|
+
- Model overview, pricing, and rate limits: https://runapi.ai/models/kling.md
|
|
70
|
+
- Provider comparison: https://runapi.ai/providers/kuaishou.md
|
|
71
|
+
- Full model catalog: https://runapi.ai/models.md
|
|
238
72
|
|
|
239
|
-
|
|
73
|
+
## Variants
|
|
240
74
|
|
|
241
|
-
|
|
242
|
-
- [
|
|
243
|
-
- [AI avatar
|
|
244
|
-
- [
|
|
245
|
-
- [V2.5 turbo
|
|
246
|
-
- [V2.5 turbo image to video pro](https://runapi.ai/models/kling/v2.5-turbo-image-to-video-pro)
|
|
75
|
+
- [Kling 3.0](https://runapi.ai/models/kling/3.0.md)
|
|
76
|
+
- [AI avatar pro](https://runapi.ai/models/kling/ai-avatar-pro.md)
|
|
77
|
+
- [AI avatar standard](https://runapi.ai/models/kling/ai-avatar-standard.md)
|
|
78
|
+
- [V2.5 turbo text to video pro](https://runapi.ai/models/kling/v2.5-turbo-text-to-video-pro.md)
|
|
79
|
+
- [V2.5 turbo image to video pro](https://runapi.ai/models/kling/v2.5-turbo-image-to-video-pro.md)
|
|
247
80
|
|
|
248
|
-
Compare Kling with other Kuaishou models at https://runapi.ai/providers/kuaishou. Browse every RunAPI model and skill at https://runapi.ai/models. SDK repository: https://github.com/runapi-ai/kling-sdk. Skill repository: https://github.com/runapi-ai/kling.
|