getaiapi 1.3.1 → 2.0.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 CHANGED
@@ -26,9 +26,531 @@ import {
26
26
  submit,
27
27
  submitAndPoll,
28
28
  uploadAsset
29
- } from "./chunk-CN4FJ4FW.js";
29
+ } from "./chunk-H6MMJNJX.js";
30
30
 
31
- // src/configure.ts
31
+ // src/providers/kling/errors.ts
32
+ var KlingError = class extends Error {
33
+ code;
34
+ constructor(code, message) {
35
+ super(message);
36
+ this.name = "KlingError";
37
+ this.code = code;
38
+ }
39
+ };
40
+ var KlingAuthError = class extends KlingError {
41
+ constructor(message = "Missing Kling credentials. Call kling.configure() or set KLING_ACCESS_KEY + KLING_SECRET_KEY.") {
42
+ super("AUTH_ERROR", message);
43
+ this.name = "KlingAuthError";
44
+ }
45
+ };
46
+ var KlingRateLimitError = class extends KlingError {
47
+ retryAfterMs;
48
+ constructor(retryAfterMs) {
49
+ super("RATE_LIMIT", `Rate limited by Kling. Retry after ${retryAfterMs}ms.`);
50
+ this.name = "KlingRateLimitError";
51
+ this.retryAfterMs = retryAfterMs;
52
+ }
53
+ };
54
+ var KlingApiError = class extends KlingError {
55
+ statusCode;
56
+ raw;
57
+ constructor(endpoint, statusCode, raw) {
58
+ super("API_ERROR", `Kling API error ${statusCode} on ${endpoint}.`);
59
+ this.name = "KlingApiError";
60
+ this.statusCode = statusCode;
61
+ this.raw = raw;
62
+ }
63
+ };
64
+ var KlingTimeoutError = class extends KlingError {
65
+ timeoutMs;
66
+ constructor(timeoutMs) {
67
+ super("TIMEOUT", `Kling task timed out after ${timeoutMs}ms.`);
68
+ this.name = "KlingTimeoutError";
69
+ this.timeoutMs = timeoutMs;
70
+ }
71
+ };
72
+ var KlingTaskFailedError = class extends KlingError {
73
+ taskId;
74
+ constructor(taskId, message) {
75
+ super("TASK_FAILED", `Kling task ${taskId} failed: ${message}`);
76
+ this.name = "KlingTaskFailedError";
77
+ this.taskId = taskId;
78
+ }
79
+ };
80
+
81
+ // src/providers/kling/auth.ts
82
+ import { createHmac } from "crypto";
83
+ function generateJwt(accessKey, secretKey) {
84
+ const header = Buffer.from(JSON.stringify({ alg: "HS256", typ: "JWT" })).toString("base64url");
85
+ const now = Math.floor(Date.now() / 1e3);
86
+ const payload = Buffer.from(JSON.stringify({
87
+ iss: accessKey,
88
+ exp: now + 1800,
89
+ nbf: now - 5
90
+ })).toString("base64url");
91
+ const signature = createHmac("sha256", secretKey).update(`${header}.${payload}`).digest("base64url");
92
+ return `${header}.${payload}.${signature}`;
93
+ }
94
+ function buildAuthHeaders(accessKey, secretKey) {
95
+ return {
96
+ Authorization: `Bearer ${generateJwt(accessKey, secretKey)}`,
97
+ "Content-Type": "application/json"
98
+ };
99
+ }
100
+
101
+ // src/providers/kling/client.ts
102
+ var API_BASE = "https://api-singapore.klingai.com";
103
+ var DEFAULT_FETCH_TIMEOUT_MS = 3e4;
104
+ var DEFAULT_POLL_TIMEOUT_MS = 3e5;
105
+ var DEFAULT_POLL_INTERVAL_MS = 2e3;
106
+ var POLL_BACKOFF_MULTIPLIER = 1.5;
107
+ var MAX_POLL_INTERVAL_MS = 1e4;
108
+ var SYNC_ENDPOINTS = /* @__PURE__ */ new Set(["v1/audio/tts", "v1/videos/image-recognize", "v1/videos/identify-face"]);
109
+ function cleanBase64(value) {
110
+ if (typeof value === "string" && value.startsWith("data:")) {
111
+ return value.split(",")[1] ?? value;
112
+ }
113
+ if (Array.isArray(value)) {
114
+ return value.map(cleanBase64);
115
+ }
116
+ if (value !== null && typeof value === "object") {
117
+ const result = {};
118
+ for (const [k, v] of Object.entries(value)) {
119
+ result[k] = cleanBase64(v);
120
+ }
121
+ return result;
122
+ }
123
+ return value;
124
+ }
125
+ var KlingClient = class {
126
+ accessKey = null;
127
+ secretKey = null;
128
+ fetchTimeoutMs = DEFAULT_FETCH_TIMEOUT_MS;
129
+ /** Update credentials and settings. */
130
+ configure(config) {
131
+ this.accessKey = config.accessKey;
132
+ this.secretKey = config.secretKey;
133
+ if (config.fetchTimeoutMs !== void 0) {
134
+ this.fetchTimeoutMs = config.fetchTimeoutMs;
135
+ }
136
+ }
137
+ resolveAuth() {
138
+ if (this.accessKey && this.secretKey) {
139
+ return { accessKey: this.accessKey, secretKey: this.secretKey };
140
+ }
141
+ const ak = process.env.KLING_ACCESS_KEY?.trim();
142
+ const sk = process.env.KLING_SECRET_KEY?.trim();
143
+ if (ak && sk) return { accessKey: ak, secretKey: sk };
144
+ throw new KlingAuthError();
145
+ }
146
+ // ── HTTP ─────────────────────────────────────────────────────────────────
147
+ async handleErrors(response, endpoint) {
148
+ if (response.ok) return;
149
+ if (response.status === 401) throw new KlingAuthError("Kling returned 401 Unauthorized.");
150
+ if (response.status === 429) {
151
+ const retryAfter = response.headers.get("retry-after");
152
+ throw new KlingRateLimitError(retryAfter ? parseInt(retryAfter, 10) * 1e3 : 6e4);
153
+ }
154
+ let raw;
155
+ try {
156
+ raw = await response.json();
157
+ } catch {
158
+ raw = await response.text().catch(() => null);
159
+ }
160
+ throw new KlingApiError(endpoint, response.status, raw);
161
+ }
162
+ handleBodyErrors(json, endpoint) {
163
+ if (json.code === 0) return;
164
+ if (json.code >= 1e3 && json.code <= 1004) {
165
+ throw new KlingAuthError(`Kling auth error code ${json.code}: ${json.message}`);
166
+ }
167
+ if (json.code >= 1100 && json.code <= 1102 || json.code >= 1302 && json.code <= 1304) {
168
+ throw new KlingRateLimitError(5e3);
169
+ }
170
+ throw new KlingApiError(endpoint, json.code, json);
171
+ }
172
+ async httpSubmit(endpoint, body) {
173
+ const auth = this.resolveAuth();
174
+ const url = `${API_BASE}/${endpoint}`;
175
+ const response = await fetch(url, {
176
+ method: "POST",
177
+ headers: buildAuthHeaders(auth.accessKey, auth.secretKey),
178
+ body: JSON.stringify(body),
179
+ signal: AbortSignal.timeout(this.fetchTimeoutMs)
180
+ });
181
+ await this.handleErrors(response, endpoint);
182
+ const json = await response.json();
183
+ this.handleBodyErrors(json, endpoint);
184
+ return json;
185
+ }
186
+ async httpPoll(endpoint, taskId) {
187
+ const auth = this.resolveAuth();
188
+ const url = `${API_BASE}/${endpoint}/${taskId}`;
189
+ const response = await fetch(url, {
190
+ headers: buildAuthHeaders(auth.accessKey, auth.secretKey),
191
+ signal: AbortSignal.timeout(this.fetchTimeoutMs)
192
+ });
193
+ await this.handleErrors(response, endpoint);
194
+ const json = await response.json();
195
+ this.handleBodyErrors(json, endpoint);
196
+ return json;
197
+ }
198
+ // ── Execute ──────────────────────────────────────────────────────────────
199
+ async execute(endpoint, defaults, input, extractor, sync) {
200
+ const { timeout, pollInterval, options, ...params } = input;
201
+ const timeoutMs = timeout ?? DEFAULT_POLL_TIMEOUT_MS;
202
+ const initialIntervalMs = pollInterval ?? DEFAULT_POLL_INTERVAL_MS;
203
+ const body = { ...params };
204
+ if (options && typeof options === "object") {
205
+ for (const [key, val] of Object.entries(options)) {
206
+ if (!(key in body)) body[key] = val;
207
+ }
208
+ }
209
+ for (const [key, val] of Object.entries(defaults)) {
210
+ if (!(key in body)) body[key] = val;
211
+ }
212
+ const cleanedBody = cleanBase64(body);
213
+ const submitResult = await this.httpSubmit(endpoint, cleanedBody);
214
+ const isSyncEndpoint = sync ?? SYNC_ENDPOINTS.has(endpoint);
215
+ if (isSyncEndpoint) {
216
+ return extractor(submitResult.data);
217
+ }
218
+ const taskId = submitResult.data.task_id;
219
+ const deadline = Date.now() + timeoutMs;
220
+ let intervalMs = initialIntervalMs;
221
+ while (Date.now() < deadline) {
222
+ await new Promise((resolve) => setTimeout(resolve, intervalMs));
223
+ intervalMs = Math.min(intervalMs * POLL_BACKOFF_MULTIPLIER, MAX_POLL_INTERVAL_MS);
224
+ const pollResult = await this.httpPoll(endpoint, taskId);
225
+ const status = pollResult.data.task_status;
226
+ if (status === "failed") {
227
+ throw new KlingTaskFailedError(taskId, pollResult.data.task_status_msg ?? "Unknown error");
228
+ }
229
+ if (status === "succeed") {
230
+ return extractor(pollResult.data);
231
+ }
232
+ }
233
+ throw new KlingTimeoutError(timeoutMs);
234
+ }
235
+ };
236
+
237
+ // src/providers/kling/extract.ts
238
+ function extractVideos(data) {
239
+ const taskResult = data.task_result;
240
+ const videos = taskResult?.videos ?? [];
241
+ return { task_id: data.task_id, videos };
242
+ }
243
+ function extractImages(data) {
244
+ const taskResult = data.task_result;
245
+ const images = taskResult?.images ?? [];
246
+ return { task_id: data.task_id, images };
247
+ }
248
+ function extractAudios(data) {
249
+ const taskResult = data.task_result;
250
+ const rawAudios = taskResult?.audios ?? [];
251
+ const audios = rawAudios.map((a) => ({
252
+ id: a.id,
253
+ url: a.url ?? a.url_mp3 ?? a.url_wav ?? "",
254
+ url_mp3: a.url_mp3,
255
+ url_wav: a.url_wav,
256
+ duration: a.duration ?? a.duration_mp3,
257
+ duration_mp3: a.duration_mp3,
258
+ duration_wav: a.duration_wav
259
+ }));
260
+ return { task_id: data.task_id, audios };
261
+ }
262
+ function extractJson(data) {
263
+ return { task_id: data.task_id, data: data.task_result ?? data };
264
+ }
265
+ function extractFace(data) {
266
+ return {
267
+ session_id: data.session_id,
268
+ face_data: data.face_data ?? []
269
+ };
270
+ }
271
+ function extractMultiShot(data) {
272
+ const taskResult = data.task_result;
273
+ const rawImages = taskResult?.images ?? [];
274
+ const images = rawImages.map((img, i) => ({
275
+ index: img.index ?? i,
276
+ url_1: img.url_1,
277
+ url_2: img.url_2,
278
+ url_3: img.url_3
279
+ }));
280
+ return { task_id: data.task_id, images };
281
+ }
282
+ function extractVoices(data) {
283
+ const taskResult = data.task_result;
284
+ const voices = taskResult?.voices ?? [];
285
+ return { task_id: data.task_id, voices };
286
+ }
287
+ function extractVideoAudio(data) {
288
+ const taskResult = data.task_result;
289
+ const videos = taskResult?.videos ?? [];
290
+ const rawAudios = taskResult?.audios ?? [];
291
+ const audios = rawAudios.map((a) => ({
292
+ id: a.id,
293
+ url_mp3: a.url_mp3,
294
+ url_wav: a.url_wav,
295
+ duration_mp3: a.duration_mp3,
296
+ duration_wav: a.duration_wav
297
+ }));
298
+ return { task_id: data.task_id, videos, audios };
299
+ }
300
+
301
+ // src/providers/kling/models.ts
302
+ function createModels(client) {
303
+ return {
304
+ // ── text2video (9 models) ──────────────────────────────────────────────
305
+ textToVideoV1Standard(input) {
306
+ return client.execute("v1/videos/text2video", { model_name: "kling-v1", mode: "std" }, input, extractVideos);
307
+ },
308
+ textToVideoV1_6Pro(input) {
309
+ return client.execute("v1/videos/text2video", { model_name: "kling-v1-6", mode: "pro" }, input, extractVideos);
310
+ },
311
+ textToVideoV1_6Standard(input) {
312
+ return client.execute("v1/videos/text2video", { model_name: "kling-v1-6", mode: "std" }, input, extractVideos);
313
+ },
314
+ textToVideoV2Master(input) {
315
+ return client.execute("v1/videos/text2video", { model_name: "kling-v2-master" }, input, extractVideos);
316
+ },
317
+ textToVideoV2_1Master(input) {
318
+ return client.execute("v1/videos/text2video", { model_name: "kling-v2-1-master" }, input, extractVideos);
319
+ },
320
+ textToVideoV2_5TurboPro(input) {
321
+ return client.execute("v1/videos/text2video", { model_name: "kling-v2-5-turbo", mode: "pro" }, input, extractVideos);
322
+ },
323
+ textToVideoV2_6Pro(input) {
324
+ return client.execute("v1/videos/text2video", { model_name: "kling-v2-6", mode: "pro" }, input, extractVideos);
325
+ },
326
+ textToVideoV3Pro(input) {
327
+ return client.execute("v1/videos/text2video", { model_name: "kling-v3", mode: "pro" }, input, extractVideos);
328
+ },
329
+ textToVideoV3Standard(input) {
330
+ return client.execute("v1/videos/text2video", { model_name: "kling-v3", mode: "std" }, input, extractVideos);
331
+ },
332
+ // ── image2video (13 models) ────────────────────────────────────────────
333
+ imageToVideoV1Standard(input) {
334
+ return client.execute("v1/videos/image2video", { model_name: "kling-v1", mode: "std" }, input, extractVideos);
335
+ },
336
+ imageToVideoV1_5Pro(input) {
337
+ return client.execute("v1/videos/image2video", { model_name: "kling-v1-5", mode: "pro" }, input, extractVideos);
338
+ },
339
+ imageToVideoV1_6Pro(input) {
340
+ return client.execute("v1/videos/image2video", { model_name: "kling-v1-6", mode: "pro" }, input, extractVideos);
341
+ },
342
+ imageToVideoV1_6Standard(input) {
343
+ return client.execute("v1/videos/image2video", { model_name: "kling-v1-6", mode: "std" }, input, extractVideos);
344
+ },
345
+ imageToVideoV2Master(input) {
346
+ return client.execute("v1/videos/image2video", { model_name: "kling-v2-master" }, input, extractVideos);
347
+ },
348
+ imageToVideoV2_1Master(input) {
349
+ return client.execute("v1/videos/image2video", { model_name: "kling-v2-1-master" }, input, extractVideos);
350
+ },
351
+ imageToVideoV2_1Pro(input) {
352
+ return client.execute("v1/videos/image2video", { model_name: "kling-v2-1", mode: "pro" }, input, extractVideos);
353
+ },
354
+ imageToVideoV2_1Standard(input) {
355
+ return client.execute("v1/videos/image2video", { model_name: "kling-v2-1", mode: "std" }, input, extractVideos);
356
+ },
357
+ imageToVideoV2_5TurboPro(input) {
358
+ return client.execute("v1/videos/image2video", { model_name: "kling-v2-5-turbo", mode: "pro" }, input, extractVideos);
359
+ },
360
+ imageToVideoV2_5TurboStandard(input) {
361
+ return client.execute("v1/videos/image2video", { model_name: "kling-v2-5-turbo", mode: "std" }, input, extractVideos);
362
+ },
363
+ imageToVideoV2_6Pro(input) {
364
+ return client.execute("v1/videos/image2video", { model_name: "kling-v2-6", mode: "pro" }, input, extractVideos);
365
+ },
366
+ imageToVideoV3Pro(input) {
367
+ return client.execute("v1/videos/image2video", { model_name: "kling-v3", mode: "pro" }, input, extractVideos);
368
+ },
369
+ imageToVideoV3Standard(input) {
370
+ return client.execute("v1/videos/image2video", { model_name: "kling-v3", mode: "std" }, input, extractVideos);
371
+ },
372
+ // ── omni-video (17 models) ─────────────────────────────────────────────
373
+ omniVideoO1ImageToVideo(input) {
374
+ return client.execute("v1/videos/omni-video", { model_name: "kling-video-o1" }, input, extractVideos);
375
+ },
376
+ omniVideoO1ReferenceToVideo(input) {
377
+ return client.execute("v1/videos/omni-video", { model_name: "kling-video-o1" }, input, extractVideos);
378
+ },
379
+ omniVideoO1StandardImageToVideo(input) {
380
+ return client.execute("v1/videos/omni-video", { model_name: "kling-video-o1", mode: "std" }, input, extractVideos);
381
+ },
382
+ omniVideoO1StandardReferenceToVideo(input) {
383
+ return client.execute("v1/videos/omni-video", { model_name: "kling-video-o1", mode: "std" }, input, extractVideos);
384
+ },
385
+ omniVideoO1StandardVideoEdit(input) {
386
+ return client.execute("v1/videos/omni-video", { model_name: "kling-video-o1", mode: "std" }, input, extractVideos);
387
+ },
388
+ omniVideoO1StandardVideoReference(input) {
389
+ return client.execute("v1/videos/omni-video", { model_name: "kling-video-o1", mode: "std" }, input, extractVideos);
390
+ },
391
+ omniVideoO1VideoEdit(input) {
392
+ return client.execute("v1/videos/omni-video", { model_name: "kling-video-o1" }, input, extractVideos);
393
+ },
394
+ omniVideoO1VideoReference(input) {
395
+ return client.execute("v1/videos/omni-video", { model_name: "kling-video-o1" }, input, extractVideos);
396
+ },
397
+ omniVideoO3ProImageToVideo(input) {
398
+ return client.execute("v1/videos/omni-video", { model_name: "kling-v3-omni", mode: "pro" }, input, extractVideos);
399
+ },
400
+ omniVideoO3ProReferenceToVideo(input) {
401
+ return client.execute("v1/videos/omni-video", { model_name: "kling-v3-omni", mode: "pro" }, input, extractVideos);
402
+ },
403
+ omniVideoO3ProTextToVideo(input) {
404
+ return client.execute("v1/videos/omni-video", { model_name: "kling-v3-omni", mode: "pro" }, input, extractVideos);
405
+ },
406
+ omniVideoO3ProVideoEdit(input) {
407
+ return client.execute("v1/videos/omni-video", { model_name: "kling-v3-omni", mode: "pro" }, input, extractVideos);
408
+ },
409
+ omniVideoO3ProVideoReference(input) {
410
+ return client.execute("v1/videos/omni-video", { model_name: "kling-v3-omni", mode: "pro" }, input, extractVideos);
411
+ },
412
+ omniVideoO3StandardReferenceToVideo(input) {
413
+ return client.execute("v1/videos/omni-video", { model_name: "kling-v3-omni", mode: "std" }, input, extractVideos);
414
+ },
415
+ omniVideoO3StandardTextToVideo(input) {
416
+ return client.execute("v1/videos/omni-video", { model_name: "kling-v3-omni", mode: "std" }, input, extractVideos);
417
+ },
418
+ omniVideoO3StandardVideoEdit(input) {
419
+ return client.execute("v1/videos/omni-video", { model_name: "kling-v3-omni", mode: "std" }, input, extractVideos);
420
+ },
421
+ omniVideoO3StandardVideoReference(input) {
422
+ return client.execute("v1/videos/omni-video", { model_name: "kling-v3-omni", mode: "std" }, input, extractVideos);
423
+ },
424
+ // ── images/generations (2 models) ──────────────────────────────────────
425
+ imageV3TextToImage(input) {
426
+ return client.execute("v1/images/generations", { model_name: "kling-v3" }, input, extractImages);
427
+ },
428
+ imageV3ImageToImage(input) {
429
+ return client.execute("v1/images/generations", { model_name: "kling-v3" }, input, extractImages);
430
+ },
431
+ // ── images/omni-image (3 models) ───────────────────────────────────────
432
+ imageO1(input) {
433
+ return client.execute("v1/images/omni-image", { model_name: "kling-image-o1" }, input, extractImages);
434
+ },
435
+ imageO3TextToImage(input) {
436
+ return client.execute("v1/images/omni-image", { model_name: "kling-v3-omni" }, input, extractImages);
437
+ },
438
+ imageO3ImageToImage(input) {
439
+ return client.execute("v1/images/omni-image", { model_name: "kling-v3-omni" }, input, extractImages);
440
+ },
441
+ // ── virtual-try-on (1 model) ───────────────────────────────────────────
442
+ virtualTryOn(input) {
443
+ return client.execute("v1/images/kolors-virtual-try-on", { model_name: "kolors-virtual-try-on-v1-5" }, input, extractImages);
444
+ },
445
+ // ── avatar (4 models) ──────────────────────────────────────────────────
446
+ avatarV2Pro(input) {
447
+ return client.execute("v1/videos/avatar/image2video", { mode: "pro" }, input, extractVideos);
448
+ },
449
+ avatarV2Standard(input) {
450
+ return client.execute("v1/videos/avatar/image2video", { mode: "std" }, input, extractVideos);
451
+ },
452
+ avatarV1Pro(input) {
453
+ return client.execute("v1/videos/avatar/image2video", { mode: "pro" }, input, extractVideos);
454
+ },
455
+ avatarV1Standard(input) {
456
+ return client.execute("v1/videos/avatar/image2video", { mode: "std" }, input, extractVideos);
457
+ },
458
+ // ── lip-sync (2 models) ────────────────────────────────────────────────
459
+ lipSyncAudioToVideo(input) {
460
+ return client.execute("v1/videos/advanced-lip-sync", {}, input, extractVideos);
461
+ },
462
+ lipSyncTextToVideo(input) {
463
+ return client.execute("v1/videos/advanced-lip-sync", {}, input, extractVideos);
464
+ },
465
+ // ── effects (4 models) ─────────────────────────────────────────────────
466
+ effectsV1Standard(input) {
467
+ return client.execute("v1/videos/effects", {}, input, extractVideos);
468
+ },
469
+ effectsV1_5Pro(input) {
470
+ return client.execute("v1/videos/effects", {}, input, extractVideos);
471
+ },
472
+ effectsV1_6Pro(input) {
473
+ return client.execute("v1/videos/effects", {}, input, extractVideos);
474
+ },
475
+ effectsV1_6Standard(input) {
476
+ return client.execute("v1/videos/effects", {}, input, extractVideos);
477
+ },
478
+ // ── motion-control (4 models) ──────────────────────────────────────────
479
+ motionControlV2_6Pro(input) {
480
+ return client.execute("v1/videos/motion-control", { model_name: "kling-v2-6", mode: "pro" }, input, extractVideos);
481
+ },
482
+ motionControlV2_6Standard(input) {
483
+ return client.execute("v1/videos/motion-control", { model_name: "kling-v2-6", mode: "std" }, input, extractVideos);
484
+ },
485
+ motionControlV3Pro(input) {
486
+ return client.execute("v1/videos/motion-control", { model_name: "kling-v3", mode: "pro" }, input, extractVideos);
487
+ },
488
+ motionControlV3Standard(input) {
489
+ return client.execute("v1/videos/motion-control", { model_name: "kling-v3", mode: "std" }, input, extractVideos);
490
+ },
491
+ // ── tts (1 model, sync) ────────────────────────────────────────────────
492
+ tts(input) {
493
+ return client.execute("v1/audio/tts", {}, input, extractAudios, true);
494
+ },
495
+ // ── video-to-audio (1 model) ───────────────────────────────────────────
496
+ videoToAudio(input) {
497
+ return client.execute("v1/audio/video-to-audio", {}, input, extractVideoAudio);
498
+ },
499
+ // ── text-to-audio (1 model) ────────────────────────────────────────────
500
+ textToAudio(input) {
501
+ return client.execute("v1/audio/text-to-audio", {}, input, extractAudios);
502
+ },
503
+ // ── create-voice (1 model) ─────────────────────────────────────────────
504
+ createVoice(input) {
505
+ return client.execute("v1/general/custom-voices", {}, input, extractVoices);
506
+ },
507
+ // ── multi-shot (1 model) ───────────────────────────────────────────────
508
+ multiShot(input) {
509
+ return client.execute("v1/general/ai-multi-shot", {}, input, extractMultiShot);
510
+ },
511
+ // ── reference-to-image (1 model) ───────────────────────────────────────
512
+ referenceToImage(input) {
513
+ return client.execute("v1/images/multi-image2image", { model_name: "kling-v2-1" }, input, extractImages);
514
+ },
515
+ // ── expand-image (1 model) ─────────────────────────────────────────────
516
+ expandImage(input) {
517
+ return client.execute("v1/images/editing/expand", {}, input, extractImages);
518
+ },
519
+ // ── extend-video (1 model) ─────────────────────────────────────────────
520
+ extendVideo(input) {
521
+ return client.execute("v1/videos/video-extend", {}, input, extractVideos);
522
+ },
523
+ // ── identify-face (1 model) ────────────────────────────────────────────
524
+ identifyFace(input) {
525
+ return client.execute("v1/videos/identify-face", {}, input, extractFace, true);
526
+ },
527
+ // ── image-recognize (1 model, sync) ────────────────────────────────────
528
+ imageRecognize(input) {
529
+ return client.execute("v1/videos/image-recognize", {}, input, extractJson, true);
530
+ },
531
+ // ── reference-to-video (1 model) ──────────────────────────────────────
532
+ referenceToVideo(input) {
533
+ return client.execute("v1/videos/multi-image2video", { model_name: "kling-v1-6" }, input, extractVideos);
534
+ }
535
+ };
536
+ }
537
+
538
+ // src/providers/kling/index.ts
539
+ function createClient(config) {
540
+ const client = new KlingClient();
541
+ client.configure(config);
542
+ return {
543
+ configure: (c) => client.configure(c),
544
+ ...createModels(client)
545
+ };
546
+ }
547
+ var defaultClient = new KlingClient();
548
+ var kling = {
549
+ configure: (config) => defaultClient.configure(config),
550
+ ...createModels(defaultClient)
551
+ };
552
+
553
+ // deprecated/src/configure.ts
32
554
  function configure(options) {
33
555
  if (options.keys) {
34
556
  configureAuth(options.keys);
@@ -43,6 +565,13 @@ function configure(options) {
43
565
  export {
44
566
  AuthError,
45
567
  GetAIApiError,
568
+ KlingApiError,
569
+ KlingAuthError,
570
+ KlingClient,
571
+ KlingError,
572
+ KlingRateLimitError,
573
+ KlingTaskFailedError,
574
+ KlingTimeoutError,
46
575
  ModelNotFoundError,
47
576
  NoProviderError,
48
577
  ProviderError,
@@ -55,9 +584,12 @@ export {
55
584
  configureAuth,
56
585
  configureFetch,
57
586
  configureStorage,
587
+ createClient,
58
588
  deleteAsset,
59
589
  deriveCategory,
60
590
  generate,
591
+ generateJwt,
592
+ kling,
61
593
  klingAdapter,
62
594
  listModels,
63
595
  loadRegistry,