@runapi.ai/kling 0.2.4 → 0.2.8
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 +4 -2
- package/dist/index.d.mts +187 -32
- package/dist/index.d.ts +187 -32
- package/dist/index.js +82 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/skills/kling/README.md +9 -0
- package/skills/kling/SKILL.md +24 -12
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
|
|
|
@@ -24,9 +24,11 @@ const status = await client.generations.get(task.id);
|
|
|
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.
|
|
26
26
|
|
|
27
|
+
RunAPI-generated file URLs are temporary. Download and store generated images, videos, audio, or other files in your own durable storage within 7 days; do not treat returned URLs as long-term assets.
|
|
28
|
+
|
|
27
29
|
## Language notes
|
|
28
30
|
|
|
29
|
-
Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building video applications. The available resources include
|
|
31
|
+
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
32
|
|
|
31
33
|
## Links
|
|
32
34
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,61 +1,111 @@
|
|
|
1
|
-
import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, ClientOptions } from '@runapi.ai/core';
|
|
1
|
+
import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, BaseClient, 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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Text-to-video model variants. kling-3.0 supports multi-shot, sound, first/last frame images,
|
|
6
|
+
* and Kling elements. V2.x models support negative prompts and cfg_scale instead.
|
|
7
|
+
*/
|
|
8
|
+
type KlingTextToVideoModel = 'kling-3.0' | 'kling-v2.5-turbo-text-to-video-pro' | 'kling-v2.1-master-text-to-video';
|
|
9
|
+
/**
|
|
10
|
+
* Image-to-video model variants. V2.5 turbo and V2.1 pro support last-frame image control.
|
|
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';
|
|
13
|
+
/** Output resolution for text-to-video. 4k is highest quality but slowest. */
|
|
14
|
+
type KlingTextToVideoOutputResolution = '720p' | '1080p' | '4k';
|
|
7
15
|
type KlingAspectRatio = '16:9' | '9:16' | '1:1';
|
|
8
|
-
|
|
16
|
+
/** Duration in seconds. Range varies by model: 3-15 for kling-3.0, 5 or 10 for V2.x. */
|
|
17
|
+
type KlingDuration = number;
|
|
9
18
|
/** A single shot in a multi-shot text-to-video sequence. */
|
|
10
19
|
interface MultiPromptItem {
|
|
11
20
|
prompt: string;
|
|
12
|
-
|
|
21
|
+
duration_seconds: number;
|
|
13
22
|
}
|
|
14
|
-
/**
|
|
23
|
+
/** Named visual element (character, object, style) with reference images or videos for generation consistency. */
|
|
15
24
|
interface KlingElement {
|
|
25
|
+
/** Element identifier used for prompt referencing. */
|
|
16
26
|
name: string;
|
|
27
|
+
/** Description of the element's visual characteristics. */
|
|
17
28
|
description: string;
|
|
29
|
+
/** Image URLs providing visual reference for the element. */
|
|
18
30
|
element_input_urls?: string[];
|
|
31
|
+
/** Video URLs providing motion/appearance reference for the element. */
|
|
19
32
|
element_input_video_urls?: string[];
|
|
20
33
|
}
|
|
21
34
|
interface Kling3TextToVideoCommonParams {
|
|
22
35
|
model: 'kling-3.0';
|
|
23
|
-
|
|
36
|
+
/** Duration in seconds (3-15). */
|
|
37
|
+
duration_seconds?: KlingDuration;
|
|
24
38
|
aspect_ratio?: KlingAspectRatio;
|
|
25
|
-
|
|
39
|
+
output_resolution?: KlingTextToVideoOutputResolution;
|
|
40
|
+
/** Visual elements for subject/style consistency across the video. */
|
|
26
41
|
kling_elements?: KlingElement[];
|
|
42
|
+
/** URL for completion callback notifications. */
|
|
27
43
|
callback_url?: string;
|
|
28
44
|
}
|
|
45
|
+
/** Kling 3.0 single-shot text-to-video with optional sound and first/last frame control. */
|
|
29
46
|
interface Kling3TextToVideoSingleShotParams extends Kling3TextToVideoCommonParams {
|
|
47
|
+
/** Video description prompt. */
|
|
30
48
|
prompt: string;
|
|
31
|
-
|
|
32
|
-
|
|
49
|
+
/** Generate synchronized audio for the video. */
|
|
50
|
+
enable_sound?: boolean;
|
|
51
|
+
/** Opening frame image URL; overrides the generated first frame. */
|
|
52
|
+
first_frame_image_url?: string;
|
|
53
|
+
/** Closing frame image URL; only available in single-shot mode. */
|
|
54
|
+
last_frame_image_url?: string;
|
|
33
55
|
}
|
|
56
|
+
/** Kling 3.0 multi-shot mode: stitch multiple prompted segments into one video with sound. */
|
|
34
57
|
interface Kling3TextToVideoMultiShotParams extends Kling3TextToVideoCommonParams {
|
|
58
|
+
/** Must be true to activate multi-shot generation. */
|
|
35
59
|
multi_shots: true;
|
|
36
|
-
|
|
60
|
+
/** Must be true; sound is always generated in multi-shot mode. */
|
|
61
|
+
enable_sound: true;
|
|
62
|
+
/** Ordered shot segments, each with its own prompt and duration. */
|
|
37
63
|
multi_prompt: MultiPromptItem[];
|
|
38
|
-
|
|
64
|
+
/** Opening frame image URL for the first shot. */
|
|
65
|
+
first_frame_image_url?: string;
|
|
39
66
|
}
|
|
67
|
+
/** V2.5 Turbo text-to-video: fast, high-quality generation with negative prompt and cfg_scale control. */
|
|
40
68
|
interface V25TurboTextToVideoParams {
|
|
41
69
|
model: 'kling-v2.5-turbo-text-to-video-pro';
|
|
42
70
|
prompt: string;
|
|
43
|
-
|
|
71
|
+
/** Duration: 5 or 10 seconds. */
|
|
72
|
+
duration_seconds?: 5 | 10;
|
|
44
73
|
aspect_ratio?: KlingAspectRatio;
|
|
74
|
+
/** Elements to exclude from the generated video. */
|
|
45
75
|
negative_prompt?: string;
|
|
76
|
+
/** Prompt adherence strength (higher = more literal). */
|
|
46
77
|
cfg_scale?: number;
|
|
47
78
|
callback_url?: string;
|
|
48
79
|
}
|
|
80
|
+
/** V2.1 Master text-to-video: highest V2.1 quality with negative prompt and cfg_scale control. */
|
|
81
|
+
interface V21MasterTextToVideoParams {
|
|
82
|
+
model: 'kling-v2.1-master-text-to-video';
|
|
83
|
+
prompt: string;
|
|
84
|
+
duration_seconds?: 5 | 10;
|
|
85
|
+
aspect_ratio?: KlingAspectRatio;
|
|
86
|
+
negative_prompt?: string;
|
|
87
|
+
cfg_scale?: number;
|
|
88
|
+
callback_url?: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Image-to-video generation parameters. A first-frame image is required; the model
|
|
92
|
+
* animates it into video guided by the text prompt. last_frame_image_url is supported
|
|
93
|
+
* on V2.5 turbo and V2.1 pro models only.
|
|
94
|
+
*/
|
|
49
95
|
interface ImageToVideoParams {
|
|
50
|
-
model:
|
|
96
|
+
model: KlingImageToVideoModel;
|
|
97
|
+
/** Video motion description prompt. */
|
|
51
98
|
prompt: string;
|
|
52
|
-
|
|
53
|
-
|
|
99
|
+
/** Source image URL used as the video's opening frame. */
|
|
100
|
+
first_frame_image_url: string;
|
|
101
|
+
duration_seconds?: 5 | 10;
|
|
54
102
|
negative_prompt?: string;
|
|
55
103
|
cfg_scale?: number;
|
|
104
|
+
/** Target ending frame image URL; supported on V2.5 turbo and V2.1 pro. */
|
|
105
|
+
last_frame_image_url?: string;
|
|
56
106
|
callback_url?: string;
|
|
57
107
|
}
|
|
58
|
-
type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | V25TurboTextToVideoParams;
|
|
108
|
+
type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams;
|
|
59
109
|
interface AsyncTaskResponse {
|
|
60
110
|
id: string;
|
|
61
111
|
status: AsyncTaskStatus;
|
|
@@ -76,11 +126,19 @@ interface ImageToVideoResponse extends AsyncTaskResponse {
|
|
|
76
126
|
error?: string;
|
|
77
127
|
[key: string]: unknown;
|
|
78
128
|
}
|
|
79
|
-
|
|
129
|
+
/**
|
|
130
|
+
* AI avatar quality tier. Pro models produce the most natural lip movements;
|
|
131
|
+
* Standard models are faster with slightly less refined lip sync.
|
|
132
|
+
*/
|
|
133
|
+
type AiAvatarModel = 'kling-ai-avatar-pro' | 'kling-ai-avatar-standard' | 'kling-ai-avatar-v1-pro' | 'kling-v1-avatar-standard';
|
|
134
|
+
/** Lip-sync a face image to an audio track, producing a talking-head video. */
|
|
80
135
|
interface AiAvatarParams {
|
|
81
136
|
model: AiAvatarModel;
|
|
82
|
-
|
|
83
|
-
|
|
137
|
+
/** Face image URL; the face will be animated to match the audio. */
|
|
138
|
+
source_image_url: string;
|
|
139
|
+
/** Audio URL for lip synchronization. */
|
|
140
|
+
source_audio_url: string;
|
|
141
|
+
/** Description of the avatar's appearance and context. */
|
|
84
142
|
prompt: string;
|
|
85
143
|
callback_url?: string;
|
|
86
144
|
}
|
|
@@ -89,14 +147,23 @@ interface AiAvatarResponse extends AsyncTaskResponse {
|
|
|
89
147
|
error?: string;
|
|
90
148
|
[key: string]: unknown;
|
|
91
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Transfer motion from a reference video onto a subject image. The subject adopts
|
|
152
|
+
* the movement patterns from the reference while preserving its own appearance.
|
|
153
|
+
*/
|
|
92
154
|
interface MotionControlParams {
|
|
93
155
|
model: 'kling-3.0';
|
|
94
|
-
|
|
95
|
-
|
|
156
|
+
/** Subject image URL whose appearance is preserved. */
|
|
157
|
+
source_image_url: string;
|
|
158
|
+
/** Reference video URL whose motion patterns are transferred. */
|
|
159
|
+
reference_video_url: string;
|
|
160
|
+
/** Optional description prompt. */
|
|
96
161
|
prompt?: string;
|
|
97
|
-
|
|
162
|
+
output_resolution?: '720p' | '1080p';
|
|
163
|
+
/** Whether the character faces the direction from the video or the image. */
|
|
98
164
|
character_orientation?: 'video' | 'image';
|
|
99
|
-
|
|
165
|
+
/** Whether the background comes from the video or the image. */
|
|
166
|
+
background_source?: 'video' | 'image';
|
|
100
167
|
callback_url?: string;
|
|
101
168
|
}
|
|
102
169
|
interface MotionControlResponse extends AsyncTaskResponse {
|
|
@@ -121,49 +188,137 @@ type CompletedMotionControlResponse = MotionControlResponse & {
|
|
|
121
188
|
videos: VideoMetadata[];
|
|
122
189
|
};
|
|
123
190
|
|
|
191
|
+
/** Generate video from text prompts. Supports multi-shot, sound, first/last frame images, and Kling elements on kling-3.0; negative prompts and cfg_scale on V2.x models. */
|
|
124
192
|
declare class TextToVideo {
|
|
125
193
|
private readonly http;
|
|
126
194
|
constructor(http: HttpClient);
|
|
195
|
+
/**
|
|
196
|
+
* Generate a video from a text prompt and wait until complete.
|
|
197
|
+
* @param params Text-to-video parameters.
|
|
198
|
+
* @param options Per-request and polling overrides.
|
|
199
|
+
* @returns The completed task with videos.
|
|
200
|
+
*/
|
|
127
201
|
run(params: TextToVideoParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToVideoResponse>;
|
|
202
|
+
/**
|
|
203
|
+
* Create a text-to-video task; returns immediately with a task id.
|
|
204
|
+
* @param params Text-to-video parameters.
|
|
205
|
+
* @param options Per-request overrides.
|
|
206
|
+
* @returns The task creation result with id.
|
|
207
|
+
*/
|
|
128
208
|
create(params: TextToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse>;
|
|
209
|
+
/**
|
|
210
|
+
* Fetch the current status of a text-to-video task.
|
|
211
|
+
* @param id The task id.
|
|
212
|
+
* @param options Per-request overrides.
|
|
213
|
+
* @returns The current text-to-video task status.
|
|
214
|
+
*/
|
|
129
215
|
get(id: string, options?: RequestOptions): Promise<TextToVideoResponse>;
|
|
130
216
|
}
|
|
131
217
|
|
|
218
|
+
/** Animate a still image into video, guided by a text prompt and first-frame image. */
|
|
132
219
|
declare class ImageToVideo {
|
|
133
220
|
private readonly http;
|
|
134
221
|
constructor(http: HttpClient);
|
|
222
|
+
/**
|
|
223
|
+
* Generate a video from an input image and wait until complete.
|
|
224
|
+
* @param params Image-to-video parameters.
|
|
225
|
+
* @param options Per-request and polling overrides.
|
|
226
|
+
* @returns The completed task with videos.
|
|
227
|
+
*/
|
|
135
228
|
run(params: ImageToVideoParams, options?: RequestOptions & PollingOptions): Promise<CompletedImageToVideoResponse>;
|
|
229
|
+
/**
|
|
230
|
+
* Create an image-to-video task; returns immediately with a task id.
|
|
231
|
+
* @param params Image-to-video parameters.
|
|
232
|
+
* @param options Per-request overrides.
|
|
233
|
+
* @returns The task creation result with id.
|
|
234
|
+
*/
|
|
136
235
|
create(params: ImageToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse>;
|
|
236
|
+
/**
|
|
237
|
+
* Fetch the current status of an image-to-video task.
|
|
238
|
+
* @param id The task id.
|
|
239
|
+
* @param options Per-request overrides.
|
|
240
|
+
* @returns The current image-to-video task status.
|
|
241
|
+
*/
|
|
137
242
|
get(id: string, options?: RequestOptions): Promise<ImageToVideoResponse>;
|
|
138
243
|
}
|
|
139
244
|
|
|
245
|
+
/** Lip-sync a face image to an audio track, producing a talking-head video. */
|
|
140
246
|
declare class AiAvatar {
|
|
141
247
|
private readonly http;
|
|
142
248
|
constructor(http: HttpClient);
|
|
249
|
+
/**
|
|
250
|
+
* Generate an AI avatar video and wait until complete.
|
|
251
|
+
* @param params AI avatar parameters.
|
|
252
|
+
* @param options Per-request and polling overrides.
|
|
253
|
+
* @returns The completed task with videos.
|
|
254
|
+
*/
|
|
143
255
|
run(params: AiAvatarParams, options?: RequestOptions & PollingOptions): Promise<CompletedAiAvatarResponse>;
|
|
256
|
+
/**
|
|
257
|
+
* Create an AI avatar generation task; returns immediately with a task id.
|
|
258
|
+
* @param params AI avatar parameters.
|
|
259
|
+
* @param options Per-request overrides.
|
|
260
|
+
* @returns The task creation result with id.
|
|
261
|
+
*/
|
|
144
262
|
create(params: AiAvatarParams, options?: RequestOptions): Promise<TaskCreateResponse>;
|
|
263
|
+
/**
|
|
264
|
+
* Fetch the current status of an AI avatar task.
|
|
265
|
+
* @param id The task id.
|
|
266
|
+
* @param options Per-request overrides.
|
|
267
|
+
* @returns The current AI avatar task status.
|
|
268
|
+
*/
|
|
145
269
|
get(id: string, options?: RequestOptions): Promise<AiAvatarResponse>;
|
|
146
270
|
}
|
|
147
271
|
|
|
272
|
+
/** Transfer motion from a reference video onto a subject image, preserving the subject's appearance. */
|
|
148
273
|
declare class MotionControl {
|
|
149
274
|
private readonly http;
|
|
150
275
|
constructor(http: HttpClient);
|
|
276
|
+
/**
|
|
277
|
+
* Generate a video with motion transfer from a reference video and wait until complete.
|
|
278
|
+
* @param params Motion control parameters.
|
|
279
|
+
* @param options Per-request and polling overrides.
|
|
280
|
+
* @returns The completed task with videos.
|
|
281
|
+
*/
|
|
151
282
|
run(params: MotionControlParams, options?: RequestOptions & PollingOptions): Promise<CompletedMotionControlResponse>;
|
|
283
|
+
/**
|
|
284
|
+
* Create a motion control generation task; returns immediately with a task id.
|
|
285
|
+
* @param params Motion control parameters.
|
|
286
|
+
* @param options Per-request overrides.
|
|
287
|
+
* @returns The task creation result with id.
|
|
288
|
+
*/
|
|
152
289
|
create(params: MotionControlParams, options?: RequestOptions): Promise<TaskCreateResponse>;
|
|
290
|
+
/**
|
|
291
|
+
* Fetch the current status of a motion control task.
|
|
292
|
+
* @param id The task id.
|
|
293
|
+
* @param options Per-request overrides.
|
|
294
|
+
* @returns The current motion control task status.
|
|
295
|
+
*/
|
|
153
296
|
get(id: string, options?: RequestOptions): Promise<MotionControlResponse>;
|
|
154
297
|
}
|
|
155
298
|
|
|
156
|
-
/**
|
|
157
|
-
|
|
158
|
-
|
|
299
|
+
/**
|
|
300
|
+
* Kling video generation, AI avatar lip-sync, and motion control API client.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```typescript
|
|
304
|
+
* const client = new KlingClient({ apiKey: 'your-api-key' });
|
|
305
|
+
*
|
|
306
|
+
* const result = await client.textToVideo.run({
|
|
307
|
+
* model: 'kling-3.0',
|
|
308
|
+
* prompt: 'A cat walking through a garden',
|
|
309
|
+
* });
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
declare class KlingClient extends BaseClient {
|
|
313
|
+
/** Text-to-video generation with multi-shot, sound, and Kling elements support on kling-3.0. */
|
|
159
314
|
readonly textToVideo: TextToVideo;
|
|
160
|
-
/** Image-to-video
|
|
315
|
+
/** Image-to-video animation from a first-frame image guided by a text prompt. */
|
|
161
316
|
readonly imageToVideo: ImageToVideo;
|
|
162
|
-
/** AI avatar
|
|
317
|
+
/** AI avatar lip-sync: animate a face image to match an audio track. */
|
|
163
318
|
readonly aiAvatar: AiAvatar;
|
|
164
|
-
/**
|
|
319
|
+
/** Transfer motion from a reference video onto a subject image. */
|
|
165
320
|
readonly motionControl: MotionControl;
|
|
166
321
|
constructor(options?: ClientOptions);
|
|
167
322
|
}
|
|
168
323
|
|
|
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
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,61 +1,111 @@
|
|
|
1
|
-
import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, ClientOptions } from '@runapi.ai/core';
|
|
1
|
+
import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, BaseClient, 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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Text-to-video model variants. kling-3.0 supports multi-shot, sound, first/last frame images,
|
|
6
|
+
* and Kling elements. V2.x models support negative prompts and cfg_scale instead.
|
|
7
|
+
*/
|
|
8
|
+
type KlingTextToVideoModel = 'kling-3.0' | 'kling-v2.5-turbo-text-to-video-pro' | 'kling-v2.1-master-text-to-video';
|
|
9
|
+
/**
|
|
10
|
+
* Image-to-video model variants. V2.5 turbo and V2.1 pro support last-frame image control.
|
|
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';
|
|
13
|
+
/** Output resolution for text-to-video. 4k is highest quality but slowest. */
|
|
14
|
+
type KlingTextToVideoOutputResolution = '720p' | '1080p' | '4k';
|
|
7
15
|
type KlingAspectRatio = '16:9' | '9:16' | '1:1';
|
|
8
|
-
|
|
16
|
+
/** Duration in seconds. Range varies by model: 3-15 for kling-3.0, 5 or 10 for V2.x. */
|
|
17
|
+
type KlingDuration = number;
|
|
9
18
|
/** A single shot in a multi-shot text-to-video sequence. */
|
|
10
19
|
interface MultiPromptItem {
|
|
11
20
|
prompt: string;
|
|
12
|
-
|
|
21
|
+
duration_seconds: number;
|
|
13
22
|
}
|
|
14
|
-
/**
|
|
23
|
+
/** Named visual element (character, object, style) with reference images or videos for generation consistency. */
|
|
15
24
|
interface KlingElement {
|
|
25
|
+
/** Element identifier used for prompt referencing. */
|
|
16
26
|
name: string;
|
|
27
|
+
/** Description of the element's visual characteristics. */
|
|
17
28
|
description: string;
|
|
29
|
+
/** Image URLs providing visual reference for the element. */
|
|
18
30
|
element_input_urls?: string[];
|
|
31
|
+
/** Video URLs providing motion/appearance reference for the element. */
|
|
19
32
|
element_input_video_urls?: string[];
|
|
20
33
|
}
|
|
21
34
|
interface Kling3TextToVideoCommonParams {
|
|
22
35
|
model: 'kling-3.0';
|
|
23
|
-
|
|
36
|
+
/** Duration in seconds (3-15). */
|
|
37
|
+
duration_seconds?: KlingDuration;
|
|
24
38
|
aspect_ratio?: KlingAspectRatio;
|
|
25
|
-
|
|
39
|
+
output_resolution?: KlingTextToVideoOutputResolution;
|
|
40
|
+
/** Visual elements for subject/style consistency across the video. */
|
|
26
41
|
kling_elements?: KlingElement[];
|
|
42
|
+
/** URL for completion callback notifications. */
|
|
27
43
|
callback_url?: string;
|
|
28
44
|
}
|
|
45
|
+
/** Kling 3.0 single-shot text-to-video with optional sound and first/last frame control. */
|
|
29
46
|
interface Kling3TextToVideoSingleShotParams extends Kling3TextToVideoCommonParams {
|
|
47
|
+
/** Video description prompt. */
|
|
30
48
|
prompt: string;
|
|
31
|
-
|
|
32
|
-
|
|
49
|
+
/** Generate synchronized audio for the video. */
|
|
50
|
+
enable_sound?: boolean;
|
|
51
|
+
/** Opening frame image URL; overrides the generated first frame. */
|
|
52
|
+
first_frame_image_url?: string;
|
|
53
|
+
/** Closing frame image URL; only available in single-shot mode. */
|
|
54
|
+
last_frame_image_url?: string;
|
|
33
55
|
}
|
|
56
|
+
/** Kling 3.0 multi-shot mode: stitch multiple prompted segments into one video with sound. */
|
|
34
57
|
interface Kling3TextToVideoMultiShotParams extends Kling3TextToVideoCommonParams {
|
|
58
|
+
/** Must be true to activate multi-shot generation. */
|
|
35
59
|
multi_shots: true;
|
|
36
|
-
|
|
60
|
+
/** Must be true; sound is always generated in multi-shot mode. */
|
|
61
|
+
enable_sound: true;
|
|
62
|
+
/** Ordered shot segments, each with its own prompt and duration. */
|
|
37
63
|
multi_prompt: MultiPromptItem[];
|
|
38
|
-
|
|
64
|
+
/** Opening frame image URL for the first shot. */
|
|
65
|
+
first_frame_image_url?: string;
|
|
39
66
|
}
|
|
67
|
+
/** V2.5 Turbo text-to-video: fast, high-quality generation with negative prompt and cfg_scale control. */
|
|
40
68
|
interface V25TurboTextToVideoParams {
|
|
41
69
|
model: 'kling-v2.5-turbo-text-to-video-pro';
|
|
42
70
|
prompt: string;
|
|
43
|
-
|
|
71
|
+
/** Duration: 5 or 10 seconds. */
|
|
72
|
+
duration_seconds?: 5 | 10;
|
|
44
73
|
aspect_ratio?: KlingAspectRatio;
|
|
74
|
+
/** Elements to exclude from the generated video. */
|
|
45
75
|
negative_prompt?: string;
|
|
76
|
+
/** Prompt adherence strength (higher = more literal). */
|
|
46
77
|
cfg_scale?: number;
|
|
47
78
|
callback_url?: string;
|
|
48
79
|
}
|
|
80
|
+
/** V2.1 Master text-to-video: highest V2.1 quality with negative prompt and cfg_scale control. */
|
|
81
|
+
interface V21MasterTextToVideoParams {
|
|
82
|
+
model: 'kling-v2.1-master-text-to-video';
|
|
83
|
+
prompt: string;
|
|
84
|
+
duration_seconds?: 5 | 10;
|
|
85
|
+
aspect_ratio?: KlingAspectRatio;
|
|
86
|
+
negative_prompt?: string;
|
|
87
|
+
cfg_scale?: number;
|
|
88
|
+
callback_url?: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Image-to-video generation parameters. A first-frame image is required; the model
|
|
92
|
+
* animates it into video guided by the text prompt. last_frame_image_url is supported
|
|
93
|
+
* on V2.5 turbo and V2.1 pro models only.
|
|
94
|
+
*/
|
|
49
95
|
interface ImageToVideoParams {
|
|
50
|
-
model:
|
|
96
|
+
model: KlingImageToVideoModel;
|
|
97
|
+
/** Video motion description prompt. */
|
|
51
98
|
prompt: string;
|
|
52
|
-
|
|
53
|
-
|
|
99
|
+
/** Source image URL used as the video's opening frame. */
|
|
100
|
+
first_frame_image_url: string;
|
|
101
|
+
duration_seconds?: 5 | 10;
|
|
54
102
|
negative_prompt?: string;
|
|
55
103
|
cfg_scale?: number;
|
|
104
|
+
/** Target ending frame image URL; supported on V2.5 turbo and V2.1 pro. */
|
|
105
|
+
last_frame_image_url?: string;
|
|
56
106
|
callback_url?: string;
|
|
57
107
|
}
|
|
58
|
-
type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | V25TurboTextToVideoParams;
|
|
108
|
+
type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams;
|
|
59
109
|
interface AsyncTaskResponse {
|
|
60
110
|
id: string;
|
|
61
111
|
status: AsyncTaskStatus;
|
|
@@ -76,11 +126,19 @@ interface ImageToVideoResponse extends AsyncTaskResponse {
|
|
|
76
126
|
error?: string;
|
|
77
127
|
[key: string]: unknown;
|
|
78
128
|
}
|
|
79
|
-
|
|
129
|
+
/**
|
|
130
|
+
* AI avatar quality tier. Pro models produce the most natural lip movements;
|
|
131
|
+
* Standard models are faster with slightly less refined lip sync.
|
|
132
|
+
*/
|
|
133
|
+
type AiAvatarModel = 'kling-ai-avatar-pro' | 'kling-ai-avatar-standard' | 'kling-ai-avatar-v1-pro' | 'kling-v1-avatar-standard';
|
|
134
|
+
/** Lip-sync a face image to an audio track, producing a talking-head video. */
|
|
80
135
|
interface AiAvatarParams {
|
|
81
136
|
model: AiAvatarModel;
|
|
82
|
-
|
|
83
|
-
|
|
137
|
+
/** Face image URL; the face will be animated to match the audio. */
|
|
138
|
+
source_image_url: string;
|
|
139
|
+
/** Audio URL for lip synchronization. */
|
|
140
|
+
source_audio_url: string;
|
|
141
|
+
/** Description of the avatar's appearance and context. */
|
|
84
142
|
prompt: string;
|
|
85
143
|
callback_url?: string;
|
|
86
144
|
}
|
|
@@ -89,14 +147,23 @@ interface AiAvatarResponse extends AsyncTaskResponse {
|
|
|
89
147
|
error?: string;
|
|
90
148
|
[key: string]: unknown;
|
|
91
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Transfer motion from a reference video onto a subject image. The subject adopts
|
|
152
|
+
* the movement patterns from the reference while preserving its own appearance.
|
|
153
|
+
*/
|
|
92
154
|
interface MotionControlParams {
|
|
93
155
|
model: 'kling-3.0';
|
|
94
|
-
|
|
95
|
-
|
|
156
|
+
/** Subject image URL whose appearance is preserved. */
|
|
157
|
+
source_image_url: string;
|
|
158
|
+
/** Reference video URL whose motion patterns are transferred. */
|
|
159
|
+
reference_video_url: string;
|
|
160
|
+
/** Optional description prompt. */
|
|
96
161
|
prompt?: string;
|
|
97
|
-
|
|
162
|
+
output_resolution?: '720p' | '1080p';
|
|
163
|
+
/** Whether the character faces the direction from the video or the image. */
|
|
98
164
|
character_orientation?: 'video' | 'image';
|
|
99
|
-
|
|
165
|
+
/** Whether the background comes from the video or the image. */
|
|
166
|
+
background_source?: 'video' | 'image';
|
|
100
167
|
callback_url?: string;
|
|
101
168
|
}
|
|
102
169
|
interface MotionControlResponse extends AsyncTaskResponse {
|
|
@@ -121,49 +188,137 @@ type CompletedMotionControlResponse = MotionControlResponse & {
|
|
|
121
188
|
videos: VideoMetadata[];
|
|
122
189
|
};
|
|
123
190
|
|
|
191
|
+
/** Generate video from text prompts. Supports multi-shot, sound, first/last frame images, and Kling elements on kling-3.0; negative prompts and cfg_scale on V2.x models. */
|
|
124
192
|
declare class TextToVideo {
|
|
125
193
|
private readonly http;
|
|
126
194
|
constructor(http: HttpClient);
|
|
195
|
+
/**
|
|
196
|
+
* Generate a video from a text prompt and wait until complete.
|
|
197
|
+
* @param params Text-to-video parameters.
|
|
198
|
+
* @param options Per-request and polling overrides.
|
|
199
|
+
* @returns The completed task with videos.
|
|
200
|
+
*/
|
|
127
201
|
run(params: TextToVideoParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToVideoResponse>;
|
|
202
|
+
/**
|
|
203
|
+
* Create a text-to-video task; returns immediately with a task id.
|
|
204
|
+
* @param params Text-to-video parameters.
|
|
205
|
+
* @param options Per-request overrides.
|
|
206
|
+
* @returns The task creation result with id.
|
|
207
|
+
*/
|
|
128
208
|
create(params: TextToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse>;
|
|
209
|
+
/**
|
|
210
|
+
* Fetch the current status of a text-to-video task.
|
|
211
|
+
* @param id The task id.
|
|
212
|
+
* @param options Per-request overrides.
|
|
213
|
+
* @returns The current text-to-video task status.
|
|
214
|
+
*/
|
|
129
215
|
get(id: string, options?: RequestOptions): Promise<TextToVideoResponse>;
|
|
130
216
|
}
|
|
131
217
|
|
|
218
|
+
/** Animate a still image into video, guided by a text prompt and first-frame image. */
|
|
132
219
|
declare class ImageToVideo {
|
|
133
220
|
private readonly http;
|
|
134
221
|
constructor(http: HttpClient);
|
|
222
|
+
/**
|
|
223
|
+
* Generate a video from an input image and wait until complete.
|
|
224
|
+
* @param params Image-to-video parameters.
|
|
225
|
+
* @param options Per-request and polling overrides.
|
|
226
|
+
* @returns The completed task with videos.
|
|
227
|
+
*/
|
|
135
228
|
run(params: ImageToVideoParams, options?: RequestOptions & PollingOptions): Promise<CompletedImageToVideoResponse>;
|
|
229
|
+
/**
|
|
230
|
+
* Create an image-to-video task; returns immediately with a task id.
|
|
231
|
+
* @param params Image-to-video parameters.
|
|
232
|
+
* @param options Per-request overrides.
|
|
233
|
+
* @returns The task creation result with id.
|
|
234
|
+
*/
|
|
136
235
|
create(params: ImageToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse>;
|
|
236
|
+
/**
|
|
237
|
+
* Fetch the current status of an image-to-video task.
|
|
238
|
+
* @param id The task id.
|
|
239
|
+
* @param options Per-request overrides.
|
|
240
|
+
* @returns The current image-to-video task status.
|
|
241
|
+
*/
|
|
137
242
|
get(id: string, options?: RequestOptions): Promise<ImageToVideoResponse>;
|
|
138
243
|
}
|
|
139
244
|
|
|
245
|
+
/** Lip-sync a face image to an audio track, producing a talking-head video. */
|
|
140
246
|
declare class AiAvatar {
|
|
141
247
|
private readonly http;
|
|
142
248
|
constructor(http: HttpClient);
|
|
249
|
+
/**
|
|
250
|
+
* Generate an AI avatar video and wait until complete.
|
|
251
|
+
* @param params AI avatar parameters.
|
|
252
|
+
* @param options Per-request and polling overrides.
|
|
253
|
+
* @returns The completed task with videos.
|
|
254
|
+
*/
|
|
143
255
|
run(params: AiAvatarParams, options?: RequestOptions & PollingOptions): Promise<CompletedAiAvatarResponse>;
|
|
256
|
+
/**
|
|
257
|
+
* Create an AI avatar generation task; returns immediately with a task id.
|
|
258
|
+
* @param params AI avatar parameters.
|
|
259
|
+
* @param options Per-request overrides.
|
|
260
|
+
* @returns The task creation result with id.
|
|
261
|
+
*/
|
|
144
262
|
create(params: AiAvatarParams, options?: RequestOptions): Promise<TaskCreateResponse>;
|
|
263
|
+
/**
|
|
264
|
+
* Fetch the current status of an AI avatar task.
|
|
265
|
+
* @param id The task id.
|
|
266
|
+
* @param options Per-request overrides.
|
|
267
|
+
* @returns The current AI avatar task status.
|
|
268
|
+
*/
|
|
145
269
|
get(id: string, options?: RequestOptions): Promise<AiAvatarResponse>;
|
|
146
270
|
}
|
|
147
271
|
|
|
272
|
+
/** Transfer motion from a reference video onto a subject image, preserving the subject's appearance. */
|
|
148
273
|
declare class MotionControl {
|
|
149
274
|
private readonly http;
|
|
150
275
|
constructor(http: HttpClient);
|
|
276
|
+
/**
|
|
277
|
+
* Generate a video with motion transfer from a reference video and wait until complete.
|
|
278
|
+
* @param params Motion control parameters.
|
|
279
|
+
* @param options Per-request and polling overrides.
|
|
280
|
+
* @returns The completed task with videos.
|
|
281
|
+
*/
|
|
151
282
|
run(params: MotionControlParams, options?: RequestOptions & PollingOptions): Promise<CompletedMotionControlResponse>;
|
|
283
|
+
/**
|
|
284
|
+
* Create a motion control generation task; returns immediately with a task id.
|
|
285
|
+
* @param params Motion control parameters.
|
|
286
|
+
* @param options Per-request overrides.
|
|
287
|
+
* @returns The task creation result with id.
|
|
288
|
+
*/
|
|
152
289
|
create(params: MotionControlParams, options?: RequestOptions): Promise<TaskCreateResponse>;
|
|
290
|
+
/**
|
|
291
|
+
* Fetch the current status of a motion control task.
|
|
292
|
+
* @param id The task id.
|
|
293
|
+
* @param options Per-request overrides.
|
|
294
|
+
* @returns The current motion control task status.
|
|
295
|
+
*/
|
|
153
296
|
get(id: string, options?: RequestOptions): Promise<MotionControlResponse>;
|
|
154
297
|
}
|
|
155
298
|
|
|
156
|
-
/**
|
|
157
|
-
|
|
158
|
-
|
|
299
|
+
/**
|
|
300
|
+
* Kling video generation, AI avatar lip-sync, and motion control API client.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```typescript
|
|
304
|
+
* const client = new KlingClient({ apiKey: 'your-api-key' });
|
|
305
|
+
*
|
|
306
|
+
* const result = await client.textToVideo.run({
|
|
307
|
+
* model: 'kling-3.0',
|
|
308
|
+
* prompt: 'A cat walking through a garden',
|
|
309
|
+
* });
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
declare class KlingClient extends BaseClient {
|
|
313
|
+
/** Text-to-video generation with multi-shot, sound, and Kling elements support on kling-3.0. */
|
|
159
314
|
readonly textToVideo: TextToVideo;
|
|
160
|
-
/** Image-to-video
|
|
315
|
+
/** Image-to-video animation from a first-frame image guided by a text prompt. */
|
|
161
316
|
readonly imageToVideo: ImageToVideo;
|
|
162
|
-
/** AI avatar
|
|
317
|
+
/** AI avatar lip-sync: animate a face image to match an audio track. */
|
|
163
318
|
readonly aiAvatar: AiAvatar;
|
|
164
|
-
/**
|
|
319
|
+
/** Transfer motion from a reference video onto a subject image. */
|
|
165
320
|
readonly motionControl: MotionControl;
|
|
166
321
|
constructor(options?: ClientOptions);
|
|
167
322
|
}
|
|
168
323
|
|
|
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
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,12 @@ var TextToVideo = class {
|
|
|
47
47
|
this.http = http;
|
|
48
48
|
}
|
|
49
49
|
http;
|
|
50
|
+
/**
|
|
51
|
+
* Generate a video from a text prompt and wait until complete.
|
|
52
|
+
* @param params Text-to-video parameters.
|
|
53
|
+
* @param options Per-request and polling overrides.
|
|
54
|
+
* @returns The completed task with videos.
|
|
55
|
+
*/
|
|
50
56
|
async run(params, options) {
|
|
51
57
|
const { id } = await this.create(params, options);
|
|
52
58
|
const response = await (0, import_internal.pollUntilComplete)(() => this.get(id, options), {
|
|
@@ -55,12 +61,24 @@ var TextToVideo = class {
|
|
|
55
61
|
});
|
|
56
62
|
return response;
|
|
57
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Create a text-to-video task; returns immediately with a task id.
|
|
66
|
+
* @param params Text-to-video parameters.
|
|
67
|
+
* @param options Per-request overrides.
|
|
68
|
+
* @returns The task creation result with id.
|
|
69
|
+
*/
|
|
58
70
|
async create(params, options) {
|
|
59
71
|
return this.http.request("POST", ENDPOINT, {
|
|
60
72
|
body: (0, import_core.compactParams)(params),
|
|
61
73
|
...options
|
|
62
74
|
});
|
|
63
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Fetch the current status of a text-to-video task.
|
|
78
|
+
* @param id The task id.
|
|
79
|
+
* @param options Per-request overrides.
|
|
80
|
+
* @returns The current text-to-video task status.
|
|
81
|
+
*/
|
|
64
82
|
async get(id, options) {
|
|
65
83
|
return this.http.request("GET", `${ENDPOINT}/${id}`, {
|
|
66
84
|
...options
|
|
@@ -77,6 +95,12 @@ var ImageToVideo = class {
|
|
|
77
95
|
this.http = http;
|
|
78
96
|
}
|
|
79
97
|
http;
|
|
98
|
+
/**
|
|
99
|
+
* Generate a video from an input image and wait until complete.
|
|
100
|
+
* @param params Image-to-video parameters.
|
|
101
|
+
* @param options Per-request and polling overrides.
|
|
102
|
+
* @returns The completed task with videos.
|
|
103
|
+
*/
|
|
80
104
|
async run(params, options) {
|
|
81
105
|
const { id } = await this.create(params, options);
|
|
82
106
|
const response = await (0, import_internal2.pollUntilComplete)(() => this.get(id, options), {
|
|
@@ -85,12 +109,24 @@ var ImageToVideo = class {
|
|
|
85
109
|
});
|
|
86
110
|
return response;
|
|
87
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Create an image-to-video task; returns immediately with a task id.
|
|
114
|
+
* @param params Image-to-video parameters.
|
|
115
|
+
* @param options Per-request overrides.
|
|
116
|
+
* @returns The task creation result with id.
|
|
117
|
+
*/
|
|
88
118
|
async create(params, options) {
|
|
89
119
|
return this.http.request("POST", ENDPOINT2, {
|
|
90
120
|
body: (0, import_core2.compactParams)(params),
|
|
91
121
|
...options
|
|
92
122
|
});
|
|
93
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Fetch the current status of an image-to-video task.
|
|
126
|
+
* @param id The task id.
|
|
127
|
+
* @param options Per-request overrides.
|
|
128
|
+
* @returns The current image-to-video task status.
|
|
129
|
+
*/
|
|
94
130
|
async get(id, options) {
|
|
95
131
|
return this.http.request("GET", `${ENDPOINT2}/${id}`, {
|
|
96
132
|
...options
|
|
@@ -107,6 +143,12 @@ var AiAvatar = class {
|
|
|
107
143
|
this.http = http;
|
|
108
144
|
}
|
|
109
145
|
http;
|
|
146
|
+
/**
|
|
147
|
+
* Generate an AI avatar video and wait until complete.
|
|
148
|
+
* @param params AI avatar parameters.
|
|
149
|
+
* @param options Per-request and polling overrides.
|
|
150
|
+
* @returns The completed task with videos.
|
|
151
|
+
*/
|
|
110
152
|
async run(params, options) {
|
|
111
153
|
const { id } = await this.create(params, options);
|
|
112
154
|
const response = await (0, import_internal3.pollUntilComplete)(() => this.get(id, options), {
|
|
@@ -115,12 +157,24 @@ var AiAvatar = class {
|
|
|
115
157
|
});
|
|
116
158
|
return response;
|
|
117
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Create an AI avatar generation task; returns immediately with a task id.
|
|
162
|
+
* @param params AI avatar parameters.
|
|
163
|
+
* @param options Per-request overrides.
|
|
164
|
+
* @returns The task creation result with id.
|
|
165
|
+
*/
|
|
118
166
|
async create(params, options) {
|
|
119
167
|
return this.http.request("POST", ENDPOINT3, {
|
|
120
168
|
body: (0, import_core3.compactParams)(params),
|
|
121
169
|
...options
|
|
122
170
|
});
|
|
123
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* Fetch the current status of an AI avatar task.
|
|
174
|
+
* @param id The task id.
|
|
175
|
+
* @param options Per-request overrides.
|
|
176
|
+
* @returns The current AI avatar task status.
|
|
177
|
+
*/
|
|
124
178
|
async get(id, options) {
|
|
125
179
|
return this.http.request("GET", `${ENDPOINT3}/${id}`, {
|
|
126
180
|
...options
|
|
@@ -137,6 +191,12 @@ var MotionControl = class {
|
|
|
137
191
|
this.http = http;
|
|
138
192
|
}
|
|
139
193
|
http;
|
|
194
|
+
/**
|
|
195
|
+
* Generate a video with motion transfer from a reference video and wait until complete.
|
|
196
|
+
* @param params Motion control parameters.
|
|
197
|
+
* @param options Per-request and polling overrides.
|
|
198
|
+
* @returns The completed task with videos.
|
|
199
|
+
*/
|
|
140
200
|
async run(params, options) {
|
|
141
201
|
const { id } = await this.create(params, options);
|
|
142
202
|
const response = await (0, import_internal4.pollUntilComplete)(() => this.get(id, options), {
|
|
@@ -145,12 +205,24 @@ var MotionControl = class {
|
|
|
145
205
|
});
|
|
146
206
|
return response;
|
|
147
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Create a motion control generation task; returns immediately with a task id.
|
|
210
|
+
* @param params Motion control parameters.
|
|
211
|
+
* @param options Per-request overrides.
|
|
212
|
+
* @returns The task creation result with id.
|
|
213
|
+
*/
|
|
148
214
|
async create(params, options) {
|
|
149
215
|
return this.http.request("POST", ENDPOINT4, {
|
|
150
216
|
body: (0, import_core4.compactParams)(params),
|
|
151
217
|
...options
|
|
152
218
|
});
|
|
153
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Fetch the current status of a motion control task.
|
|
222
|
+
* @param id The task id.
|
|
223
|
+
* @param options Per-request overrides.
|
|
224
|
+
* @returns The current motion control task status.
|
|
225
|
+
*/
|
|
154
226
|
async get(id, options) {
|
|
155
227
|
return this.http.request("GET", `${ENDPOINT4}/${id}`, {
|
|
156
228
|
...options
|
|
@@ -159,21 +231,21 @@ var MotionControl = class {
|
|
|
159
231
|
};
|
|
160
232
|
|
|
161
233
|
// src/client.ts
|
|
162
|
-
var KlingClient = class {
|
|
163
|
-
/** Text-to-video
|
|
234
|
+
var KlingClient = class extends import_core5.BaseClient {
|
|
235
|
+
/** Text-to-video generation with multi-shot, sound, and Kling elements support on kling-3.0. */
|
|
164
236
|
textToVideo;
|
|
165
|
-
/** Image-to-video
|
|
237
|
+
/** Image-to-video animation from a first-frame image guided by a text prompt. */
|
|
166
238
|
imageToVideo;
|
|
167
|
-
/** AI avatar
|
|
239
|
+
/** AI avatar lip-sync: animate a face image to match an audio track. */
|
|
168
240
|
aiAvatar;
|
|
169
|
-
/**
|
|
241
|
+
/** Transfer motion from a reference video onto a subject image. */
|
|
170
242
|
motionControl;
|
|
171
243
|
constructor(options = {}) {
|
|
172
|
-
|
|
173
|
-
this.textToVideo = new TextToVideo(http);
|
|
174
|
-
this.imageToVideo = new ImageToVideo(http);
|
|
175
|
-
this.aiAvatar = new AiAvatar(http);
|
|
176
|
-
this.motionControl = new MotionControl(http);
|
|
244
|
+
super(options);
|
|
245
|
+
this.textToVideo = new TextToVideo(this.http);
|
|
246
|
+
this.imageToVideo = new ImageToVideo(this.http);
|
|
247
|
+
this.aiAvatar = new AiAvatar(this.http);
|
|
248
|
+
this.motionControl = new MotionControl(this.http);
|
|
177
249
|
}
|
|
178
250
|
};
|
|
179
251
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/resources/text-to-video.ts","../src/resources/image-to-video.ts","../src/resources/ai-avatar.ts","../src/resources/motion-control.ts"],"sourcesContent":["export { KlingClient } from './client';\nexport * from './types';\n\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n","import { createHttpClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToVideo } from './resources/text-to-video';\nimport { ImageToVideo } from './resources/image-to-video';\nimport { AiAvatar } from './resources/ai-avatar';\nimport { MotionControl } from './resources/motion-control';\n\n/** Kling video API client. */\nexport class KlingClient {\n /** Text-to-video operations. */\n public readonly textToVideo: TextToVideo;\n /** Image-to-video operations. */\n public readonly imageToVideo: ImageToVideo;\n /** AI avatar operations. */\n public readonly aiAvatar: AiAvatar;\n /** Motion control operations. */\n public readonly motionControl: MotionControl;\n\n constructor(options: ClientOptions = {}) {\n const http = createHttpClient(options);\n this.textToVideo = new TextToVideo(http);\n this.imageToVideo = new ImageToVideo(http);\n this.aiAvatar = new AiAvatar(http);\n this.motionControl = new MotionControl(http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedTextToVideoResponse,\n TextToVideoParams,\n TextToVideoResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/text_to_video';\n\nexport class TextToVideo {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: TextToVideoParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToVideoResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<TextToVideoResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedTextToVideoResponse;\n }\n\n async create(params: TextToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n async get(id: string, options?: RequestOptions): Promise<TextToVideoResponse> {\n return this.http.request<TextToVideoResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedImageToVideoResponse,\n ImageToVideoParams,\n ImageToVideoResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/image_to_video';\n\nexport class ImageToVideo {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: ImageToVideoParams, options?: RequestOptions & PollingOptions): Promise<CompletedImageToVideoResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<ImageToVideoResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedImageToVideoResponse;\n }\n\n async create(params: ImageToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n async get(id: string, options?: RequestOptions): Promise<ImageToVideoResponse> {\n return this.http.request<ImageToVideoResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedAiAvatarResponse,\n AiAvatarParams,\n AiAvatarResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/ai_avatar';\n\nexport class AiAvatar {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: AiAvatarParams, options?: RequestOptions & PollingOptions): Promise<CompletedAiAvatarResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<AiAvatarResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedAiAvatarResponse;\n }\n\n async create(params: AiAvatarParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n async get(id: string, options?: RequestOptions): Promise<AiAvatarResponse> {\n return this.http.request<AiAvatarResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedMotionControlResponse,\n MotionControlParams,\n MotionControlResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/motion_control';\n\nexport class MotionControl {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: MotionControlParams, options?: RequestOptions & PollingOptions): Promise<CompletedMotionControlResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<MotionControlResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedMotionControlResponse;\n }\n\n async create(params: MotionControlParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n async get(id: string, options?: RequestOptions): Promise<MotionControlResponse> {\n return this.http.request<MotionControlResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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F;AACzH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,UAAM,oCAAyC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MAC3F,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,OAAO,QAA6B,SAAuD;AAC/F,WAAO,KAAK,KAAK,QAA4B,QAAQA,WAAU;AAAA,MAC7D,UAAM,4BAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAA0D;AAC9E,WAAO,KAAK,KAAK,QAA+B,OAAO,GAAGA,SAAQ,IAAI,EAAE,IAAI;AAAA,MAC1E,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;AJ7BO,IAAM,cAAN,MAAkB;AAAA;AAAA,EAEP;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,WAAO,+BAAiB,OAAO;AACrC,SAAK,cAAc,IAAI,YAAY,IAAI;AACvC,SAAK,eAAe,IAAI,aAAa,IAAI;AACzC,SAAK,WAAW,IAAI,SAAS,IAAI;AACjC,SAAK,gBAAgB,IAAI,cAAc,IAAI;AAAA,EAC7C;AACF;;;ADrBA,IAAAC,eAYO;","names":["import_core","import_core","import_internal","ENDPOINT","import_core","import_internal","ENDPOINT","import_core","import_internal","ENDPOINT","import_core"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/resources/text-to-video.ts","../src/resources/image-to-video.ts","../src/resources/ai-avatar.ts","../src/resources/motion-control.ts"],"sourcesContent":["export { KlingClient } from './client';\nexport * from './types';\n\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n","import { BaseClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToVideo } from './resources/text-to-video';\nimport { ImageToVideo } from './resources/image-to-video';\nimport { AiAvatar } from './resources/ai-avatar';\nimport { MotionControl } from './resources/motion-control';\n\n/**\n * Kling video generation, AI avatar lip-sync, and motion control API client.\n *\n * @example\n * ```typescript\n * const client = new KlingClient({ apiKey: 'your-api-key' });\n *\n * const result = await client.textToVideo.run({\n * model: 'kling-3.0',\n * prompt: 'A cat walking through a garden',\n * });\n * ```\n */\nexport class KlingClient extends BaseClient {\n /** Text-to-video generation with multi-shot, sound, and Kling elements support on kling-3.0. */\n public readonly textToVideo: TextToVideo;\n /** Image-to-video animation from a first-frame image guided by a text prompt. */\n public readonly imageToVideo: ImageToVideo;\n /** AI avatar lip-sync: animate a face image to match an audio track. */\n public readonly aiAvatar: AiAvatar;\n /** Transfer motion from a reference video onto a subject image. */\n public readonly motionControl: MotionControl;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToVideo = new TextToVideo(this.http);\n this.imageToVideo = new ImageToVideo(this.http);\n this.aiAvatar = new AiAvatar(this.http);\n this.motionControl = new MotionControl(this.http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedTextToVideoResponse,\n TextToVideoParams,\n TextToVideoResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/text_to_video';\n\n/** Generate video from text prompts. Supports multi-shot, sound, first/last frame images, and Kling elements on kling-3.0; negative prompts and cfg_scale on V2.x models. */\nexport class TextToVideo {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate a video from a text prompt and wait until complete.\n * @param params Text-to-video parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with videos.\n */\n async run(params: TextToVideoParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToVideoResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<TextToVideoResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedTextToVideoResponse;\n }\n\n /**\n * Create a text-to-video task; returns immediately with a task id.\n * @param params Text-to-video parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: TextToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a text-to-video task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current text-to-video task status.\n */\n async get(id: string, options?: RequestOptions): Promise<TextToVideoResponse> {\n return this.http.request<TextToVideoResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedImageToVideoResponse,\n ImageToVideoParams,\n ImageToVideoResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/image_to_video';\n\n/** Animate a still image into video, guided by a text prompt and first-frame image. */\nexport class ImageToVideo {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate a video from an input image and wait until complete.\n * @param params Image-to-video parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with videos.\n */\n async run(params: ImageToVideoParams, options?: RequestOptions & PollingOptions): Promise<CompletedImageToVideoResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<ImageToVideoResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedImageToVideoResponse;\n }\n\n /**\n * Create an image-to-video task; returns immediately with a task id.\n * @param params Image-to-video parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: ImageToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image-to-video task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current image-to-video task status.\n */\n async get(id: string, options?: RequestOptions): Promise<ImageToVideoResponse> {\n return this.http.request<ImageToVideoResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedAiAvatarResponse,\n AiAvatarParams,\n AiAvatarResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/ai_avatar';\n\n/** Lip-sync a face image to an audio track, producing a talking-head video. */\nexport class AiAvatar {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate an AI avatar video and wait until complete.\n * @param params AI avatar parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with videos.\n */\n async run(params: AiAvatarParams, options?: RequestOptions & PollingOptions): Promise<CompletedAiAvatarResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<AiAvatarResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedAiAvatarResponse;\n }\n\n /**\n * Create an AI avatar generation task; returns immediately with a task id.\n * @param params AI avatar parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: AiAvatarParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an AI avatar task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current AI avatar task status.\n */\n async get(id: string, options?: RequestOptions): Promise<AiAvatarResponse> {\n return this.http.request<AiAvatarResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedMotionControlResponse,\n MotionControlParams,\n MotionControlResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/motion_control';\n\n/** Transfer motion from a reference video onto a subject image, preserving the subject's appearance. */\nexport class MotionControl {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate a video with motion transfer from a reference video and wait until complete.\n * @param params Motion control parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with videos.\n */\n async run(params: MotionControlParams, options?: RequestOptions & PollingOptions): Promise<CompletedMotionControlResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<MotionControlResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedMotionControlResponse;\n }\n\n /**\n * Create a motion control generation task; returns immediately with a task id.\n * @param params Motion control parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: MotionControlParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a motion control task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current motion control task status.\n */\n async get(id: string, options?: RequestOptions): Promise<MotionControlResponse> {\n return this.http.request<MotionControlResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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,IAAI;AACtC,SAAK,gBAAgB,IAAI,cAAc,KAAK,IAAI;AAAA,EAClD;AACF;;;ADjCA,IAAAC,eAYO;","names":["import_core","import_core","import_internal","ENDPOINT","import_core","import_internal","ENDPOINT","import_core","import_internal","ENDPOINT","import_core"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/client.ts
|
|
2
|
-
import {
|
|
2
|
+
import { BaseClient } from "@runapi.ai/core";
|
|
3
3
|
|
|
4
4
|
// src/resources/text-to-video.ts
|
|
5
5
|
import { compactParams } from "@runapi.ai/core";
|
|
@@ -10,6 +10,12 @@ var TextToVideo = class {
|
|
|
10
10
|
this.http = http;
|
|
11
11
|
}
|
|
12
12
|
http;
|
|
13
|
+
/**
|
|
14
|
+
* Generate a video from a text prompt and wait until complete.
|
|
15
|
+
* @param params Text-to-video parameters.
|
|
16
|
+
* @param options Per-request and polling overrides.
|
|
17
|
+
* @returns The completed task with videos.
|
|
18
|
+
*/
|
|
13
19
|
async run(params, options) {
|
|
14
20
|
const { id } = await this.create(params, options);
|
|
15
21
|
const response = await pollUntilComplete(() => this.get(id, options), {
|
|
@@ -18,12 +24,24 @@ var TextToVideo = class {
|
|
|
18
24
|
});
|
|
19
25
|
return response;
|
|
20
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Create a text-to-video task; returns immediately with a task id.
|
|
29
|
+
* @param params Text-to-video parameters.
|
|
30
|
+
* @param options Per-request overrides.
|
|
31
|
+
* @returns The task creation result with id.
|
|
32
|
+
*/
|
|
21
33
|
async create(params, options) {
|
|
22
34
|
return this.http.request("POST", ENDPOINT, {
|
|
23
35
|
body: compactParams(params),
|
|
24
36
|
...options
|
|
25
37
|
});
|
|
26
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Fetch the current status of a text-to-video task.
|
|
41
|
+
* @param id The task id.
|
|
42
|
+
* @param options Per-request overrides.
|
|
43
|
+
* @returns The current text-to-video task status.
|
|
44
|
+
*/
|
|
27
45
|
async get(id, options) {
|
|
28
46
|
return this.http.request("GET", `${ENDPOINT}/${id}`, {
|
|
29
47
|
...options
|
|
@@ -40,6 +58,12 @@ var ImageToVideo = class {
|
|
|
40
58
|
this.http = http;
|
|
41
59
|
}
|
|
42
60
|
http;
|
|
61
|
+
/**
|
|
62
|
+
* Generate a video from an input image and wait until complete.
|
|
63
|
+
* @param params Image-to-video parameters.
|
|
64
|
+
* @param options Per-request and polling overrides.
|
|
65
|
+
* @returns The completed task with videos.
|
|
66
|
+
*/
|
|
43
67
|
async run(params, options) {
|
|
44
68
|
const { id } = await this.create(params, options);
|
|
45
69
|
const response = await pollUntilComplete2(() => this.get(id, options), {
|
|
@@ -48,12 +72,24 @@ var ImageToVideo = class {
|
|
|
48
72
|
});
|
|
49
73
|
return response;
|
|
50
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Create an image-to-video task; returns immediately with a task id.
|
|
77
|
+
* @param params Image-to-video parameters.
|
|
78
|
+
* @param options Per-request overrides.
|
|
79
|
+
* @returns The task creation result with id.
|
|
80
|
+
*/
|
|
51
81
|
async create(params, options) {
|
|
52
82
|
return this.http.request("POST", ENDPOINT2, {
|
|
53
83
|
body: compactParams2(params),
|
|
54
84
|
...options
|
|
55
85
|
});
|
|
56
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Fetch the current status of an image-to-video task.
|
|
89
|
+
* @param id The task id.
|
|
90
|
+
* @param options Per-request overrides.
|
|
91
|
+
* @returns The current image-to-video task status.
|
|
92
|
+
*/
|
|
57
93
|
async get(id, options) {
|
|
58
94
|
return this.http.request("GET", `${ENDPOINT2}/${id}`, {
|
|
59
95
|
...options
|
|
@@ -70,6 +106,12 @@ var AiAvatar = class {
|
|
|
70
106
|
this.http = http;
|
|
71
107
|
}
|
|
72
108
|
http;
|
|
109
|
+
/**
|
|
110
|
+
* Generate an AI avatar video and wait until complete.
|
|
111
|
+
* @param params AI avatar parameters.
|
|
112
|
+
* @param options Per-request and polling overrides.
|
|
113
|
+
* @returns The completed task with videos.
|
|
114
|
+
*/
|
|
73
115
|
async run(params, options) {
|
|
74
116
|
const { id } = await this.create(params, options);
|
|
75
117
|
const response = await pollUntilComplete3(() => this.get(id, options), {
|
|
@@ -78,12 +120,24 @@ var AiAvatar = class {
|
|
|
78
120
|
});
|
|
79
121
|
return response;
|
|
80
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Create an AI avatar generation task; returns immediately with a task id.
|
|
125
|
+
* @param params AI avatar parameters.
|
|
126
|
+
* @param options Per-request overrides.
|
|
127
|
+
* @returns The task creation result with id.
|
|
128
|
+
*/
|
|
81
129
|
async create(params, options) {
|
|
82
130
|
return this.http.request("POST", ENDPOINT3, {
|
|
83
131
|
body: compactParams3(params),
|
|
84
132
|
...options
|
|
85
133
|
});
|
|
86
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Fetch the current status of an AI avatar task.
|
|
137
|
+
* @param id The task id.
|
|
138
|
+
* @param options Per-request overrides.
|
|
139
|
+
* @returns The current AI avatar task status.
|
|
140
|
+
*/
|
|
87
141
|
async get(id, options) {
|
|
88
142
|
return this.http.request("GET", `${ENDPOINT3}/${id}`, {
|
|
89
143
|
...options
|
|
@@ -100,6 +154,12 @@ var MotionControl = class {
|
|
|
100
154
|
this.http = http;
|
|
101
155
|
}
|
|
102
156
|
http;
|
|
157
|
+
/**
|
|
158
|
+
* Generate a video with motion transfer from a reference video and wait until complete.
|
|
159
|
+
* @param params Motion control parameters.
|
|
160
|
+
* @param options Per-request and polling overrides.
|
|
161
|
+
* @returns The completed task with videos.
|
|
162
|
+
*/
|
|
103
163
|
async run(params, options) {
|
|
104
164
|
const { id } = await this.create(params, options);
|
|
105
165
|
const response = await pollUntilComplete4(() => this.get(id, options), {
|
|
@@ -108,12 +168,24 @@ var MotionControl = class {
|
|
|
108
168
|
});
|
|
109
169
|
return response;
|
|
110
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Create a motion control generation task; returns immediately with a task id.
|
|
173
|
+
* @param params Motion control parameters.
|
|
174
|
+
* @param options Per-request overrides.
|
|
175
|
+
* @returns The task creation result with id.
|
|
176
|
+
*/
|
|
111
177
|
async create(params, options) {
|
|
112
178
|
return this.http.request("POST", ENDPOINT4, {
|
|
113
179
|
body: compactParams4(params),
|
|
114
180
|
...options
|
|
115
181
|
});
|
|
116
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Fetch the current status of a motion control task.
|
|
185
|
+
* @param id The task id.
|
|
186
|
+
* @param options Per-request overrides.
|
|
187
|
+
* @returns The current motion control task status.
|
|
188
|
+
*/
|
|
117
189
|
async get(id, options) {
|
|
118
190
|
return this.http.request("GET", `${ENDPOINT4}/${id}`, {
|
|
119
191
|
...options
|
|
@@ -122,21 +194,21 @@ var MotionControl = class {
|
|
|
122
194
|
};
|
|
123
195
|
|
|
124
196
|
// src/client.ts
|
|
125
|
-
var KlingClient = class {
|
|
126
|
-
/** Text-to-video
|
|
197
|
+
var KlingClient = class extends BaseClient {
|
|
198
|
+
/** Text-to-video generation with multi-shot, sound, and Kling elements support on kling-3.0. */
|
|
127
199
|
textToVideo;
|
|
128
|
-
/** Image-to-video
|
|
200
|
+
/** Image-to-video animation from a first-frame image guided by a text prompt. */
|
|
129
201
|
imageToVideo;
|
|
130
|
-
/** AI avatar
|
|
202
|
+
/** AI avatar lip-sync: animate a face image to match an audio track. */
|
|
131
203
|
aiAvatar;
|
|
132
|
-
/**
|
|
204
|
+
/** Transfer motion from a reference video onto a subject image. */
|
|
133
205
|
motionControl;
|
|
134
206
|
constructor(options = {}) {
|
|
135
|
-
|
|
136
|
-
this.textToVideo = new TextToVideo(http);
|
|
137
|
-
this.imageToVideo = new ImageToVideo(http);
|
|
138
|
-
this.aiAvatar = new AiAvatar(http);
|
|
139
|
-
this.motionControl = new MotionControl(http);
|
|
207
|
+
super(options);
|
|
208
|
+
this.textToVideo = new TextToVideo(this.http);
|
|
209
|
+
this.imageToVideo = new ImageToVideo(this.http);
|
|
210
|
+
this.aiAvatar = new AiAvatar(this.http);
|
|
211
|
+
this.motionControl = new MotionControl(this.http);
|
|
140
212
|
}
|
|
141
213
|
};
|
|
142
214
|
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts","../src/resources/text-to-video.ts","../src/resources/image-to-video.ts","../src/resources/ai-avatar.ts","../src/resources/motion-control.ts","../src/index.ts"],"sourcesContent":["import { createHttpClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToVideo } from './resources/text-to-video';\nimport { ImageToVideo } from './resources/image-to-video';\nimport { AiAvatar } from './resources/ai-avatar';\nimport { MotionControl } from './resources/motion-control';\n\n/** Kling video API client. */\nexport class KlingClient {\n /** Text-to-video operations. */\n public readonly textToVideo: TextToVideo;\n /** Image-to-video operations. */\n public readonly imageToVideo: ImageToVideo;\n /** AI avatar operations. */\n public readonly aiAvatar: AiAvatar;\n /** Motion control operations. */\n public readonly motionControl: MotionControl;\n\n constructor(options: ClientOptions = {}) {\n const http = createHttpClient(options);\n this.textToVideo = new TextToVideo(http);\n this.imageToVideo = new ImageToVideo(http);\n this.aiAvatar = new AiAvatar(http);\n this.motionControl = new MotionControl(http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedTextToVideoResponse,\n TextToVideoParams,\n TextToVideoResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/text_to_video';\n\nexport class TextToVideo {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: TextToVideoParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToVideoResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<TextToVideoResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedTextToVideoResponse;\n }\n\n async create(params: TextToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n async get(id: string, options?: RequestOptions): Promise<TextToVideoResponse> {\n return this.http.request<TextToVideoResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedImageToVideoResponse,\n ImageToVideoParams,\n ImageToVideoResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/image_to_video';\n\nexport class ImageToVideo {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: ImageToVideoParams, options?: RequestOptions & PollingOptions): Promise<CompletedImageToVideoResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<ImageToVideoResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedImageToVideoResponse;\n }\n\n async create(params: ImageToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n async get(id: string, options?: RequestOptions): Promise<ImageToVideoResponse> {\n return this.http.request<ImageToVideoResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedAiAvatarResponse,\n AiAvatarParams,\n AiAvatarResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/ai_avatar';\n\nexport class AiAvatar {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: AiAvatarParams, options?: RequestOptions & PollingOptions): Promise<CompletedAiAvatarResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<AiAvatarResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedAiAvatarResponse;\n }\n\n async create(params: AiAvatarParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n async get(id: string, options?: RequestOptions): Promise<AiAvatarResponse> {\n return this.http.request<AiAvatarResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedMotionControlResponse,\n MotionControlParams,\n MotionControlResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/motion_control';\n\nexport class MotionControl {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: MotionControlParams, options?: RequestOptions & PollingOptions): Promise<CompletedMotionControlResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<MotionControlResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedMotionControlResponse;\n }\n\n async create(params: MotionControlParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n async get(id: string, options?: RequestOptions): Promise<MotionControlResponse> {\n return this.http.request<MotionControlResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","export { KlingClient } from './client';\nexport * from './types';\n\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTime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AA,EAAnB;AAAA,EAE7B,MAAM,IAAI,QAA6B,SAAoF;AACzH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,MAAMD,mBAAyC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MAC3F,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,OAAO,QAA6B,SAAuD;AAC/F,WAAO,KAAK,KAAK,QAA4B,QAAQC,WAAU;AAAA,MAC7D,MAAMF,eAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAA0D;AAC9E,WAAO,KAAK,KAAK,QAA+B,OAAO,GAAGE,SAAQ,IAAI,EAAE,IAAI;AAAA,MAC1E,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;AJ7BO,IAAM,cAAN,MAAkB;AAAA;AAAA,EAEP;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,OAAO,iBAAiB,OAAO;AACrC,SAAK,cAAc,IAAI,YAAY,IAAI;AACvC,SAAK,eAAe,IAAI,aAAa,IAAI;AACzC,SAAK,WAAW,IAAI,SAAS,IAAI;AACjC,SAAK,gBAAgB,IAAI,cAAc,IAAI;AAAA,EAC7C;AACF;;;AKrBA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["compactParams","pollUntilComplete","ENDPOINT","compactParams","pollUntilComplete","ENDPOINT","compactParams","pollUntilComplete","ENDPOINT"]}
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/resources/text-to-video.ts","../src/resources/image-to-video.ts","../src/resources/ai-avatar.ts","../src/resources/motion-control.ts","../src/index.ts"],"sourcesContent":["import { BaseClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToVideo } from './resources/text-to-video';\nimport { ImageToVideo } from './resources/image-to-video';\nimport { AiAvatar } from './resources/ai-avatar';\nimport { MotionControl } from './resources/motion-control';\n\n/**\n * Kling video generation, AI avatar lip-sync, and motion control API client.\n *\n * @example\n * ```typescript\n * const client = new KlingClient({ apiKey: 'your-api-key' });\n *\n * const result = await client.textToVideo.run({\n * model: 'kling-3.0',\n * prompt: 'A cat walking through a garden',\n * });\n * ```\n */\nexport class KlingClient extends BaseClient {\n /** Text-to-video generation with multi-shot, sound, and Kling elements support on kling-3.0. */\n public readonly textToVideo: TextToVideo;\n /** Image-to-video animation from a first-frame image guided by a text prompt. */\n public readonly imageToVideo: ImageToVideo;\n /** AI avatar lip-sync: animate a face image to match an audio track. */\n public readonly aiAvatar: AiAvatar;\n /** Transfer motion from a reference video onto a subject image. */\n public readonly motionControl: MotionControl;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToVideo = new TextToVideo(this.http);\n this.imageToVideo = new ImageToVideo(this.http);\n this.aiAvatar = new AiAvatar(this.http);\n this.motionControl = new MotionControl(this.http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedTextToVideoResponse,\n TextToVideoParams,\n TextToVideoResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/text_to_video';\n\n/** Generate video from text prompts. Supports multi-shot, sound, first/last frame images, and Kling elements on kling-3.0; negative prompts and cfg_scale on V2.x models. */\nexport class TextToVideo {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate a video from a text prompt and wait until complete.\n * @param params Text-to-video parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with videos.\n */\n async run(params: TextToVideoParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToVideoResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<TextToVideoResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedTextToVideoResponse;\n }\n\n /**\n * Create a text-to-video task; returns immediately with a task id.\n * @param params Text-to-video parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: TextToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a text-to-video task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current text-to-video task status.\n */\n async get(id: string, options?: RequestOptions): Promise<TextToVideoResponse> {\n return this.http.request<TextToVideoResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedImageToVideoResponse,\n ImageToVideoParams,\n ImageToVideoResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/image_to_video';\n\n/** Animate a still image into video, guided by a text prompt and first-frame image. */\nexport class ImageToVideo {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate a video from an input image and wait until complete.\n * @param params Image-to-video parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with videos.\n */\n async run(params: ImageToVideoParams, options?: RequestOptions & PollingOptions): Promise<CompletedImageToVideoResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<ImageToVideoResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedImageToVideoResponse;\n }\n\n /**\n * Create an image-to-video task; returns immediately with a task id.\n * @param params Image-to-video parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: ImageToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image-to-video task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current image-to-video task status.\n */\n async get(id: string, options?: RequestOptions): Promise<ImageToVideoResponse> {\n return this.http.request<ImageToVideoResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedAiAvatarResponse,\n AiAvatarParams,\n AiAvatarResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/ai_avatar';\n\n/** Lip-sync a face image to an audio track, producing a talking-head video. */\nexport class AiAvatar {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate an AI avatar video and wait until complete.\n * @param params AI avatar parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with videos.\n */\n async run(params: AiAvatarParams, options?: RequestOptions & PollingOptions): Promise<CompletedAiAvatarResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<AiAvatarResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedAiAvatarResponse;\n }\n\n /**\n * Create an AI avatar generation task; returns immediately with a task id.\n * @param params AI avatar parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: AiAvatarParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an AI avatar task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current AI avatar task status.\n */\n async get(id: string, options?: RequestOptions): Promise<AiAvatarResponse> {\n return this.http.request<AiAvatarResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedMotionControlResponse,\n MotionControlParams,\n MotionControlResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/motion_control';\n\n/** Transfer motion from a reference video onto a subject image, preserving the subject's appearance. */\nexport class MotionControl {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate a video with motion transfer from a reference video and wait until complete.\n * @param params Motion control parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with videos.\n */\n async run(params: MotionControlParams, options?: RequestOptions & PollingOptions): Promise<CompletedMotionControlResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<MotionControlResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedMotionControlResponse;\n }\n\n /**\n * Create a motion control generation task; returns immediately with a task id.\n * @param params Motion control parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: MotionControlParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a motion control task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current motion control task status.\n */\n async get(id: string, options?: RequestOptions): Promise<MotionControlResponse> {\n return this.http.request<MotionControlResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","export { KlingClient } from './client';\nexport * from './types';\n\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n Networ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AK,cAAc,IAAI,YAAY,KAAK,IAAI;AAC5C,SAAK,eAAe,IAAI,aAAa,KAAK,IAAI;AAC9C,SAAK,WAAW,IAAI,SAAS,KAAK,IAAI;AACtC,SAAK,gBAAgB,IAAI,cAAc,KAAK,IAAI;AAAA,EAClD;AACF;;;AKjCA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["compactParams","pollUntilComplete","ENDPOINT","compactParams","pollUntilComplete","ENDPOINT","compactParams","pollUntilComplete","ENDPOINT"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runapi.ai/kling",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
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.6"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^20.0.0",
|
package/skills/kling/README.md
CHANGED
|
@@ -53,6 +53,7 @@ const client = new KlingClient();
|
|
|
53
53
|
const result = await client.textToVideo.run({
|
|
54
54
|
model: 'kling-3.0',
|
|
55
55
|
prompt: 'A cat walking through a sunlit garden',
|
|
56
|
+
output_resolution: '4k',
|
|
56
57
|
});
|
|
57
58
|
const url = result.videos[0].url;
|
|
58
59
|
```
|
|
@@ -72,11 +73,19 @@ const url = result.videos[0].url;
|
|
|
72
73
|
- [Kling 3.0](https://runapi.ai/models/kling/3.0)
|
|
73
74
|
- [AI avatar pro](https://runapi.ai/models/kling/ai-avatar-pro)
|
|
74
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)
|
|
75
82
|
- [V2.5 turbo text to video pro](https://runapi.ai/models/kling/v2.5-turbo-text-to-video-pro)
|
|
76
83
|
- [V2.5 turbo image to video pro](https://runapi.ai/models/kling/v2.5-turbo-image-to-video-pro)
|
|
77
84
|
|
|
78
85
|
## Agent rules
|
|
79
86
|
|
|
87
|
+
- Integration work uses the target language SDK; one-off generation, manual smoke tests, debugging, or user-requested CLI runs use the RunAPI CLI skill: https://github.com/runapi-ai/cli-skill
|
|
88
|
+
- RunAPI-generated file URLs are temporary. Download and store generated images, videos, audio, or other files in your own durable storage within 7 days; do not treat returned URLs as long-term assets.
|
|
80
89
|
- Keep API keys in `RUNAPI_API_KEY` or RunAPI CLI config; never commit secrets.
|
|
81
90
|
- Prefer `create`, `get`, and `run` JSON passthrough patterns instead of inventing flags for every model parameter.
|
|
82
91
|
- For kling ai api pricing, rate-limit, and commercial-usage answers, link to the variant page rather than the repository README.
|
package/skills/kling/SKILL.md
CHANGED
|
@@ -25,16 +25,25 @@ metadata:
|
|
|
25
25
|
|
|
26
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.
|
|
27
27
|
|
|
28
|
-
##
|
|
28
|
+
## Critical: Integration Runtime
|
|
29
29
|
|
|
30
|
-
-
|
|
31
|
-
-
|
|
30
|
+
- Integration work (app, backend, worker, library, Rails service, Node service, Go service, webhook pipeline, or production codebase) uses the **SDK integration path** for the target language.
|
|
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.
|
|
33
|
+
|
|
34
|
+
## SDK integration path
|
|
35
|
+
|
|
36
|
+
When integrating Kling into an app, backend, worker, library, Rails service, Node service, Go service, webhook pipeline, or production workflow, start by checking the current SDK package and official usage. Confirm install commands, client methods (`create`, `get`, `run`), request fields, response shape, and error classes before using CLI help or raw HTTP examples. Use a RunAPI SDK package:
|
|
37
|
+
|
|
38
|
+
- JavaScript / TypeScript: `@runapi.ai/kling`
|
|
39
|
+
- Ruby: `runapi-kling`
|
|
40
|
+
- Go: `github.com/runapi-ai/kling-sdk/go`
|
|
32
41
|
|
|
33
42
|
## CLI path
|
|
34
43
|
|
|
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.
|
|
44
|
+
The `runapi` binary is the one-off and manual testing runtime dependency. For full CLI-specific agent guidance, see https://github.com/runapi-ai/cli-skill. 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.
|
|
36
45
|
|
|
37
|
-
Inspect the available
|
|
46
|
+
Inspect the available commands and request fields with CLI help:
|
|
38
47
|
|
|
39
48
|
```shell
|
|
40
49
|
runapi kling --help
|
|
@@ -54,15 +63,13 @@ runapi kling text-to-video --async --input-file request.json
|
|
|
54
63
|
runapi wait <task-id> --service kling --action text-to-video
|
|
55
64
|
```
|
|
56
65
|
|
|
57
|
-
Available
|
|
66
|
+
Available commands: `text-to-video`, `avatar`, `image-to-video`, `motion-control`.
|
|
58
67
|
|
|
59
|
-
|
|
68
|
+
For Kling 3.0 text-to-video requests, keep `model: "kling-3.0"` and choose `output_resolution: "720p"`, `"1080p"`, or `"4k"` as needed.
|
|
60
69
|
|
|
61
|
-
|
|
70
|
+
## Generated file storage
|
|
62
71
|
|
|
63
|
-
-
|
|
64
|
-
- Ruby: `runapi-kling`
|
|
65
|
-
- Go: `github.com/runapi-ai/kling-sdk/go`
|
|
72
|
+
RunAPI-generated file URLs are temporary. Download and store generated images, videos, audio, or other files in your own durable storage within 7 days; do not treat returned URLs as long-term assets.
|
|
66
73
|
|
|
67
74
|
## References
|
|
68
75
|
|
|
@@ -75,6 +82,11 @@ When integrating Kling into an app, backend, worker, or library — not for one-
|
|
|
75
82
|
- [Kling 3.0](https://runapi.ai/models/kling/3.0.md)
|
|
76
83
|
- [AI avatar pro](https://runapi.ai/models/kling/ai-avatar-pro.md)
|
|
77
84
|
- [AI avatar standard](https://runapi.ai/models/kling/ai-avatar-standard.md)
|
|
85
|
+
- [AI avatar v1 pro](https://runapi.ai/models/kling/ai-avatar-v1-pro.md)
|
|
86
|
+
- [V1 avatar standard](https://runapi.ai/models/kling/v1-avatar-standard.md)
|
|
87
|
+
- [V2.1 pro](https://runapi.ai/models/kling/v2.1-pro.md)
|
|
88
|
+
- [V2.1 standard](https://runapi.ai/models/kling/v2.1-standard.md)
|
|
89
|
+
- [V2.1 master text to video](https://runapi.ai/models/kling/v2.1-master-text-to-video.md)
|
|
90
|
+
- [V2.1 master image to video](https://runapi.ai/models/kling/v2.1-master-image-to-video.md)
|
|
78
91
|
- [V2.5 turbo text to video pro](https://runapi.ai/models/kling/v2.5-turbo-text-to-video-pro.md)
|
|
79
92
|
- [V2.5 turbo image to video pro](https://runapi.ai/models/kling/v2.5-turbo-image-to-video-pro.md)
|
|
80
|
-
|