@runapi.ai/kling 0.2.7 → 0.2.9

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/dist/index.d.ts CHANGED
@@ -1,52 +1,91 @@
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
- type KlingTextToVideoModel = 'kling-3.0' | 'kling-v2.5-turbo-text-to-video-pro' | 'kling-v2.1-master-text-to-video';
5
- 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';
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-v3-turbo-text-to-video' | '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 KlingV2ImageToVideoModel = 'kling-v2.5-turbo-image-to-video-pro' | 'kling-v2.1-pro' | 'kling-v2.1-standard' | 'kling-v2.1-master-image-to-video';
13
+ type KlingImageToVideoModel = KlingV2ImageToVideoModel | 'kling-v3-turbo-image-to-video';
14
+ /** Output resolution for text-to-video. 4k is highest quality but slowest. */
6
15
  type KlingTextToVideoOutputResolution = '720p' | '1080p' | '4k';
16
+ type KlingV3TurboOutputResolution = '720p' | '1080p';
7
17
  type KlingAspectRatio = '16:9' | '9:16' | '1:1';
18
+ /** Duration in seconds. Range varies by model: 3-15 for kling-3.0, 5 or 10 for V2.x. */
8
19
  type KlingDuration = number;
9
20
  /** A single shot in a multi-shot text-to-video sequence. */
10
21
  interface MultiPromptItem {
11
22
  prompt: string;
12
23
  duration_seconds: number;
13
24
  }
14
- /** Element reference for subject/style guidance. */
25
+ /** Named element (character, object, style) with reference image, video, or audio materials for generation consistency. */
15
26
  interface KlingElement {
27
+ /** Element identifier used for prompt referencing. */
16
28
  name: string;
29
+ /** Description of the element's visual characteristics. */
17
30
  description: string;
31
+ /** Image or video URLs providing visual reference for the element. */
18
32
  element_input_urls?: string[];
33
+ /** Video URLs providing motion reference for the element. */
19
34
  element_input_video_urls?: string[];
35
+ /** Audio URLs providing voice or sound reference for the element. */
36
+ element_input_audio_urls?: string[];
37
+ /** Start time in milliseconds for video element capture. */
38
+ start_time?: number;
39
+ /** End time in milliseconds for video element capture; must be 3000-8000 ms after start_time. */
40
+ end_time?: number;
20
41
  }
21
42
  interface Kling3TextToVideoCommonParams {
22
43
  model: 'kling-3.0';
44
+ /** Duration in seconds (3-15). */
23
45
  duration_seconds?: KlingDuration;
24
46
  aspect_ratio?: KlingAspectRatio;
25
47
  output_resolution?: KlingTextToVideoOutputResolution;
48
+ /** Visual elements for subject/style consistency across the video. */
26
49
  kling_elements?: KlingElement[];
50
+ /** URL for completion callback notifications. */
27
51
  callback_url?: string;
28
52
  }
53
+ /** Kling 3.0 single-shot text-to-video with optional sound and first/last frame control. */
29
54
  interface Kling3TextToVideoSingleShotParams extends Kling3TextToVideoCommonParams {
55
+ /** Video description prompt. */
30
56
  prompt: string;
57
+ /** Generate synchronized audio for the video. */
31
58
  enable_sound?: boolean;
59
+ /** Opening frame image URL; overrides the generated first frame. */
32
60
  first_frame_image_url?: string;
61
+ /** Closing frame image URL; only available in single-shot mode. */
33
62
  last_frame_image_url?: string;
34
63
  }
64
+ /** Kling 3.0 multi-shot mode: stitch multiple prompted segments into one video with sound. */
35
65
  interface Kling3TextToVideoMultiShotParams extends Kling3TextToVideoCommonParams {
66
+ /** Must be true to activate multi-shot generation. */
36
67
  multi_shots: true;
68
+ /** Must be true; sound is always generated in multi-shot mode. */
37
69
  enable_sound: true;
70
+ /** Ordered shot segments, each with its own prompt and duration. */
38
71
  multi_prompt: MultiPromptItem[];
72
+ /** Opening frame image URL for the first shot. */
39
73
  first_frame_image_url?: string;
40
74
  }
75
+ /** V2.5 Turbo text-to-video: fast, high-quality generation with negative prompt and cfg_scale control. */
41
76
  interface V25TurboTextToVideoParams {
42
77
  model: 'kling-v2.5-turbo-text-to-video-pro';
43
78
  prompt: string;
79
+ /** Duration: 5 or 10 seconds. */
44
80
  duration_seconds?: 5 | 10;
45
81
  aspect_ratio?: KlingAspectRatio;
82
+ /** Elements to exclude from the generated video. */
46
83
  negative_prompt?: string;
84
+ /** Prompt adherence strength (higher = more literal). */
47
85
  cfg_scale?: number;
48
86
  callback_url?: string;
49
87
  }
88
+ /** V2.1 Master text-to-video: highest V2.1 quality with negative prompt and cfg_scale control. */
50
89
  interface V21MasterTextToVideoParams {
51
90
  model: 'kling-v2.1-master-text-to-video';
52
91
  prompt: string;
@@ -56,17 +95,45 @@ interface V21MasterTextToVideoParams {
56
95
  cfg_scale?: number;
57
96
  callback_url?: string;
58
97
  }
59
- interface ImageToVideoParams {
60
- model: KlingImageToVideoModel;
98
+ /** V3 Turbo text-to-video: prompt-driven 3-15 second clips at 720p or 1080p. */
99
+ interface V3TurboTextToVideoParams {
100
+ model: 'kling-v3-turbo-text-to-video';
61
101
  prompt: string;
102
+ /** Duration in seconds (3-15). */
103
+ duration_seconds?: KlingDuration;
104
+ aspect_ratio?: KlingAspectRatio;
105
+ output_resolution?: KlingV3TurboOutputResolution;
106
+ callback_url?: string;
107
+ }
108
+ /**
109
+ * Image-to-video generation parameters. A first-frame image is required; the model
110
+ * animates it into video guided by the text prompt. last_frame_image_url is supported
111
+ * on V2.5 turbo and V2.1 pro models only.
112
+ */
113
+ interface V2ImageToVideoParams {
114
+ model: KlingV2ImageToVideoModel;
115
+ /** Video motion description prompt. */
116
+ prompt: string;
117
+ /** Source image URL used as the video's opening frame. */
62
118
  first_frame_image_url: string;
63
119
  duration_seconds?: 5 | 10;
64
120
  negative_prompt?: string;
65
121
  cfg_scale?: number;
122
+ /** Target ending frame image URL; supported on V2.5 turbo and V2.1 pro. */
66
123
  last_frame_image_url?: string;
67
124
  callback_url?: string;
68
125
  }
69
- type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams;
126
+ /** V3 Turbo image-to-video: animate one first-frame image at 720p or 1080p. */
127
+ interface V3TurboImageToVideoParams {
128
+ model: 'kling-v3-turbo-image-to-video';
129
+ prompt: string;
130
+ first_frame_image_url: string;
131
+ duration_seconds?: KlingDuration;
132
+ output_resolution?: KlingV3TurboOutputResolution;
133
+ callback_url?: string;
134
+ }
135
+ type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams | V3TurboTextToVideoParams;
136
+ type ImageToVideoParams = V2ImageToVideoParams | V3TurboImageToVideoParams;
70
137
  interface AsyncTaskResponse {
71
138
  id: string;
72
139
  status: AsyncTaskStatus;
@@ -87,11 +154,19 @@ interface ImageToVideoResponse extends AsyncTaskResponse {
87
154
  error?: string;
88
155
  [key: string]: unknown;
89
156
  }
157
+ /**
158
+ * AI avatar quality tier. Pro models produce the most natural lip movements;
159
+ * Standard models are faster with slightly less refined lip sync.
160
+ */
90
161
  type AiAvatarModel = 'kling-ai-avatar-pro' | 'kling-ai-avatar-standard' | 'kling-ai-avatar-v1-pro' | 'kling-v1-avatar-standard';
162
+ /** Lip-sync a face image to an audio track, producing a talking-head video. */
91
163
  interface AiAvatarParams {
92
164
  model: AiAvatarModel;
165
+ /** Face image URL; the face will be animated to match the audio. */
93
166
  source_image_url: string;
167
+ /** Audio URL for lip synchronization. */
94
168
  source_audio_url: string;
169
+ /** Description of the avatar's appearance and context. */
95
170
  prompt: string;
96
171
  callback_url?: string;
97
172
  }
@@ -100,13 +175,22 @@ interface AiAvatarResponse extends AsyncTaskResponse {
100
175
  error?: string;
101
176
  [key: string]: unknown;
102
177
  }
178
+ /**
179
+ * Transfer motion from a reference video onto a subject image. The subject adopts
180
+ * the movement patterns from the reference while preserving its own appearance.
181
+ */
103
182
  interface MotionControlParams {
104
183
  model: 'kling-3.0';
184
+ /** Subject image URL whose appearance is preserved. */
105
185
  source_image_url: string;
186
+ /** Reference video URL whose motion patterns are transferred. */
106
187
  reference_video_url: string;
188
+ /** Optional description prompt. */
107
189
  prompt?: string;
108
190
  output_resolution?: '720p' | '1080p';
191
+ /** Whether the character faces the direction from the video or the image. */
109
192
  character_orientation?: 'video' | 'image';
193
+ /** Whether the background comes from the video or the image. */
110
194
  background_source?: 'video' | 'image';
111
195
  callback_url?: string;
112
196
  }
@@ -132,49 +216,137 @@ type CompletedMotionControlResponse = MotionControlResponse & {
132
216
  videos: VideoMetadata[];
133
217
  };
134
218
 
219
+ /** 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
220
  declare class TextToVideo {
136
221
  private readonly http;
137
222
  constructor(http: HttpClient);
223
+ /**
224
+ * Generate a video from a text prompt and wait until complete.
225
+ * @param params Text-to-video parameters.
226
+ * @param options Per-request and polling overrides.
227
+ * @returns The completed task with videos.
228
+ */
138
229
  run(params: TextToVideoParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToVideoResponse>;
230
+ /**
231
+ * Create a text-to-video task; returns immediately with a task id.
232
+ * @param params Text-to-video parameters.
233
+ * @param options Per-request overrides.
234
+ * @returns The task creation result with id.
235
+ */
139
236
  create(params: TextToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse>;
237
+ /**
238
+ * Fetch the current status of a text-to-video task.
239
+ * @param id The task id.
240
+ * @param options Per-request overrides.
241
+ * @returns The current text-to-video task status.
242
+ */
140
243
  get(id: string, options?: RequestOptions): Promise<TextToVideoResponse>;
141
244
  }
142
245
 
246
+ /** Animate a still image into video, guided by a text prompt and first-frame image. */
143
247
  declare class ImageToVideo {
144
248
  private readonly http;
145
249
  constructor(http: HttpClient);
250
+ /**
251
+ * Generate a video from an input image and wait until complete.
252
+ * @param params Image-to-video parameters.
253
+ * @param options Per-request and polling overrides.
254
+ * @returns The completed task with videos.
255
+ */
146
256
  run(params: ImageToVideoParams, options?: RequestOptions & PollingOptions): Promise<CompletedImageToVideoResponse>;
257
+ /**
258
+ * Create an image-to-video task; returns immediately with a task id.
259
+ * @param params Image-to-video parameters.
260
+ * @param options Per-request overrides.
261
+ * @returns The task creation result with id.
262
+ */
147
263
  create(params: ImageToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse>;
264
+ /**
265
+ * Fetch the current status of an image-to-video task.
266
+ * @param id The task id.
267
+ * @param options Per-request overrides.
268
+ * @returns The current image-to-video task status.
269
+ */
148
270
  get(id: string, options?: RequestOptions): Promise<ImageToVideoResponse>;
149
271
  }
150
272
 
273
+ /** Lip-sync a face image to an audio track, producing a talking-head video. */
151
274
  declare class AiAvatar {
152
275
  private readonly http;
153
276
  constructor(http: HttpClient);
277
+ /**
278
+ * Generate an AI avatar video and wait until complete.
279
+ * @param params AI avatar parameters.
280
+ * @param options Per-request and polling overrides.
281
+ * @returns The completed task with videos.
282
+ */
154
283
  run(params: AiAvatarParams, options?: RequestOptions & PollingOptions): Promise<CompletedAiAvatarResponse>;
284
+ /**
285
+ * Create an AI avatar generation task; returns immediately with a task id.
286
+ * @param params AI avatar parameters.
287
+ * @param options Per-request overrides.
288
+ * @returns The task creation result with id.
289
+ */
155
290
  create(params: AiAvatarParams, options?: RequestOptions): Promise<TaskCreateResponse>;
291
+ /**
292
+ * Fetch the current status of an AI avatar task.
293
+ * @param id The task id.
294
+ * @param options Per-request overrides.
295
+ * @returns The current AI avatar task status.
296
+ */
156
297
  get(id: string, options?: RequestOptions): Promise<AiAvatarResponse>;
157
298
  }
158
299
 
300
+ /** Transfer motion from a reference video onto a subject image, preserving the subject's appearance. */
159
301
  declare class MotionControl {
160
302
  private readonly http;
161
303
  constructor(http: HttpClient);
304
+ /**
305
+ * Generate a video with motion transfer from a reference video and wait until complete.
306
+ * @param params Motion control parameters.
307
+ * @param options Per-request and polling overrides.
308
+ * @returns The completed task with videos.
309
+ */
162
310
  run(params: MotionControlParams, options?: RequestOptions & PollingOptions): Promise<CompletedMotionControlResponse>;
311
+ /**
312
+ * Create a motion control generation task; returns immediately with a task id.
313
+ * @param params Motion control parameters.
314
+ * @param options Per-request overrides.
315
+ * @returns The task creation result with id.
316
+ */
163
317
  create(params: MotionControlParams, options?: RequestOptions): Promise<TaskCreateResponse>;
318
+ /**
319
+ * Fetch the current status of a motion control task.
320
+ * @param id The task id.
321
+ * @param options Per-request overrides.
322
+ * @returns The current motion control task status.
323
+ */
164
324
  get(id: string, options?: RequestOptions): Promise<MotionControlResponse>;
165
325
  }
166
326
 
167
- /** Kling video API client. */
168
- declare class KlingClient {
169
- /** Text-to-video operations. */
327
+ /**
328
+ * Kling video generation, AI avatar lip-sync, and motion control API client.
329
+ *
330
+ * @example
331
+ * ```typescript
332
+ * const client = new KlingClient({ apiKey: 'your-api-key' });
333
+ *
334
+ * const result = await client.textToVideo.run({
335
+ * model: 'kling-3.0',
336
+ * prompt: 'A cat walking through a garden',
337
+ * });
338
+ * ```
339
+ */
340
+ declare class KlingClient extends BaseClient {
341
+ /** Text-to-video generation with multi-shot, sound, and Kling elements support on kling-3.0. */
170
342
  readonly textToVideo: TextToVideo;
171
- /** Image-to-video operations. */
343
+ /** Image-to-video animation from a first-frame image guided by a text prompt. */
172
344
  readonly imageToVideo: ImageToVideo;
173
- /** AI avatar operations. */
345
+ /** AI avatar lip-sync: animate a face image to match an audio track. */
174
346
  readonly aiAvatar: AiAvatar;
175
- /** Motion control operations. */
347
+ /** Transfer motion from a reference video onto a subject image. */
176
348
  readonly motionControl: MotionControl;
177
349
  constructor(options?: ClientOptions);
178
350
  }
179
351
 
180
- 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 };
352
+ 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 KlingV2ImageToVideoModel, type KlingV3TurboOutputResolution, type MotionControlParams, type MotionControlResponse, type MultiPromptItem, type TaskCreateResponse, type TextToVideoParams, type TextToVideoResponse, type V21MasterTextToVideoParams, type V25TurboTextToVideoParams, type V2ImageToVideoParams, type V3TurboImageToVideoParams, type V3TurboTextToVideoParams, type VideoMetadata };