@runapi.ai/kling 0.2.0

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.js ADDED
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AuthenticationError: () => import_core6.AuthenticationError,
24
+ InsufficientCreditsError: () => import_core6.InsufficientCreditsError,
25
+ KlingClient: () => KlingClient,
26
+ NetworkError: () => import_core6.NetworkError,
27
+ NotFoundError: () => import_core6.NotFoundError,
28
+ RateLimitError: () => import_core6.RateLimitError,
29
+ RunApiError: () => import_core6.RunApiError,
30
+ ServiceUnavailableError: () => import_core6.ServiceUnavailableError,
31
+ TaskFailedError: () => import_core6.TaskFailedError,
32
+ TaskTimeoutError: () => import_core6.TaskTimeoutError,
33
+ TimeoutError: () => import_core6.TimeoutError,
34
+ ValidationError: () => import_core6.ValidationError
35
+ });
36
+ module.exports = __toCommonJS(index_exports);
37
+
38
+ // src/client.ts
39
+ var import_core5 = require("@runapi.ai/core");
40
+
41
+ // src/resources/text-to-video.ts
42
+ var import_core = require("@runapi.ai/core");
43
+ var import_internal = require("@runapi.ai/core/internal");
44
+ var ENDPOINT = "/api/v1/kling/text_to_video";
45
+ var TextToVideo = class {
46
+ constructor(http) {
47
+ this.http = http;
48
+ }
49
+ http;
50
+ async run(params, options) {
51
+ const { id } = await this.create(params, options);
52
+ const response = await (0, import_internal.pollUntilComplete)(() => this.get(id, options), {
53
+ maxWaitMs: options?.maxWaitMs,
54
+ pollIntervalMs: options?.pollIntervalMs
55
+ });
56
+ return response;
57
+ }
58
+ async create(params, options) {
59
+ return this.http.request("POST", ENDPOINT, {
60
+ body: (0, import_core.compactParams)(params),
61
+ ...options
62
+ });
63
+ }
64
+ async get(id, options) {
65
+ return this.http.request("GET", `${ENDPOINT}/${id}`, {
66
+ ...options
67
+ });
68
+ }
69
+ };
70
+
71
+ // src/resources/image-to-video.ts
72
+ var import_core2 = require("@runapi.ai/core");
73
+ var import_internal2 = require("@runapi.ai/core/internal");
74
+ var ENDPOINT2 = "/api/v1/kling/image_to_video";
75
+ var ImageToVideo = class {
76
+ constructor(http) {
77
+ this.http = http;
78
+ }
79
+ http;
80
+ async run(params, options) {
81
+ const { id } = await this.create(params, options);
82
+ const response = await (0, import_internal2.pollUntilComplete)(() => this.get(id, options), {
83
+ maxWaitMs: options?.maxWaitMs,
84
+ pollIntervalMs: options?.pollIntervalMs
85
+ });
86
+ return response;
87
+ }
88
+ async create(params, options) {
89
+ return this.http.request("POST", ENDPOINT2, {
90
+ body: (0, import_core2.compactParams)(params),
91
+ ...options
92
+ });
93
+ }
94
+ async get(id, options) {
95
+ return this.http.request("GET", `${ENDPOINT2}/${id}`, {
96
+ ...options
97
+ });
98
+ }
99
+ };
100
+
101
+ // src/resources/ai-avatar.ts
102
+ var import_core3 = require("@runapi.ai/core");
103
+ var import_internal3 = require("@runapi.ai/core/internal");
104
+ var ENDPOINT3 = "/api/v1/kling/ai_avatar";
105
+ var AiAvatar = class {
106
+ constructor(http) {
107
+ this.http = http;
108
+ }
109
+ http;
110
+ async run(params, options) {
111
+ const { id } = await this.create(params, options);
112
+ const response = await (0, import_internal3.pollUntilComplete)(() => this.get(id, options), {
113
+ maxWaitMs: options?.maxWaitMs,
114
+ pollIntervalMs: options?.pollIntervalMs
115
+ });
116
+ return response;
117
+ }
118
+ async create(params, options) {
119
+ return this.http.request("POST", ENDPOINT3, {
120
+ body: (0, import_core3.compactParams)(params),
121
+ ...options
122
+ });
123
+ }
124
+ async get(id, options) {
125
+ return this.http.request("GET", `${ENDPOINT3}/${id}`, {
126
+ ...options
127
+ });
128
+ }
129
+ };
130
+
131
+ // src/resources/motion-control.ts
132
+ var import_core4 = require("@runapi.ai/core");
133
+ var import_internal4 = require("@runapi.ai/core/internal");
134
+ var ENDPOINT4 = "/api/v1/kling/motion_control";
135
+ var MotionControl = class {
136
+ constructor(http) {
137
+ this.http = http;
138
+ }
139
+ http;
140
+ async run(params, options) {
141
+ const { id } = await this.create(params, options);
142
+ const response = await (0, import_internal4.pollUntilComplete)(() => this.get(id, options), {
143
+ maxWaitMs: options?.maxWaitMs,
144
+ pollIntervalMs: options?.pollIntervalMs
145
+ });
146
+ return response;
147
+ }
148
+ async create(params, options) {
149
+ return this.http.request("POST", ENDPOINT4, {
150
+ body: (0, import_core4.compactParams)(params),
151
+ ...options
152
+ });
153
+ }
154
+ async get(id, options) {
155
+ return this.http.request("GET", `${ENDPOINT4}/${id}`, {
156
+ ...options
157
+ });
158
+ }
159
+ };
160
+
161
+ // src/client.ts
162
+ var KlingClient = class {
163
+ /** Text-to-video operations. */
164
+ textToVideo;
165
+ /** Image-to-video operations. */
166
+ imageToVideo;
167
+ /** AI avatar operations. */
168
+ aiAvatar;
169
+ /** Motion control operations. */
170
+ motionControl;
171
+ constructor(options = {}) {
172
+ const http = (0, import_core5.createHttpClient)(options);
173
+ this.textToVideo = new TextToVideo(http);
174
+ this.imageToVideo = new ImageToVideo(http);
175
+ this.aiAvatar = new AiAvatar(http);
176
+ this.motionControl = new MotionControl(http);
177
+ }
178
+ };
179
+
180
+ // src/index.ts
181
+ var import_core6 = require("@runapi.ai/core");
182
+ // Annotate the CommonJS export names for ESM import in node:
183
+ 0 && (module.exports = {
184
+ AuthenticationError,
185
+ InsufficientCreditsError,
186
+ KlingClient,
187
+ NetworkError,
188
+ NotFoundError,
189
+ RateLimitError,
190
+ RunApiError,
191
+ ServiceUnavailableError,
192
+ TaskFailedError,
193
+ TaskTimeoutError,
194
+ TimeoutError,
195
+ ValidationError
196
+ });
197
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,IAAI;AAAA,MACxE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;ACnCA,IAAAC,eAA8B;AAC9B,IAAAC,mBAAkC;AAQlC,IAAMC,YAAW;AAEV,IAAM,eAAN,MAAmB;AAAA,EACxB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EAE7B,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_internal","ENDPOINT","import_core"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,171 @@
1
+ // src/client.ts
2
+ import { createHttpClient } from "@runapi.ai/core";
3
+
4
+ // src/resources/text-to-video.ts
5
+ import { compactParams } from "@runapi.ai/core";
6
+ import { pollUntilComplete } from "@runapi.ai/core/internal";
7
+ var ENDPOINT = "/api/v1/kling/text_to_video";
8
+ var TextToVideo = class {
9
+ constructor(http) {
10
+ this.http = http;
11
+ }
12
+ http;
13
+ async run(params, options) {
14
+ const { id } = await this.create(params, options);
15
+ const response = await pollUntilComplete(() => this.get(id, options), {
16
+ maxWaitMs: options?.maxWaitMs,
17
+ pollIntervalMs: options?.pollIntervalMs
18
+ });
19
+ return response;
20
+ }
21
+ async create(params, options) {
22
+ return this.http.request("POST", ENDPOINT, {
23
+ body: compactParams(params),
24
+ ...options
25
+ });
26
+ }
27
+ async get(id, options) {
28
+ return this.http.request("GET", `${ENDPOINT}/${id}`, {
29
+ ...options
30
+ });
31
+ }
32
+ };
33
+
34
+ // src/resources/image-to-video.ts
35
+ import { compactParams as compactParams2 } from "@runapi.ai/core";
36
+ import { pollUntilComplete as pollUntilComplete2 } from "@runapi.ai/core/internal";
37
+ var ENDPOINT2 = "/api/v1/kling/image_to_video";
38
+ var ImageToVideo = class {
39
+ constructor(http) {
40
+ this.http = http;
41
+ }
42
+ http;
43
+ async run(params, options) {
44
+ const { id } = await this.create(params, options);
45
+ const response = await pollUntilComplete2(() => this.get(id, options), {
46
+ maxWaitMs: options?.maxWaitMs,
47
+ pollIntervalMs: options?.pollIntervalMs
48
+ });
49
+ return response;
50
+ }
51
+ async create(params, options) {
52
+ return this.http.request("POST", ENDPOINT2, {
53
+ body: compactParams2(params),
54
+ ...options
55
+ });
56
+ }
57
+ async get(id, options) {
58
+ return this.http.request("GET", `${ENDPOINT2}/${id}`, {
59
+ ...options
60
+ });
61
+ }
62
+ };
63
+
64
+ // src/resources/ai-avatar.ts
65
+ import { compactParams as compactParams3 } from "@runapi.ai/core";
66
+ import { pollUntilComplete as pollUntilComplete3 } from "@runapi.ai/core/internal";
67
+ var ENDPOINT3 = "/api/v1/kling/ai_avatar";
68
+ var AiAvatar = class {
69
+ constructor(http) {
70
+ this.http = http;
71
+ }
72
+ http;
73
+ async run(params, options) {
74
+ const { id } = await this.create(params, options);
75
+ const response = await pollUntilComplete3(() => this.get(id, options), {
76
+ maxWaitMs: options?.maxWaitMs,
77
+ pollIntervalMs: options?.pollIntervalMs
78
+ });
79
+ return response;
80
+ }
81
+ async create(params, options) {
82
+ return this.http.request("POST", ENDPOINT3, {
83
+ body: compactParams3(params),
84
+ ...options
85
+ });
86
+ }
87
+ async get(id, options) {
88
+ return this.http.request("GET", `${ENDPOINT3}/${id}`, {
89
+ ...options
90
+ });
91
+ }
92
+ };
93
+
94
+ // src/resources/motion-control.ts
95
+ import { compactParams as compactParams4 } from "@runapi.ai/core";
96
+ import { pollUntilComplete as pollUntilComplete4 } from "@runapi.ai/core/internal";
97
+ var ENDPOINT4 = "/api/v1/kling/motion_control";
98
+ var MotionControl = class {
99
+ constructor(http) {
100
+ this.http = http;
101
+ }
102
+ http;
103
+ async run(params, options) {
104
+ const { id } = await this.create(params, options);
105
+ const response = await pollUntilComplete4(() => this.get(id, options), {
106
+ maxWaitMs: options?.maxWaitMs,
107
+ pollIntervalMs: options?.pollIntervalMs
108
+ });
109
+ return response;
110
+ }
111
+ async create(params, options) {
112
+ return this.http.request("POST", ENDPOINT4, {
113
+ body: compactParams4(params),
114
+ ...options
115
+ });
116
+ }
117
+ async get(id, options) {
118
+ return this.http.request("GET", `${ENDPOINT4}/${id}`, {
119
+ ...options
120
+ });
121
+ }
122
+ };
123
+
124
+ // src/client.ts
125
+ var KlingClient = class {
126
+ /** Text-to-video operations. */
127
+ textToVideo;
128
+ /** Image-to-video operations. */
129
+ imageToVideo;
130
+ /** AI avatar operations. */
131
+ aiAvatar;
132
+ /** Motion control operations. */
133
+ motionControl;
134
+ constructor(options = {}) {
135
+ const http = createHttpClient(options);
136
+ this.textToVideo = new TextToVideo(http);
137
+ this.imageToVideo = new ImageToVideo(http);
138
+ this.aiAvatar = new AiAvatar(http);
139
+ this.motionControl = new MotionControl(http);
140
+ }
141
+ };
142
+
143
+ // src/index.ts
144
+ import {
145
+ RunApiError,
146
+ AuthenticationError,
147
+ InsufficientCreditsError,
148
+ NotFoundError,
149
+ ValidationError,
150
+ RateLimitError,
151
+ ServiceUnavailableError,
152
+ NetworkError,
153
+ TimeoutError,
154
+ TaskTimeoutError,
155
+ TaskFailedError
156
+ } from "@runapi.ai/core";
157
+ export {
158
+ AuthenticationError,
159
+ InsufficientCreditsError,
160
+ KlingClient,
161
+ NetworkError,
162
+ NotFoundError,
163
+ RateLimitError,
164
+ RunApiError,
165
+ ServiceUnavailableError,
166
+ TaskFailedError,
167
+ TaskTimeoutError,
168
+ TimeoutError,
169
+ ValidationError
170
+ };
171
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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,IAAI;AAAA,MACxE,GAAG;AAAA,IACL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,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"]}
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@runapi.ai/kling",
3
+ "version": "0.2.0",
4
+ "description": "RunAPI Kling SDK for JavaScript, Ruby, and Go",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "skills",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "engines": {
22
+ "node": ">=18.0.0"
23
+ },
24
+ "scripts": {
25
+ "build": "tsup",
26
+ "test": "vitest run",
27
+ "typecheck": "tsc --noEmit",
28
+ "clean": "rm -rf dist"
29
+ },
30
+ "dependencies": {
31
+ "@runapi.ai/core": "^0.2.0"
32
+ },
33
+ "devDependencies": {
34
+ "@types/node": "^20.0.0",
35
+ "@vitest/coverage-v8": "^1.6.0",
36
+ "dotenv-cli": "^11.0.0",
37
+ "tsup": "^8.0.0",
38
+ "tsx": "^4.7.0",
39
+ "typescript": "^5.4.0",
40
+ "vitest": "^1.6.0"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "keywords": [
46
+ "runapi",
47
+ "runapi-ai",
48
+ "kling",
49
+ "api",
50
+ "sdk",
51
+ "typescript",
52
+ "ruby",
53
+ "golang"
54
+ ],
55
+ "author": "RunAPI",
56
+ "license": "Apache-2.0",
57
+ "homepage": "https://runapi.ai/models/kling",
58
+ "repository": {
59
+ "type": "git",
60
+ "url": "git+https://github.com/runapi-ai/kling-sdk.git"
61
+ }
62
+ }
@@ -0,0 +1,54 @@
1
+ # Kling AI API Skill for RunAPI
2
+
3
+ Generate video, AI avatars, and motion-controlled clips with the Kling SDK. This skill helps Claude Code, Codex, Gemini CLI, Cursor, and 50+ agents integrate Kling through RunAPI.
4
+
5
+ The canonical agent file is `skills/kling/SKILL.md`.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npx skills add runapi-ai/kling -g
11
+ ```
12
+
13
+ Or manually: clone this repo and copy `skills/kling/` into your agent's skills directory.
14
+
15
+ ## Quick example
16
+
17
+ ```typescript
18
+ import { KlingClient } from '@runapi.ai/kling';
19
+
20
+ const client = new KlingClient();
21
+ const result = await client.textToVideo.run({
22
+ model: 'kling-3.0',
23
+ prompt: 'A cat walking through a sunlit garden',
24
+ });
25
+ const url = result.videos[0].url;
26
+ ```
27
+
28
+ ## Routing
29
+
30
+ - Model page: https://runapi.ai/models/kling
31
+ - Product docs: https://runapi.ai/docs#kling
32
+ - SDK docs: https://runapi.ai/docs#sdk-kling
33
+ - SDK repository: https://github.com/runapi-ai/kling-sdk
34
+ - Pricing and rate limits: https://runapi.ai/models/kling/3.0
35
+ - Provider comparison: https://runapi.ai/providers/kuaishou
36
+ - Browse all RunAPI models and skills: https://runapi.ai/models
37
+
38
+ ## Variants
39
+
40
+ - [Kling 3.0](https://runapi.ai/models/kling/3.0)
41
+ - [AI avatar pro](https://runapi.ai/models/kling/ai-avatar-pro)
42
+ - [AI avatar standard](https://runapi.ai/models/kling/ai-avatar-standard)
43
+ - [V2.5 turbo text to video pro](https://runapi.ai/models/kling/v2.5-turbo-text-to-video-pro)
44
+ - [V2.5 turbo image to video pro](https://runapi.ai/models/kling/v2.5-turbo-image-to-video-pro)
45
+
46
+ ## Agent rules
47
+
48
+ - Keep API keys in `RUNAPI_API_KEY` or RunAPI CLI config; never commit secrets.
49
+ - Prefer `create`, `get`, and `run` JSON passthrough patterns instead of inventing flags for every model parameter.
50
+ - For kling ai api pricing, rate-limit, and commercial-usage answers, link to the variant page rather than the repository README.
51
+
52
+ ## License
53
+
54
+ Licensed under the Apache License, Version 2.0.