@runapi.ai/kling 0.2.7 → 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 +2 -0
- package/dist/index.d.mts +152 -8
- package/dist/index.d.ts +152 -8
- 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 +2 -0
- package/skills/kling/SKILL.md +15 -10
package/README.md
CHANGED
|
@@ -24,6 +24,8 @@ 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
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.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,52 +1,83 @@
|
|
|
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
|
+
* 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
|
+
*/
|
|
4
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
|
+
*/
|
|
5
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. */
|
|
6
14
|
type KlingTextToVideoOutputResolution = '720p' | '1080p' | '4k';
|
|
7
15
|
type KlingAspectRatio = '16:9' | '9:16' | '1:1';
|
|
16
|
+
/** Duration in seconds. Range varies by model: 3-15 for kling-3.0, 5 or 10 for V2.x. */
|
|
8
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';
|
|
36
|
+
/** Duration in seconds (3-15). */
|
|
23
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;
|
|
49
|
+
/** Generate synchronized audio for the video. */
|
|
31
50
|
enable_sound?: boolean;
|
|
51
|
+
/** Opening frame image URL; overrides the generated first frame. */
|
|
32
52
|
first_frame_image_url?: string;
|
|
53
|
+
/** Closing frame image URL; only available in single-shot mode. */
|
|
33
54
|
last_frame_image_url?: string;
|
|
34
55
|
}
|
|
56
|
+
/** Kling 3.0 multi-shot mode: stitch multiple prompted segments into one video with sound. */
|
|
35
57
|
interface Kling3TextToVideoMultiShotParams extends Kling3TextToVideoCommonParams {
|
|
58
|
+
/** Must be true to activate multi-shot generation. */
|
|
36
59
|
multi_shots: true;
|
|
60
|
+
/** Must be true; sound is always generated in multi-shot mode. */
|
|
37
61
|
enable_sound: true;
|
|
62
|
+
/** Ordered shot segments, each with its own prompt and duration. */
|
|
38
63
|
multi_prompt: MultiPromptItem[];
|
|
64
|
+
/** Opening frame image URL for the first shot. */
|
|
39
65
|
first_frame_image_url?: string;
|
|
40
66
|
}
|
|
67
|
+
/** V2.5 Turbo text-to-video: fast, high-quality generation with negative prompt and cfg_scale control. */
|
|
41
68
|
interface V25TurboTextToVideoParams {
|
|
42
69
|
model: 'kling-v2.5-turbo-text-to-video-pro';
|
|
43
70
|
prompt: string;
|
|
71
|
+
/** Duration: 5 or 10 seconds. */
|
|
44
72
|
duration_seconds?: 5 | 10;
|
|
45
73
|
aspect_ratio?: KlingAspectRatio;
|
|
74
|
+
/** Elements to exclude from the generated video. */
|
|
46
75
|
negative_prompt?: string;
|
|
76
|
+
/** Prompt adherence strength (higher = more literal). */
|
|
47
77
|
cfg_scale?: number;
|
|
48
78
|
callback_url?: string;
|
|
49
79
|
}
|
|
80
|
+
/** V2.1 Master text-to-video: highest V2.1 quality with negative prompt and cfg_scale control. */
|
|
50
81
|
interface V21MasterTextToVideoParams {
|
|
51
82
|
model: 'kling-v2.1-master-text-to-video';
|
|
52
83
|
prompt: string;
|
|
@@ -56,13 +87,21 @@ interface V21MasterTextToVideoParams {
|
|
|
56
87
|
cfg_scale?: number;
|
|
57
88
|
callback_url?: string;
|
|
58
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
|
+
*/
|
|
59
95
|
interface ImageToVideoParams {
|
|
60
96
|
model: KlingImageToVideoModel;
|
|
97
|
+
/** Video motion description prompt. */
|
|
61
98
|
prompt: string;
|
|
99
|
+
/** Source image URL used as the video's opening frame. */
|
|
62
100
|
first_frame_image_url: string;
|
|
63
101
|
duration_seconds?: 5 | 10;
|
|
64
102
|
negative_prompt?: string;
|
|
65
103
|
cfg_scale?: number;
|
|
104
|
+
/** Target ending frame image URL; supported on V2.5 turbo and V2.1 pro. */
|
|
66
105
|
last_frame_image_url?: string;
|
|
67
106
|
callback_url?: string;
|
|
68
107
|
}
|
|
@@ -87,11 +126,19 @@ interface ImageToVideoResponse extends AsyncTaskResponse {
|
|
|
87
126
|
error?: string;
|
|
88
127
|
[key: string]: unknown;
|
|
89
128
|
}
|
|
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
|
+
*/
|
|
90
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. */
|
|
91
135
|
interface AiAvatarParams {
|
|
92
136
|
model: AiAvatarModel;
|
|
137
|
+
/** Face image URL; the face will be animated to match the audio. */
|
|
93
138
|
source_image_url: string;
|
|
139
|
+
/** Audio URL for lip synchronization. */
|
|
94
140
|
source_audio_url: string;
|
|
141
|
+
/** Description of the avatar's appearance and context. */
|
|
95
142
|
prompt: string;
|
|
96
143
|
callback_url?: string;
|
|
97
144
|
}
|
|
@@ -100,13 +147,22 @@ interface AiAvatarResponse extends AsyncTaskResponse {
|
|
|
100
147
|
error?: string;
|
|
101
148
|
[key: string]: unknown;
|
|
102
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
|
+
*/
|
|
103
154
|
interface MotionControlParams {
|
|
104
155
|
model: 'kling-3.0';
|
|
156
|
+
/** Subject image URL whose appearance is preserved. */
|
|
105
157
|
source_image_url: string;
|
|
158
|
+
/** Reference video URL whose motion patterns are transferred. */
|
|
106
159
|
reference_video_url: string;
|
|
160
|
+
/** Optional description prompt. */
|
|
107
161
|
prompt?: string;
|
|
108
162
|
output_resolution?: '720p' | '1080p';
|
|
163
|
+
/** Whether the character faces the direction from the video or the image. */
|
|
109
164
|
character_orientation?: 'video' | 'image';
|
|
165
|
+
/** Whether the background comes from the video or the image. */
|
|
110
166
|
background_source?: 'video' | 'image';
|
|
111
167
|
callback_url?: string;
|
|
112
168
|
}
|
|
@@ -132,47 +188,135 @@ type CompletedMotionControlResponse = MotionControlResponse & {
|
|
|
132
188
|
videos: VideoMetadata[];
|
|
133
189
|
};
|
|
134
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. */
|
|
135
192
|
declare class TextToVideo {
|
|
136
193
|
private readonly http;
|
|
137
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
|
+
*/
|
|
138
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
|
+
*/
|
|
139
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
|
+
*/
|
|
140
215
|
get(id: string, options?: RequestOptions): Promise<TextToVideoResponse>;
|
|
141
216
|
}
|
|
142
217
|
|
|
218
|
+
/** Animate a still image into video, guided by a text prompt and first-frame image. */
|
|
143
219
|
declare class ImageToVideo {
|
|
144
220
|
private readonly http;
|
|
145
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
|
+
*/
|
|
146
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
|
+
*/
|
|
147
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
|
+
*/
|
|
148
242
|
get(id: string, options?: RequestOptions): Promise<ImageToVideoResponse>;
|
|
149
243
|
}
|
|
150
244
|
|
|
245
|
+
/** Lip-sync a face image to an audio track, producing a talking-head video. */
|
|
151
246
|
declare class AiAvatar {
|
|
152
247
|
private readonly http;
|
|
153
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
|
+
*/
|
|
154
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
|
+
*/
|
|
155
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
|
+
*/
|
|
156
269
|
get(id: string, options?: RequestOptions): Promise<AiAvatarResponse>;
|
|
157
270
|
}
|
|
158
271
|
|
|
272
|
+
/** Transfer motion from a reference video onto a subject image, preserving the subject's appearance. */
|
|
159
273
|
declare class MotionControl {
|
|
160
274
|
private readonly http;
|
|
161
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
|
+
*/
|
|
162
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
|
+
*/
|
|
163
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
|
+
*/
|
|
164
296
|
get(id: string, options?: RequestOptions): Promise<MotionControlResponse>;
|
|
165
297
|
}
|
|
166
298
|
|
|
167
|
-
/**
|
|
168
|
-
|
|
169
|
-
|
|
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. */
|
|
170
314
|
readonly textToVideo: TextToVideo;
|
|
171
|
-
/** Image-to-video
|
|
315
|
+
/** Image-to-video animation from a first-frame image guided by a text prompt. */
|
|
172
316
|
readonly imageToVideo: ImageToVideo;
|
|
173
|
-
/** AI avatar
|
|
317
|
+
/** AI avatar lip-sync: animate a face image to match an audio track. */
|
|
174
318
|
readonly aiAvatar: AiAvatar;
|
|
175
|
-
/**
|
|
319
|
+
/** Transfer motion from a reference video onto a subject image. */
|
|
176
320
|
readonly motionControl: MotionControl;
|
|
177
321
|
constructor(options?: ClientOptions);
|
|
178
322
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,52 +1,83 @@
|
|
|
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
|
+
* 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
|
+
*/
|
|
4
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
|
+
*/
|
|
5
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. */
|
|
6
14
|
type KlingTextToVideoOutputResolution = '720p' | '1080p' | '4k';
|
|
7
15
|
type KlingAspectRatio = '16:9' | '9:16' | '1:1';
|
|
16
|
+
/** Duration in seconds. Range varies by model: 3-15 for kling-3.0, 5 or 10 for V2.x. */
|
|
8
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';
|
|
36
|
+
/** Duration in seconds (3-15). */
|
|
23
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;
|
|
49
|
+
/** Generate synchronized audio for the video. */
|
|
31
50
|
enable_sound?: boolean;
|
|
51
|
+
/** Opening frame image URL; overrides the generated first frame. */
|
|
32
52
|
first_frame_image_url?: string;
|
|
53
|
+
/** Closing frame image URL; only available in single-shot mode. */
|
|
33
54
|
last_frame_image_url?: string;
|
|
34
55
|
}
|
|
56
|
+
/** Kling 3.0 multi-shot mode: stitch multiple prompted segments into one video with sound. */
|
|
35
57
|
interface Kling3TextToVideoMultiShotParams extends Kling3TextToVideoCommonParams {
|
|
58
|
+
/** Must be true to activate multi-shot generation. */
|
|
36
59
|
multi_shots: true;
|
|
60
|
+
/** Must be true; sound is always generated in multi-shot mode. */
|
|
37
61
|
enable_sound: true;
|
|
62
|
+
/** Ordered shot segments, each with its own prompt and duration. */
|
|
38
63
|
multi_prompt: MultiPromptItem[];
|
|
64
|
+
/** Opening frame image URL for the first shot. */
|
|
39
65
|
first_frame_image_url?: string;
|
|
40
66
|
}
|
|
67
|
+
/** V2.5 Turbo text-to-video: fast, high-quality generation with negative prompt and cfg_scale control. */
|
|
41
68
|
interface V25TurboTextToVideoParams {
|
|
42
69
|
model: 'kling-v2.5-turbo-text-to-video-pro';
|
|
43
70
|
prompt: string;
|
|
71
|
+
/** Duration: 5 or 10 seconds. */
|
|
44
72
|
duration_seconds?: 5 | 10;
|
|
45
73
|
aspect_ratio?: KlingAspectRatio;
|
|
74
|
+
/** Elements to exclude from the generated video. */
|
|
46
75
|
negative_prompt?: string;
|
|
76
|
+
/** Prompt adherence strength (higher = more literal). */
|
|
47
77
|
cfg_scale?: number;
|
|
48
78
|
callback_url?: string;
|
|
49
79
|
}
|
|
80
|
+
/** V2.1 Master text-to-video: highest V2.1 quality with negative prompt and cfg_scale control. */
|
|
50
81
|
interface V21MasterTextToVideoParams {
|
|
51
82
|
model: 'kling-v2.1-master-text-to-video';
|
|
52
83
|
prompt: string;
|
|
@@ -56,13 +87,21 @@ interface V21MasterTextToVideoParams {
|
|
|
56
87
|
cfg_scale?: number;
|
|
57
88
|
callback_url?: string;
|
|
58
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
|
+
*/
|
|
59
95
|
interface ImageToVideoParams {
|
|
60
96
|
model: KlingImageToVideoModel;
|
|
97
|
+
/** Video motion description prompt. */
|
|
61
98
|
prompt: string;
|
|
99
|
+
/** Source image URL used as the video's opening frame. */
|
|
62
100
|
first_frame_image_url: string;
|
|
63
101
|
duration_seconds?: 5 | 10;
|
|
64
102
|
negative_prompt?: string;
|
|
65
103
|
cfg_scale?: number;
|
|
104
|
+
/** Target ending frame image URL; supported on V2.5 turbo and V2.1 pro. */
|
|
66
105
|
last_frame_image_url?: string;
|
|
67
106
|
callback_url?: string;
|
|
68
107
|
}
|
|
@@ -87,11 +126,19 @@ interface ImageToVideoResponse extends AsyncTaskResponse {
|
|
|
87
126
|
error?: string;
|
|
88
127
|
[key: string]: unknown;
|
|
89
128
|
}
|
|
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
|
+
*/
|
|
90
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. */
|
|
91
135
|
interface AiAvatarParams {
|
|
92
136
|
model: AiAvatarModel;
|
|
137
|
+
/** Face image URL; the face will be animated to match the audio. */
|
|
93
138
|
source_image_url: string;
|
|
139
|
+
/** Audio URL for lip synchronization. */
|
|
94
140
|
source_audio_url: string;
|
|
141
|
+
/** Description of the avatar's appearance and context. */
|
|
95
142
|
prompt: string;
|
|
96
143
|
callback_url?: string;
|
|
97
144
|
}
|
|
@@ -100,13 +147,22 @@ interface AiAvatarResponse extends AsyncTaskResponse {
|
|
|
100
147
|
error?: string;
|
|
101
148
|
[key: string]: unknown;
|
|
102
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
|
+
*/
|
|
103
154
|
interface MotionControlParams {
|
|
104
155
|
model: 'kling-3.0';
|
|
156
|
+
/** Subject image URL whose appearance is preserved. */
|
|
105
157
|
source_image_url: string;
|
|
158
|
+
/** Reference video URL whose motion patterns are transferred. */
|
|
106
159
|
reference_video_url: string;
|
|
160
|
+
/** Optional description prompt. */
|
|
107
161
|
prompt?: string;
|
|
108
162
|
output_resolution?: '720p' | '1080p';
|
|
163
|
+
/** Whether the character faces the direction from the video or the image. */
|
|
109
164
|
character_orientation?: 'video' | 'image';
|
|
165
|
+
/** Whether the background comes from the video or the image. */
|
|
110
166
|
background_source?: 'video' | 'image';
|
|
111
167
|
callback_url?: string;
|
|
112
168
|
}
|
|
@@ -132,47 +188,135 @@ type CompletedMotionControlResponse = MotionControlResponse & {
|
|
|
132
188
|
videos: VideoMetadata[];
|
|
133
189
|
};
|
|
134
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. */
|
|
135
192
|
declare class TextToVideo {
|
|
136
193
|
private readonly http;
|
|
137
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
|
+
*/
|
|
138
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
|
+
*/
|
|
139
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
|
+
*/
|
|
140
215
|
get(id: string, options?: RequestOptions): Promise<TextToVideoResponse>;
|
|
141
216
|
}
|
|
142
217
|
|
|
218
|
+
/** Animate a still image into video, guided by a text prompt and first-frame image. */
|
|
143
219
|
declare class ImageToVideo {
|
|
144
220
|
private readonly http;
|
|
145
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
|
+
*/
|
|
146
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
|
+
*/
|
|
147
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
|
+
*/
|
|
148
242
|
get(id: string, options?: RequestOptions): Promise<ImageToVideoResponse>;
|
|
149
243
|
}
|
|
150
244
|
|
|
245
|
+
/** Lip-sync a face image to an audio track, producing a talking-head video. */
|
|
151
246
|
declare class AiAvatar {
|
|
152
247
|
private readonly http;
|
|
153
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
|
+
*/
|
|
154
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
|
+
*/
|
|
155
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
|
+
*/
|
|
156
269
|
get(id: string, options?: RequestOptions): Promise<AiAvatarResponse>;
|
|
157
270
|
}
|
|
158
271
|
|
|
272
|
+
/** Transfer motion from a reference video onto a subject image, preserving the subject's appearance. */
|
|
159
273
|
declare class MotionControl {
|
|
160
274
|
private readonly http;
|
|
161
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
|
+
*/
|
|
162
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
|
+
*/
|
|
163
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
|
+
*/
|
|
164
296
|
get(id: string, options?: RequestOptions): Promise<MotionControlResponse>;
|
|
165
297
|
}
|
|
166
298
|
|
|
167
|
-
/**
|
|
168
|
-
|
|
169
|
-
|
|
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. */
|
|
170
314
|
readonly textToVideo: TextToVideo;
|
|
171
|
-
/** Image-to-video
|
|
315
|
+
/** Image-to-video animation from a first-frame image guided by a text prompt. */
|
|
172
316
|
readonly imageToVideo: ImageToVideo;
|
|
173
|
-
/** AI avatar
|
|
317
|
+
/** AI avatar lip-sync: animate a face image to match an audio track. */
|
|
174
318
|
readonly aiAvatar: AiAvatar;
|
|
175
|
-
/**
|
|
319
|
+
/** Transfer motion from a reference video onto a subject image. */
|
|
176
320
|
readonly motionControl: MotionControl;
|
|
177
321
|
constructor(options?: ClientOptions);
|
|
178
322
|
}
|
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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAAqD;;;ACCrD,kBAA8B;AAC9B,sBAAkC;AAQlC,IAAM,WAAW;AAEV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EAE7B,MAAM,IAAI,QAA2B,SAAkF;AACrH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,UAAM,mCAAuC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACzF,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,OAAO,QAA2B,SAAuD;AAC7F,WAAO,KAAK,KAAK,QAA4B,QAAQ,UAAU;AAAA,MAC7D,UAAM,2BAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAAwD;AAC5E,WAAO,KAAK,KAAK,QAA6B,OAAO,GAAG,QAAQ,IAAI,EAAE,IA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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;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAA+C;;;ACC/C,kBAA8B;AAC9B,sBAAkC;AAQlC,IAAM,WAAW;AAGV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,MAAM,IAAI,QAA2B,SAAkF;AACrH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,UAAM,mCAAuC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACzF,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,OAAO,QAA2B,SAAuD;AAC7F,WAAO,KAAK,KAAK,QAA4B,QAAQ,UAAU;AAAA,MAC7D,UAAM,2BAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,IAAY,SAAw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ACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,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;;;AJpCO,IAAM,cAAN,cAA0B,wBAAW;AAAA;AAAA,EAE1B;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,OAAO;AACb,SAAK,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;;;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 TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n"],"mappings":";AAAA,SAAS,wBAA4C;;;ACCrD,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAQlC,IAAM,WAAW;AAEV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EAE7B,MAAM,IAAI,QAA2B,SAAkF;AACrH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,MAAM,kBAAuC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACzF,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,OAAO,QAA2B,SAAuD;AAC7F,WAAO,KAAK,KAAK,QAA4B,QAAQ,UAAU;AAAA,MAC7D,MAAM,cAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAAwD;AAC5E,WAAO,KAAK,KAAK,QAA6B,OAAO,GAAG,QAAQ,IAAI,EAAE,IAA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AAM,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 NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n"],"mappings":";AAAA,SAAS,kBAAsC;;;ACC/C,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAQlC,IAAM,WAAW;AAGV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,MAAM,IAAI,QAA2B,SAAkF;AACrH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,MAAM,kBAAuC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACzF,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,OAAO,QAA2B,SAAuD;AAC7F,WAAO,KAAK,KAAK,QAA4B,QAAQ,UAAU;AAAA,MAC7D,MAAM,cAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA;A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WAAO,KAAK,KAAK,QAA4B,QAAQC,WAAU;AAAA,MAC7D,MAAMF,eAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,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;;;AJpCO,IAAM,cAAN,cAA0B,WAAW;AAAA;AAAA,EAE1B;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,OAAO;AACb,SAAK,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
|
@@ -84,6 +84,8 @@ const url = result.videos[0].url;
|
|
|
84
84
|
|
|
85
85
|
## Agent rules
|
|
86
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.
|
|
87
89
|
- Keep API keys in `RUNAPI_API_KEY` or RunAPI CLI config; never commit secrets.
|
|
88
90
|
- Prefer `create`, `get`, and `run` JSON passthrough patterns instead of inventing flags for every model parameter.
|
|
89
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,14 +25,23 @@ 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
46
|
Inspect the available commands and request fields with CLI help:
|
|
38
47
|
|
|
@@ -58,13 +67,9 @@ 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
|
-
##
|
|
62
|
-
|
|
63
|
-
When integrating Kling into an app, backend, worker, or library — not for one-off tasks — use a RunAPI SDK package:
|
|
70
|
+
## Generated file storage
|
|
64
71
|
|
|
65
|
-
-
|
|
66
|
-
- Ruby: `runapi-kling`
|
|
67
|
-
- 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.
|
|
68
73
|
|
|
69
74
|
## References
|
|
70
75
|
|