@ai-sdk/klingai 0.0.0-b66d09a8-20260328011513
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/CHANGELOG.md +152 -0
- package/LICENSE +13 -0
- package/README.md +157 -0
- package/dist/index.d.mts +211 -0
- package/dist/index.d.ts +211 -0
- package/dist/index.js +639 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +630 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +70 -0
- package/src/index.ts +11 -0
- package/src/klingai-auth.ts +75 -0
- package/src/klingai-error.ts +14 -0
- package/src/klingai-provider.ts +116 -0
- package/src/klingai-video-model.ts +921 -0
- package/src/klingai-video-settings.ts +23 -0
- package/src/version.ts +3 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# @ai-sdk/klingai
|
|
2
|
+
|
|
3
|
+
## 0.0.0-b66d09a8-20260328011513
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 8359612: Start v7 pre-release
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- e569f5d: feat (provider/klingai): add kling v3.0 motion control support
|
|
12
|
+
- Updated dependencies [531251e]
|
|
13
|
+
- Updated dependencies [1f509d4]
|
|
14
|
+
- Updated dependencies [5c2a5a2]
|
|
15
|
+
- Updated dependencies [f7d4f01]
|
|
16
|
+
- Updated dependencies [776b617]
|
|
17
|
+
- Updated dependencies [3887c70]
|
|
18
|
+
- Updated dependencies [61753c3]
|
|
19
|
+
- Updated dependencies [8359612]
|
|
20
|
+
- @ai-sdk/provider-utils@0.0.0-b66d09a8-20260328011513
|
|
21
|
+
- @ai-sdk/provider@0.0.0-b66d09a8-20260328011513
|
|
22
|
+
|
|
23
|
+
## 4.0.0-beta.8
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [1f509d4]
|
|
28
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
29
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
30
|
+
|
|
31
|
+
## 4.0.0-beta.7
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [3887c70]
|
|
36
|
+
- @ai-sdk/provider-utils@5.0.0-beta.6
|
|
37
|
+
- @ai-sdk/provider@4.0.0-beta.4
|
|
38
|
+
|
|
39
|
+
## 4.0.0-beta.6
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Updated dependencies [776b617]
|
|
44
|
+
- @ai-sdk/provider-utils@5.0.0-beta.5
|
|
45
|
+
- @ai-sdk/provider@4.0.0-beta.3
|
|
46
|
+
|
|
47
|
+
## 4.0.0-beta.5
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- Updated dependencies [61753c3]
|
|
52
|
+
- @ai-sdk/provider-utils@5.0.0-beta.4
|
|
53
|
+
|
|
54
|
+
## 4.0.0-beta.4
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- Updated dependencies [f7d4f01]
|
|
59
|
+
- @ai-sdk/provider-utils@5.0.0-beta.3
|
|
60
|
+
- @ai-sdk/provider@4.0.0-beta.2
|
|
61
|
+
|
|
62
|
+
## 4.0.0-beta.3
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- Updated dependencies [5c2a5a2]
|
|
67
|
+
- @ai-sdk/provider@4.0.0-beta.1
|
|
68
|
+
- @ai-sdk/provider-utils@5.0.0-beta.2
|
|
69
|
+
|
|
70
|
+
## 4.0.0-beta.2
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- e569f5d: feat (provider/klingai): add kling v3.0 motion control support
|
|
75
|
+
|
|
76
|
+
## 4.0.0-beta.1
|
|
77
|
+
|
|
78
|
+
### Patch Changes
|
|
79
|
+
|
|
80
|
+
- Updated dependencies [531251e]
|
|
81
|
+
- @ai-sdk/provider-utils@5.0.0-beta.1
|
|
82
|
+
|
|
83
|
+
## 4.0.0-beta.0
|
|
84
|
+
|
|
85
|
+
### Major Changes
|
|
86
|
+
|
|
87
|
+
- 8359612: Start v7 pre-release
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- Updated dependencies [8359612]
|
|
92
|
+
- @ai-sdk/provider@4.0.0-beta.0
|
|
93
|
+
- @ai-sdk/provider-utils@5.0.0-beta.0
|
|
94
|
+
|
|
95
|
+
## 3.0.8
|
|
96
|
+
|
|
97
|
+
### Patch Changes
|
|
98
|
+
|
|
99
|
+
- Updated dependencies [ad4cfc2]
|
|
100
|
+
- @ai-sdk/provider-utils@4.0.19
|
|
101
|
+
|
|
102
|
+
## 3.0.7
|
|
103
|
+
|
|
104
|
+
### Patch Changes
|
|
105
|
+
|
|
106
|
+
- Updated dependencies [824b295]
|
|
107
|
+
- @ai-sdk/provider-utils@4.0.18
|
|
108
|
+
|
|
109
|
+
## 3.0.6
|
|
110
|
+
|
|
111
|
+
### Patch Changes
|
|
112
|
+
|
|
113
|
+
- Updated dependencies [08336f1]
|
|
114
|
+
- @ai-sdk/provider-utils@4.0.17
|
|
115
|
+
|
|
116
|
+
## 3.0.5
|
|
117
|
+
|
|
118
|
+
### Patch Changes
|
|
119
|
+
|
|
120
|
+
- Updated dependencies [58bc42d]
|
|
121
|
+
- @ai-sdk/provider-utils@4.0.16
|
|
122
|
+
|
|
123
|
+
## 3.0.4
|
|
124
|
+
|
|
125
|
+
### Patch Changes
|
|
126
|
+
|
|
127
|
+
- 3b19702: feat (provider/klingai): add kling v3.0 t2v and i2v support
|
|
128
|
+
|
|
129
|
+
## 3.0.3
|
|
130
|
+
|
|
131
|
+
### Patch Changes
|
|
132
|
+
|
|
133
|
+
- Updated dependencies [4024a3a]
|
|
134
|
+
- @ai-sdk/provider-utils@4.0.15
|
|
135
|
+
|
|
136
|
+
## 3.0.2
|
|
137
|
+
|
|
138
|
+
### Patch Changes
|
|
139
|
+
|
|
140
|
+
- 99fbed8: feat: normalize provider specific model options type names and ensure they are exported
|
|
141
|
+
|
|
142
|
+
## 3.0.1
|
|
143
|
+
|
|
144
|
+
### Patch Changes
|
|
145
|
+
|
|
146
|
+
- c43aeb2: feat (provider/klingai): add text-to-video and image-to-video support
|
|
147
|
+
|
|
148
|
+
## 3.0.0
|
|
149
|
+
|
|
150
|
+
### Major Changes
|
|
151
|
+
|
|
152
|
+
- cc12a89: feat (provider/klingai): initial klingai provider
|
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Vercel, Inc.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# AI SDK - Kling AI Provider
|
|
2
|
+
|
|
3
|
+
The **Kling AI provider** for the [AI SDK](https://ai-sdk.dev/docs) contains video model support for the [Kling AI API](https://app.klingai.com/global/dev/document-api/quickStart/productIntroduction/overview).
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
The Kling AI provider is available in the `@ai-sdk/klingai` module. You can install it with:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i @ai-sdk/klingai
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Skill for Coding Agents
|
|
14
|
+
|
|
15
|
+
If you use coding agents such as Claude Code or Cursor, we highly recommend adding the AI SDK skill to your repository:
|
|
16
|
+
|
|
17
|
+
```shell
|
|
18
|
+
npx skills add vercel/ai
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Provider Instance
|
|
22
|
+
|
|
23
|
+
You can import the default provider instance `klingai` from `@ai-sdk/klingai`:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { klingai } from '@ai-sdk/klingai';
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Video Models
|
|
30
|
+
|
|
31
|
+
This provider currently supports three video generation modes: text-to-video, image-to-video, and motion control.
|
|
32
|
+
|
|
33
|
+
> **Note:** Not all options are supported by every model version and mode combination. See the [KlingAI Capability Map](https://app.klingai.com/global/dev/document-api/apiReference/model/skillsMap) for detailed compatibility.
|
|
34
|
+
|
|
35
|
+
### Text-to-Video
|
|
36
|
+
|
|
37
|
+
Generate video from a text prompt.
|
|
38
|
+
|
|
39
|
+
Available models: `kling-v1-t2v`, `kling-v1.6-t2v`, `kling-v2-master-t2v`, `kling-v2.1-master-t2v`, `kling-v2.5-turbo-t2v`, `kling-v2.6-t2v`
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { klingai } from '@ai-sdk/klingai';
|
|
43
|
+
import { experimental_generateVideo } from 'ai';
|
|
44
|
+
|
|
45
|
+
const { videos } = await experimental_generateVideo({
|
|
46
|
+
model: klingai.video('kling-v2.6-t2v'),
|
|
47
|
+
prompt: 'A chicken flying into the sunset in the style of 90s anime.',
|
|
48
|
+
aspectRatio: '16:9',
|
|
49
|
+
duration: 5,
|
|
50
|
+
providerOptions: {
|
|
51
|
+
klingai: {
|
|
52
|
+
mode: 'std',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Image-to-Video
|
|
59
|
+
|
|
60
|
+
Generate video from a start frame image, with optional end frame control.
|
|
61
|
+
|
|
62
|
+
Available models: `kling-v1-i2v`, `kling-v1.5-i2v`, `kling-v1.6-i2v`, `kling-v2-master-i2v`, `kling-v2.1-i2v`, `kling-v2.1-master-i2v`, `kling-v2.5-turbo-i2v`, `kling-v2.6-i2v`
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { klingai } from '@ai-sdk/klingai';
|
|
66
|
+
import { experimental_generateVideo } from 'ai';
|
|
67
|
+
|
|
68
|
+
const { videos } = await experimental_generateVideo({
|
|
69
|
+
model: klingai.video('kling-v2.6-i2v'),
|
|
70
|
+
prompt: {
|
|
71
|
+
image: 'https://example.com/start-frame.png',
|
|
72
|
+
text: 'The cat slowly turns its head and blinks',
|
|
73
|
+
},
|
|
74
|
+
duration: 5,
|
|
75
|
+
providerOptions: {
|
|
76
|
+
klingai: {
|
|
77
|
+
// Pro mode required for start+end frame control
|
|
78
|
+
mode: 'pro',
|
|
79
|
+
// Optional: end frame image
|
|
80
|
+
imageTail: 'https://example.com/end-frame.png',
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Motion Control
|
|
87
|
+
|
|
88
|
+
Generate video using a reference motion video.
|
|
89
|
+
|
|
90
|
+
Available models: `kling-v2.6-motion-control`
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import { klingai } from '@ai-sdk/klingai';
|
|
94
|
+
import { experimental_generateVideo } from 'ai';
|
|
95
|
+
|
|
96
|
+
const { videos } = await experimental_generateVideo({
|
|
97
|
+
model: klingai.video('kling-v2.6-motion-control'),
|
|
98
|
+
prompt: {
|
|
99
|
+
image: 'https://example.com/character.png',
|
|
100
|
+
text: 'The character performs a smooth dance move',
|
|
101
|
+
},
|
|
102
|
+
providerOptions: {
|
|
103
|
+
klingai: {
|
|
104
|
+
videoUrl: 'https://example.com/reference-motion.mp4',
|
|
105
|
+
characterOrientation: 'image',
|
|
106
|
+
mode: 'std',
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Provider Options
|
|
113
|
+
|
|
114
|
+
Use `providerOptions.klingai` to configure video generation. Options vary by mode:
|
|
115
|
+
|
|
116
|
+
| Option | T2V | I2V | Motion Control | Description |
|
|
117
|
+
| ---------------------- | ----------------- | ----------------- | ----------------- | ------------------------------- |
|
|
118
|
+
| `mode` | `'std'` / `'pro'` | `'std'` / `'pro'` | `'std'` / `'pro'` | Generation quality mode |
|
|
119
|
+
| `negativePrompt` | Yes | Yes | — | What to avoid (max 2500 chars) |
|
|
120
|
+
| `sound` | V2.6+ pro only | V2.6+ pro only | — | `'on'` / `'off'` for audio |
|
|
121
|
+
| `cfgScale` | Yes (V1.x) | Yes (V1.x) | — | Prompt adherence [0, 1] |
|
|
122
|
+
| `cameraControl` | Yes | Yes | — | Camera movement presets |
|
|
123
|
+
| `imageTail` | — | Pro mode | — | End frame image (URL or base64) |
|
|
124
|
+
| `staticMask` | — | Yes | — | Static brush mask |
|
|
125
|
+
| `dynamicMasks` | — | Yes | — | Dynamic brush configs |
|
|
126
|
+
| `videoUrl` | — | — | Required | Reference motion video URL |
|
|
127
|
+
| `characterOrientation` | — | — | Required | `'image'` or `'video'` |
|
|
128
|
+
| `keepOriginalSound` | — | — | Yes | `'yes'` / `'no'` |
|
|
129
|
+
| `watermarkEnabled` | — | — | Yes | Enable watermark |
|
|
130
|
+
| `pollIntervalMs` | Yes | Yes | Yes | Poll interval (default: 5000ms) |
|
|
131
|
+
| `pollTimeoutMs` | Yes | Yes | Yes | Max wait (default: 600000ms) |
|
|
132
|
+
|
|
133
|
+
See the [KlingAI Capability Map](https://app.klingai.com/global/dev/document-api/apiReference/model/skillsMap) for which features each model version supports.
|
|
134
|
+
|
|
135
|
+
## Authentication
|
|
136
|
+
|
|
137
|
+
Kling AI uses access key / secret key authentication. Set the following environment variables:
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
KLINGAI_ACCESS_KEY=your-access-key
|
|
141
|
+
KLINGAI_SECRET_KEY=your-secret-key
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Or pass them directly:
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
import { createKlingAI } from '@ai-sdk/klingai';
|
|
148
|
+
|
|
149
|
+
const klingai = createKlingAI({
|
|
150
|
+
accessKey: 'your-access-key',
|
|
151
|
+
secretKey: 'your-secret-key',
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Documentation
|
|
156
|
+
|
|
157
|
+
Please check out the [Kling AI API documentation](https://app.klingai.com/global/dev/document-api/quickStart/productIntroduction/overview) for more information.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { ProviderV4, Experimental_VideoModelV4 } from '@ai-sdk/provider';
|
|
2
|
+
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
+
|
|
4
|
+
type KlingAIVideoModelId = 'kling-v1-t2v' | 'kling-v1.6-t2v' | 'kling-v2-master-t2v' | 'kling-v2.1-master-t2v' | 'kling-v2.5-turbo-t2v' | 'kling-v2.6-t2v' | 'kling-v3.0-t2v' | 'kling-v1-i2v' | 'kling-v1.5-i2v' | 'kling-v1.6-i2v' | 'kling-v2-master-i2v' | 'kling-v2.1-i2v' | 'kling-v2.1-master-i2v' | 'kling-v2.5-turbo-i2v' | 'kling-v2.6-i2v' | 'kling-v3.0-i2v' | 'kling-v2.6-motion-control' | 'kling-v3.0-motion-control' | (string & {});
|
|
5
|
+
|
|
6
|
+
interface KlingAIProviderSettings {
|
|
7
|
+
/**
|
|
8
|
+
* KlingAI Access key. Default value is taken from the `KLINGAI_ACCESS_KEY`
|
|
9
|
+
* environment variable.
|
|
10
|
+
*/
|
|
11
|
+
accessKey?: string;
|
|
12
|
+
/**
|
|
13
|
+
* KlingAI Secret key. Default value is taken from the `KLINGAI_SECRET_KEY`
|
|
14
|
+
* environment variable.
|
|
15
|
+
*/
|
|
16
|
+
secretKey?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Base URL for the API calls.
|
|
19
|
+
*/
|
|
20
|
+
baseURL?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Custom headers to include in the requests.
|
|
23
|
+
*/
|
|
24
|
+
headers?: Record<string, string>;
|
|
25
|
+
/**
|
|
26
|
+
* Custom fetch implementation. You can use it as a middleware to intercept
|
|
27
|
+
* requests, or to provide a custom fetch implementation for e.g. testing.
|
|
28
|
+
*/
|
|
29
|
+
fetch?: FetchFunction;
|
|
30
|
+
}
|
|
31
|
+
interface KlingAIProvider extends ProviderV4 {
|
|
32
|
+
/**
|
|
33
|
+
* Creates a model for video generation.
|
|
34
|
+
*/
|
|
35
|
+
video(modelId: KlingAIVideoModelId): Experimental_VideoModelV4;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a model for video generation.
|
|
38
|
+
*/
|
|
39
|
+
videoModel(modelId: KlingAIVideoModelId): Experimental_VideoModelV4;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Create a KlingAI provider instance.
|
|
43
|
+
*/
|
|
44
|
+
declare function createKlingAI(options?: KlingAIProviderSettings): KlingAIProvider;
|
|
45
|
+
/**
|
|
46
|
+
* Default KlingAI provider instance.
|
|
47
|
+
*/
|
|
48
|
+
declare const klingai: KlingAIProvider;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Provider-specific options for KlingAI video generation.
|
|
52
|
+
*
|
|
53
|
+
* Not all options are supported by every model version and video mode (T2V, I2V,
|
|
54
|
+
* motion control). See the KlingAI capability map for detailed compatibility:
|
|
55
|
+
* https://app.klingai.com/global/dev/document-api/apiReference/model/skillsMap
|
|
56
|
+
*/
|
|
57
|
+
type KlingAIVideoModelOptions = {
|
|
58
|
+
/**
|
|
59
|
+
* Video generation mode.
|
|
60
|
+
*
|
|
61
|
+
* - `'std'`: Standard mode — cost-effective.
|
|
62
|
+
* - `'pro'`: Professional mode — higher quality but longer generation time.
|
|
63
|
+
*/
|
|
64
|
+
mode?: 'std' | 'pro' | null;
|
|
65
|
+
/**
|
|
66
|
+
* Polling interval in milliseconds for checking task status.
|
|
67
|
+
* Default: 5000 (5 seconds).
|
|
68
|
+
*/
|
|
69
|
+
pollIntervalMs?: number | null;
|
|
70
|
+
/**
|
|
71
|
+
* Maximum time in milliseconds to wait for video generation.
|
|
72
|
+
* Default: 600000 (10 minutes).
|
|
73
|
+
*/
|
|
74
|
+
pollTimeoutMs?: number | null;
|
|
75
|
+
/**
|
|
76
|
+
* Negative text prompt to specify what to avoid.
|
|
77
|
+
* Cannot exceed 2500 characters.
|
|
78
|
+
*/
|
|
79
|
+
negativePrompt?: string | null;
|
|
80
|
+
/**
|
|
81
|
+
* Whether to generate sound simultaneously when generating videos.
|
|
82
|
+
* Only V2.6 and subsequent versions support this parameter,
|
|
83
|
+
* and requires `mode: 'pro'`.
|
|
84
|
+
*/
|
|
85
|
+
sound?: 'on' | 'off' | null;
|
|
86
|
+
/**
|
|
87
|
+
* Flexibility in video generation. The higher the value, the lower the
|
|
88
|
+
* model's flexibility, and the stronger the relevance to the user's prompt.
|
|
89
|
+
* Value range: [0, 1]. Kling-v2.x models do not support this parameter.
|
|
90
|
+
*/
|
|
91
|
+
cfgScale?: number | null;
|
|
92
|
+
/**
|
|
93
|
+
* Camera movement control. If not specified, the model will intelligently
|
|
94
|
+
* match based on the input text/images.
|
|
95
|
+
*/
|
|
96
|
+
cameraControl?: {
|
|
97
|
+
type: 'simple' | 'down_back' | 'forward_up' | 'right_turn_forward' | 'left_turn_forward';
|
|
98
|
+
config?: {
|
|
99
|
+
horizontal?: number | null;
|
|
100
|
+
vertical?: number | null;
|
|
101
|
+
pan?: number | null;
|
|
102
|
+
tilt?: number | null;
|
|
103
|
+
roll?: number | null;
|
|
104
|
+
zoom?: number | null;
|
|
105
|
+
} | null;
|
|
106
|
+
} | null;
|
|
107
|
+
/**
|
|
108
|
+
* End frame image for I2V start+end frame control.
|
|
109
|
+
* Supports image URL or raw base64-encoded image data.
|
|
110
|
+
* Requires `mode: 'pro'` for most models.
|
|
111
|
+
*/
|
|
112
|
+
imageTail?: string | null;
|
|
113
|
+
/**
|
|
114
|
+
* Static brush mask image for I2V motion brush.
|
|
115
|
+
* Supports image URL or raw base64-encoded image data.
|
|
116
|
+
*/
|
|
117
|
+
staticMask?: string | null;
|
|
118
|
+
/**
|
|
119
|
+
* Dynamic brush configurations for I2V motion brush.
|
|
120
|
+
* Up to 6 groups, each with a mask and motion trajectories.
|
|
121
|
+
*/
|
|
122
|
+
dynamicMasks?: Array<{
|
|
123
|
+
mask: string;
|
|
124
|
+
trajectories: Array<{
|
|
125
|
+
x: number;
|
|
126
|
+
y: number;
|
|
127
|
+
}>;
|
|
128
|
+
}> | null;
|
|
129
|
+
/**
|
|
130
|
+
* Enable multi-shot video generation (Kling v3.0+).
|
|
131
|
+
* When true, the video is split into up to 6 storyboard shots
|
|
132
|
+
* with individual prompts and durations.
|
|
133
|
+
*
|
|
134
|
+
* When multiShot is true with shotType 'customize', multiPrompt is required.
|
|
135
|
+
* When multiShot is true, the main prompt parameter is ignored by the API.
|
|
136
|
+
*/
|
|
137
|
+
multiShot?: boolean | null;
|
|
138
|
+
/**
|
|
139
|
+
* Storyboard method for multi-shot video generation (Kling v3.0+).
|
|
140
|
+
* Required when multiShot is true.
|
|
141
|
+
*
|
|
142
|
+
* - `'customize'`: User-defined shots via multiPrompt.
|
|
143
|
+
* - `'intelligence'`: Model auto-segments based on the main prompt.
|
|
144
|
+
*/
|
|
145
|
+
shotType?: 'customize' | 'intelligence' | null;
|
|
146
|
+
/**
|
|
147
|
+
* Per-shot details for multi-shot video generation (Kling v3.0+).
|
|
148
|
+
* Required when multiShot is true and shotType is 'customize'.
|
|
149
|
+
*
|
|
150
|
+
* Up to 6 shots. Each shot has an index, prompt (max 512 chars),
|
|
151
|
+
* and duration in seconds. Shot durations must sum to the total duration.
|
|
152
|
+
*/
|
|
153
|
+
multiPrompt?: Array<{
|
|
154
|
+
index: number;
|
|
155
|
+
prompt: string;
|
|
156
|
+
duration: string;
|
|
157
|
+
}> | null;
|
|
158
|
+
/**
|
|
159
|
+
* Reference elements for element control (Kling v3.0+).
|
|
160
|
+
* Supports video character elements and multi-image elements.
|
|
161
|
+
*
|
|
162
|
+
* - I2V: Up to 3 reference elements. Cannot coexist with voiceList.
|
|
163
|
+
* - Motion Control: Currently only 1 element supported.
|
|
164
|
+
* When referencing an element, the generated video can only
|
|
165
|
+
* refer to the orientation of the person in the video.
|
|
166
|
+
*/
|
|
167
|
+
elementList?: Array<{
|
|
168
|
+
element_id: number;
|
|
169
|
+
}> | null;
|
|
170
|
+
/**
|
|
171
|
+
* Voice references for voice control (Kling v3.0+).
|
|
172
|
+
* Up to 2 voice references. Referenced via `<<<voice_1>>>` template
|
|
173
|
+
* syntax in the prompt.
|
|
174
|
+
*
|
|
175
|
+
* When voiceList is used and the prompt references voice IDs,
|
|
176
|
+
* sound must be set to 'on'.
|
|
177
|
+
* Cannot coexist with elementList on the I2V endpoint.
|
|
178
|
+
*/
|
|
179
|
+
voiceList?: Array<{
|
|
180
|
+
voice_id: string;
|
|
181
|
+
}> | null;
|
|
182
|
+
/**
|
|
183
|
+
* Whether to generate watermarked results simultaneously.
|
|
184
|
+
*/
|
|
185
|
+
watermarkEnabled?: boolean | null;
|
|
186
|
+
/**
|
|
187
|
+
* URL of the reference video. The character actions in the generated video
|
|
188
|
+
* are consistent with the reference video.
|
|
189
|
+
*
|
|
190
|
+
* Supports .mp4/.mov, max 100MB, side lengths 340px–3850px,
|
|
191
|
+
* duration 3–30 seconds (depends on `characterOrientation`).
|
|
192
|
+
*/
|
|
193
|
+
videoUrl?: string | null;
|
|
194
|
+
/**
|
|
195
|
+
* Orientation of the characters in the generated video.
|
|
196
|
+
*
|
|
197
|
+
* - `'image'`: Same orientation as the person in the image.
|
|
198
|
+
* Reference video duration max 10 seconds.
|
|
199
|
+
* - `'video'`: Same orientation as the person in the video.
|
|
200
|
+
* Reference video duration max 30 seconds.
|
|
201
|
+
*/
|
|
202
|
+
characterOrientation?: 'image' | 'video' | null;
|
|
203
|
+
/**
|
|
204
|
+
* Whether to keep the original sound of the reference video.
|
|
205
|
+
* Default: `'yes'`.
|
|
206
|
+
*/
|
|
207
|
+
keepOriginalSound?: 'yes' | 'no' | null;
|
|
208
|
+
[key: string]: unknown;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export { type KlingAIProvider, type KlingAIProviderSettings, type KlingAIVideoModelId, type KlingAIVideoModelOptions, type KlingAIVideoModelOptions as KlingAIVideoProviderOptions, createKlingAI, klingai };
|