@runapi.ai/kling 0.2.13 → 0.3.1
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 +9 -5
- package/dist/index.d.mts +52 -2
- package/dist/index.d.ts +52 -2
- package/dist/index.js +457 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +443 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/skills/kling/README.md +3 -2
- package/skills/kling/SKILL.md +78 -49
package/skills/kling/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: kling
|
|
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.
|
|
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
4
|
documentation: https://runapi.ai/models/kling.md
|
|
5
5
|
provider_page: https://runapi.ai/providers/kuaishou.md
|
|
6
6
|
catalog: https://runapi.ai/models.md
|
|
@@ -23,81 +23,110 @@ metadata:
|
|
|
23
23
|
|
|
24
24
|
# Kling on RunAPI
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
## Choose route
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
- For a one-off artifact or result, use the registered `kling` service in the `runapi` CLI. If the installed command catalog does not list it, stop and report the missing service instead of inventing a command.
|
|
29
|
+
- For an app, backend, worker, library, webhook pipeline, or production codebase, go directly to **Integrate with SDK**. Never shell out to the CLI as the production runtime.
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
- One-off generation, editing, transformation, manual smoke tests, debugging, or user-requested CLI runs use the **CLI path** with the `runapi` binary. For full CLI-specific agent guidance, see https://github.com/runapi-ai/cli-skill.
|
|
32
|
-
- Never shell out to the `runapi` CLI as the production runtime integration layer.
|
|
31
|
+
## Discover contract
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
Authenticate, then inspect the installed command catalog and the selected operation's current contract:
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
```shell
|
|
36
|
+
runapi auth status > auth.json
|
|
37
|
+
jq -e '.authenticated == true' auth.json
|
|
38
|
+
runapi kling --help
|
|
39
|
+
runapi kling <operation> --help
|
|
40
|
+
curl --fail --location https://runapi.ai/docs/api/kling/<operation>.md --output contract.md
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
If authentication is false, stop before submitting. Ask the user to provide a valid `RUNAPI_API_KEY`, or import a user-provided key from stdin with `runapi auth import-token --token -`; use interactive browser login only when the user explicitly requests it. Choose `<operation>` only from service help. Treat command help as authoritative for the installed operation, model, and top-level field roster. Treat its API Reference as authoritative for the complete request schema, nested fields, conditional rules, task behavior, and response variants. If the two surfaces disagree, stop and report the contract mismatch instead of guessing.
|
|
44
|
+
|
|
45
|
+
## Build request
|
|
37
46
|
|
|
38
|
-
|
|
39
|
-
- PHP: `runapi-ai/kling`
|
|
40
|
-
- Ruby: `runapi-kling`
|
|
41
|
-
- Go: `github.com/runapi-ai/kling-sdk/go`
|
|
47
|
+
Create `request.json` as valid JSON using only fields accepted by the discovered operation contract. For the chosen model and values, evaluate every applicable conditional rule as a set: satisfy every required field, omit every forbidden field, and stop on unresolved contradictions.
|
|
42
48
|
|
|
43
|
-
|
|
49
|
+
Traverse nested objects and arrays before execution. Close every relationship stated by the discovered contract, including uniqueness constraints and cross-references between nested values.
|
|
44
50
|
|
|
45
|
-
|
|
51
|
+
For a discovered local media input, including file-typed fields and top-level media URL fields, put an agent-readable local file path directly in `request.json`. The CLI consumes file fields as declared and uploads local paths in top-level media URL fields. Use `runapi files create` only when the user needs a reusable URL, provides Base64, or the discovered contract explicitly requires a separate upload.
|
|
46
52
|
|
|
47
|
-
|
|
53
|
+
Validate the file before sending it:
|
|
48
54
|
|
|
49
55
|
```shell
|
|
50
|
-
|
|
51
|
-
runapi kling text-to-video --help
|
|
56
|
+
jq empty request.json
|
|
52
57
|
```
|
|
53
58
|
|
|
54
|
-
|
|
59
|
+
## Execute
|
|
60
|
+
|
|
61
|
+
Submit exactly once and persist the task response before waiting:
|
|
55
62
|
|
|
56
63
|
```shell
|
|
57
|
-
runapi kling
|
|
64
|
+
runapi kling <operation> --async --input-file request.json > task.json
|
|
65
|
+
task_id="$(jq -er '.id' task.json)"
|
|
58
66
|
```
|
|
59
67
|
|
|
60
|
-
|
|
68
|
+
For a one-off result, immediately wait for that same task and save the complete JSON response. This blocking wait is the default:
|
|
61
69
|
|
|
62
70
|
```shell
|
|
63
|
-
runapi
|
|
64
|
-
runapi wait <task-id> --service kling --action text-to-video
|
|
71
|
+
runapi wait "$task_id" --service kling --action <operation> > result.json
|
|
65
72
|
```
|
|
66
73
|
|
|
67
|
-
|
|
74
|
+
Only when the user explicitly asks for background execution, polling, or webhook integration may you stop after validating `task.json`. Report the task id and do not claim that the deliverable is complete.
|
|
68
75
|
|
|
69
|
-
|
|
70
|
-
For V3 Turbo text-to-video requests, use `model: "kling-v3-turbo-text-to-video"` with `output_resolution: "720p"` or `"1080p"`.
|
|
71
|
-
For V3 Turbo image-to-video requests, use `model: "kling-v3-turbo-image-to-video"` and provide `first_frame_image_url`.
|
|
72
|
-
For Kling 2.6 text-to-video, image-to-video, or motion-control requests, use `model: "kling-v2.6"`; `enable_sound: true` requires `mode: "pro"`, and `last_frame_image_url` additionally requires `duration_seconds: 5`. Motion control requires `source_image_url`, `output_resolution`, and `character_orientation`; its `reference_video_url` may be 3-10 seconds for image orientation or 3-30 seconds for video orientation. Do not send `background_source`.
|
|
73
|
-
For Kling O1 text-to-video or image-to-video requests, use `model: "kling-o1"`. Reference ordered images with public HTTP(S) `reference_image_urls` and `<<<image_1>>>`, `<<<image_2>>>`, and so on in `prompt`; reference the optional public HTTP(S) `reference_video_url` as `<<<video_1>>>`. With a video, send no more than four images. Do not combine `last_frame_image_url` with reference images or a reference video. Use `reference_video_type: "feature"` with the required first frame; `"base"` cannot be combined with frame inputs. Use `duration_seconds: 5`, `mode: "std"` or `"pro"`, and keep `enable_sound: false`.
|
|
74
|
-
For Kling V3 Omni text-to-video or image-to-video requests, use `model: "kling-v3-omni"`; image-to-video requires `first_frame_image_url`, and `last_frame_image_url` requires `duration_seconds: 5`.
|
|
76
|
+
## Verify
|
|
75
77
|
|
|
76
|
-
|
|
78
|
+
A success status is not the deliverable. Read and validate the complete response according to the discovered result contract. Preserve the complete non-media result in the exact requested format, including JSON, text, SRT, or VTT.
|
|
77
79
|
|
|
78
|
-
|
|
80
|
+
For every requested media deliverable listed anywhere in the response, download all of them rather than returning only the first URL. Before downloading, derive its expected MIME type or family from response metadata when present, then the selected output format, then an unambiguous result field such as `videos`, `images`, or `audios` in the API Reference. The Catalog-declared fallback families for this skill are `video/*`. Stop only when no single expected type or family can be established from those sources.
|
|
81
|
+
|
|
82
|
+
For every downloaded file, require both a non-empty file and the expected MIME type or family:
|
|
83
|
+
|
|
84
|
+
```shell
|
|
85
|
+
curl --fail --location <deliverable-url> --output <downloaded-file>
|
|
86
|
+
for file in <downloaded-files>; do
|
|
87
|
+
expected_mime=<expected-MIME-or-family-pattern-for-this-file>
|
|
88
|
+
test -s "$file"
|
|
89
|
+
[[ "$(file --brief --mime-type "$file")" == $expected_mime ]]
|
|
90
|
+
done
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Do not report completion when any requested deliverable is missing, empty, or has an unexpected MIME type. Record `Skill Conformance` separately from `Task Outcome` so a service failure does not hide whether this recipe was followed.
|
|
94
|
+
|
|
95
|
+
## Recover or stop
|
|
96
|
+
|
|
97
|
+
- Correct a request shape at most once, and only when the discovered contract or returned validation error identifies the correction.
|
|
98
|
+
- Retry a transient transport failure at most once, and only when evidence confirms that no task was created, no billing occurred, and retrying is safe.
|
|
99
|
+
- If waiting times out or loses transport after `task.json` exists, preserve the error and rerun `runapi wait` for that same task at most once. Never submit a replacement task.
|
|
100
|
+
- On a terminal RunAPI or service failure, preserve the task/error evidence and stop. Keep the selected model and capability, and do not submit another paid request without user authorization.
|
|
101
|
+
- If the contract is missing a fact required to build or verify the request, stop and report the contract gap. Do not turn a product defect into a permanent skill workaround.
|
|
102
|
+
|
|
103
|
+
## Integrate with SDK
|
|
104
|
+
|
|
105
|
+
Use this route only for application or production-code integration. Open the current RunAPI SDK reference below, select the package for the target language and `Kling`, and confirm its install command, client methods, request types, response types, and error classes before coding. Build the request from the same discovered product contract and apply the same deliverable verification and stop rules. Do not invoke `runapi` as a subprocess from production code.
|
|
79
106
|
|
|
80
107
|
## References
|
|
81
108
|
|
|
82
109
|
- Model overview, pricing, and rate limits: https://runapi.ai/models/kling.md
|
|
83
|
-
- Provider
|
|
110
|
+
- Provider overview: https://runapi.ai/providers/kuaishou.md
|
|
84
111
|
- Full model catalog: https://runapi.ai/models.md
|
|
112
|
+
- SDK integration: https://github.com/runapi-ai/kling-sdk
|
|
85
113
|
|
|
86
114
|
## Variants
|
|
87
|
-
|
|
88
|
-
-
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
-
-
|
|
94
|
-
-
|
|
95
|
-
-
|
|
96
|
-
-
|
|
97
|
-
-
|
|
98
|
-
-
|
|
99
|
-
-
|
|
100
|
-
-
|
|
101
|
-
-
|
|
102
|
-
-
|
|
103
|
-
-
|
|
115
|
+
- `kling-3.0`: https://runapi.ai/models/kling/3.0.md
|
|
116
|
+
- `kling-ai-avatar-pro`: https://runapi.ai/models/kling/ai-avatar-pro.md
|
|
117
|
+
- `kling-ai-avatar-standard`: https://runapi.ai/models/kling/ai-avatar-standard.md
|
|
118
|
+
- `kling-ai-avatar-v1-pro`: https://runapi.ai/models/kling/ai-avatar-v1-pro.md
|
|
119
|
+
- `kling-o1`: https://runapi.ai/models/kling/o1.md
|
|
120
|
+
- `kling-v1-avatar-standard`: https://runapi.ai/models/kling/v1-avatar-standard.md
|
|
121
|
+
- `kling-v2.1-master-image-to-video`: https://runapi.ai/models/kling/v2.1-master-image-to-video.md
|
|
122
|
+
- `kling-v2.1-master-text-to-video`: https://runapi.ai/models/kling/v2.1-master-text-to-video.md
|
|
123
|
+
- `kling-v2.1-pro`: https://runapi.ai/models/kling/v2.1-pro.md
|
|
124
|
+
- `kling-v2.1-standard`: https://runapi.ai/models/kling/v2.1-standard.md
|
|
125
|
+
- `kling-v2.5-turbo-image-to-video-pro`: https://runapi.ai/models/kling/v2.5-turbo-image-to-video-pro.md
|
|
126
|
+
- `kling-v2.5-turbo-text-to-video-pro`: https://runapi.ai/models/kling/v2.5-turbo-text-to-video-pro.md
|
|
127
|
+
- `kling-v2.6`: https://runapi.ai/models/kling/v2.6.md
|
|
128
|
+
- `kling-v3-omni`: https://runapi.ai/models/kling/v3-omni.md
|
|
129
|
+
- `kling-v3-omni-edit`: https://runapi.ai/models/kling/v3-omni-edit.md
|
|
130
|
+
- `kling-v3-omni-reference`: https://runapi.ai/models/kling/v3-omni-reference.md
|
|
131
|
+
- `kling-v3-turbo-image-to-video`: https://runapi.ai/models/kling/v3-turbo-image-to-video.md
|
|
132
|
+
- `kling-v3-turbo-text-to-video`: https://runapi.ai/models/kling/v3-turbo-text-to-video.md
|