@runapi.ai/kling 0.2.12 → 0.2.13

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 CHANGED
@@ -22,6 +22,23 @@ const task = await client.textToVideo.create({
22
22
  const status = await client.textToVideo.get(task.id);
23
23
  ```
24
24
 
25
+ ## Kling O1 reference media
26
+
27
+ ```typescript
28
+ const result = await client.textToVideo.run({
29
+ model: 'kling-o1',
30
+ prompt: 'Keep <<<image_1>>> beside the performer from <<<video_1>>>',
31
+ reference_image_urls: ['https://cdn.runapi.ai/public/samples/portrait.jpg'],
32
+ reference_video_url: 'https://cdn.runapi.ai/public/samples/video.mp4',
33
+ reference_video_type: 'feature',
34
+ preserve_reference_video_audio: true,
35
+ mode: 'pro',
36
+ duration_seconds: 5,
37
+ });
38
+ ```
39
+
40
+ Number reference images in prompt order as `<<<image_1>>>`, `<<<image_2>>>`, and so on; the optional video is `<<<video_1>>>`. With a video, send at most four images. Do not combine `last_frame_image_url` with reference images or a reference video. A `feature` reference video may be used with the required first frame; `base` cannot be combined with frame inputs. O1 requests are five seconds and keep sound disabled. Pricing and limits: https://runapi.ai/models/kling/o1.
41
+
25
42
  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
43
 
27
44
  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.
package/dist/index.d.mts CHANGED
@@ -1,9 +1,10 @@
1
- import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, BaseClient, ClientOptions } from '@runapi.ai/core';
1
+ import { TaskResponse, AsyncTaskStatus, TaskBillingResponse, 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
4
  declare const modelValues: {
5
5
  readonly textToVideo: {
6
6
  readonly KLING_3_0: "kling-3.0";
7
+ readonly KLING_O1: "kling-o1";
7
8
  readonly KLING_V2_1_MASTER_TEXT_TO_VIDEO: "kling-v2.1-master-text-to-video";
8
9
  readonly KLING_V2_5_TURBO_TEXT_TO_VIDEO_PRO: "kling-v2.5-turbo-text-to-video-pro";
9
10
  readonly KLING_V2_6: "kling-v2.6";
@@ -11,6 +12,7 @@ declare const modelValues: {
11
12
  readonly KLING_V3_TURBO_TEXT_TO_VIDEO: "kling-v3-turbo-text-to-video";
12
13
  };
13
14
  readonly imageToVideo: {
15
+ readonly KLING_O1: "kling-o1";
14
16
  readonly KLING_V2_1_MASTER_IMAGE_TO_VIDEO: "kling-v2.1-master-image-to-video";
15
17
  readonly KLING_V2_1_PRO: "kling-v2.1-pro";
16
18
  readonly KLING_V2_1_STANDARD: "kling-v2.1-standard";
@@ -46,6 +48,7 @@ type KlingAspectRatio = '16:9' | '9:16' | '1:1';
46
48
  /** Duration in seconds. Range varies by model: 3-15 for kling-3.0, 5 or 10 for V2.x. */
47
49
  type KlingDuration = number;
48
50
  type KlingV26Mode = 'std' | 'pro';
51
+ type KlingO1ReferenceVideoType = 'base' | 'feature';
49
52
  /** A single shot in a multi-shot text-to-video sequence. */
50
53
  interface MultiPromptItem {
51
54
  prompt: string;
@@ -145,6 +148,26 @@ interface KlingV26TextToVideoParams {
145
148
  aspect_ratio?: KlingAspectRatio;
146
149
  callback_url?: string;
147
150
  }
151
+ interface KlingO1ReferenceParams {
152
+ /** Ordered public HTTP(S) image references; use matching `<<<image_N>>>` markers in prompt. */
153
+ reference_image_urls?: string[];
154
+ /** Public HTTP(S) MP4 or MOV reference video; use `<<<video_1>>>` in prompt. */
155
+ reference_video_url?: string;
156
+ /** Base edit or feature reference; defaults to base. */
157
+ reference_video_type?: KlingO1ReferenceVideoType;
158
+ /** Preserve audio from the reference video. */
159
+ preserve_reference_video_audio?: boolean;
160
+ }
161
+ /** Kling O1 text-to-video with image and video references. */
162
+ interface KlingO1TextToVideoParams extends KlingO1ReferenceParams {
163
+ model: (typeof modelValues.textToVideo.KLING_O1);
164
+ prompt: string;
165
+ mode?: KlingV26Mode;
166
+ duration_seconds?: 5;
167
+ enable_sound?: false;
168
+ aspect_ratio?: KlingAspectRatio;
169
+ callback_url?: string;
170
+ }
148
171
  /** Kling v3 Omni text-to-video with native 4K, synchronized sound, and flexible duration. */
149
172
  interface V3OmniTextToVideoParams {
150
173
  model: (typeof modelValues.textToVideo.KLING_V3_OMNI);
@@ -196,6 +219,19 @@ interface KlingV26ImageToVideoParams {
196
219
  aspect_ratio?: KlingAspectRatio;
197
220
  callback_url?: string;
198
221
  }
222
+ /** Kling O1 image-to-video with a first frame plus either a final frame or reference media. */
223
+ interface KlingO1ImageToVideoParams extends KlingO1ReferenceParams {
224
+ model: (typeof modelValues.imageToVideo.KLING_O1);
225
+ prompt: string;
226
+ first_frame_image_url: string;
227
+ /** Final frame URL; cannot be combined with reference_image_urls or reference_video_url. */
228
+ last_frame_image_url?: string;
229
+ mode?: KlingV26Mode;
230
+ duration_seconds?: 5;
231
+ enable_sound?: false;
232
+ aspect_ratio?: KlingAspectRatio;
233
+ callback_url?: string;
234
+ }
199
235
  /** Kling v3 Omni image-to-video from caller-owned first and optional final frames. */
200
236
  interface V3OmniImageToVideoParams {
201
237
  model: (typeof modelValues.imageToVideo.KLING_V3_OMNI);
@@ -209,8 +245,8 @@ interface V3OmniImageToVideoParams {
209
245
  aspect_ratio?: KlingAspectRatio;
210
246
  callback_url?: string;
211
247
  }
212
- type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | KlingV26TextToVideoParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams | V3TurboTextToVideoParams | V3OmniTextToVideoParams;
213
- type ImageToVideoParams = V2ImageToVideoParams | KlingV26ImageToVideoParams | V3TurboImageToVideoParams | V3OmniImageToVideoParams;
248
+ type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | KlingV26TextToVideoParams | KlingO1TextToVideoParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams | V3TurboTextToVideoParams | V3OmniTextToVideoParams;
249
+ type ImageToVideoParams = V2ImageToVideoParams | KlingV26ImageToVideoParams | KlingO1ImageToVideoParams | V3TurboImageToVideoParams | V3OmniImageToVideoParams;
214
250
  /** Continue a completed Kling V2.5 Turbo video task. */
215
251
  interface KlingExtendVideoParams {
216
252
  source_task_id: string;
@@ -218,11 +254,11 @@ interface KlingExtendVideoParams {
218
254
  prompt?: string;
219
255
  callback_url?: string;
220
256
  }
221
- interface AsyncTaskResponse {
257
+ interface AsyncTaskResponse extends TaskResponse {
222
258
  id: string;
223
259
  status: AsyncTaskStatus;
224
260
  }
225
- interface TaskCreateResponse {
261
+ interface TaskCreateResponse extends TaskBillingResponse {
226
262
  id: string;
227
263
  }
228
264
  interface VideoMetadata {
@@ -450,4 +486,4 @@ declare class KlingClient extends BaseClient {
450
486
  constructor(options?: ClientOptions);
451
487
  }
452
488
 
453
- export { type AiAvatarModel, type AiAvatarParams, type AiAvatarResponse, type AsyncTaskResponse, type CompletedAiAvatarResponse, type CompletedImageToVideoResponse, type CompletedMotionControlResponse, type CompletedTextToVideoResponse, type ImageToVideoParams, type ImageToVideoResponse, type Kling3MotionControlParams, type Kling3TextToVideoMultiShotParams, type Kling3TextToVideoSingleShotParams, type KlingAspectRatio, KlingClient, type KlingDuration, type KlingElement, type KlingExtendVideoParams, type KlingImageToVideoModel, type KlingTextToVideoModel, type KlingTextToVideoOutputResolution, type KlingV26ImageToVideoParams, type KlingV26Mode, type KlingV26MotionControlParams, type KlingV26TextToVideoParams, type KlingV2ImageToVideoModel, type KlingV3TurboOutputResolution, type MotionControlModel, type MotionControlParams, type MotionControlResponse, type MultiPromptItem, type TaskCreateResponse, type TextToVideoParams, type TextToVideoResponse, type V21MasterTextToVideoParams, type V25TurboTextToVideoParams, type V2ImageToVideoParams, type V3OmniImageToVideoParams, type V3OmniTextToVideoParams, type V3TurboImageToVideoParams, type V3TurboTextToVideoParams, type VideoMetadata };
489
+ export { type AiAvatarModel, type AiAvatarParams, type AiAvatarResponse, type AsyncTaskResponse, type CompletedAiAvatarResponse, type CompletedImageToVideoResponse, type CompletedMotionControlResponse, type CompletedTextToVideoResponse, type ImageToVideoParams, type ImageToVideoResponse, type Kling3MotionControlParams, type Kling3TextToVideoMultiShotParams, type Kling3TextToVideoSingleShotParams, type KlingAspectRatio, KlingClient, type KlingDuration, type KlingElement, type KlingExtendVideoParams, type KlingImageToVideoModel, type KlingO1ImageToVideoParams, type KlingO1ReferenceVideoType, type KlingO1TextToVideoParams, type KlingTextToVideoModel, type KlingTextToVideoOutputResolution, type KlingV26ImageToVideoParams, type KlingV26Mode, type KlingV26MotionControlParams, type KlingV26TextToVideoParams, type KlingV2ImageToVideoModel, type KlingV3TurboOutputResolution, type MotionControlModel, type MotionControlParams, type MotionControlResponse, type MultiPromptItem, type TaskCreateResponse, type TextToVideoParams, type TextToVideoResponse, type V21MasterTextToVideoParams, type V25TurboTextToVideoParams, type V2ImageToVideoParams, type V3OmniImageToVideoParams, type V3OmniTextToVideoParams, type V3TurboImageToVideoParams, type V3TurboTextToVideoParams, type VideoMetadata };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, BaseClient, ClientOptions } from '@runapi.ai/core';
1
+ import { TaskResponse, AsyncTaskStatus, TaskBillingResponse, 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
4
  declare const modelValues: {
5
5
  readonly textToVideo: {
6
6
  readonly KLING_3_0: "kling-3.0";
7
+ readonly KLING_O1: "kling-o1";
7
8
  readonly KLING_V2_1_MASTER_TEXT_TO_VIDEO: "kling-v2.1-master-text-to-video";
8
9
  readonly KLING_V2_5_TURBO_TEXT_TO_VIDEO_PRO: "kling-v2.5-turbo-text-to-video-pro";
9
10
  readonly KLING_V2_6: "kling-v2.6";
@@ -11,6 +12,7 @@ declare const modelValues: {
11
12
  readonly KLING_V3_TURBO_TEXT_TO_VIDEO: "kling-v3-turbo-text-to-video";
12
13
  };
13
14
  readonly imageToVideo: {
15
+ readonly KLING_O1: "kling-o1";
14
16
  readonly KLING_V2_1_MASTER_IMAGE_TO_VIDEO: "kling-v2.1-master-image-to-video";
15
17
  readonly KLING_V2_1_PRO: "kling-v2.1-pro";
16
18
  readonly KLING_V2_1_STANDARD: "kling-v2.1-standard";
@@ -46,6 +48,7 @@ type KlingAspectRatio = '16:9' | '9:16' | '1:1';
46
48
  /** Duration in seconds. Range varies by model: 3-15 for kling-3.0, 5 or 10 for V2.x. */
47
49
  type KlingDuration = number;
48
50
  type KlingV26Mode = 'std' | 'pro';
51
+ type KlingO1ReferenceVideoType = 'base' | 'feature';
49
52
  /** A single shot in a multi-shot text-to-video sequence. */
50
53
  interface MultiPromptItem {
51
54
  prompt: string;
@@ -145,6 +148,26 @@ interface KlingV26TextToVideoParams {
145
148
  aspect_ratio?: KlingAspectRatio;
146
149
  callback_url?: string;
147
150
  }
151
+ interface KlingO1ReferenceParams {
152
+ /** Ordered public HTTP(S) image references; use matching `<<<image_N>>>` markers in prompt. */
153
+ reference_image_urls?: string[];
154
+ /** Public HTTP(S) MP4 or MOV reference video; use `<<<video_1>>>` in prompt. */
155
+ reference_video_url?: string;
156
+ /** Base edit or feature reference; defaults to base. */
157
+ reference_video_type?: KlingO1ReferenceVideoType;
158
+ /** Preserve audio from the reference video. */
159
+ preserve_reference_video_audio?: boolean;
160
+ }
161
+ /** Kling O1 text-to-video with image and video references. */
162
+ interface KlingO1TextToVideoParams extends KlingO1ReferenceParams {
163
+ model: (typeof modelValues.textToVideo.KLING_O1);
164
+ prompt: string;
165
+ mode?: KlingV26Mode;
166
+ duration_seconds?: 5;
167
+ enable_sound?: false;
168
+ aspect_ratio?: KlingAspectRatio;
169
+ callback_url?: string;
170
+ }
148
171
  /** Kling v3 Omni text-to-video with native 4K, synchronized sound, and flexible duration. */
149
172
  interface V3OmniTextToVideoParams {
150
173
  model: (typeof modelValues.textToVideo.KLING_V3_OMNI);
@@ -196,6 +219,19 @@ interface KlingV26ImageToVideoParams {
196
219
  aspect_ratio?: KlingAspectRatio;
197
220
  callback_url?: string;
198
221
  }
222
+ /** Kling O1 image-to-video with a first frame plus either a final frame or reference media. */
223
+ interface KlingO1ImageToVideoParams extends KlingO1ReferenceParams {
224
+ model: (typeof modelValues.imageToVideo.KLING_O1);
225
+ prompt: string;
226
+ first_frame_image_url: string;
227
+ /** Final frame URL; cannot be combined with reference_image_urls or reference_video_url. */
228
+ last_frame_image_url?: string;
229
+ mode?: KlingV26Mode;
230
+ duration_seconds?: 5;
231
+ enable_sound?: false;
232
+ aspect_ratio?: KlingAspectRatio;
233
+ callback_url?: string;
234
+ }
199
235
  /** Kling v3 Omni image-to-video from caller-owned first and optional final frames. */
200
236
  interface V3OmniImageToVideoParams {
201
237
  model: (typeof modelValues.imageToVideo.KLING_V3_OMNI);
@@ -209,8 +245,8 @@ interface V3OmniImageToVideoParams {
209
245
  aspect_ratio?: KlingAspectRatio;
210
246
  callback_url?: string;
211
247
  }
212
- type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | KlingV26TextToVideoParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams | V3TurboTextToVideoParams | V3OmniTextToVideoParams;
213
- type ImageToVideoParams = V2ImageToVideoParams | KlingV26ImageToVideoParams | V3TurboImageToVideoParams | V3OmniImageToVideoParams;
248
+ type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | KlingV26TextToVideoParams | KlingO1TextToVideoParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams | V3TurboTextToVideoParams | V3OmniTextToVideoParams;
249
+ type ImageToVideoParams = V2ImageToVideoParams | KlingV26ImageToVideoParams | KlingO1ImageToVideoParams | V3TurboImageToVideoParams | V3OmniImageToVideoParams;
214
250
  /** Continue a completed Kling V2.5 Turbo video task. */
215
251
  interface KlingExtendVideoParams {
216
252
  source_task_id: string;
@@ -218,11 +254,11 @@ interface KlingExtendVideoParams {
218
254
  prompt?: string;
219
255
  callback_url?: string;
220
256
  }
221
- interface AsyncTaskResponse {
257
+ interface AsyncTaskResponse extends TaskResponse {
222
258
  id: string;
223
259
  status: AsyncTaskStatus;
224
260
  }
225
- interface TaskCreateResponse {
261
+ interface TaskCreateResponse extends TaskBillingResponse {
226
262
  id: string;
227
263
  }
228
264
  interface VideoMetadata {
@@ -450,4 +486,4 @@ declare class KlingClient extends BaseClient {
450
486
  constructor(options?: ClientOptions);
451
487
  }
452
488
 
453
- export { type AiAvatarModel, type AiAvatarParams, type AiAvatarResponse, type AsyncTaskResponse, type CompletedAiAvatarResponse, type CompletedImageToVideoResponse, type CompletedMotionControlResponse, type CompletedTextToVideoResponse, type ImageToVideoParams, type ImageToVideoResponse, type Kling3MotionControlParams, type Kling3TextToVideoMultiShotParams, type Kling3TextToVideoSingleShotParams, type KlingAspectRatio, KlingClient, type KlingDuration, type KlingElement, type KlingExtendVideoParams, type KlingImageToVideoModel, type KlingTextToVideoModel, type KlingTextToVideoOutputResolution, type KlingV26ImageToVideoParams, type KlingV26Mode, type KlingV26MotionControlParams, type KlingV26TextToVideoParams, type KlingV2ImageToVideoModel, type KlingV3TurboOutputResolution, type MotionControlModel, type MotionControlParams, type MotionControlResponse, type MultiPromptItem, type TaskCreateResponse, type TextToVideoParams, type TextToVideoResponse, type V21MasterTextToVideoParams, type V25TurboTextToVideoParams, type V2ImageToVideoParams, type V3OmniImageToVideoParams, type V3OmniTextToVideoParams, type V3TurboImageToVideoParams, type V3TurboTextToVideoParams, type VideoMetadata };
489
+ export { type AiAvatarModel, type AiAvatarParams, type AiAvatarResponse, type AsyncTaskResponse, type CompletedAiAvatarResponse, type CompletedImageToVideoResponse, type CompletedMotionControlResponse, type CompletedTextToVideoResponse, type ImageToVideoParams, type ImageToVideoResponse, type Kling3MotionControlParams, type Kling3TextToVideoMultiShotParams, type Kling3TextToVideoSingleShotParams, type KlingAspectRatio, KlingClient, type KlingDuration, type KlingElement, type KlingExtendVideoParams, type KlingImageToVideoModel, type KlingO1ImageToVideoParams, type KlingO1ReferenceVideoType, type KlingO1TextToVideoParams, type KlingTextToVideoModel, type KlingTextToVideoOutputResolution, type KlingV26ImageToVideoParams, type KlingV26Mode, type KlingV26MotionControlParams, type KlingV26TextToVideoParams, type KlingV2ImageToVideoModel, type KlingV3TurboOutputResolution, type MotionControlModel, type MotionControlParams, type MotionControlResponse, type MultiPromptItem, type TaskCreateResponse, type TextToVideoParams, type TextToVideoResponse, type V21MasterTextToVideoParams, type V25TurboTextToVideoParams, type V2ImageToVideoParams, type V3OmniImageToVideoParams, type V3OmniTextToVideoParams, type V3TurboImageToVideoParams, type V3TurboTextToVideoParams, type VideoMetadata };