vidspotai-shared 1.0.135 → 1.0.137
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/lib/globals/aiModels/enums.d.ts +2 -0
- package/lib/globals/aiModels/enums.d.ts.map +1 -1
- package/lib/globals/aiModels/enums.js +4 -0
- package/lib/globals/aiModels/providers/kling.d.ts.map +1 -1
- package/lib/globals/aiModels/providers/kling.js +100 -0
- package/lib/libs/storage/cdnUrl.d.ts +1 -3
- package/lib/libs/storage/cdnUrl.d.ts.map +1 -1
- package/lib/libs/storage/cdnUrl.js +8 -6
- package/lib/services/agent/providerFallback/chains.d.ts.map +1 -1
- package/lib/services/agent/providerFallback/chains.js +5 -0
- package/lib/services/agent/tools/generateVideo.tool.d.ts.map +1 -1
- package/lib/services/agent/tools/generateVideo.tool.js +2 -1
- package/lib/services/aiGen/aiGenFactory.service.d.ts.map +1 -1
- package/lib/services/aiGen/aiGenFactory.service.js +2 -0
- package/lib/services/aiGen/providers/bytedance/bytedance.service.d.ts.map +1 -1
- package/lib/services/aiGen/providers/bytedance/bytedance.service.js +17 -0
- package/lib/services/aiGen/providers/kling/kling.service.d.ts +7 -1
- package/lib/services/aiGen/providers/kling/kling.service.d.ts.map +1 -1
- package/lib/services/aiGen/providers/kling/kling.service.js +32 -3
- package/lib/services/aiGen/providers/kling/klingCredits.d.ts.map +1 -1
- package/lib/services/aiGen/providers/kling/klingCredits.js +13 -0
- package/lib/services/aiGen/providers/kling/klingRequests.d.ts +26 -1
- package/lib/services/aiGen/providers/kling/klingRequests.d.ts.map +1 -1
- package/lib/services/aiGen/providers/kling/klingRequests.js +135 -0
- package/lib/services/aiGen/providers/kling/types.d.ts +31 -0
- package/lib/services/aiGen/providers/kling/types.d.ts.map +1 -1
- package/lib/services/aiGen/providers/types.d.ts +6 -0
- package/lib/services/aiGen/providers/types.d.ts.map +1 -1
- package/lib/services/index.d.ts +1 -0
- package/lib/services/index.d.ts.map +1 -1
- package/lib/services/index.js +1 -0
- package/lib/services/providerHealth.service.d.ts +12 -0
- package/lib/services/providerHealth.service.d.ts.map +1 -0
- package/lib/services/providerHealth.service.js +75 -0
- package/lib/services/translation/translation.service.d.ts +10 -1
- package/lib/services/translation/translation.service.d.ts.map +1 -1
- package/lib/services/translation/translation.service.js +34 -1
- package/lib/utils/errors.d.ts +3 -0
- package/lib/utils/errors.d.ts.map +1 -1
- package/lib/utils/errors.js +6 -0
- package/lib/utils/helpers.d.ts +1 -1
- package/lib/utils/helpers.d.ts.map +1 -1
- package/lib/utils/helpers.js +2 -1
- package/package.json +1 -1
- package/lib/globals/aiModels/providers/falVideo.d.ts +0 -34
- package/lib/globals/aiModels/providers/falVideo.d.ts.map +0 -1
- package/lib/globals/aiModels/providers/falVideo.js +0 -102
- package/lib/services/aiGen/providers/fal/falVideo.service.d.ts +0 -39
- package/lib/services/aiGen/providers/fal/falVideo.service.d.ts.map +0 -1
- package/lib/services/aiGen/providers/fal/falVideo.service.js +0 -266
|
@@ -42,6 +42,8 @@ export declare enum EVideoGenModels {
|
|
|
42
42
|
KLING_V3_0 = "kling-v3.0",
|
|
43
43
|
KLING_V3_0_TURBO = "kling-v3.0-turbo",
|
|
44
44
|
KLING_V3_0_OMNI = "kling-v3.0-omni",
|
|
45
|
+
KLING_V4_0 = "kling-v4.0",
|
|
46
|
+
KLING_V4_0_FLASH = "kling-v4.0-flash",
|
|
45
47
|
KLING_AVATAR = "kling-avatar",
|
|
46
48
|
KLING_VIDEO_O1 = "kling-video-o1",
|
|
47
49
|
KLING_V3_OMNI_VIDEO = "kling-v3-omni-video",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/globals/aiModels/enums.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACzB,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;IAC/B,WAAW,gBAAgB;IAC3B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AmB;IAC7B,mBAAmB,wBAAwB;CAC5C;AACD,MAAM,MAAM,qBAAqB,GAAG,GAAG,mBAAmB,EAAE,CAAC;AAE7D,MAAM,MAAM,WAAW,GACnB,eAAe,GACf,cAAc,GACd,iBAAiB,GACjB,eAAe,GACf,aAAa,GACb,qBAAqB,GACrB,qBAAqB,CAAC"}
|
|
@@ -54,6 +54,10 @@ var EVideoGenModels;
|
|
|
54
54
|
// globals/aiModels/providers/kling.ts for the full delta.
|
|
55
55
|
EVideoGenModels["KLING_V3_0_TURBO"] = "kling-v3.0-turbo";
|
|
56
56
|
EVideoGenModels["KLING_V3_0_OMNI"] = "kling-v3.0-omni";
|
|
57
|
+
// Kling 4.0 / 4.0 Flash on Kling's own API 2.0 (KLING_API_KEY, Flagship
|
|
58
|
+
// resource pack). The fal-hosted `fal-kling-v4.0*` keys live on dev only.
|
|
59
|
+
EVideoGenModels["KLING_V4_0"] = "kling-v4.0";
|
|
60
|
+
EVideoGenModels["KLING_V4_0_FLASH"] = "kling-v4.0-flash";
|
|
57
61
|
EVideoGenModels["KLING_AVATAR"] = "kling-avatar";
|
|
58
62
|
// OmniVideo endpoint (/v1/videos/omni-video) — different from standard text2video/image2video
|
|
59
63
|
EVideoGenModels["KLING_VIDEO_O1"] = "kling-video-o1";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kling.d.ts","sourceRoot":"","sources":["../../../../src/globals/aiModels/providers/kling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAsB,YAAY,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"kling.d.ts","sourceRoot":"","sources":["../../../../src/globals/aiModels/providers/kling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAsB,YAAY,EAAE,MAAM,UAAU,CAAC;AA4C5D,eAAO,MAAM,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,YAAY,CAAC,CA8mBnE,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.klingConfigs = void 0;
|
|
4
|
+
const range = (min, max) => Array.from({ length: max - min + 1 }, (_, i) => min + i);
|
|
4
5
|
// Fields shared across all standard Kling video models. I2V-capable models
|
|
5
6
|
// also pick up image_tail / static_mask / dynamic_masks via spread below.
|
|
6
7
|
const klingCommonFields = {
|
|
@@ -401,6 +402,105 @@ exports.klingConfigs = {
|
|
|
401
402
|
notes: "Video input bills 50% above text/image input. A reference video forces silent output; an edit can keep the original sound. For plain text/image-to-video with sound, kling-v3.0-turbo is the same price and faster.",
|
|
402
403
|
},
|
|
403
404
|
},
|
|
405
|
+
// ─── Kling 4.0 / 4.0 Flash on API 2.0 ──────────────────────────────────────
|
|
406
|
+
// Same envelope, apiKey auth and GET /tasks poller as Turbo / 3.0 Omni.
|
|
407
|
+
// Verified 2026-10-28 against /document-api/api/video/4-0[-flash]/*:
|
|
408
|
+
// POST /text-to-video/<id> prompt, 21:9|16:9|9:16|1:1
|
|
409
|
+
// POST /image-to-video/<id> first (+ last) frame; no aspect_ratio
|
|
410
|
+
// POST /omni-video/<id> ≤10 images, ≤5 videos (≤1 base), ≤7 elements,
|
|
411
|
+
// ≤15 inputs total; aspect defaults "adaptive"
|
|
412
|
+
// buildKling4VideoBody picks the path from the inputs. Kling's resolution
|
|
413
|
+
// default is 1080p, so the builder ALWAYS sends it (std→720p, pro→1080p).
|
|
414
|
+
// No audio / multi_shot setting: stereo audio is always on (→ AUDIO_MODELS
|
|
415
|
+
// in chains.ts); multi-shot is prompt-encoded like Turbo.
|
|
416
|
+
//
|
|
417
|
+
// Billing (kling.ai/dev/pricing, Flagship Models, 2026-10-28): 4.0 costs
|
|
418
|
+
// 1.0 unit/s at 720p and 1.5 units/s at 1080p; with an input video 0.6 /
|
|
419
|
+
// 0.9 units/s on (output × 2) or (input + output) seconds. Only the
|
|
420
|
+
// Flagship resource pack covers 4.0; we bought the Trial pack at
|
|
421
|
+
// $0.1563/unit ($10 / 64 units), so that is the rate used below — not the
|
|
422
|
+
// $0.14 list price — to keep margins honest. Concurrency 5 per pack.
|
|
423
|
+
"kling-v4.0": {
|
|
424
|
+
modelId: "kling-4.0", // also the URL path segment — keep exact
|
|
425
|
+
type: ["text-to-video", "image-to-video", "video-to-video"],
|
|
426
|
+
tier: "T3",
|
|
427
|
+
fields: {
|
|
428
|
+
prompt: { required: true },
|
|
429
|
+
aspectRatio: { allowedValues: ["16:9", "9:16", "1:1", "21:9"] },
|
|
430
|
+
duration: { allowedValues: range(3, 30), default: 5 },
|
|
431
|
+
mode: { allowedValues: ["std", "pro"] },
|
|
432
|
+
resolution: { allowedValues: ["720p", "1080p"], default: "720p" },
|
|
433
|
+
inputImageUrl: {}, // → first_frame
|
|
434
|
+
lastFrameImageUrl: {}, // → last_frame
|
|
435
|
+
referenceImageUrls: { max: 10 }, // → omni refer_image (@image_n)
|
|
436
|
+
referenceVideoUrls: { max: 5 }, // → omni feature_video (@video_n)
|
|
437
|
+
inputVideoUrl: {}, // → omni base_video (edit)
|
|
438
|
+
klingElements: { max: 7 }, // → omni element (@element_n)
|
|
439
|
+
multiShot: {}, // prompt-encoded
|
|
440
|
+
callbackUrl: {},
|
|
441
|
+
externalTaskId: {},
|
|
442
|
+
watermark: {},
|
|
443
|
+
},
|
|
444
|
+
concurrentRequests: 5,
|
|
445
|
+
pollIntervalMs: 10000,
|
|
446
|
+
// 30s 1080p generations run long.
|
|
447
|
+
pollTimeoutMs: 30 * 60000,
|
|
448
|
+
cost: {
|
|
449
|
+
perSecondByResolution: { "720p": 0.1563, "1080p": 0.2345 },
|
|
450
|
+
videoInputPerSecondByResolution: { "720p": 0.0938, "1080p": 0.1407 },
|
|
451
|
+
},
|
|
452
|
+
guidance: {
|
|
453
|
+
quality: 5,
|
|
454
|
+
speed: 3,
|
|
455
|
+
bestFor: "Kling's newest flagship: single takes up to 30s with native stereo audio, first/last frames, and Omni reference (10 images + 5 videos cited as @image_1/@video_1). Best Kling for cinematic, multi-shot storytelling and readable on-screen text.",
|
|
456
|
+
notes: "Audio is always on and included in the price. 1080p costs 1.5× 720p. A reference or edit video bills on output × 2 (or input + output) seconds at 0.6×. No 4K.",
|
|
457
|
+
},
|
|
458
|
+
},
|
|
459
|
+
// Flash: 720p only, 3–20s, first frame only (no last frame); omni takes
|
|
460
|
+
// first_frame + refer_image, videos and elements. Kling publishes no Flash
|
|
461
|
+
// rate yet — priced at 0.6 units/s ($0.0938 at our pack price), an
|
|
462
|
+
// estimate (fal's Flash/4.0 ratio). Re-measure on the first live run.
|
|
463
|
+
//
|
|
464
|
+
// GATED 2026-10-28: the smoke test's POST /text-to-video/kling-4.0-flash
|
|
465
|
+
// (the documented path) returned 404 code 1203 "the resource is not
|
|
466
|
+
// existed" while kling-4.0 on the same key was accepted — Flash isn't open
|
|
467
|
+
// to our account yet (Kling: limited early access). Set
|
|
468
|
+
// KLING_V4_FLASH_LIVE=true (Doppler + Railway) once a 3s run succeeds.
|
|
469
|
+
"kling-v4.0-flash": {
|
|
470
|
+
modelId: "kling-4.0-flash", // also the URL path segment — keep exact
|
|
471
|
+
type: ["text-to-video", "image-to-video", "video-to-video"],
|
|
472
|
+
tier: "T2",
|
|
473
|
+
gatedByEnv: "KLING_V4_FLASH_LIVE",
|
|
474
|
+
fields: {
|
|
475
|
+
prompt: { required: true },
|
|
476
|
+
aspectRatio: { allowedValues: ["16:9", "9:16", "1:1", "21:9"] },
|
|
477
|
+
duration: { allowedValues: range(3, 20), default: 5 },
|
|
478
|
+
mode: { allowedValues: ["std"] },
|
|
479
|
+
resolution: { allowedValues: ["720p"], default: "720p" },
|
|
480
|
+
inputImageUrl: {}, // → first_frame
|
|
481
|
+
referenceImageUrls: { max: 10 }, // → omni refer_image
|
|
482
|
+
referenceVideoUrls: { max: 5 }, // → omni feature_video
|
|
483
|
+
inputVideoUrl: {}, // → omni base_video
|
|
484
|
+
klingElements: { max: 7 },
|
|
485
|
+
multiShot: {},
|
|
486
|
+
callbackUrl: {},
|
|
487
|
+
externalTaskId: {},
|
|
488
|
+
watermark: {},
|
|
489
|
+
},
|
|
490
|
+
concurrentRequests: 5,
|
|
491
|
+
pollIntervalMs: 10000,
|
|
492
|
+
pollTimeoutMs: 20 * 60000,
|
|
493
|
+
cost: {
|
|
494
|
+
perSecondByResolution: { "720p": 0.0938 },
|
|
495
|
+
videoInputPerSecondByResolution: { "720p": 0.0563 },
|
|
496
|
+
},
|
|
497
|
+
guidance: {
|
|
498
|
+
quality: 4,
|
|
499
|
+
speed: 5,
|
|
500
|
+
bestFor: "Fast, budget Kling 4.0: text, image or reference to video up to 20s with native audio at 720p. Great for drafts, social clips and high-volume B-roll.",
|
|
501
|
+
notes: "720p only, no last frame. About 40% cheaper than Kling 4.0.",
|
|
502
|
+
},
|
|
503
|
+
},
|
|
404
504
|
"kling-v2.6": {
|
|
405
505
|
modelId: "kling-v2-6",
|
|
406
506
|
type: ["text-to-video", "image-to-video"],
|
|
@@ -78,9 +78,7 @@ export declare function fetchOwnMedia(url: string, init?: RequestInit): Promise<
|
|
|
78
78
|
*
|
|
79
79
|
* Always routes through the prod BUCKET token, in every env: the Worker only
|
|
80
80
|
* resolves `/gcs-pub/<that bucket>/`, and R2 keys carry no bucket name, so dev
|
|
81
|
-
* writes land in the same R2 namespace and resolve fine.
|
|
82
|
-
* URL (`storage.googleapis.com/vidspot-dev…`) is never rewritten by `cdn()`
|
|
83
|
-
* and 404s against GCS, which no longer holds the bytes.
|
|
81
|
+
* writes land in the same R2 namespace and resolve fine.
|
|
84
82
|
*/
|
|
85
83
|
export declare function publicCdnUrl(objectPath: string): string;
|
|
86
84
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cdnUrl.d.ts","sourceRoot":"","sources":["../../../src/libs/storage/cdnUrl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"cdnUrl.d.ts","sourceRoot":"","sources":["../../../src/libs/storage/cdnUrl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAmBH,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEnD;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CACtB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,eAAe,CAAA;CAAE,GACtC,MAAM,CAeR;AAQD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,eAAe,CAAA;CAA8B,GACjE,CAAC,CASH;AAQD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,eAAe,CAAA;CAA8B,GACjE,MAAM,CAER;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEhF;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAalD"}
|
|
@@ -22,7 +22,11 @@ exports.isOwnMediaUrl = isOwnMediaUrl;
|
|
|
22
22
|
const FIREBASE_STORAGE_HOST = "https://firebasestorage.googleapis.com";
|
|
23
23
|
const GCS_HOST = "https://storage.googleapis.com";
|
|
24
24
|
const BUCKET = "vidspot-firebase.firebasestorage.app";
|
|
25
|
-
|
|
25
|
+
// Every bucket the Worker serves (its SERVED_BUCKETS). The dev project mints
|
|
26
|
+
// dev-bucket-shaped URLs whose bytes live only in R2, so they must be
|
|
27
|
+
// rewritten too or they stay dead at their literal GCS address.
|
|
28
|
+
const SIGNED_BUCKETS = [BUCKET, "vidspot-dev.firebasestorage.app"];
|
|
29
|
+
const GCS_SIGNED_PREFIXES = SIGNED_BUCKETS.map((b) => `${GCS_HOST}/${b}/`);
|
|
26
30
|
function cdnBase() {
|
|
27
31
|
return (process.env.MEDIA_CDN_BASE ||
|
|
28
32
|
process.env.NEXT_PUBLIC_MEDIA_CDN_BASE ||
|
|
@@ -44,7 +48,7 @@ function toCdnUrl(url, opts) {
|
|
|
44
48
|
if (url.startsWith(FIREBASE_STORAGE_HOST)) {
|
|
45
49
|
return base + url.slice(FIREBASE_STORAGE_HOST.length);
|
|
46
50
|
}
|
|
47
|
-
if (url.startsWith(
|
|
51
|
+
if (GCS_SIGNED_PREFIXES.some((p) => url.startsWith(p))) {
|
|
48
52
|
const rest = url.slice(GCS_HOST.length); // "/<bucket>/<object>?<signed>"
|
|
49
53
|
const seg = opts?.visibility === "private" ? "gcs-priv" : "gcs-pub";
|
|
50
54
|
return `${base}/${seg}${rest}`;
|
|
@@ -82,7 +86,7 @@ function toCdnUrlsDeep(value, opts = { visibility: "private" }) {
|
|
|
82
86
|
return value;
|
|
83
87
|
}
|
|
84
88
|
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
85
|
-
const OWN_URL_IN_TEXT = new RegExp(`(?:${escapeRe
|
|
89
|
+
const OWN_URL_IN_TEXT = new RegExp(`(?:${[FIREBASE_STORAGE_HOST, ...GCS_SIGNED_PREFIXES].map(escapeRe).join("|")})[^\\s"'<>)\\]]+`, "g");
|
|
86
90
|
/**
|
|
87
91
|
* `toCdnUrl` for every one of our storage URLs embedded in free text (a tool
|
|
88
92
|
* result line like "• Video: <url>", an email body). Other text is untouched.
|
|
@@ -125,9 +129,7 @@ function fetchOwnMedia(url, init) {
|
|
|
125
129
|
*
|
|
126
130
|
* Always routes through the prod BUCKET token, in every env: the Worker only
|
|
127
131
|
* resolves `/gcs-pub/<that bucket>/`, and R2 keys carry no bucket name, so dev
|
|
128
|
-
* writes land in the same R2 namespace and resolve fine.
|
|
129
|
-
* URL (`storage.googleapis.com/vidspot-dev…`) is never rewritten by `cdn()`
|
|
130
|
-
* and 404s against GCS, which no longer holds the bytes.
|
|
132
|
+
* writes land in the same R2 namespace and resolve fine.
|
|
131
133
|
*/
|
|
132
134
|
function publicCdnUrl(objectPath) {
|
|
133
135
|
const encoded = objectPath.split("/").map(encodeURIComponent).join("/");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../../../src/services/agent/providerFallback/chains.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EACf,eAAe,EACf,aAAa,EAGb,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AAGnC;;;;;;;;;;;;GAYG;AAGH,eAAO,MAAM,sBAAsB,EAAE,SAAS,eAAe,EAc5D,CAAC;AAKF,eAAO,MAAM,sBAAsB,EAAE,SAAS,eAAe,EAc5D,CAAC;AAQF,eAAO,MAAM,uBAAuB,EAAE,SAAS,eAAe,EAc7D,CAAC;AAKF,eAAO,MAAM,uBAAuB,EAAE,SAAS,eAAe,EAW7D,CAAC;AASF,eAAO,MAAM,kBAAkB,EAAE,SAAS,eAAe,EAIxD,CAAC;AAGF,eAAO,MAAM,WAAW,EAAE,SAAS,eAAe,EAIjD,CAAC;AAGF,eAAO,MAAM,SAAS,EAAE,SAAS,aAAa,EAE7C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wCAAwC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,eAAe,EACtB,GAAG,EAAE,sBAAsB,GAC1B,OAAO,CAyCT;AAED,+EAA+E;AAC/E,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CASjD;
|
|
1
|
+
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../../../src/services/agent/providerFallback/chains.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EACf,eAAe,EACf,aAAa,EAGb,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AAGnC;;;;;;;;;;;;GAYG;AAGH,eAAO,MAAM,sBAAsB,EAAE,SAAS,eAAe,EAc5D,CAAC;AAKF,eAAO,MAAM,sBAAsB,EAAE,SAAS,eAAe,EAc5D,CAAC;AAQF,eAAO,MAAM,uBAAuB,EAAE,SAAS,eAAe,EAc7D,CAAC;AAKF,eAAO,MAAM,uBAAuB,EAAE,SAAS,eAAe,EAW7D,CAAC;AASF,eAAO,MAAM,kBAAkB,EAAE,SAAS,eAAe,EAIxD,CAAC;AAGF,eAAO,MAAM,WAAW,EAAE,SAAS,eAAe,EAIjD,CAAC;AAGF,eAAO,MAAM,SAAS,EAAE,SAAS,aAAa,EAE7C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wCAAwC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,eAAe,EACtB,GAAG,EA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0 Turbo, the avatar model).
|
|
203
203
|
const AUDIO_MODELS = new Set([
|
|
204
204
|
aiModels_1.EVideoGenModels.KLING_V3_0_TURBO,
|
|
205
|
+
// Kling 4.0 / Flash: stereo audio always on, no toggle field. Not in any
|
|
206
|
+
// fallback chain on purpose — the Flagship pack is small and prepaid, so
|
|
207
|
+
// 4.0 runs only when a user or the planner picks it explicitly.
|
|
208
|
+
aiModels_1.EVideoGenModels.KLING_V4_0,
|
|
209
|
+
aiModels_1.EVideoGenModels.KLING_V4_0_FLASH,
|
|
205
210
|
aiModels_1.EVideoGenModels.GOOGLE_GEMINI_OMNI_FLASH,
|
|
206
211
|
// REMOVED FOR v2 — kept for reference: Veo 3.0 shut down 2026-06-30.
|
|
207
212
|
// EVideoGenModels.GOOGLE_VEO_3,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateVideo.tool.d.ts","sourceRoot":"","sources":["../../../../src/services/agent/tools/generateVideo.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAM5D,OAAO,EAAgB,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"generateVideo.tool.d.ts","sourceRoot":"","sources":["../../../../src/services/agent/tools/generateVideo.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAM5D,OAAO,EAAgB,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAiC/D,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyDf,CAAC;AAEH,QAAA,MAAM,YAAY;;;;;;iBAOhB,CAAC;AAEH,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAC5C,OAAO,WAAW,EAClB,OAAO,YAAY,CA0IpB,CAAC"}
|
|
@@ -16,7 +16,8 @@ function pickChain(modelKey, isI2V) {
|
|
|
16
16
|
modelKey === aiModels_1.EVideoGenModels.KLING_V2_6 ||
|
|
17
17
|
modelKey === aiModels_1.EVideoGenModels.RUNWAY_GEN4_5 ||
|
|
18
18
|
modelKey === aiModels_1.EVideoGenModels.BYTEDANCE_SEEDANCE_2_5 ||
|
|
19
|
-
modelKey === aiModels_1.EVideoGenModels.BYTEDANCE_SEEDANCE_2_0
|
|
19
|
+
modelKey === aiModels_1.EVideoGenModels.BYTEDANCE_SEEDANCE_2_0 ||
|
|
20
|
+
modelKey === aiModels_1.EVideoGenModels.KLING_V4_0;
|
|
20
21
|
// REMOVED FOR v2 — kept for reference: Sora 2 shut down upstream 2026-09-24.
|
|
21
22
|
// || modelKey.startsWith("openai-sora");
|
|
22
23
|
if (isI2V)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aiGenFactory.service.d.ts","sourceRoot":"","sources":["../../../src/services/aiGen/aiGenFactory.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EACL,iBAAiB,EAEjB,eAAe,EACf,aAAa,EACb,cAAc,EACd,qBAAqB,EAErB,qBAAqB,EAErB,eAAe,EACf,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAkBhC,KAAK,uBAAuB,GAAG,UAAU,wBAAwB,CAAC;AASlE,eAAO,MAAM,gBAAgB,EAAE,OAAO,CACpC,MAAM,CAAC,eAAe,EAAE,uBAAuB,CAAC,
|
|
1
|
+
{"version":3,"file":"aiGenFactory.service.d.ts","sourceRoot":"","sources":["../../../src/services/aiGen/aiGenFactory.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EACL,iBAAiB,EAEjB,eAAe,EACf,aAAa,EACb,cAAc,EACd,qBAAqB,EAErB,qBAAqB,EAErB,eAAe,EACf,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAkBhC,KAAK,uBAAuB,GAAG,UAAU,wBAAwB,CAAC;AASlE,eAAO,MAAM,gBAAgB,EAAE,OAAO,CACpC,MAAM,CAAC,eAAe,EAAE,uBAAuB,CAAC,CAmGjD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,iBAAiB,EACjB,uBAAuB,CA4DxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,eAAe,EACf,uBAAuB,CAMxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,aAAa,EACb,uBAAuB,CAGxB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,cAAc,EAAE,uBAAuB,CAsBzE,CAAC;AAEJ;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAC1C,qBAAqB,EACrB,uBAAuB,CAGxB,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAC1C,qBAAqB,EACrB,uBAAuB,CAGxB,CAAC;AA6BF,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,qBAAqB,GAC9B,wBAAwB,CAM1B;AAED,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,qBAAqB,GAC9B,wBAAwB,CAM1B;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,WAAW,GACpB,wBAAwB,CAmB1B"}
|
|
@@ -78,6 +78,8 @@ exports.videoServicesMap = {
|
|
|
78
78
|
"kling-v3.0": kling_service_1.KlingService,
|
|
79
79
|
"kling-v3.0-turbo": kling_service_1.KlingService,
|
|
80
80
|
"kling-v3.0-omni": kling_service_1.KlingService,
|
|
81
|
+
"kling-v4.0": kling_service_1.KlingService,
|
|
82
|
+
"kling-v4.0-flash": kling_service_1.KlingService,
|
|
81
83
|
"kling-avatar": kling_service_1.KlingService,
|
|
82
84
|
"kling-video-o1": kling_service_1.KlingService,
|
|
83
85
|
"kling-v3-omni-video": kling_service_1.KlingService,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bytedance.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/bytedance/bytedance.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AA8BlB;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQlF;AAsBD,qBAAa,gBAAiB,SAAQ,wBAAwB;IAC5D,OAAO,CAAC,QAAQ,CAAC,OAAO,CACsD;IAQ9E,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,WAAW;IAIb,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAyR3B,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"bytedance.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/bytedance/bytedance.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AA8BlB;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQlF;AAsBD,qBAAa,gBAAiB,SAAQ,wBAAwB;IAC5D,OAAO,CAAC,QAAQ,CAAC,OAAO,CACsD;IAQ9E,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,WAAW;IAIb,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAyR3B,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA+JjD;;;;;;;;;;;OAWG;IACG,aAAa,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAyIlF,+EAA+E;YACjE,mBAAmB;IAoCjC;;;OAGG;YACW,eAAe;IAyD7B,aAAa,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM;CAsFjD"}
|
|
@@ -347,6 +347,17 @@ class ByteDanceService extends baseAiGenProvider_service_1.BaseAiGenProviderServ
|
|
|
347
347
|
errorMessage: "user_input_error: This model couldn't process your input image. Please re-save it as a standard JPEG or PNG (or use a different image) and try again.",
|
|
348
348
|
};
|
|
349
349
|
}
|
|
350
|
+
// Async "Invalid input image" — ModelArk accepted the task, then
|
|
351
|
+
// rejected the image itself. Seen on in-spec uploads (1080x2400 and
|
|
352
|
+
// 1080x646 JPEGs, prod 2026-10-31..11-02), so it's a content-level
|
|
353
|
+
// rejection of that image, not a request we built wrong. User-fixable,
|
|
354
|
+
// so don't page.
|
|
355
|
+
if (errCode === "InvalidParameter" && /invalid input image/i.test(errMessage)) {
|
|
356
|
+
return {
|
|
357
|
+
status: types_1.EVideoSceneStatus.FAILED,
|
|
358
|
+
errorMessage: "user_input_error: This model couldn't use your input image. Please try a different image, or pick another model, and try again.",
|
|
359
|
+
};
|
|
360
|
+
}
|
|
350
361
|
return {
|
|
351
362
|
status: types_1.EVideoSceneStatus.FAILED,
|
|
352
363
|
errorMessage: data.error
|
|
@@ -629,6 +640,12 @@ class ByteDanceService extends baseAiGenProvider_service_1.BaseAiGenProviderServ
|
|
|
629
640
|
if (resp.status === 400) {
|
|
630
641
|
throw new errors_1.UserFacingError(message, errors_1.USER_FACING_ERROR_CODES.CAPABILITY_MISMATCH);
|
|
631
642
|
}
|
|
643
|
+
// Model not activated on our Ark account (prod 2026-11-01, 5.0 Pro, HTTP
|
|
644
|
+
// 404). Same treatment as the video path: operator action, still pages
|
|
645
|
+
// via PROVIDER_AUTH_ERROR, but typed instead of a raw Error.
|
|
646
|
+
if (code === "ModelNotOpen" || code.startsWith("ModelNotOpen")) {
|
|
647
|
+
throw new errors_1.UserFacingError(`ByteDance model ${String(body.model)} is not activated on the Ark account: ${message}`, errors_1.USER_FACING_ERROR_CODES.PROVIDER_AUTH_ERROR);
|
|
648
|
+
}
|
|
632
649
|
throw new Error(`seedream images failed (${resp.status}): ${code} ${message}`);
|
|
633
650
|
}
|
|
634
651
|
getCreditUsed(params) {
|
|
@@ -58,6 +58,12 @@ export declare class KlingService extends BaseAiGenProviderService {
|
|
|
58
58
|
* envelope, auth and poller.
|
|
59
59
|
*/
|
|
60
60
|
private generateOmni2Video;
|
|
61
|
+
/**
|
|
62
|
+
* Kling 4.0 / 4.0 Flash submit (API 2.0). buildKling4VideoBody picks the
|
|
63
|
+
* endpoint (text-to-video / image-to-video / omni-video) from the inputs;
|
|
64
|
+
* envelope, auth and poller are Turbo's.
|
|
65
|
+
*/
|
|
66
|
+
private generateKling4Video;
|
|
61
67
|
/**
|
|
62
68
|
* Extend a previously-generated Kling video by ~4-5s. Takes the Kling task id
|
|
63
69
|
* of the source video (must have been generated by this Kling account).
|
|
@@ -80,7 +86,7 @@ export declare class KlingService extends BaseAiGenProviderService {
|
|
|
80
86
|
deleteElement(elementId: string): Promise<void>;
|
|
81
87
|
/**
|
|
82
88
|
* Pick the credential for the surface being called. The API 2.0 key is
|
|
83
|
-
* optional in env — only the API 2.0 models (turbo, 3.0-omni) need it — so its absence must not
|
|
89
|
+
* optional in env — only the API 2.0 models (turbo, 3.0-omni, 4.0) need it — so its absence must not
|
|
84
90
|
* break the JWT models that make up the rest of the catalog. Failing here
|
|
85
91
|
* (rather than letting Kling return an opaque 401) means the scene fails at
|
|
86
92
|
* SUBMIT with no task id, which our refund policy treats as never-billed →
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kling.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/kling/kling.service.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,gBAAgB,EAMjB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"kling.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/kling/kling.service.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,gBAAgB,EAMjB,MAAM,SAAS,CAAC;AAsBjB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,QAAQ,CAAC;AAE7C;;;;;GAKG;AACH,qBAAa,YAAa,SAAQ,wBAAwB;IACxD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuC;IAC/D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAW;IAC3C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAU;IASxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAkD;IAC9E,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAmD;;YAWlE,OAAO;IAiCf,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAuFjC;;;;;;;;OAQG;YACW,kBAAkB;IAgChC;;;;;OAKG;YACW,kBAAkB;IA4BhC;;;;OAIG;YACW,mBAAmB;IA+BjC;;;;OAIG;YACW,WAAW;YA6BX,iBAAiB;YA6BjB,qBAAqB;YAgCrB,eAAe;YAkDf,mBAAmB;YAgCnB,uBAAuB;IAsI/B,gBAAgB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA0B7E,gEAAgE;IAC1D,aAAa,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC;IASrE,sCAAsC;IAChC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAQ/D,kEAAkE;IAC5D,kBAAkB,CAAC,OAAO,SAAI,EAAE,QAAQ,SAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAUlF,0DAA0D;IACpD,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASrD;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;IAiBxB,cAAc,IAAI,MAAM;IAexB,aAAa,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM;CAGjD"}
|
|
@@ -105,6 +105,9 @@ class KlingService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
105
105
|
if (params.modelKey === "kling-v3.0-omni") {
|
|
106
106
|
return this.generateOmni2Video(params);
|
|
107
107
|
}
|
|
108
|
+
if (klingRequests_1.KLING_4_MODEL_KEYS.includes(params.modelKey)) {
|
|
109
|
+
return this.generateKling4Video(params);
|
|
110
|
+
}
|
|
108
111
|
const modelId = aiModels_1.aiModelConfigs[params.modelKey]?.modelId;
|
|
109
112
|
if (!modelId)
|
|
110
113
|
throw new Error(`Unknown modelKey: ${params.modelKey}`);
|
|
@@ -171,6 +174,30 @@ class KlingService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
171
174
|
});
|
|
172
175
|
return { task: task.data.id, status: types_1.EVideoSceneStatus.TRIGGERED };
|
|
173
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Kling 4.0 / 4.0 Flash submit (API 2.0). buildKling4VideoBody picks the
|
|
179
|
+
* endpoint (text-to-video / image-to-video / omni-video) from the inputs;
|
|
180
|
+
* envelope, auth and poller are Turbo's.
|
|
181
|
+
*/
|
|
182
|
+
async generateKling4Video(params) {
|
|
183
|
+
const modelId = aiModels_1.aiModelConfigs[params.modelKey]?.modelId;
|
|
184
|
+
if (!modelId)
|
|
185
|
+
throw new Error(`Unknown modelKey: ${params.modelKey}`);
|
|
186
|
+
const { endpoint, body } = (0, klingRequests_1.buildKling4VideoBody)(params);
|
|
187
|
+
const starttime = Date.now();
|
|
188
|
+
const task = await this.requestWithTimeoutRetry(`/${endpoint}/${modelId}`, "POST", body, 4, this.generateTimeout, "apiKey");
|
|
189
|
+
logger_1.logger.info("Kling generateKling4Video submitted", {
|
|
190
|
+
modelKey: params.modelKey,
|
|
191
|
+
modelId,
|
|
192
|
+
endpoint,
|
|
193
|
+
contentTypes: "contents" in body ? body.contents.map((c) => c.type) : ["prompt"],
|
|
194
|
+
resolution: body.settings.resolution,
|
|
195
|
+
duration: body.settings.duration,
|
|
196
|
+
taskId: task.data.id,
|
|
197
|
+
durationMs: Date.now() - starttime,
|
|
198
|
+
});
|
|
199
|
+
return { task: task.data.id, status: types_1.EVideoSceneStatus.TRIGGERED };
|
|
200
|
+
}
|
|
174
201
|
/**
|
|
175
202
|
* Extend a previously-generated Kling video by ~4-5s. Takes the Kling task id
|
|
176
203
|
* of the source video (must have been generated by this Kling account).
|
|
@@ -393,7 +420,9 @@ class KlingService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
393
420
|
// API 2.0 task — different endpoint, array response, and "succeeded" vs
|
|
394
421
|
// v1's "succeed". The v1 prober would 404 down its whole endpoint list and
|
|
395
422
|
// report the task missing.
|
|
396
|
-
if (params.modelKey === "kling-v3.0-turbo" ||
|
|
423
|
+
if (params.modelKey === "kling-v3.0-turbo" ||
|
|
424
|
+
params.modelKey === "kling-v3.0-omni" ||
|
|
425
|
+
klingRequests_1.KLING_4_MODEL_KEYS.includes(params.modelKey)) {
|
|
397
426
|
return (0, klingStatus_1.checkTurboVideoStatus)(deps, params);
|
|
398
427
|
}
|
|
399
428
|
return (0, klingStatus_1.checkRegularVideoStatus)(deps, params);
|
|
@@ -424,7 +453,7 @@ class KlingService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
424
453
|
}
|
|
425
454
|
/**
|
|
426
455
|
* Pick the credential for the surface being called. The API 2.0 key is
|
|
427
|
-
* optional in env — only the API 2.0 models (turbo, 3.0-omni) need it — so its absence must not
|
|
456
|
+
* optional in env — only the API 2.0 models (turbo, 3.0-omni, 4.0) need it — so its absence must not
|
|
428
457
|
* break the JWT models that make up the rest of the catalog. Failing here
|
|
429
458
|
* (rather than letting Kling return an opaque 401) means the scene fails at
|
|
430
459
|
* SUBMIT with no task id, which our refund policy treats as never-billed →
|
|
@@ -436,7 +465,7 @@ class KlingService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
436
465
|
const apiKey = process.env.KLING_API_KEY;
|
|
437
466
|
if (!apiKey) {
|
|
438
467
|
// Operator detail goes to Loki/Slack; the user sees only the safe copy.
|
|
439
|
-
logger_1.logger.error("KLING_API_KEY is not set — Kling API 2.0 models (kling-v3.0-turbo, kling-v3.0-omni) need a console-issued API key from https://kling.ai/dev/api-key. The legacy AK/SK JWT is rejected by that surface with HTTP 401 code 1002.");
|
|
468
|
+
logger_1.logger.error("KLING_API_KEY is not set — Kling API 2.0 models (kling-v3.0-turbo, kling-v3.0-omni, kling-v4.0, kling-v4.0-flash) need a console-issued API key from https://kling.ai/dev/api-key. The legacy AK/SK JWT is rejected by that surface with HTTP 401 code 1002.");
|
|
440
469
|
throw new errors_1.UserFacingError("This model is temporarily unavailable. Please pick another model.", errors_1.USER_FACING_ERROR_CODES.PROVIDER_AUTH_ERROR);
|
|
441
470
|
}
|
|
442
471
|
return apiKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"klingCredits.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/kling/klingCredits.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG7C;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,IAAI,EAAE,aAAa,EACnB,QAAY,EACZ,SAAiB,EACjB,KAAa,EACb,SAAS,EACT,UAAU,GACX,EAAE,iBAAiB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"klingCredits.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/kling/klingCredits.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG7C;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,IAAI,EAAE,aAAa,EACnB,QAAY,EACZ,SAAiB,EACjB,KAAa,EACb,SAAS,EACT,UAAU,GACX,EAAE,iBAAiB,GAAG,MAAM,CAqG5B"}
|
|
@@ -53,6 +53,19 @@ function getKlingCreditUsed({ modelKey, mode: requestedMode, duration = 5, multi
|
|
|
53
53
|
const perSecond = table?.[res] ?? 0.168;
|
|
54
54
|
return (0, helpers_1.getCreditsFromCost)(perSecond * duration, applyFloor);
|
|
55
55
|
}
|
|
56
|
+
// Kling 4.0 / Flash: per second by resolution, audio always included. With
|
|
57
|
+
// an input video Kling bills a 0.6× rate on (output × 2) seconds when the
|
|
58
|
+
// input is no longer than the output, else on (input + output). Input
|
|
59
|
+
// length isn't known here, so the common output × 2 case is billed.
|
|
60
|
+
if (klingRequests_1.KLING_4_MODEL_KEYS.includes(modelKey)) {
|
|
61
|
+
const res = (0, klingRequests_1.resolveKling4Resolution)(modelKey, resolution, requestedMode);
|
|
62
|
+
if (inputType === "video") {
|
|
63
|
+
const perSecond = modelConfig?.cost?.videoInputPerSecondByResolution?.[res] ?? 0.141;
|
|
64
|
+
return (0, helpers_1.getCreditsFromCost)(perSecond * duration * 2, applyFloor);
|
|
65
|
+
}
|
|
66
|
+
const perSecond = modelConfig?.cost?.perSecondByResolution?.[res] ?? 0.235;
|
|
67
|
+
return (0, helpers_1.getCreditsFromCost)(perSecond * duration, applyFloor);
|
|
68
|
+
}
|
|
56
69
|
// v2.6 splits cost by audio/noAudio tier (audio is 2× upcharge).
|
|
57
70
|
if (modelKey === "kling-v2.6") {
|
|
58
71
|
const branch = audio ? modelConfig?.cost?.audio : modelConfig?.cost?.noAudio;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VideoGenerationParams } from "../types";
|
|
2
2
|
import type { MultiShot } from "../../canonicalAdapters/multiShot.types";
|
|
3
|
-
import { KlingAvatarGenerateRequest, KlingImageToVideoRequest, KlingLipSyncRequest, KlingMotionControlRequest, KlingOmniVideoRequest, KlingOmni2Request, KlingOmni2Resolution, KlingTurboImageToVideoRequest, KlingTurboTextToVideoRequest, KlingVideoGenerateRequest } from "./types";
|
|
3
|
+
import { Kling4ContentsRequest, Kling4Endpoint, Kling4Resolution, Kling4TextToVideoRequest, KlingAvatarGenerateRequest, KlingImageToVideoRequest, KlingLipSyncRequest, KlingMotionControlRequest, KlingOmniVideoRequest, KlingOmni2Request, KlingOmni2Resolution, KlingTurboImageToVideoRequest, KlingTurboTextToVideoRequest, KlingVideoGenerateRequest } from "./types";
|
|
4
4
|
/**
|
|
5
5
|
* Canonical multiShot → Kling 3.0's prompt-encoded storyboard,
|
|
6
6
|
* "shot 1, 3, words; shot 2, 2, words;" (kling.ai/document-api/api/video/
|
|
@@ -72,4 +72,29 @@ export declare function resolveKlingOmni2Resolution(resolution: string | undefin
|
|
|
72
72
|
* an opaque provider 400.
|
|
73
73
|
*/
|
|
74
74
|
export declare function buildOmni2VideoBody(params: VideoGenerationParams): KlingOmni2Request;
|
|
75
|
+
/** Model keys served by buildKling4VideoBody (path segment = config modelId). */
|
|
76
|
+
export declare const KLING_4_MODEL_KEYS: readonly string[];
|
|
77
|
+
/**
|
|
78
|
+
* Output resolution for Kling 4.0. Flash is 720p-only. Otherwise an explicit
|
|
79
|
+
* `resolution` wins, then std→720p / pro→1080p. Never left to Kling: its
|
|
80
|
+
* default is 1080p (1.5× the 720p rate). Shared with getKlingCreditUsed so
|
|
81
|
+
* the billed tier is always the requested tier.
|
|
82
|
+
*/
|
|
83
|
+
export declare function resolveKling4Resolution(modelKey: string, resolution: string | undefined, mode: string | undefined): Kling4Resolution;
|
|
84
|
+
/**
|
|
85
|
+
* Kling 4.0 / 4.0 Flash body + endpoint. One model, three API 2.0 paths:
|
|
86
|
+
* • omni-video any reference image, reference/base video or element
|
|
87
|
+
* • image-to-video first frame (and, on 4.0, a last frame)
|
|
88
|
+
* • text-to-video prompt only (top-level `prompt`, not contents[])
|
|
89
|
+
* Canonical params map like kling-3.0-omni's (refer_image → image_n,
|
|
90
|
+
* feature_video/base_video → video_n, element → element_n) so prompts cite
|
|
91
|
+
* inputs the same way across Kling Omni models.
|
|
92
|
+
*
|
|
93
|
+
* Kling's combination caps are enforced here so a bad mix fails at submit
|
|
94
|
+
* (no task id → full refund) with a readable message, not a provider 400.
|
|
95
|
+
*/
|
|
96
|
+
export declare function buildKling4VideoBody(params: VideoGenerationParams): {
|
|
97
|
+
endpoint: Kling4Endpoint;
|
|
98
|
+
body: Kling4TextToVideoRequest | Kling4ContentsRequest;
|
|
99
|
+
};
|
|
75
100
|
//# sourceMappingURL=klingRequests.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"klingRequests.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/kling/klingRequests.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE,OAAO,
|
|
1
|
+
{"version":3,"file":"klingRequests.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/kling/klingRequests.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE,OAAO,EAGL,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAEhB,wBAAwB,EAExB,0BAA0B,EAE1B,wBAAwB,EACxB,mBAAmB,EAEnB,yBAAyB,EACzB,qBAAqB,EAGrB,iBAAiB,EACjB,oBAAoB,EAGpB,6BAA6B,EAI7B,4BAA4B,EAC5B,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAcjB;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAgBjF;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,MAAM,GACd,yBAAyB,GAAG,wBAAwB,CA+DtD;AAED,uEAAuE;AACvE,wBAAgB,eAAe,CAC7B,MAAM,EAAE,qBAAqB,GAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzB;AAED,gFAAgF;AAChF,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,MAAM,GACd,qBAAqB,CA+CvB;AAED,sEAAsE;AACtE,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,MAAM,GACd,yBAAyB,CAc3B;AAED,iDAAiD;AACjD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,qBAAqB,GAC5B,0BAA0B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