@ai-sdk/klingai 4.0.0-beta.5 → 4.0.0-beta.52
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/CHANGELOG.md +379 -0
- package/README.md +2 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +157 -161
- package/dist/index.js.map +1 -1
- package/package.json +14 -14
- package/src/index.ts +2 -1
- package/src/klingai-provider.ts +2 -2
- package/src/klingai-video-model-options.ts +279 -0
- package/src/klingai-video-model.ts +23 -286
- package/src/version.ts +6 -3
- package/dist/index.d.mts +0 -211
- package/dist/index.mjs +0 -630
- package/dist/index.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,48 +1,26 @@
|
|
|
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
|
-
createKlingAI: () => createKlingAI,
|
|
24
|
-
klingai: () => klingai
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(index_exports);
|
|
27
|
-
|
|
28
1
|
// src/klingai-provider.ts
|
|
29
|
-
|
|
30
|
-
|
|
2
|
+
import {
|
|
3
|
+
NoSuchModelError as NoSuchModelError2
|
|
4
|
+
} from "@ai-sdk/provider";
|
|
5
|
+
import {
|
|
6
|
+
withoutTrailingSlash,
|
|
7
|
+
withUserAgentSuffix
|
|
8
|
+
} from "@ai-sdk/provider-utils";
|
|
31
9
|
|
|
32
10
|
// src/klingai-auth.ts
|
|
33
|
-
|
|
11
|
+
import { loadSetting } from "@ai-sdk/provider-utils";
|
|
34
12
|
var base64url = (str) => btoa(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
35
13
|
async function generateKlingAIAuthToken({
|
|
36
14
|
accessKey,
|
|
37
15
|
secretKey
|
|
38
16
|
}) {
|
|
39
|
-
const ak =
|
|
17
|
+
const ak = loadSetting({
|
|
40
18
|
settingValue: accessKey,
|
|
41
19
|
settingName: "accessKey",
|
|
42
20
|
environmentVariableName: "KLINGAI_ACCESS_KEY",
|
|
43
21
|
description: "KlingAI access key"
|
|
44
22
|
});
|
|
45
|
-
const sk =
|
|
23
|
+
const sk = loadSetting({
|
|
46
24
|
settingValue: secretKey,
|
|
47
25
|
settingName: "secretKey",
|
|
48
26
|
environmentVariableName: "KLINGAI_SECRET_KEY",
|
|
@@ -81,105 +59,121 @@ async function generateKlingAIAuthToken({
|
|
|
81
59
|
}
|
|
82
60
|
|
|
83
61
|
// src/klingai-video-model.ts
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
62
|
+
import {
|
|
63
|
+
AISDKError,
|
|
64
|
+
NoSuchModelError
|
|
65
|
+
} from "@ai-sdk/provider";
|
|
66
|
+
import {
|
|
67
|
+
combineHeaders,
|
|
68
|
+
convertUint8ArrayToBase64,
|
|
69
|
+
createJsonResponseHandler,
|
|
70
|
+
delay,
|
|
71
|
+
getFromApi,
|
|
72
|
+
parseProviderOptions,
|
|
73
|
+
postJsonToApi,
|
|
74
|
+
resolve
|
|
75
|
+
} from "@ai-sdk/provider-utils";
|
|
76
|
+
import { z as z3 } from "zod/v4";
|
|
87
77
|
|
|
88
78
|
// src/klingai-error.ts
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
var klingaiErrorDataSchema =
|
|
92
|
-
code:
|
|
93
|
-
message:
|
|
79
|
+
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
80
|
+
import { z } from "zod/v4";
|
|
81
|
+
var klingaiErrorDataSchema = z.object({
|
|
82
|
+
code: z.number(),
|
|
83
|
+
message: z.string()
|
|
94
84
|
});
|
|
95
|
-
var klingaiFailedResponseHandler =
|
|
85
|
+
var klingaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
96
86
|
errorSchema: klingaiErrorDataSchema,
|
|
97
87
|
errorToMessage: (data) => data.message
|
|
98
88
|
});
|
|
99
89
|
|
|
100
|
-
// src/klingai-video-model.ts
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
i2v: "/v1/videos/image2video",
|
|
110
|
-
"motion-control": "/v1/videos/motion-control"
|
|
111
|
-
};
|
|
112
|
-
function getApiModelName(modelId, mode) {
|
|
113
|
-
const suffix = mode === "motion-control" ? "-motion-control" : `-${mode}`;
|
|
114
|
-
const baseName = modelId.slice(0, -suffix.length);
|
|
115
|
-
return baseName.replace(/\.0$/, "").replace(/\./g, "-");
|
|
116
|
-
}
|
|
117
|
-
var klingaiVideoModelOptionsSchema = (0, import_provider_utils3.lazySchema)(
|
|
118
|
-
() => (0, import_provider_utils3.zodSchema)(
|
|
119
|
-
import_v42.z.object({
|
|
120
|
-
mode: import_v42.z.enum(["std", "pro"]).nullish(),
|
|
121
|
-
pollIntervalMs: import_v42.z.number().positive().nullish(),
|
|
122
|
-
pollTimeoutMs: import_v42.z.number().positive().nullish(),
|
|
90
|
+
// src/klingai-video-model-options.ts
|
|
91
|
+
import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
|
|
92
|
+
import { z as z2 } from "zod/v4";
|
|
93
|
+
var klingaiVideoModelOptionsSchema = lazySchema(
|
|
94
|
+
() => zodSchema(
|
|
95
|
+
z2.object({
|
|
96
|
+
mode: z2.enum(["std", "pro"]).nullish(),
|
|
97
|
+
pollIntervalMs: z2.number().positive().nullish(),
|
|
98
|
+
pollTimeoutMs: z2.number().positive().nullish(),
|
|
123
99
|
// T2V and I2V
|
|
124
|
-
negativePrompt:
|
|
125
|
-
sound:
|
|
126
|
-
cfgScale:
|
|
127
|
-
cameraControl:
|
|
128
|
-
type:
|
|
100
|
+
negativePrompt: z2.string().nullish(),
|
|
101
|
+
sound: z2.enum(["on", "off"]).nullish(),
|
|
102
|
+
cfgScale: z2.number().nullish(),
|
|
103
|
+
cameraControl: z2.object({
|
|
104
|
+
type: z2.enum([
|
|
129
105
|
"simple",
|
|
130
106
|
"down_back",
|
|
131
107
|
"forward_up",
|
|
132
108
|
"right_turn_forward",
|
|
133
109
|
"left_turn_forward"
|
|
134
110
|
]),
|
|
135
|
-
config:
|
|
136
|
-
horizontal:
|
|
137
|
-
vertical:
|
|
138
|
-
pan:
|
|
139
|
-
tilt:
|
|
140
|
-
roll:
|
|
141
|
-
zoom:
|
|
111
|
+
config: z2.object({
|
|
112
|
+
horizontal: z2.number().nullish(),
|
|
113
|
+
vertical: z2.number().nullish(),
|
|
114
|
+
pan: z2.number().nullish(),
|
|
115
|
+
tilt: z2.number().nullish(),
|
|
116
|
+
roll: z2.number().nullish(),
|
|
117
|
+
zoom: z2.number().nullish()
|
|
142
118
|
}).nullish()
|
|
143
119
|
}).nullish(),
|
|
144
120
|
// v3.0 multi-shot
|
|
145
|
-
multiShot:
|
|
146
|
-
shotType:
|
|
147
|
-
multiPrompt:
|
|
148
|
-
|
|
149
|
-
index:
|
|
150
|
-
prompt:
|
|
151
|
-
duration:
|
|
121
|
+
multiShot: z2.boolean().nullish(),
|
|
122
|
+
shotType: z2.enum(["customize", "intelligence"]).nullish(),
|
|
123
|
+
multiPrompt: z2.array(
|
|
124
|
+
z2.object({
|
|
125
|
+
index: z2.number(),
|
|
126
|
+
prompt: z2.string(),
|
|
127
|
+
duration: z2.string()
|
|
152
128
|
})
|
|
153
129
|
).nullish(),
|
|
154
130
|
// v3.0 element control (I2V)
|
|
155
|
-
elementList:
|
|
156
|
-
|
|
157
|
-
element_id:
|
|
131
|
+
elementList: z2.array(
|
|
132
|
+
z2.object({
|
|
133
|
+
element_id: z2.number()
|
|
158
134
|
})
|
|
159
135
|
).nullish(),
|
|
160
136
|
// v3.0 voice control
|
|
161
|
-
voiceList:
|
|
162
|
-
|
|
163
|
-
voice_id:
|
|
137
|
+
voiceList: z2.array(
|
|
138
|
+
z2.object({
|
|
139
|
+
voice_id: z2.string()
|
|
164
140
|
})
|
|
165
141
|
).nullish(),
|
|
166
142
|
// I2V-specific
|
|
167
|
-
imageTail:
|
|
168
|
-
staticMask:
|
|
169
|
-
dynamicMasks:
|
|
170
|
-
|
|
171
|
-
mask:
|
|
172
|
-
trajectories:
|
|
143
|
+
imageTail: z2.string().nullish(),
|
|
144
|
+
staticMask: z2.string().nullish(),
|
|
145
|
+
dynamicMasks: z2.array(
|
|
146
|
+
z2.object({
|
|
147
|
+
mask: z2.string(),
|
|
148
|
+
trajectories: z2.array(z2.object({ x: z2.number(), y: z2.number() }))
|
|
173
149
|
})
|
|
174
150
|
).nullish(),
|
|
175
151
|
// Motion-control-specific
|
|
176
|
-
videoUrl:
|
|
177
|
-
characterOrientation:
|
|
178
|
-
keepOriginalSound:
|
|
179
|
-
watermarkEnabled:
|
|
152
|
+
videoUrl: z2.string().nullish(),
|
|
153
|
+
characterOrientation: z2.enum(["image", "video"]).nullish(),
|
|
154
|
+
keepOriginalSound: z2.enum(["yes", "no"]).nullish(),
|
|
155
|
+
watermarkEnabled: z2.boolean().nullish()
|
|
180
156
|
}).passthrough()
|
|
181
157
|
)
|
|
182
158
|
);
|
|
159
|
+
|
|
160
|
+
// src/klingai-video-model.ts
|
|
161
|
+
function detectMode(modelId) {
|
|
162
|
+
if (modelId.endsWith("-t2v")) return "t2v";
|
|
163
|
+
if (modelId.endsWith("-i2v")) return "i2v";
|
|
164
|
+
if (modelId.endsWith("-motion-control")) return "motion-control";
|
|
165
|
+
throw new NoSuchModelError({ modelId, modelType: "videoModel" });
|
|
166
|
+
}
|
|
167
|
+
var modeEndpointMap = {
|
|
168
|
+
t2v: "/v1/videos/text2video",
|
|
169
|
+
i2v: "/v1/videos/image2video",
|
|
170
|
+
"motion-control": "/v1/videos/motion-control"
|
|
171
|
+
};
|
|
172
|
+
function getApiModelName(modelId, mode) {
|
|
173
|
+
const suffix = mode === "motion-control" ? "-motion-control" : `-${mode}`;
|
|
174
|
+
const baseName = modelId.slice(0, -suffix.length);
|
|
175
|
+
return baseName.replace(/\.0$/, "").replace(/\./g, "-");
|
|
176
|
+
}
|
|
183
177
|
var HANDLED_PROVIDER_OPTIONS = /* @__PURE__ */ new Set([
|
|
184
178
|
"mode",
|
|
185
179
|
"pollIntervalMs",
|
|
@@ -216,7 +210,7 @@ var KlingAIVideoModel = class {
|
|
|
216
210
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
217
211
|
const warnings = [];
|
|
218
212
|
const mode = detectMode(this.modelId);
|
|
219
|
-
const klingaiOptions = await
|
|
213
|
+
const klingaiOptions = await parseProviderOptions({
|
|
220
214
|
provider: "klingai",
|
|
221
215
|
providerOptions: options.providerOptions,
|
|
222
216
|
schema: klingaiVideoModelOptionsSchema
|
|
@@ -258,14 +252,14 @@ var KlingAIVideoModel = class {
|
|
|
258
252
|
});
|
|
259
253
|
}
|
|
260
254
|
const endpointPath = modeEndpointMap[mode];
|
|
261
|
-
const { value: createResponse, responseHeaders: createHeaders } = await
|
|
255
|
+
const { value: createResponse, responseHeaders: createHeaders } = await postJsonToApi({
|
|
262
256
|
url: `${this.config.baseURL}${endpointPath}`,
|
|
263
|
-
headers:
|
|
264
|
-
await
|
|
257
|
+
headers: combineHeaders(
|
|
258
|
+
await resolve(this.config.headers),
|
|
265
259
|
options.headers
|
|
266
260
|
),
|
|
267
261
|
body,
|
|
268
|
-
successfulResponseHandler:
|
|
262
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
269
263
|
klingaiCreateTaskSchema
|
|
270
264
|
),
|
|
271
265
|
failedResponseHandler: klingaiFailedResponseHandler,
|
|
@@ -274,7 +268,7 @@ var KlingAIVideoModel = class {
|
|
|
274
268
|
});
|
|
275
269
|
const taskId = (_d = createResponse.data) == null ? void 0 : _d.task_id;
|
|
276
270
|
if (!taskId) {
|
|
277
|
-
throw new
|
|
271
|
+
throw new AISDKError({
|
|
278
272
|
name: "KLINGAI_VIDEO_GENERATION_ERROR",
|
|
279
273
|
message: `No task_id returned from KlingAI API. Response: ${JSON.stringify(createResponse)}`
|
|
280
274
|
});
|
|
@@ -285,20 +279,20 @@ var KlingAIVideoModel = class {
|
|
|
285
279
|
let finalResponse;
|
|
286
280
|
let responseHeaders = createHeaders;
|
|
287
281
|
while (true) {
|
|
288
|
-
await
|
|
282
|
+
await delay(pollIntervalMs, { abortSignal: options.abortSignal });
|
|
289
283
|
if (Date.now() - startTime > pollTimeoutMs) {
|
|
290
|
-
throw new
|
|
284
|
+
throw new AISDKError({
|
|
291
285
|
name: "KLINGAI_VIDEO_GENERATION_TIMEOUT",
|
|
292
286
|
message: `Video generation timed out after ${pollTimeoutMs}ms`
|
|
293
287
|
});
|
|
294
288
|
}
|
|
295
|
-
const { value: statusResponse, responseHeaders: pollHeaders } = await
|
|
289
|
+
const { value: statusResponse, responseHeaders: pollHeaders } = await getFromApi({
|
|
296
290
|
url: `${this.config.baseURL}${endpointPath}/${taskId}`,
|
|
297
|
-
headers:
|
|
298
|
-
await
|
|
291
|
+
headers: combineHeaders(
|
|
292
|
+
await resolve(this.config.headers),
|
|
299
293
|
options.headers
|
|
300
294
|
),
|
|
301
|
-
successfulResponseHandler:
|
|
295
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
302
296
|
klingaiTaskStatusSchema
|
|
303
297
|
),
|
|
304
298
|
failedResponseHandler: klingaiFailedResponseHandler,
|
|
@@ -312,14 +306,14 @@ var KlingAIVideoModel = class {
|
|
|
312
306
|
break;
|
|
313
307
|
}
|
|
314
308
|
if (taskStatus === "failed") {
|
|
315
|
-
throw new
|
|
309
|
+
throw new AISDKError({
|
|
316
310
|
name: "KLINGAI_VIDEO_GENERATION_FAILED",
|
|
317
311
|
message: `Video generation failed: ${(_i = (_h = statusResponse.data) == null ? void 0 : _h.task_status_msg) != null ? _i : "Unknown error"}`
|
|
318
312
|
});
|
|
319
313
|
}
|
|
320
314
|
}
|
|
321
315
|
if (!((_l = (_k = (_j = finalResponse == null ? void 0 : finalResponse.data) == null ? void 0 : _j.task_result) == null ? void 0 : _k.videos) == null ? void 0 : _l.length)) {
|
|
322
|
-
throw new
|
|
316
|
+
throw new AISDKError({
|
|
323
317
|
name: "KLINGAI_VIDEO_GENERATION_ERROR",
|
|
324
318
|
message: `No videos in response. Response: ${JSON.stringify(finalResponse)}`
|
|
325
319
|
});
|
|
@@ -342,7 +336,7 @@ var KlingAIVideoModel = class {
|
|
|
342
336
|
}
|
|
343
337
|
}
|
|
344
338
|
if (videos.length === 0) {
|
|
345
|
-
throw new
|
|
339
|
+
throw new AISDKError({
|
|
346
340
|
name: "KLINGAI_VIDEO_GENERATION_ERROR",
|
|
347
341
|
message: "No valid video URLs in response"
|
|
348
342
|
});
|
|
@@ -374,8 +368,9 @@ var KlingAIVideoModel = class {
|
|
|
374
368
|
if ((klingaiOptions == null ? void 0 : klingaiOptions.negativePrompt) != null) {
|
|
375
369
|
body.negative_prompt = klingaiOptions.negativePrompt;
|
|
376
370
|
}
|
|
377
|
-
|
|
378
|
-
|
|
371
|
+
const sound = options.generateAudio != null ? options.generateAudio ? "on" : "off" : klingaiOptions == null ? void 0 : klingaiOptions.sound;
|
|
372
|
+
if (sound != null) {
|
|
373
|
+
body.sound = sound;
|
|
379
374
|
}
|
|
380
375
|
if ((klingaiOptions == null ? void 0 : klingaiOptions.cfgScale) != null) {
|
|
381
376
|
body.cfg_scale = klingaiOptions.cfgScale;
|
|
@@ -429,7 +424,7 @@ var KlingAIVideoModel = class {
|
|
|
429
424
|
if (options.image.type === "url") {
|
|
430
425
|
body.image = options.image.url;
|
|
431
426
|
} else {
|
|
432
|
-
body.image = typeof options.image.data === "string" ? options.image.data :
|
|
427
|
+
body.image = typeof options.image.data === "string" ? options.image.data : convertUint8ArrayToBase64(options.image.data);
|
|
433
428
|
}
|
|
434
429
|
}
|
|
435
430
|
if ((klingaiOptions == null ? void 0 : klingaiOptions.imageTail) != null) {
|
|
@@ -438,8 +433,9 @@ var KlingAIVideoModel = class {
|
|
|
438
433
|
if ((klingaiOptions == null ? void 0 : klingaiOptions.negativePrompt) != null) {
|
|
439
434
|
body.negative_prompt = klingaiOptions.negativePrompt;
|
|
440
435
|
}
|
|
441
|
-
|
|
442
|
-
|
|
436
|
+
const sound = options.generateAudio != null ? options.generateAudio ? "on" : "off" : klingaiOptions == null ? void 0 : klingaiOptions.sound;
|
|
437
|
+
if (sound != null) {
|
|
438
|
+
body.sound = sound;
|
|
443
439
|
}
|
|
444
440
|
if ((klingaiOptions == null ? void 0 : klingaiOptions.cfgScale) != null) {
|
|
445
441
|
body.cfg_scale = klingaiOptions.cfgScale;
|
|
@@ -489,7 +485,7 @@ var KlingAIVideoModel = class {
|
|
|
489
485
|
}
|
|
490
486
|
buildMotionControlBody(options, klingaiOptions, warnings) {
|
|
491
487
|
if (!(klingaiOptions == null ? void 0 : klingaiOptions.videoUrl) || !(klingaiOptions == null ? void 0 : klingaiOptions.characterOrientation) || !(klingaiOptions == null ? void 0 : klingaiOptions.mode)) {
|
|
492
|
-
throw new
|
|
488
|
+
throw new AISDKError({
|
|
493
489
|
name: "KLINGAI_VIDEO_MISSING_OPTIONS",
|
|
494
490
|
message: "KlingAI Motion Control requires providerOptions.klingai with videoUrl, characterOrientation, and mode."
|
|
495
491
|
});
|
|
@@ -508,7 +504,7 @@ var KlingAIVideoModel = class {
|
|
|
508
504
|
if (options.image.type === "url") {
|
|
509
505
|
body.image_url = options.image.url;
|
|
510
506
|
} else {
|
|
511
|
-
body.image_url = typeof options.image.data === "string" ? options.image.data :
|
|
507
|
+
body.image_url = typeof options.image.data === "string" ? options.image.data : convertUint8ArrayToBase64(options.image.data);
|
|
512
508
|
}
|
|
513
509
|
}
|
|
514
510
|
if (klingaiOptions.keepOriginalSound != null) {
|
|
@@ -546,44 +542,44 @@ var KlingAIVideoModel = class {
|
|
|
546
542
|
}
|
|
547
543
|
}
|
|
548
544
|
};
|
|
549
|
-
var klingaiCreateTaskSchema =
|
|
550
|
-
code:
|
|
551
|
-
message:
|
|
552
|
-
request_id:
|
|
553
|
-
data:
|
|
554
|
-
task_id:
|
|
555
|
-
task_status:
|
|
556
|
-
task_info:
|
|
557
|
-
external_task_id:
|
|
545
|
+
var klingaiCreateTaskSchema = z3.object({
|
|
546
|
+
code: z3.number(),
|
|
547
|
+
message: z3.string(),
|
|
548
|
+
request_id: z3.string().nullish(),
|
|
549
|
+
data: z3.object({
|
|
550
|
+
task_id: z3.string(),
|
|
551
|
+
task_status: z3.string().nullish(),
|
|
552
|
+
task_info: z3.object({
|
|
553
|
+
external_task_id: z3.string().nullish()
|
|
558
554
|
}).nullish(),
|
|
559
|
-
created_at:
|
|
560
|
-
updated_at:
|
|
555
|
+
created_at: z3.number().nullish(),
|
|
556
|
+
updated_at: z3.number().nullish()
|
|
561
557
|
}).nullish()
|
|
562
558
|
});
|
|
563
|
-
var klingaiTaskStatusSchema =
|
|
564
|
-
code:
|
|
565
|
-
message:
|
|
566
|
-
request_id:
|
|
567
|
-
data:
|
|
568
|
-
task_id:
|
|
569
|
-
task_status:
|
|
570
|
-
task_status_msg:
|
|
571
|
-
task_info:
|
|
572
|
-
external_task_id:
|
|
559
|
+
var klingaiTaskStatusSchema = z3.object({
|
|
560
|
+
code: z3.number(),
|
|
561
|
+
message: z3.string(),
|
|
562
|
+
request_id: z3.string().nullish(),
|
|
563
|
+
data: z3.object({
|
|
564
|
+
task_id: z3.string(),
|
|
565
|
+
task_status: z3.string(),
|
|
566
|
+
task_status_msg: z3.string().nullish(),
|
|
567
|
+
task_info: z3.object({
|
|
568
|
+
external_task_id: z3.string().nullish()
|
|
573
569
|
}).nullish(),
|
|
574
|
-
watermark_info:
|
|
575
|
-
enabled:
|
|
570
|
+
watermark_info: z3.object({
|
|
571
|
+
enabled: z3.boolean().nullish()
|
|
576
572
|
}).nullish(),
|
|
577
|
-
final_unit_deduction:
|
|
578
|
-
created_at:
|
|
579
|
-
updated_at:
|
|
580
|
-
task_result:
|
|
581
|
-
videos:
|
|
582
|
-
|
|
583
|
-
id:
|
|
584
|
-
url:
|
|
585
|
-
watermark_url:
|
|
586
|
-
duration:
|
|
573
|
+
final_unit_deduction: z3.string().nullish(),
|
|
574
|
+
created_at: z3.number().nullish(),
|
|
575
|
+
updated_at: z3.number().nullish(),
|
|
576
|
+
task_result: z3.object({
|
|
577
|
+
videos: z3.array(
|
|
578
|
+
z3.object({
|
|
579
|
+
id: z3.string().nullish(),
|
|
580
|
+
url: z3.string().nullish(),
|
|
581
|
+
watermark_url: z3.string().nullish(),
|
|
582
|
+
duration: z3.string().nullish()
|
|
587
583
|
})
|
|
588
584
|
).nullish()
|
|
589
585
|
}).nullish()
|
|
@@ -591,19 +587,19 @@ var klingaiTaskStatusSchema = import_v42.z.object({
|
|
|
591
587
|
});
|
|
592
588
|
|
|
593
589
|
// src/version.ts
|
|
594
|
-
var VERSION = "4.0.0-beta.
|
|
590
|
+
var VERSION = true ? "4.0.0-beta.52" : "0.0.0-test";
|
|
595
591
|
|
|
596
592
|
// src/klingai-provider.ts
|
|
597
593
|
var defaultBaseURL = "https://api-singapore.klingai.com";
|
|
598
594
|
function createKlingAI(options = {}) {
|
|
599
595
|
var _a, _b;
|
|
600
|
-
const baseURL = (_b =
|
|
596
|
+
const baseURL = (_b = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL)) != null ? _b : defaultBaseURL;
|
|
601
597
|
const getHeaders = async () => {
|
|
602
598
|
const token = await generateKlingAIAuthToken({
|
|
603
599
|
accessKey: options.accessKey,
|
|
604
600
|
secretKey: options.secretKey
|
|
605
601
|
});
|
|
606
|
-
return
|
|
602
|
+
return withUserAgentSuffix(
|
|
607
603
|
{
|
|
608
604
|
Authorization: `Bearer ${token}`,
|
|
609
605
|
...options.headers
|
|
@@ -618,7 +614,7 @@ function createKlingAI(options = {}) {
|
|
|
618
614
|
fetch: options.fetch
|
|
619
615
|
});
|
|
620
616
|
const noSuchModel = (modelId, modelType) => {
|
|
621
|
-
throw new
|
|
617
|
+
throw new NoSuchModelError2({ modelId, modelType });
|
|
622
618
|
};
|
|
623
619
|
const provider = {
|
|
624
620
|
specificationVersion: "v4",
|
|
@@ -631,9 +627,9 @@ function createKlingAI(options = {}) {
|
|
|
631
627
|
return provider;
|
|
632
628
|
}
|
|
633
629
|
var klingai = createKlingAI();
|
|
634
|
-
|
|
635
|
-
|
|
630
|
+
export {
|
|
631
|
+
VERSION,
|
|
636
632
|
createKlingAI,
|
|
637
633
|
klingai
|
|
638
|
-
}
|
|
634
|
+
};
|
|
639
635
|
//# sourceMappingURL=index.js.map
|