@runapi.ai/kling 0.2.4 → 0.2.7

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
@@ -1,6 +1,6 @@
1
1
  # Kling AI API JavaScript SDK for RunAPI
2
2
 
3
- The kling ai api JavaScript SDK is the language-specific package for Kling on RunAPI. Use this kling ai api package for text-to-video, image-to-video, video-to-video, animation, and edit flows when your application needs JSON request bodies, task status lookup, and consistent RunAPI errors in JavaScript.
3
+ The kling ai api JavaScript SDK is the language-specific package for Kling on RunAPI. Use this kling ai api package for text-to-video, image-to-video, video editing, and animation flows when your application needs JSON request bodies, task status lookup, and consistent RunAPI errors in JavaScript.
4
4
 
5
5
  This kling ai api README is the JavaScript package guide inside the public `kling-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/kling; for API reference, use https://runapi.ai/docs#kling; for SDK docs, use https://runapi.ai/docs#sdk-kling.
6
6
 
@@ -26,7 +26,7 @@ Use `create` when you want to submit a task and return quickly, `get` when you n
26
26
 
27
27
  ## Language notes
28
28
 
29
- Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building video applications. The available resources include generations, ai avatars, v25 turbo generations, and motion controls. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
29
+ Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building video applications. The available resources include text-to-video, image-to-video, AI avatars, V2.1/V2.5 video variants, and motion controls. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
30
30
 
31
31
  ## Links
32
32
 
package/dist/index.d.mts CHANGED
@@ -1,15 +1,15 @@
1
1
  import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, 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';
5
- type KlingImageToVideoModel = 'kling-v2.5-turbo-image-to-video-pro';
6
- type KlingMode = 'std' | 'pro';
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';
6
+ type KlingTextToVideoOutputResolution = '720p' | '1080p' | '4k';
7
7
  type KlingAspectRatio = '16:9' | '9:16' | '1:1';
8
- type KlingDuration = string;
8
+ type KlingDuration = number;
9
9
  /** A single shot in a multi-shot text-to-video sequence. */
10
10
  interface MultiPromptItem {
11
11
  prompt: string;
12
- duration: number;
12
+ duration_seconds: number;
13
13
  }
14
14
  /** Element reference for subject/style guidance. */
15
15
  interface KlingElement {
@@ -20,42 +20,53 @@ interface KlingElement {
20
20
  }
21
21
  interface Kling3TextToVideoCommonParams {
22
22
  model: 'kling-3.0';
23
- duration?: KlingDuration;
23
+ duration_seconds?: KlingDuration;
24
24
  aspect_ratio?: KlingAspectRatio;
25
- mode?: KlingMode;
25
+ output_resolution?: KlingTextToVideoOutputResolution;
26
26
  kling_elements?: KlingElement[];
27
27
  callback_url?: string;
28
28
  }
29
29
  interface Kling3TextToVideoSingleShotParams extends Kling3TextToVideoCommonParams {
30
30
  prompt: string;
31
- sound?: boolean;
32
- image_urls?: string[];
31
+ enable_sound?: boolean;
32
+ first_frame_image_url?: string;
33
+ last_frame_image_url?: string;
33
34
  }
34
35
  interface Kling3TextToVideoMultiShotParams extends Kling3TextToVideoCommonParams {
35
36
  multi_shots: true;
36
- sound: true;
37
+ enable_sound: true;
37
38
  multi_prompt: MultiPromptItem[];
38
- image_urls?: string[];
39
+ first_frame_image_url?: string;
39
40
  }
40
41
  interface V25TurboTextToVideoParams {
41
42
  model: 'kling-v2.5-turbo-text-to-video-pro';
42
43
  prompt: string;
43
- duration?: '5' | '10';
44
+ duration_seconds?: 5 | 10;
45
+ aspect_ratio?: KlingAspectRatio;
46
+ negative_prompt?: string;
47
+ cfg_scale?: number;
48
+ callback_url?: string;
49
+ }
50
+ interface V21MasterTextToVideoParams {
51
+ model: 'kling-v2.1-master-text-to-video';
52
+ prompt: string;
53
+ duration_seconds?: 5 | 10;
44
54
  aspect_ratio?: KlingAspectRatio;
45
55
  negative_prompt?: string;
46
56
  cfg_scale?: number;
47
57
  callback_url?: string;
48
58
  }
49
59
  interface ImageToVideoParams {
50
- model: 'kling-v2.5-turbo-image-to-video-pro';
60
+ model: KlingImageToVideoModel;
51
61
  prompt: string;
52
- image_url: string;
53
- duration?: '5' | '10';
62
+ first_frame_image_url: string;
63
+ duration_seconds?: 5 | 10;
54
64
  negative_prompt?: string;
55
65
  cfg_scale?: number;
66
+ last_frame_image_url?: string;
56
67
  callback_url?: string;
57
68
  }
58
- type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | V25TurboTextToVideoParams;
69
+ type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams;
59
70
  interface AsyncTaskResponse {
60
71
  id: string;
61
72
  status: AsyncTaskStatus;
@@ -76,11 +87,11 @@ interface ImageToVideoResponse extends AsyncTaskResponse {
76
87
  error?: string;
77
88
  [key: string]: unknown;
78
89
  }
79
- type AiAvatarModel = 'kling-ai-avatar-pro' | 'kling-ai-avatar-standard';
90
+ type AiAvatarModel = 'kling-ai-avatar-pro' | 'kling-ai-avatar-standard' | 'kling-ai-avatar-v1-pro' | 'kling-v1-avatar-standard';
80
91
  interface AiAvatarParams {
81
92
  model: AiAvatarModel;
82
- image_url: string;
83
- audio_url: string;
93
+ source_image_url: string;
94
+ source_audio_url: string;
84
95
  prompt: string;
85
96
  callback_url?: string;
86
97
  }
@@ -91,12 +102,12 @@ interface AiAvatarResponse extends AsyncTaskResponse {
91
102
  }
92
103
  interface MotionControlParams {
93
104
  model: 'kling-3.0';
94
- input_urls: string[];
95
- video_urls: string[];
105
+ source_image_url: string;
106
+ reference_video_url: string;
96
107
  prompt?: string;
97
- mode?: '720p' | '1080p';
108
+ output_resolution?: '720p' | '1080p';
98
109
  character_orientation?: 'video' | 'image';
99
- background_source?: 'input_video' | 'input_image';
110
+ background_source?: 'video' | 'image';
100
111
  callback_url?: string;
101
112
  }
102
113
  interface MotionControlResponse extends AsyncTaskResponse {
@@ -166,4 +177,4 @@ declare class KlingClient {
166
177
  constructor(options?: ClientOptions);
167
178
  }
168
179
 
169
- export { type AiAvatarModel, type AiAvatarParams, type AiAvatarResponse, type AsyncTaskResponse, type CompletedAiAvatarResponse, type CompletedImageToVideoResponse, type CompletedMotionControlResponse, type CompletedTextToVideoResponse, type ImageToVideoParams, type ImageToVideoResponse, type Kling3TextToVideoMultiShotParams, type Kling3TextToVideoSingleShotParams, type KlingAspectRatio, KlingClient, type KlingDuration, type KlingElement, type KlingImageToVideoModel, type KlingMode, type KlingTextToVideoModel, type MotionControlParams, type MotionControlResponse, type MultiPromptItem, type TaskCreateResponse, type TextToVideoParams, type TextToVideoResponse, type V25TurboTextToVideoParams, type VideoMetadata };
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 };
package/dist/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, 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';
5
- type KlingImageToVideoModel = 'kling-v2.5-turbo-image-to-video-pro';
6
- type KlingMode = 'std' | 'pro';
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';
6
+ type KlingTextToVideoOutputResolution = '720p' | '1080p' | '4k';
7
7
  type KlingAspectRatio = '16:9' | '9:16' | '1:1';
8
- type KlingDuration = string;
8
+ type KlingDuration = number;
9
9
  /** A single shot in a multi-shot text-to-video sequence. */
10
10
  interface MultiPromptItem {
11
11
  prompt: string;
12
- duration: number;
12
+ duration_seconds: number;
13
13
  }
14
14
  /** Element reference for subject/style guidance. */
15
15
  interface KlingElement {
@@ -20,42 +20,53 @@ interface KlingElement {
20
20
  }
21
21
  interface Kling3TextToVideoCommonParams {
22
22
  model: 'kling-3.0';
23
- duration?: KlingDuration;
23
+ duration_seconds?: KlingDuration;
24
24
  aspect_ratio?: KlingAspectRatio;
25
- mode?: KlingMode;
25
+ output_resolution?: KlingTextToVideoOutputResolution;
26
26
  kling_elements?: KlingElement[];
27
27
  callback_url?: string;
28
28
  }
29
29
  interface Kling3TextToVideoSingleShotParams extends Kling3TextToVideoCommonParams {
30
30
  prompt: string;
31
- sound?: boolean;
32
- image_urls?: string[];
31
+ enable_sound?: boolean;
32
+ first_frame_image_url?: string;
33
+ last_frame_image_url?: string;
33
34
  }
34
35
  interface Kling3TextToVideoMultiShotParams extends Kling3TextToVideoCommonParams {
35
36
  multi_shots: true;
36
- sound: true;
37
+ enable_sound: true;
37
38
  multi_prompt: MultiPromptItem[];
38
- image_urls?: string[];
39
+ first_frame_image_url?: string;
39
40
  }
40
41
  interface V25TurboTextToVideoParams {
41
42
  model: 'kling-v2.5-turbo-text-to-video-pro';
42
43
  prompt: string;
43
- duration?: '5' | '10';
44
+ duration_seconds?: 5 | 10;
45
+ aspect_ratio?: KlingAspectRatio;
46
+ negative_prompt?: string;
47
+ cfg_scale?: number;
48
+ callback_url?: string;
49
+ }
50
+ interface V21MasterTextToVideoParams {
51
+ model: 'kling-v2.1-master-text-to-video';
52
+ prompt: string;
53
+ duration_seconds?: 5 | 10;
44
54
  aspect_ratio?: KlingAspectRatio;
45
55
  negative_prompt?: string;
46
56
  cfg_scale?: number;
47
57
  callback_url?: string;
48
58
  }
49
59
  interface ImageToVideoParams {
50
- model: 'kling-v2.5-turbo-image-to-video-pro';
60
+ model: KlingImageToVideoModel;
51
61
  prompt: string;
52
- image_url: string;
53
- duration?: '5' | '10';
62
+ first_frame_image_url: string;
63
+ duration_seconds?: 5 | 10;
54
64
  negative_prompt?: string;
55
65
  cfg_scale?: number;
66
+ last_frame_image_url?: string;
56
67
  callback_url?: string;
57
68
  }
58
- type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | V25TurboTextToVideoParams;
69
+ type TextToVideoParams = Kling3TextToVideoSingleShotParams | Kling3TextToVideoMultiShotParams | V25TurboTextToVideoParams | V21MasterTextToVideoParams;
59
70
  interface AsyncTaskResponse {
60
71
  id: string;
61
72
  status: AsyncTaskStatus;
@@ -76,11 +87,11 @@ interface ImageToVideoResponse extends AsyncTaskResponse {
76
87
  error?: string;
77
88
  [key: string]: unknown;
78
89
  }
79
- type AiAvatarModel = 'kling-ai-avatar-pro' | 'kling-ai-avatar-standard';
90
+ type AiAvatarModel = 'kling-ai-avatar-pro' | 'kling-ai-avatar-standard' | 'kling-ai-avatar-v1-pro' | 'kling-v1-avatar-standard';
80
91
  interface AiAvatarParams {
81
92
  model: AiAvatarModel;
82
- image_url: string;
83
- audio_url: string;
93
+ source_image_url: string;
94
+ source_audio_url: string;
84
95
  prompt: string;
85
96
  callback_url?: string;
86
97
  }
@@ -91,12 +102,12 @@ interface AiAvatarResponse extends AsyncTaskResponse {
91
102
  }
92
103
  interface MotionControlParams {
93
104
  model: 'kling-3.0';
94
- input_urls: string[];
95
- video_urls: string[];
105
+ source_image_url: string;
106
+ reference_video_url: string;
96
107
  prompt?: string;
97
- mode?: '720p' | '1080p';
108
+ output_resolution?: '720p' | '1080p';
98
109
  character_orientation?: 'video' | 'image';
99
- background_source?: 'input_video' | 'input_image';
110
+ background_source?: 'video' | 'image';
100
111
  callback_url?: string;
101
112
  }
102
113
  interface MotionControlResponse extends AsyncTaskResponse {
@@ -166,4 +177,4 @@ declare class KlingClient {
166
177
  constructor(options?: ClientOptions);
167
178
  }
168
179
 
169
- export { type AiAvatarModel, type AiAvatarParams, type AiAvatarResponse, type AsyncTaskResponse, type CompletedAiAvatarResponse, type CompletedImageToVideoResponse, type CompletedMotionControlResponse, type CompletedTextToVideoResponse, type ImageToVideoParams, type ImageToVideoResponse, type Kling3TextToVideoMultiShotParams, type Kling3TextToVideoSingleShotParams, type KlingAspectRatio, KlingClient, type KlingDuration, type KlingElement, type KlingImageToVideoModel, type KlingMode, type KlingTextToVideoModel, type MotionControlParams, type MotionControlResponse, type MultiPromptItem, type TaskCreateResponse, type TextToVideoParams, type TextToVideoResponse, type V25TurboTextToVideoParams, type VideoMetadata };
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runapi.ai/kling",
3
- "version": "0.2.4",
3
+ "version": "0.2.7",
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.4"
31
+ "@runapi.ai/core": "^0.2.5"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^20.0.0",
@@ -53,6 +53,7 @@ const client = new KlingClient();
53
53
  const result = await client.textToVideo.run({
54
54
  model: 'kling-3.0',
55
55
  prompt: 'A cat walking through a sunlit garden',
56
+ output_resolution: '4k',
56
57
  });
57
58
  const url = result.videos[0].url;
58
59
  ```
@@ -72,6 +73,12 @@ const url = result.videos[0].url;
72
73
  - [Kling 3.0](https://runapi.ai/models/kling/3.0)
73
74
  - [AI avatar pro](https://runapi.ai/models/kling/ai-avatar-pro)
74
75
  - [AI avatar standard](https://runapi.ai/models/kling/ai-avatar-standard)
76
+ - [AI avatar v1 pro](https://runapi.ai/models/kling/ai-avatar-v1-pro)
77
+ - [V1 avatar standard](https://runapi.ai/models/kling/v1-avatar-standard)
78
+ - [V2.1 pro](https://runapi.ai/models/kling/v2.1-pro)
79
+ - [V2.1 standard](https://runapi.ai/models/kling/v2.1-standard)
80
+ - [V2.1 master text to video](https://runapi.ai/models/kling/v2.1-master-text-to-video)
81
+ - [V2.1 master image to video](https://runapi.ai/models/kling/v2.1-master-image-to-video)
75
82
  - [V2.5 turbo text to video pro](https://runapi.ai/models/kling/v2.5-turbo-text-to-video-pro)
76
83
  - [V2.5 turbo image to video pro](https://runapi.ai/models/kling/v2.5-turbo-image-to-video-pro)
77
84
 
@@ -34,7 +34,7 @@ Generate and edit video with Kling through RunAPI. The default path for one-off
34
34
 
35
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.
36
36
 
37
- Inspect the available actions and request fields with CLI help:
37
+ Inspect the available commands and request fields with CLI help:
38
38
 
39
39
  ```shell
40
40
  runapi kling --help
@@ -54,7 +54,9 @@ runapi kling text-to-video --async --input-file request.json
54
54
  runapi wait <task-id> --service kling --action text-to-video
55
55
  ```
56
56
 
57
- Available actions: `text-to-video`, `avatar`, `image-to-video`, `motion-control`.
57
+ Available commands: `text-to-video`, `avatar`, `image-to-video`, `motion-control`.
58
+
59
+ For Kling 3.0 text-to-video requests, keep `model: "kling-3.0"` and choose `output_resolution: "720p"`, `"1080p"`, or `"4k"` as needed.
58
60
 
59
61
  ## SDK integration path
60
62
 
@@ -75,6 +77,11 @@ When integrating Kling into an app, backend, worker, or library — not for one-
75
77
  - [Kling 3.0](https://runapi.ai/models/kling/3.0.md)
76
78
  - [AI avatar pro](https://runapi.ai/models/kling/ai-avatar-pro.md)
77
79
  - [AI avatar standard](https://runapi.ai/models/kling/ai-avatar-standard.md)
80
+ - [AI avatar v1 pro](https://runapi.ai/models/kling/ai-avatar-v1-pro.md)
81
+ - [V1 avatar standard](https://runapi.ai/models/kling/v1-avatar-standard.md)
82
+ - [V2.1 pro](https://runapi.ai/models/kling/v2.1-pro.md)
83
+ - [V2.1 standard](https://runapi.ai/models/kling/v2.1-standard.md)
84
+ - [V2.1 master text to video](https://runapi.ai/models/kling/v2.1-master-text-to-video.md)
85
+ - [V2.1 master image to video](https://runapi.ai/models/kling/v2.1-master-image-to-video.md)
78
86
  - [V2.5 turbo text to video pro](https://runapi.ai/models/kling/v2.5-turbo-text-to-video-pro.md)
79
87
  - [V2.5 turbo image to video pro](https://runapi.ai/models/kling/v2.5-turbo-image-to-video-pro.md)
80
-