@ai-sdk/klingai 4.0.0-beta.4 → 4.0.0-beta.51
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 +377 -0
- package/README.md +2 -0
- package/dist/index.d.ts +7 -5
- package/dist/index.js +153 -159
- package/dist/index.js.map +1 -1
- package/package.json +14 -14
- package/src/index.ts +2 -1
- package/src/klingai-provider.ts +8 -8
- package/src/klingai-video-model-options.ts +279 -0
- package/src/klingai-video-model.ts +19 -294
- 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",
|
|
@@ -205,7 +199,7 @@ var KlingAIVideoModel = class {
|
|
|
205
199
|
constructor(modelId, config) {
|
|
206
200
|
this.modelId = modelId;
|
|
207
201
|
this.config = config;
|
|
208
|
-
this.specificationVersion = "
|
|
202
|
+
this.specificationVersion = "v4";
|
|
209
203
|
this.maxVideosPerCall = 1;
|
|
210
204
|
}
|
|
211
205
|
get provider() {
|
|
@@ -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
|
});
|
|
@@ -429,7 +423,7 @@ var KlingAIVideoModel = class {
|
|
|
429
423
|
if (options.image.type === "url") {
|
|
430
424
|
body.image = options.image.url;
|
|
431
425
|
} else {
|
|
432
|
-
body.image = typeof options.image.data === "string" ? options.image.data :
|
|
426
|
+
body.image = typeof options.image.data === "string" ? options.image.data : convertUint8ArrayToBase64(options.image.data);
|
|
433
427
|
}
|
|
434
428
|
}
|
|
435
429
|
if ((klingaiOptions == null ? void 0 : klingaiOptions.imageTail) != null) {
|
|
@@ -489,7 +483,7 @@ var KlingAIVideoModel = class {
|
|
|
489
483
|
}
|
|
490
484
|
buildMotionControlBody(options, klingaiOptions, warnings) {
|
|
491
485
|
if (!(klingaiOptions == null ? void 0 : klingaiOptions.videoUrl) || !(klingaiOptions == null ? void 0 : klingaiOptions.characterOrientation) || !(klingaiOptions == null ? void 0 : klingaiOptions.mode)) {
|
|
492
|
-
throw new
|
|
486
|
+
throw new AISDKError({
|
|
493
487
|
name: "KLINGAI_VIDEO_MISSING_OPTIONS",
|
|
494
488
|
message: "KlingAI Motion Control requires providerOptions.klingai with videoUrl, characterOrientation, and mode."
|
|
495
489
|
});
|
|
@@ -508,7 +502,7 @@ var KlingAIVideoModel = class {
|
|
|
508
502
|
if (options.image.type === "url") {
|
|
509
503
|
body.image_url = options.image.url;
|
|
510
504
|
} else {
|
|
511
|
-
body.image_url = typeof options.image.data === "string" ? options.image.data :
|
|
505
|
+
body.image_url = typeof options.image.data === "string" ? options.image.data : convertUint8ArrayToBase64(options.image.data);
|
|
512
506
|
}
|
|
513
507
|
}
|
|
514
508
|
if (klingaiOptions.keepOriginalSound != null) {
|
|
@@ -546,44 +540,44 @@ var KlingAIVideoModel = class {
|
|
|
546
540
|
}
|
|
547
541
|
}
|
|
548
542
|
};
|
|
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:
|
|
543
|
+
var klingaiCreateTaskSchema = z3.object({
|
|
544
|
+
code: z3.number(),
|
|
545
|
+
message: z3.string(),
|
|
546
|
+
request_id: z3.string().nullish(),
|
|
547
|
+
data: z3.object({
|
|
548
|
+
task_id: z3.string(),
|
|
549
|
+
task_status: z3.string().nullish(),
|
|
550
|
+
task_info: z3.object({
|
|
551
|
+
external_task_id: z3.string().nullish()
|
|
558
552
|
}).nullish(),
|
|
559
|
-
created_at:
|
|
560
|
-
updated_at:
|
|
553
|
+
created_at: z3.number().nullish(),
|
|
554
|
+
updated_at: z3.number().nullish()
|
|
561
555
|
}).nullish()
|
|
562
556
|
});
|
|
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:
|
|
557
|
+
var klingaiTaskStatusSchema = z3.object({
|
|
558
|
+
code: z3.number(),
|
|
559
|
+
message: z3.string(),
|
|
560
|
+
request_id: z3.string().nullish(),
|
|
561
|
+
data: z3.object({
|
|
562
|
+
task_id: z3.string(),
|
|
563
|
+
task_status: z3.string(),
|
|
564
|
+
task_status_msg: z3.string().nullish(),
|
|
565
|
+
task_info: z3.object({
|
|
566
|
+
external_task_id: z3.string().nullish()
|
|
573
567
|
}).nullish(),
|
|
574
|
-
watermark_info:
|
|
575
|
-
enabled:
|
|
568
|
+
watermark_info: z3.object({
|
|
569
|
+
enabled: z3.boolean().nullish()
|
|
576
570
|
}).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:
|
|
571
|
+
final_unit_deduction: z3.string().nullish(),
|
|
572
|
+
created_at: z3.number().nullish(),
|
|
573
|
+
updated_at: z3.number().nullish(),
|
|
574
|
+
task_result: z3.object({
|
|
575
|
+
videos: z3.array(
|
|
576
|
+
z3.object({
|
|
577
|
+
id: z3.string().nullish(),
|
|
578
|
+
url: z3.string().nullish(),
|
|
579
|
+
watermark_url: z3.string().nullish(),
|
|
580
|
+
duration: z3.string().nullish()
|
|
587
581
|
})
|
|
588
582
|
).nullish()
|
|
589
583
|
}).nullish()
|
|
@@ -591,19 +585,19 @@ var klingaiTaskStatusSchema = import_v42.z.object({
|
|
|
591
585
|
});
|
|
592
586
|
|
|
593
587
|
// src/version.ts
|
|
594
|
-
var VERSION = "4.0.0-beta.
|
|
588
|
+
var VERSION = true ? "4.0.0-beta.51" : "0.0.0-test";
|
|
595
589
|
|
|
596
590
|
// src/klingai-provider.ts
|
|
597
591
|
var defaultBaseURL = "https://api-singapore.klingai.com";
|
|
598
592
|
function createKlingAI(options = {}) {
|
|
599
593
|
var _a, _b;
|
|
600
|
-
const baseURL = (_b =
|
|
594
|
+
const baseURL = (_b = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL)) != null ? _b : defaultBaseURL;
|
|
601
595
|
const getHeaders = async () => {
|
|
602
596
|
const token = await generateKlingAIAuthToken({
|
|
603
597
|
accessKey: options.accessKey,
|
|
604
598
|
secretKey: options.secretKey
|
|
605
599
|
});
|
|
606
|
-
return
|
|
600
|
+
return withUserAgentSuffix(
|
|
607
601
|
{
|
|
608
602
|
Authorization: `Bearer ${token}`,
|
|
609
603
|
...options.headers
|
|
@@ -618,10 +612,10 @@ function createKlingAI(options = {}) {
|
|
|
618
612
|
fetch: options.fetch
|
|
619
613
|
});
|
|
620
614
|
const noSuchModel = (modelId, modelType) => {
|
|
621
|
-
throw new
|
|
615
|
+
throw new NoSuchModelError2({ modelId, modelType });
|
|
622
616
|
};
|
|
623
617
|
const provider = {
|
|
624
|
-
specificationVersion: "
|
|
618
|
+
specificationVersion: "v4",
|
|
625
619
|
video: createVideoModel,
|
|
626
620
|
videoModel: createVideoModel,
|
|
627
621
|
languageModel: (modelId) => noSuchModel(modelId, "languageModel"),
|
|
@@ -631,9 +625,9 @@ function createKlingAI(options = {}) {
|
|
|
631
625
|
return provider;
|
|
632
626
|
}
|
|
633
627
|
var klingai = createKlingAI();
|
|
634
|
-
|
|
635
|
-
|
|
628
|
+
export {
|
|
629
|
+
VERSION,
|
|
636
630
|
createKlingAI,
|
|
637
631
|
klingai
|
|
638
|
-
}
|
|
632
|
+
};
|
|
639
633
|
//# sourceMappingURL=index.js.map
|