@shop-os/modelkit 0.25.1 → 0.26.1
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 +27 -0
- package/dist/catalog.cjs +175 -18
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +48 -1
- package/dist/catalog.d.ts +48 -1
- package/dist/catalog.js +175 -18
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +669 -225
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -1
- package/dist/index.d.ts +48 -1
- package/dist/index.js +668 -225
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -32,13 +32,13 @@ var ModelKitError = class _ModelKitError extends Error {
|
|
|
32
32
|
this.finishReason = init.finishReason;
|
|
33
33
|
this.usage = init.usage;
|
|
34
34
|
}
|
|
35
|
-
withUsage(
|
|
35
|
+
withUsage(usage6) {
|
|
36
36
|
const init = {
|
|
37
37
|
code: this.code,
|
|
38
38
|
message: this.message,
|
|
39
39
|
cause: this.cause,
|
|
40
40
|
retryable: this.retryable,
|
|
41
|
-
usage:
|
|
41
|
+
usage: usage6
|
|
42
42
|
};
|
|
43
43
|
if (this.provider !== void 0) init.provider = this.provider;
|
|
44
44
|
if (this.model !== void 0) init.model = this.model;
|
|
@@ -378,7 +378,8 @@ var FAL_IMAGE_MODELS = [
|
|
|
378
378
|
constraints: {
|
|
379
379
|
aspectRatios: [...KLING_RATIOS, "adaptive"],
|
|
380
380
|
sizes: ["2K", "4K", "8K"],
|
|
381
|
-
|
|
381
|
+
// fal refuses a reference under 300x300 (422 image_too_small, prod COWORK-5S).
|
|
382
|
+
references: { images: 10, imagePixels: { minWidth: 300, minHeight: 300 } },
|
|
382
383
|
supports: ["count"],
|
|
383
384
|
prompt: { referenceSyntax: "numbered", maxChars: 21e3 }
|
|
384
385
|
},
|
|
@@ -2401,6 +2402,94 @@ var GEMINI_TTS_VOICES = [
|
|
|
2401
2402
|
{ id: "Zubenelgenubi", name: "Zubenelgenubi" }
|
|
2402
2403
|
];
|
|
2403
2404
|
|
|
2405
|
+
// src/catalog/speech-gemini-direct.ts
|
|
2406
|
+
var GOOGLE_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png";
|
|
2407
|
+
var GEMINI_VOICE_CONSENT = {
|
|
2408
|
+
"ar-XA": "\u0623\u0646\u0627 \u0645\u0627\u0644\u0643 \u0647\u0630\u0627 \u0627\u0644\u0635\u0648\u062A \u0648\u0623\u0648\u0627\u0641\u0642 \u0639\u0644\u0649 \u0623\u0646 \u062A\u0633\u062A\u062E\u062F\u0645 Google \u0647\u0630\u0627 \u0627\u0644\u0635\u0648\u062A \u0644\u0625\u0646\u0634\u0627\u0621 \u0646\u0645\u0648\u0630\u062C \u0635\u0648\u062A\u064A \u0627\u0635\u0637\u0646\u0627\u0639\u064A.",
|
|
2409
|
+
"bn-IN": "\u0986\u09AE\u09BF \u098F\u0987 \u09AD\u09AF\u09BC\u09C7\u09B8\u09C7\u09B0 \u09AE\u09BE\u09B2\u09BF\u0995 \u098F\u09AC\u0982 \u0986\u09AE\u09BF \u098F\u0995\u099F\u09BF \u09B8\u09BF\u09A8\u09CD\u09A5\u09C7\u099F\u09BF\u0995 \u09AD\u09AF\u09BC\u09C7\u09B8 \u09AE\u09A1\u09C7\u09B2 \u09A4\u09C8\u09B0\u09BF \u0995\u09B0\u09A4\u09C7 \u098F\u0987 \u09AD\u09AF\u09BC\u09C7\u09B8 \u09AC\u09CD\u09AF\u09AC\u09B9\u09BE\u09B0 \u0995\u09B0\u09C7 Google-\u098F\u09B0 \u09B8\u09BE\u09A5\u09C7 \u09B8\u09AE\u09CD\u09AE\u09A4\u09BF \u09A6\u09BF\u099A\u09CD\u099B\u09BF\u0964",
|
|
2410
|
+
"de-DE": "Ich bin der Eigent\xFCmer dieser Stimme und bin damit einverstanden, dass Google diese Stimme zur Erstellung eines synthetischen Stimmmodells verwendet.",
|
|
2411
|
+
"en-AU": "I am the owner of this voice and I consent to Google using this voice to create a synthetic voice model.",
|
|
2412
|
+
"en-GB": "I am the owner of this voice and I consent to Google using this voice to create a synthetic voice model.",
|
|
2413
|
+
"en-IN": "I am the owner of this voice and I consent to Google using this voice to create a synthetic voice model.",
|
|
2414
|
+
"en-US": "I am the owner of this voice and I consent to Google using this voice to create a synthetic voice model.",
|
|
2415
|
+
"es-ES": "Soy el propietario de esta voz y doy mi consentimiento para que Google la utilice para crear un modelo de voz sint\xE9tica.",
|
|
2416
|
+
"es-US": "Soy el propietario de esta voz y doy mi consentimiento para que Google la utilice para crear un modelo de voz sint\xE9tica.",
|
|
2417
|
+
"fr-CA": "Je suis le propri\xE9taire de cette voix et j'autorise Google \xE0 utiliser cette voix pour cr\xE9er un mod\xE8le de voix synth\xE9tique.",
|
|
2418
|
+
"fr-FR": "Je suis le propri\xE9taire de cette voix et j'autorise Google \xE0 utiliser cette voix pour cr\xE9er un mod\xE8le de voix synth\xE9tique.",
|
|
2419
|
+
"gu-IN": "\u0AB9\u0AC1\u0A82 \u0A86 \u0AB5\u0ACB\u0A88\u0AB8\u0AA8\u0ACB \u0AAE\u0ABE\u0AB2\u0ABF\u0A95 \u0A9B\u0AC1\u0A82 \u0A85\u0AA8\u0AC7 \u0AB8\u0ABF\u0AA8\u0ACD\u0AA5\u0AC7\u0A9F\u0ABF\u0A95 \u0AB5\u0ACB\u0A88\u0AB8 \u0AAE\u0ACB\u0AA1\u0AB2 \u0AAC\u0AA8\u0ABE\u0AB5\u0AB5\u0ABE \u0AAE\u0ABE\u0A9F\u0AC7 \u0A86 \u0AB5\u0ACB\u0A88\u0AB8\u0AA8\u0ACB \u0A89\u0AAA\u0AAF\u0ACB\u0A97 \u0A95\u0AB0\u0AC0\u0AA8\u0AC7 google \u0AA8\u0AC7 \u0AB9\u0AC1\u0A82 \u0AB8\u0A82\u0AAE\u0AA4\u0ABF \u0A86\u0AAA\u0AC1\u0A82 \u0A9B\u0AC1\u0A82",
|
|
2420
|
+
"hi-IN": "\u092E\u0948\u0902 \u0907\u0938 \u0906\u0935\u093E\u091C \u0915\u093E \u092E\u093E\u0932\u093F\u0915 \u0939\u0942\u0902 \u0914\u0930 \u092E\u0948\u0902 \u0938\u093F\u0902\u0925\u0947\u091F\u093F\u0915 \u0906\u0935\u093E\u091C \u092E\u0949\u0921\u0932 \u092C\u0928\u093E\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F Google \u0915\u094B \u0907\u0938 \u0906\u0935\u093E\u091C \u0915\u093E \u0909\u092A\u092F\u094B\u0917 \u0915\u0930\u0928\u0947 \u0915\u0940 \u0938\u0939\u092E\u0924\u093F \u0926\u0947\u0924\u093E \u0939\u0942\u0902",
|
|
2421
|
+
"id-ID": "Saya pemilik suara ini dan saya menyetujui Google menggunakan suara ini untuk membuat model suara sintetis.",
|
|
2422
|
+
"it-IT": "Sono il proprietario di questa voce e acconsento che Google la utilizzi per creare un modello di voce sintetica.",
|
|
2423
|
+
"ja-JP": "\u79C1\u306F\u3053\u306E\u97F3\u58F0\u306E\u6240\u6709\u8005\u3067\u3042\u308A\u3001Google\u304C\u3053\u306E\u97F3\u58F0\u3092\u4F7F\u7528\u3057\u3066\u97F3\u58F0\u5408\u6210\u30E2\u30C7\u30EB\u3092\u4F5C\u6210\u3059\u308B\u3053\u3068\u3092\u627F\u8A8D\u3057\u307E\u3059\u3002",
|
|
2424
|
+
"kn-IN": "\u0CA8\u0CBE\u0CA8\u0CC1 \u0C88 \u0CA7\u0CCD\u0CB5\u0CA8\u0CBF\u0CAF \u0CAE\u0CBE\u0CB2\u0CBF\u0C95 \u0CAE\u0CA4\u0CCD\u0CA4\u0CC1 \u0CB8\u0C82\u0CB6\u0CCD\u0CB2\u0CC7\u0CB7\u0CBF\u0CA4 \u0CA7\u0CCD\u0CB5\u0CA8\u0CBF \u0CAE\u0CBE\u0CA6\u0CB0\u0CBF\u0CAF\u0CA8\u0CCD\u0CA8\u0CC1 \u0CB0\u0C9A\u0CBF\u0CB8\u0CB2\u0CC1 \u0C88 \u0CA7\u0CCD\u0CB5\u0CA8\u0CBF\u0CAF\u0CA8\u0CCD\u0CA8\u0CC1 \u0CAC\u0CB3\u0CB8\u0CBF\u0C95\u0CCA\u0C82\u0CA1\u0CC1\u0C97\u0CC2\u0C97\u0CB2\u0CCD \u0C97\u0CC6 \u0CA8\u0CBE\u0CA8\u0CC1 \u0CB8\u0CAE\u0CCD\u0CAE\u0CA4\u0CBF\u0CB8\u0CC1\u0CA4\u0CCD\u0CA4\u0CC7\u0CA8\u0CC6.",
|
|
2425
|
+
"ko-KR": "\uB098\uB294 \uC774 \uC74C\uC131\uC758 \uC18C\uC720\uC790\uC774\uBA70 \uAD6C\uAE00\uC774 \uC774 \uC74C\uC131\uC744 \uC0AC\uC6A9\uD558\uC5EC \uC74C\uC131 \uD569\uC131 \uBAA8\uB378\uC744 \uC0DD\uC131\uD560 \uAC83\uC744 \uD5C8\uC6A9\uD569\uB2C8\uB2E4.",
|
|
2426
|
+
"ml-IN": "\u0D08 \u0D36\u0D2C\u0D4D\u0D26\u0D24\u0D4D\u0D24\u0D3F\u0D28\u0D4D\u0D31\u0D46 \u0D09\u0D1F\u0D2E \u0D1E\u0D3E\u0D28\u0D3E\u0D23\u0D4D, \u0D12\u0D30\u0D41 \u0D38\u0D3F\u0D28\u0D4D\u0D24\u0D31\u0D4D\u0D31\u0D3F\u0D15\u0D4D \u0D35\u0D4B\u0D2F\u0D4D\u0D38\u0D4D \u0D2E\u0D4B\u0D21\u0D7D \u0D38\u0D43\u0D37\u0D4D\u0D1F\u0D3F\u0D15\u0D4D\u0D15\u0D3E\u0D7B \u0D08 \u0D36\u0D2C\u0D4D\u0D26\u0D02 \u0D09\u0D2A\u0D2F\u0D4B\u0D17\u0D3F\u0D15\u0D4D\u0D15\u0D41\u0D28\u0D4D\u0D28\u0D24\u0D3F\u0D28\u0D4D \u0D1E\u0D3E\u0D7B Google-\u0D28\u0D4D \u0D38\u0D2E\u0D4D\u0D2E\u0D24\u0D02 \u0D28\u0D7D\u0D15\u0D41\u0D28\u0D4D\u0D28\u0D41.",
|
|
2427
|
+
"mr-IN": "\u092E\u0940 \u092F\u093E \u0906\u0935\u093E\u091C\u093E\u091A\u093E \u092E\u093E\u0932\u0915 \u0906\u0939\u0947 \u0906\u0923\u093F \u0938\u093F\u0902\u0925\u0947\u091F\u093F\u0915 \u0935\u094D\u0939\u0949\u0907\u0938 \u092E\u0949\u0921\u0947\u0932 \u0924\u092F\u093E\u0930 \u0915\u0930\u0923\u094D\u092F\u093E\u0938\u093E\u0920\u0940 \u0939\u093E \u0906\u0935\u093E\u091C \u0935\u093E\u092A\u0930\u0923\u094D\u092F\u093E\u0938\u093E\u0920\u0940 \u092E\u0940 Google \u0932\u093E \u0938\u0902\u092E\u0924\u0940 \u0926\u0947\u0924\u094B",
|
|
2428
|
+
"nl-NL": "Ik ben de eigenaar van deze stem en ik geef Google toestemming om deze stem te gebruiken om een synthetisch stemmodel te maken.",
|
|
2429
|
+
"pl-PL": "Jestem w\u0142a\u015Bcicielem tego g\u0142osu i wyra\u017Cam zgod\u0119 na wykorzystanie go przez Google w celu utworzenia syntetycznego modelu g\u0142osu.",
|
|
2430
|
+
"pt-BR": "Eu sou o propriet\xE1rio desta voz e autorizo o Google a us\xE1-la para criar um modelo de voz sint\xE9tica.",
|
|
2431
|
+
"ru-RU": "\u042F \u044F\u0432\u043B\u044F\u044E\u0441\u044C \u0432\u043B\u0430\u0434\u0435\u043B\u044C\u0446\u0435\u043C \u044D\u0442\u043E\u0433\u043E \u0433\u043E\u043B\u043E\u0441\u0430 \u0438 \u0434\u0430\u044E \u0441\u043E\u0433\u043B\u0430\u0441\u0438\u0435 Google \u043D\u0430 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435 \u044D\u0442\u043E\u0433\u043E \u0433\u043E\u043B\u043E\u0441\u0430 \u0434\u043B\u044F \u0441\u043E\u0437\u0434\u0430\u043D\u0438\u044F \u043C\u043E\u0434\u0435\u043B\u0438 \u0441\u0438\u043D\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043A\u043E\u0433\u043E \u0433\u043E\u043B\u043E\u0441\u0430.",
|
|
2432
|
+
"ta-IN": "\u0BA8\u0BBE\u0BA9\u0BCD \u0B87\u0BA8\u0BCD\u0BA4 \u0B95\u0BC1\u0BB0\u0BB2\u0BBF\u0BA9\u0BCD \u0B89\u0BB0\u0BBF\u0BAE\u0BC8\u0BAF\u0BBE\u0BB3\u0BB0\u0BCD \u0BAE\u0BB1\u0BCD\u0BB1\u0BC1\u0BAE\u0BCD \u0B9A\u0BC6\u0BAF\u0BB1\u0BCD\u0B95\u0BC8 \u0B95\u0BC1\u0BB0\u0BB2\u0BCD \u0BAE\u0BBE\u0BA4\u0BBF\u0BB0\u0BBF\u0BAF\u0BC8 \u0B89\u0BB0\u0BC1\u0BB5\u0BBE\u0B95\u0BCD\u0B95 \u0B87\u0BA8\u0BCD\u0BA4 \u0B95\u0BC1\u0BB0\u0BB2\u0BC8 \u0BAA\u0BAF\u0BA9\u0BCD\u0BAA\u0B9F\u0BC1\u0BA4\u0BCD\u0BA4 \u0B95\u0BC1\u0B95\u0BB2\u0BCD\u0B95\u0BCD\u0B95\u0BC1 \u0BA8\u0BBE\u0BA9\u0BCD \u0B92\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BCD\u0B95\u0BCA\u0BB3\u0BCD\u0B95\u0BBF\u0BB1\u0BC7\u0BA9\u0BCD.",
|
|
2433
|
+
"te-IN": "\u0C28\u0C47\u0C28\u0C41 \u0C08 \u0C35\u0C3E\u0C2F\u0C3F\u0C38\u0C4D \u0C2F\u0C1C\u0C2E\u0C3E\u0C28\u0C3F\u0C28\u0C3F \u0C2E\u0C30\u0C3F\u0C2F\u0C41 \u0C38\u0C3F\u0C02\u0C24\u0C1F\u0C3F\u0C15\u0C4D \u0C35\u0C3E\u0C2F\u0C3F\u0C38\u0C4D \u0C2E\u0C4B\u0C21\u0C32\u0C4D \u0C28\u0C3F \u0C30\u0C42\u0C2A\u0C4A\u0C02\u0C26\u0C3F\u0C02\u0C1A\u0C21\u0C3E\u0C28\u0C3F\u0C15\u0C3F \u0C08 \u0C35\u0C3E\u0C2F\u0C3F\u0C38\u0C4D \u0C28\u0C3F \u0C09\u0C2A\u0C2F\u0C4B\u0C17\u0C3F\u0C02\u0C1A\u0C21\u0C3E\u0C28\u0C3F\u0C15\u0C3F google\u0C15\u0C3F \u0C28\u0C47\u0C28\u0C41 \u0C38\u0C2E\u0C4D\u0C2E\u0C24\u0C3F\u0C38\u0C4D\u0C24\u0C41\u0C28\u0C4D\u0C28\u0C3E\u0C28\u0C41.",
|
|
2434
|
+
"th-TH": "\u0E09\u0E31\u0E19\u0E40\u0E1B\u0E47\u0E19\u0E40\u0E08\u0E49\u0E32\u0E02\u0E2D\u0E07\u0E40\u0E2A\u0E35\u0E22\u0E07\u0E19\u0E35\u0E49 \u0E41\u0E25\u0E30\u0E09\u0E31\u0E19\u0E22\u0E34\u0E19\u0E22\u0E2D\u0E21\u0E43\u0E2B\u0E49 Google \u0E43\u0E0A\u0E49\u0E40\u0E2A\u0E35\u0E22\u0E07\u0E19\u0E35\u0E49\u0E40\u0E1E\u0E37\u0E48\u0E2D\u0E2A\u0E23\u0E49\u0E32\u0E07\u0E41\u0E1A\u0E1A\u0E08\u0E33\u0E25\u0E2D\u0E07\u0E40\u0E2A\u0E35\u0E22\u0E07\u0E2A\u0E31\u0E07\u0E40\u0E04\u0E23\u0E32\u0E30\u0E2B\u0E4C",
|
|
2435
|
+
"tr-TR": "Bu sesin sahibi benim ve Google'\u0131n bu sesi kullanarak sentetik bir ses modeli olu\u015Fturmas\u0131na izin veriyorum.",
|
|
2436
|
+
"vi-VN": "T\xF4i l\xE0 ch\u1EE7 s\u1EDF h\u1EEFu gi\u1ECDng n\xF3i n\xE0y v\xE0 t\xF4i \u0111\u1ED3ng \xFD cho Google s\u1EED d\u1EE5ng gi\u1ECDng n\xF3i n\xE0y \u0111\u1EC3 t\u1EA1o m\xF4 h\xECnh gi\u1ECDng n\xF3i t\u1ED5ng h\u1EE3p.",
|
|
2437
|
+
"zh-CN": "\u6211\u662F\u6B64\u58F0\u97F3\u7684\u62E5\u6709\u8005\u5E76\u6388\u6743\u8C37\u6B4C\u4F7F\u7528\u6B64\u58F0\u97F3\u521B\u5EFA\u8BED\u97F3\u5408\u6210\u6A21\u578B"
|
|
2438
|
+
};
|
|
2439
|
+
var GEMINI_DIRECT_MODELS = [
|
|
2440
|
+
{
|
|
2441
|
+
id: "gemini-3.8-flash-tts-direct",
|
|
2442
|
+
aliases: [],
|
|
2443
|
+
label: "Gemini 3.8 Flash TTS",
|
|
2444
|
+
type: "speech",
|
|
2445
|
+
adapter: "google-genai",
|
|
2446
|
+
providerModelId: "gemini-3.8-flash-tts",
|
|
2447
|
+
lifecycle: "active",
|
|
2448
|
+
exposure: ["cowork"],
|
|
2449
|
+
constraints: {
|
|
2450
|
+
voices: GEMINI_TTS_VOICES,
|
|
2451
|
+
// Returns a 24 kHz mono WAV; the language is detected from the script.
|
|
2452
|
+
supports: ["style"],
|
|
2453
|
+
// Google's docs state no script limit; fal gives 8,192 input tokens for this model
|
|
2454
|
+
// (a token is at least one character), so the same cap is kept here.
|
|
2455
|
+
prompt: { referenceSyntax: "numbered", maxChars: 8192 }
|
|
2456
|
+
},
|
|
2457
|
+
defaults: { voice: "Kore" },
|
|
2458
|
+
usage: { unit: "images" },
|
|
2459
|
+
pricingKind: "flat",
|
|
2460
|
+
display: {
|
|
2461
|
+
provider: "google",
|
|
2462
|
+
logo: GOOGLE_LOGO,
|
|
2463
|
+
description: "Google Gemini 3.8 Flash text to speech in 30 prebuilt voices or your own replicated voice, with separate style instructions."
|
|
2464
|
+
},
|
|
2465
|
+
capabilities: { customVoices: true }
|
|
2466
|
+
},
|
|
2467
|
+
{
|
|
2468
|
+
id: "gemini-voice-clone",
|
|
2469
|
+
aliases: [],
|
|
2470
|
+
label: "Gemini Voice Replication",
|
|
2471
|
+
type: "voice-clone",
|
|
2472
|
+
adapter: "google-genai",
|
|
2473
|
+
providerModelId: "gemini-3.8-flash-tts",
|
|
2474
|
+
lifecycle: "active",
|
|
2475
|
+
exposure: ["cowork"],
|
|
2476
|
+
constraints: {
|
|
2477
|
+
// One 10-30 s recording, plus the consent recording. Google's samples are WAV.
|
|
2478
|
+
references: { audios: 1, audioFormats: ["wav"], audioSeconds: { min: 10, max: 30 } },
|
|
2479
|
+
supports: []
|
|
2480
|
+
},
|
|
2481
|
+
defaults: {},
|
|
2482
|
+
usage: { unit: "requests" },
|
|
2483
|
+
pricingKind: "flat",
|
|
2484
|
+
display: {
|
|
2485
|
+
provider: "google",
|
|
2486
|
+
logo: GOOGLE_LOGO,
|
|
2487
|
+
description: "Replicate a private, reusable voice from one 10 to 30 second recording and a spoken consent line, then speak with it on Gemini 3.8 Flash TTS."
|
|
2488
|
+
},
|
|
2489
|
+
capabilities: {}
|
|
2490
|
+
}
|
|
2491
|
+
];
|
|
2492
|
+
|
|
2404
2493
|
// src/catalog/voices-minimax.ts
|
|
2405
2494
|
var MINIMAX_VOICES = [
|
|
2406
2495
|
{ id: "Wise_Woman", name: "Wise Woman" },
|
|
@@ -3901,7 +3990,7 @@ var MINIMAX_VOICES = [
|
|
|
3901
3990
|
|
|
3902
3991
|
// src/catalog/media-nodes.ts
|
|
3903
3992
|
var ELEVENLABS_LOGO2 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/elevenlabs.png";
|
|
3904
|
-
var
|
|
3993
|
+
var GOOGLE_LOGO2 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png";
|
|
3905
3994
|
var MINIMAX_LOGO2 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
|
|
3906
3995
|
var SYNC_LOGO = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/sync.png";
|
|
3907
3996
|
var PER_CALL3 = { unit: "images" };
|
|
@@ -3951,7 +4040,7 @@ function geminiTts(id, label, description) {
|
|
|
3951
4040
|
defaults: { voice: "Kore" },
|
|
3952
4041
|
usage: PER_CALL3,
|
|
3953
4042
|
pricingKind: "flat",
|
|
3954
|
-
display: { provider: "google", logo:
|
|
4043
|
+
display: { provider: "google", logo: GOOGLE_LOGO2, description },
|
|
3955
4044
|
capabilities: {}
|
|
3956
4045
|
};
|
|
3957
4046
|
}
|
|
@@ -4197,7 +4286,8 @@ var MEDIA_NODE_MODELS = [
|
|
|
4197
4286
|
},
|
|
4198
4287
|
SAM_3_IMAGE,
|
|
4199
4288
|
...FISH_MODELS,
|
|
4200
|
-
...ELEVENLABS_DIRECT_MODELS
|
|
4289
|
+
...ELEVENLABS_DIRECT_MODELS,
|
|
4290
|
+
...GEMINI_DIRECT_MODELS
|
|
4201
4291
|
];
|
|
4202
4292
|
|
|
4203
4293
|
// src/catalog/model3d.ts
|
|
@@ -4391,9 +4481,67 @@ var MODEL3D_MODELS = [
|
|
|
4391
4481
|
)
|
|
4392
4482
|
];
|
|
4393
4483
|
|
|
4394
|
-
// src/catalog/
|
|
4395
|
-
var GOOGLE_LOGO2 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png";
|
|
4484
|
+
// src/catalog/audio-elevenlabs-direct.ts
|
|
4396
4485
|
var ELEVENLABS_LOGO3 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/elevenlabs.png";
|
|
4486
|
+
var ELEVENLABS_DIRECT_AUDIO_MODELS = [
|
|
4487
|
+
{
|
|
4488
|
+
id: "elevenlabs-music-direct",
|
|
4489
|
+
aliases: [],
|
|
4490
|
+
label: "Eleven Music",
|
|
4491
|
+
type: "audio",
|
|
4492
|
+
adapter: "elevenlabs",
|
|
4493
|
+
providerModelId: "music_v2_5",
|
|
4494
|
+
lifecycle: "active",
|
|
4495
|
+
exposure: ["cowork"],
|
|
4496
|
+
constraints: {
|
|
4497
|
+
// The API takes 3 s to 10 min; ElevenLabs' overview says 5 min, so stop there.
|
|
4498
|
+
durations: { min: 3, max: 300 },
|
|
4499
|
+
durationPresets: [30, 60, 120, 180],
|
|
4500
|
+
// No `seed`: the API refuses it with a prompt (composition plans only).
|
|
4501
|
+
supports: ["instrumental"],
|
|
4502
|
+
outputFormats: ELEVENLABS_MUSIC_FORMATS
|
|
4503
|
+
},
|
|
4504
|
+
defaults: { durationSeconds: 60, outputFormat: "mp3_48000_192" },
|
|
4505
|
+
usage: { unit: "seconds" },
|
|
4506
|
+
pricingKind: "flat",
|
|
4507
|
+
display: {
|
|
4508
|
+
provider: "elevenlabs",
|
|
4509
|
+
logo: ELEVENLABS_LOGO3,
|
|
4510
|
+
description: "Songs and instrumentals in any genre, from 3 seconds to 5 minutes."
|
|
4511
|
+
},
|
|
4512
|
+
capabilities: {}
|
|
4513
|
+
},
|
|
4514
|
+
{
|
|
4515
|
+
id: "elevenlabs-sound-effects-direct",
|
|
4516
|
+
aliases: [],
|
|
4517
|
+
label: "Eleven Sound Effects",
|
|
4518
|
+
type: "sound-effect",
|
|
4519
|
+
adapter: "elevenlabs",
|
|
4520
|
+
providerModelId: "eleven_text_to_sound_v3",
|
|
4521
|
+
lifecycle: "active",
|
|
4522
|
+
exposure: ["cowork"],
|
|
4523
|
+
constraints: {
|
|
4524
|
+
durations: { min: 0.5, max: 30 },
|
|
4525
|
+
durationPresets: [2, 5, 10, 22],
|
|
4526
|
+
supports: ["loop"],
|
|
4527
|
+
outputFormats: ELEVENLABS_MP3_FORMATS
|
|
4528
|
+
},
|
|
4529
|
+
// No default length: a request without one gets ElevenLabs' auto length.
|
|
4530
|
+
defaults: { outputFormat: "mp3_44100_128" },
|
|
4531
|
+
usage: { unit: "seconds" },
|
|
4532
|
+
pricingKind: "flat",
|
|
4533
|
+
display: {
|
|
4534
|
+
provider: "elevenlabs",
|
|
4535
|
+
logo: ELEVENLABS_LOGO3,
|
|
4536
|
+
description: "Any sound from a text description, up to 30 seconds, at a set or automatic length; can loop."
|
|
4537
|
+
},
|
|
4538
|
+
capabilities: {}
|
|
4539
|
+
}
|
|
4540
|
+
];
|
|
4541
|
+
|
|
4542
|
+
// src/catalog/other.ts
|
|
4543
|
+
var GOOGLE_LOGO3 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png";
|
|
4544
|
+
var ELEVENLABS_LOGO4 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/elevenlabs.png";
|
|
4397
4545
|
var MINIMAX_LOGO3 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
|
|
4398
4546
|
var OTHER_MODELS = [
|
|
4399
4547
|
{
|
|
@@ -4415,7 +4563,7 @@ var OTHER_MODELS = [
|
|
|
4415
4563
|
pricingKind: "flat",
|
|
4416
4564
|
display: {
|
|
4417
4565
|
provider: "google",
|
|
4418
|
-
logo:
|
|
4566
|
+
logo: GOOGLE_LOGO3,
|
|
4419
4567
|
description: "Google Lyria 3 Clip short music clips, loops, and previews; takes text and up to 10 image prompts and returns a fixed 30-second MP3 plus lyrics."
|
|
4420
4568
|
},
|
|
4421
4569
|
capabilities: {}
|
|
@@ -4438,7 +4586,7 @@ var OTHER_MODELS = [
|
|
|
4438
4586
|
pricingKind: "flat",
|
|
4439
4587
|
display: {
|
|
4440
4588
|
provider: "google",
|
|
4441
|
-
logo:
|
|
4589
|
+
logo: GOOGLE_LOGO3,
|
|
4442
4590
|
description: "Google Lyria 3 Pro flagship music model for full-length songs with verses, choruses, and bridges; takes text and up to 10 image prompts and returns MP3 plus lyrics."
|
|
4443
4591
|
},
|
|
4444
4592
|
capabilities: {}
|
|
@@ -4530,7 +4678,7 @@ var OTHER_MODELS = [
|
|
|
4530
4678
|
pricingKind: "flat",
|
|
4531
4679
|
display: {
|
|
4532
4680
|
provider: "google",
|
|
4533
|
-
logo:
|
|
4681
|
+
logo: GOOGLE_LOGO3,
|
|
4534
4682
|
description: "Google Lyria 3.5 full-length songs with verses, choruses and bridges; takes text and up to 10 image prompts and returns 44.1 kHz stereo MP3 plus lyrics."
|
|
4535
4683
|
},
|
|
4536
4684
|
capabilities: {}
|
|
@@ -4558,7 +4706,7 @@ var OTHER_MODELS = [
|
|
|
4558
4706
|
pricingKind: "flat",
|
|
4559
4707
|
display: {
|
|
4560
4708
|
provider: "elevenlabs",
|
|
4561
|
-
logo:
|
|
4709
|
+
logo: ELEVENLABS_LOGO4,
|
|
4562
4710
|
description: "ElevenLabs Music v2.5 text-to-music; full songs or instrumentals from 3 seconds to 1 minute."
|
|
4563
4711
|
},
|
|
4564
4712
|
capabilities: {}
|
|
@@ -4610,7 +4758,7 @@ var OTHER_MODELS = [
|
|
|
4610
4758
|
pricingKind: "flat",
|
|
4611
4759
|
display: {
|
|
4612
4760
|
provider: "elevenlabs",
|
|
4613
|
-
logo:
|
|
4761
|
+
logo: ELEVENLABS_LOGO4,
|
|
4614
4762
|
description: "ElevenLabs Sound Effects v2; a sound effect from a text description, up to 22 seconds."
|
|
4615
4763
|
},
|
|
4616
4764
|
capabilities: {}
|
|
@@ -4746,7 +4894,8 @@ var OTHER_MODELS = [
|
|
|
4746
4894
|
provider: "prodia",
|
|
4747
4895
|
description: "Background removal; takes one input image and returns a PNG cut-out of the subject plus an optional black-and-white mask."
|
|
4748
4896
|
}
|
|
4749
|
-
}
|
|
4897
|
+
},
|
|
4898
|
+
...ELEVENLABS_DIRECT_AUDIO_MODELS
|
|
4750
4899
|
];
|
|
4751
4900
|
|
|
4752
4901
|
// src/catalog/text.ts
|
|
@@ -6018,7 +6167,7 @@ var H3_PROMPT2 = { referenceSyntax: "numbered", maxChars: 5e4 };
|
|
|
6018
6167
|
var WAN_PROMPT = { referenceSyntax: "numbered", maxChars: 2e4 };
|
|
6019
6168
|
var OMNI_PROMPT = { referenceSyntax: "caption", maxChars: 5e4 };
|
|
6020
6169
|
var BYTEDANCE_LOGO2 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/3bba5d81-4e57-4e71-911b-cdfa05acca2c_compressed.png";
|
|
6021
|
-
var
|
|
6170
|
+
var GOOGLE_LOGO4 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png";
|
|
6022
6171
|
var VIDEO_MODELS = [
|
|
6023
6172
|
// Google shuts down the Veo 3.1 previews and Omni Flash 1.0 on 2026-10-22.
|
|
6024
6173
|
{
|
|
@@ -6054,7 +6203,7 @@ var VIDEO_MODELS = [
|
|
|
6054
6203
|
display: {
|
|
6055
6204
|
provider: "google",
|
|
6056
6205
|
description: "Google's highest-quality video generation model. Supports up to 4K resolution and 8-second clips with reference image conditioning.",
|
|
6057
|
-
logo:
|
|
6206
|
+
logo: GOOGLE_LOGO4
|
|
6058
6207
|
},
|
|
6059
6208
|
// Veo's lastFrame "must be used in combination with the image parameter".
|
|
6060
6209
|
capabilities: { ...FRAMES_EXCLUDE_REFERENCES, lastFrameRequiresFirstFrame: true }
|
|
@@ -6155,7 +6304,7 @@ var VIDEO_MODELS = [
|
|
|
6155
6304
|
display: {
|
|
6156
6305
|
provider: "google",
|
|
6157
6306
|
description: "Google's conversational video model with native audio, human support, and natural language editing. Aspect ratio only \u2014 resolution and duration are model-determined.",
|
|
6158
|
-
logo:
|
|
6307
|
+
logo: GOOGLE_LOGO4
|
|
6159
6308
|
},
|
|
6160
6309
|
capabilities: { acceptsSourceVideo: true, videoEdit: true }
|
|
6161
6310
|
},
|
|
@@ -6192,7 +6341,7 @@ var VIDEO_MODELS = [
|
|
|
6192
6341
|
pricingKind: "video_per_second",
|
|
6193
6342
|
display: {
|
|
6194
6343
|
provider: "google",
|
|
6195
|
-
logo:
|
|
6344
|
+
logo: GOOGLE_LOGO4,
|
|
6196
6345
|
description: "Google Gemini Omni Flash 1.1 conversational video generation, editing and extension; text, image, and up to 10-second video input, 3-10 second output at up to 4K and 24 FPS, extendable to 40 seconds."
|
|
6197
6346
|
},
|
|
6198
6347
|
capabilities: {
|
|
@@ -6231,7 +6380,7 @@ var VIDEO_MODELS = [
|
|
|
6231
6380
|
pricingKind: "video_per_second",
|
|
6232
6381
|
display: {
|
|
6233
6382
|
provider: "google",
|
|
6234
|
-
logo:
|
|
6383
|
+
logo: GOOGLE_LOGO4,
|
|
6235
6384
|
description: "Google Gemini Omni Flash 1.2 conversational video generation, editing and extension; text, image, and up to 15-second video input, 3-15 second output at up to 4K and 24 FPS (start and end frames up to 10 seconds), extendable to 30 seconds."
|
|
6236
6385
|
},
|
|
6237
6386
|
capabilities: {
|
|
@@ -8247,6 +8396,7 @@ var SupportedOptionSchema = z3.enum([
|
|
|
8247
8396
|
"videoExtension",
|
|
8248
8397
|
"instrumental",
|
|
8249
8398
|
"lyrics",
|
|
8399
|
+
"loop",
|
|
8250
8400
|
"style",
|
|
8251
8401
|
"insertWindow",
|
|
8252
8402
|
"points",
|
|
@@ -9883,7 +10033,7 @@ async function generateAlibabaImage(req, ctx) {
|
|
|
9883
10033
|
return { bytes: new Uint8Array(await res.arrayBuffer()), mime };
|
|
9884
10034
|
})
|
|
9885
10035
|
);
|
|
9886
|
-
const
|
|
10036
|
+
const usage6 = {
|
|
9887
10037
|
model: modelId,
|
|
9888
10038
|
provider: "alibaba",
|
|
9889
10039
|
modality: "IMAGE",
|
|
@@ -9891,9 +10041,9 @@ async function generateAlibabaImage(req, ctx) {
|
|
|
9891
10041
|
quantity: data.usage?.output_image_count ?? images.length
|
|
9892
10042
|
};
|
|
9893
10043
|
const tier = billedTier(data.usage?.output_image_type, req.size);
|
|
9894
|
-
if (tier !== void 0)
|
|
9895
|
-
if (req.quality !== void 0)
|
|
9896
|
-
return { images, usage:
|
|
10044
|
+
if (tier !== void 0) usage6.imageSize = tier;
|
|
10045
|
+
if (req.quality !== void 0) usage6.imageQuality = req.quality;
|
|
10046
|
+
return { images, usage: usage6, raw: data };
|
|
9897
10047
|
}
|
|
9898
10048
|
|
|
9899
10049
|
// src/adapters/alibaba-video.ts
|
|
@@ -10301,17 +10451,17 @@ var RENDERED = /* @__PURE__ */ new Map([
|
|
|
10301
10451
|
[720, "720p"],
|
|
10302
10452
|
[1080, "1080p"]
|
|
10303
10453
|
]);
|
|
10304
|
-
function settleUsage(
|
|
10454
|
+
function settleUsage(usage6, task) {
|
|
10305
10455
|
const reported = task.usage;
|
|
10306
10456
|
if (reported?.duration !== void 0 && reported.duration > 0) {
|
|
10307
|
-
|
|
10457
|
+
usage6.quantity = reported.duration;
|
|
10308
10458
|
}
|
|
10309
10459
|
const output = reported?.output_video_duration;
|
|
10310
|
-
if (output !== void 0 && output > 0)
|
|
10460
|
+
if (output !== void 0 && output > 0) usage6.durationSeconds = output;
|
|
10311
10461
|
const rendered = reported?.SR === void 0 ? void 0 : RENDERED.get(reported.SR);
|
|
10312
|
-
if (rendered !== void 0)
|
|
10462
|
+
if (rendered !== void 0) usage6.resolution = rendered;
|
|
10313
10463
|
}
|
|
10314
|
-
function alibabaVideoJob(ctx, jobId,
|
|
10464
|
+
function alibabaVideoJob(ctx, jobId, usage6) {
|
|
10315
10465
|
const { key } = alibabaCredentials(ctx);
|
|
10316
10466
|
const modelId = ctx.model.id;
|
|
10317
10467
|
const fetchTask = async () => {
|
|
@@ -10355,10 +10505,10 @@ function alibabaVideoJob(ctx, jobId, usage5) {
|
|
|
10355
10505
|
if (!url) {
|
|
10356
10506
|
throw alibabaError(void 0, "task succeeded with no video_url", modelId);
|
|
10357
10507
|
}
|
|
10358
|
-
settleUsage(
|
|
10508
|
+
settleUsage(usage6, task);
|
|
10359
10509
|
return {
|
|
10360
10510
|
video: { url, expiresAt: new Date(Date.now() + VIDEO_URL_TTL_MS) },
|
|
10361
|
-
usage:
|
|
10511
|
+
usage: usage6,
|
|
10362
10512
|
raw: task
|
|
10363
10513
|
};
|
|
10364
10514
|
}
|
|
@@ -10660,16 +10810,16 @@ async function generateSeedreamImage(req, ctx) {
|
|
|
10660
10810
|
} else {
|
|
10661
10811
|
throwArkError(void 0, "Seedream returned no image URL or base64 data", modelId);
|
|
10662
10812
|
}
|
|
10663
|
-
const
|
|
10813
|
+
const usage6 = {
|
|
10664
10814
|
model: modelId,
|
|
10665
10815
|
provider: "ark",
|
|
10666
10816
|
modality: "IMAGE",
|
|
10667
10817
|
unit: "images",
|
|
10668
10818
|
quantity: 1
|
|
10669
10819
|
};
|
|
10670
|
-
if (req.size !== void 0)
|
|
10671
|
-
if (req.quality !== void 0)
|
|
10672
|
-
return { images: [{ bytes, mime: sniffedImageMime(bytes) }], usage:
|
|
10820
|
+
if (req.size !== void 0) usage6.imageSize = req.size;
|
|
10821
|
+
if (req.quality !== void 0) usage6.imageQuality = req.quality;
|
|
10822
|
+
return { images: [{ bytes, mime: sniffedImageMime(bytes) }], usage: usage6, raw: data };
|
|
10673
10823
|
}
|
|
10674
10824
|
var SeedanceUsageSchema = z10.object({
|
|
10675
10825
|
total_tokens: z10.number().optional(),
|
|
@@ -10724,7 +10874,7 @@ function seedanceErrorCode(error) {
|
|
|
10724
10874
|
const parsed = SeedanceErrorSchema.safeParse(error);
|
|
10725
10875
|
return parsed.success ? parsed.data.code : void 0;
|
|
10726
10876
|
}
|
|
10727
|
-
function seedanceJob(ctx, key, jobId,
|
|
10877
|
+
function seedanceJob(ctx, key, jobId, usage6) {
|
|
10728
10878
|
const modelId = ctx.model.id;
|
|
10729
10879
|
const fetchStatus = async () => {
|
|
10730
10880
|
const res = await arkFetch(ctx, `${arkBaseUrl(ctx)}${SUBMIT_PATH2}/${jobId}`, {
|
|
@@ -10774,21 +10924,21 @@ function seedanceJob(ctx, key, jobId, usage5) {
|
|
|
10774
10924
|
modelId
|
|
10775
10925
|
);
|
|
10776
10926
|
if (polled.duration !== void 0 && polled.duration > 0) {
|
|
10777
|
-
|
|
10778
|
-
|
|
10927
|
+
usage6.quantity = polled.duration;
|
|
10928
|
+
usage6.durationSeconds = polled.duration;
|
|
10779
10929
|
}
|
|
10780
10930
|
const rendered = VideoResolutionSchema.safeParse(
|
|
10781
10931
|
polled.resolution?.toLowerCase()
|
|
10782
10932
|
);
|
|
10783
|
-
if (rendered.success)
|
|
10933
|
+
if (rendered.success) usage6.resolution = rendered.data;
|
|
10784
10934
|
const tokens = polled.usage;
|
|
10785
10935
|
if (tokens?.total_tokens !== void 0 && tokens.completion_tokens !== void 0) {
|
|
10786
|
-
|
|
10787
|
-
|
|
10936
|
+
usage6.inputTokens = tokens.total_tokens - tokens.completion_tokens;
|
|
10937
|
+
usage6.outputTokens = tokens.completion_tokens;
|
|
10788
10938
|
}
|
|
10789
10939
|
return {
|
|
10790
10940
|
video: { url, expiresAt: new Date(Date.now() + VIDEO_URL_TTL_MS2) },
|
|
10791
|
-
usage:
|
|
10941
|
+
usage: usage6,
|
|
10792
10942
|
raw: polled
|
|
10793
10943
|
};
|
|
10794
10944
|
}
|
|
@@ -10941,8 +11091,8 @@ async function generateSeedanceVideo(req, ctx) {
|
|
|
10941
11091
|
if (req.watermark !== void 0) body.watermark = req.watermark;
|
|
10942
11092
|
if (ctx.model.constraints.draft) body.draft = true;
|
|
10943
11093
|
const jobId = await submitSeedanceTask(ctx, key, body);
|
|
10944
|
-
const
|
|
10945
|
-
return seedanceJob(ctx, key, jobId,
|
|
11094
|
+
const usage6 = seedanceUsage(ctx, req, taskType === "edit" ? requestedDuration : duration);
|
|
11095
|
+
return seedanceJob(ctx, key, jobId, usage6);
|
|
10946
11096
|
}
|
|
10947
11097
|
|
|
10948
11098
|
// src/adapters/fal.ts
|
|
@@ -12085,7 +12235,7 @@ async function collectFalPlanImages(payload, plan4, ctx, req) {
|
|
|
12085
12235
|
return { bytes, mime: mime || "image/png" };
|
|
12086
12236
|
})
|
|
12087
12237
|
);
|
|
12088
|
-
const
|
|
12238
|
+
const usage6 = {
|
|
12089
12239
|
model: ctx.model.id,
|
|
12090
12240
|
provider: "fal",
|
|
12091
12241
|
modality: "IMAGE",
|
|
@@ -12093,9 +12243,9 @@ async function collectFalPlanImages(payload, plan4, ctx, req) {
|
|
|
12093
12243
|
quantity: images.length
|
|
12094
12244
|
};
|
|
12095
12245
|
const billedSize = plan4.imageSize ?? req.size;
|
|
12096
|
-
if (billedSize !== void 0 && ctx.model.type === "image")
|
|
12097
|
-
if (plan4.imageQuality !== void 0)
|
|
12098
|
-
const result = { images, usage:
|
|
12246
|
+
if (billedSize !== void 0 && ctx.model.type === "image") usage6.imageSize = billedSize;
|
|
12247
|
+
if (plan4.imageQuality !== void 0) usage6.imageQuality = plan4.imageQuality;
|
|
12248
|
+
const result = { images, usage: usage6, raw: payload };
|
|
12099
12249
|
const remote = files.find((f) => !f.url.startsWith("data:"));
|
|
12100
12250
|
if (remote !== void 0) result.outputUrl = remote.url;
|
|
12101
12251
|
return result;
|
|
@@ -13942,6 +14092,11 @@ var DEFAULT_BASE_URL = "https://api.elevenlabs.io";
|
|
|
13942
14092
|
var DEFAULT_FORMAT = "mp3_44100_128";
|
|
13943
14093
|
var ELEVENLABS_TTS_MODEL_IDS = /* @__PURE__ */ new Set(["eleven_v4"]);
|
|
13944
14094
|
var ELEVENLABS_IVC = "ivc";
|
|
14095
|
+
var ELEVENLABS_MUSIC_MODEL_IDS = /* @__PURE__ */ new Set(["music_v2_5", "music_v2"]);
|
|
14096
|
+
var ELEVENLABS_SFX_MODEL_IDS = /* @__PURE__ */ new Set([
|
|
14097
|
+
"eleven_text_to_sound_v3",
|
|
14098
|
+
"eleven_text_to_sound_v2"
|
|
14099
|
+
]);
|
|
13945
14100
|
var VOICE_ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
13946
14101
|
function elevenLabsRowRefusal(row2) {
|
|
13947
14102
|
const id = row2.providerModelId;
|
|
@@ -13951,6 +14106,12 @@ function elevenLabsRowRefusal(row2) {
|
|
|
13951
14106
|
if (row2.type === "voice-clone") {
|
|
13952
14107
|
return id === ELEVENLABS_IVC ? void 0 : `elevenlabs voice-clone rows need providerModelId ${ELEVENLABS_IVC}`;
|
|
13953
14108
|
}
|
|
14109
|
+
if (row2.type === "audio") {
|
|
14110
|
+
return ELEVENLABS_MUSIC_MODEL_IDS.has(id) ? void 0 : `elevenlabs music rows need providerModelId ${[...ELEVENLABS_MUSIC_MODEL_IDS].join(", ")}`;
|
|
14111
|
+
}
|
|
14112
|
+
if (row2.type === "sound-effect") {
|
|
14113
|
+
return ELEVENLABS_SFX_MODEL_IDS.has(id) ? void 0 : `elevenlabs sound-effect rows need providerModelId ${[...ELEVENLABS_SFX_MODEL_IDS].join(", ")}`;
|
|
14114
|
+
}
|
|
13954
14115
|
return `elevenlabs has no ${row2.type} rows`;
|
|
13955
14116
|
}
|
|
13956
14117
|
function elevenLabsError(ctx, code, message) {
|
|
@@ -14081,6 +14242,57 @@ async function generateSpeech(req, ctx) {
|
|
|
14081
14242
|
throw elevenLabsError(ctx, "provider_rejected", "ElevenLabs TTS returned no audio");
|
|
14082
14243
|
return { audio: { bytes, mime }, usage: usage2(ctx) };
|
|
14083
14244
|
}
|
|
14245
|
+
function mp3Seconds(format, byteLength) {
|
|
14246
|
+
const kbps = /^mp3_\d+_(\d+)$/.exec(format)?.[1];
|
|
14247
|
+
if (kbps === void 0 || byteLength <= 0) return void 0;
|
|
14248
|
+
return Math.round(byteLength * 8 / (Number(kbps) * 1e3) * 10) / 10;
|
|
14249
|
+
}
|
|
14250
|
+
function audioCall(req, ctx) {
|
|
14251
|
+
const prompt = req.prompt.trim();
|
|
14252
|
+
if (prompt.length === 0) throw elevenLabsError(ctx, "missing_input", "needs a prompt");
|
|
14253
|
+
const format = encodeURIComponent(req.outputFormat ?? DEFAULT_FORMAT);
|
|
14254
|
+
const model_id = ctx.model.providerModelId;
|
|
14255
|
+
if (ctx.model.type === "audio") {
|
|
14256
|
+
const body2 = { prompt, model_id };
|
|
14257
|
+
if (req.durationSeconds !== void 0)
|
|
14258
|
+
body2["music_length_ms"] = Math.round(req.durationSeconds * 1e3);
|
|
14259
|
+
if (req.instrumental !== void 0) body2["force_instrumental"] = req.instrumental;
|
|
14260
|
+
return { path: `/v1/music?output_format=${format}`, body: body2 };
|
|
14261
|
+
}
|
|
14262
|
+
const body = { text: prompt, model_id };
|
|
14263
|
+
if (req.durationSeconds !== void 0) body["duration_seconds"] = req.durationSeconds;
|
|
14264
|
+
if (req.loop !== void 0) body["loop"] = req.loop;
|
|
14265
|
+
return { path: `/v1/sound-generation?output_format=${format}`, body };
|
|
14266
|
+
}
|
|
14267
|
+
async function generateAudio(req, ctx) {
|
|
14268
|
+
checkRow(ctx, ctx.model.type === "sound-effect" ? "sound-effect" : "audio");
|
|
14269
|
+
const { path, body } = audioCall(req, ctx);
|
|
14270
|
+
const { bytes, mime } = await withRetry(
|
|
14271
|
+
async () => {
|
|
14272
|
+
const res = await elevenLabsFetch(ctx, path, {
|
|
14273
|
+
method: "POST",
|
|
14274
|
+
headers: { "Content-Type": "application/json" },
|
|
14275
|
+
body: JSON.stringify(body)
|
|
14276
|
+
});
|
|
14277
|
+
let audio;
|
|
14278
|
+
try {
|
|
14279
|
+
audio = new Uint8Array(await res.arrayBuffer());
|
|
14280
|
+
} catch (cause) {
|
|
14281
|
+
throw classifyThrown("elevenlabs", cause, ctx.model.id);
|
|
14282
|
+
}
|
|
14283
|
+
return { bytes: audio, mime: audioMime(res) };
|
|
14284
|
+
},
|
|
14285
|
+
mediaRetryOptions(ctx.call, ctx.signal)
|
|
14286
|
+
);
|
|
14287
|
+
if (bytes.byteLength === 0)
|
|
14288
|
+
throw elevenLabsError(ctx, "provider_rejected", "ElevenLabs returned no audio");
|
|
14289
|
+
const seconds3 = mp3Seconds(req.outputFormat ?? DEFAULT_FORMAT, bytes.byteLength) ?? req.durationSeconds;
|
|
14290
|
+
const perSecond = ctx.model.usage.unit === "seconds";
|
|
14291
|
+
return {
|
|
14292
|
+
audio: { bytes, mime },
|
|
14293
|
+
usage: { ...usage2(ctx), quantity: perSecond ? seconds3 ?? 0 : 1 }
|
|
14294
|
+
};
|
|
14295
|
+
}
|
|
14084
14296
|
var createdVoiceSchema = z24.object({
|
|
14085
14297
|
voice_id: z24.string().min(1),
|
|
14086
14298
|
requires_verification: z24.boolean().optional().catch(void 0)
|
|
@@ -14204,6 +14416,7 @@ async function deleteVoice(req, ctx) {
|
|
|
14204
14416
|
}
|
|
14205
14417
|
var elevenLabsAdapter = {
|
|
14206
14418
|
id: "elevenlabs",
|
|
14419
|
+
generateAudio,
|
|
14207
14420
|
generateSpeech,
|
|
14208
14421
|
createVoice,
|
|
14209
14422
|
deleteVoice
|
|
@@ -14489,14 +14702,228 @@ var fishAdapter = {
|
|
|
14489
14702
|
deleteVoice: deleteVoice2
|
|
14490
14703
|
};
|
|
14491
14704
|
|
|
14705
|
+
// src/adapters/google-voice.ts
|
|
14706
|
+
import { z as z26 } from "zod";
|
|
14707
|
+
var BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
|
|
14708
|
+
var PROVIDER = "google-genai";
|
|
14709
|
+
var GEMINI_TTS_MODEL_IDS = /* @__PURE__ */ new Set([
|
|
14710
|
+
"gemini-3.8-flash-tts",
|
|
14711
|
+
"gemini-3.8-flash-lite-tts"
|
|
14712
|
+
]);
|
|
14713
|
+
var VOICE_ID3 = /^voice_[A-Za-z0-9_-]{1,128}$/;
|
|
14714
|
+
function googleVoiceRowRefusal(row2) {
|
|
14715
|
+
if (row2.type !== "speech" && row2.type !== "voice-clone") {
|
|
14716
|
+
return `google-genai has no ${row2.type} rows`;
|
|
14717
|
+
}
|
|
14718
|
+
return GEMINI_TTS_MODEL_IDS.has(row2.providerModelId) ? void 0 : `google-genai ${row2.type} rows need providerModelId ${[...GEMINI_TTS_MODEL_IDS].join(", ")}`;
|
|
14719
|
+
}
|
|
14720
|
+
function refuse(ctx, code, message) {
|
|
14721
|
+
return new ModelKitError({
|
|
14722
|
+
code,
|
|
14723
|
+
message,
|
|
14724
|
+
provider: PROVIDER,
|
|
14725
|
+
model: ctx.model.id,
|
|
14726
|
+
retryable: false
|
|
14727
|
+
});
|
|
14728
|
+
}
|
|
14729
|
+
function checkRow3(ctx, type) {
|
|
14730
|
+
const refusal3 = ctx.model.type === type ? googleVoiceRowRefusal(ctx.model) : `${ctx.model.id} is not a ${type} row`;
|
|
14731
|
+
if (refusal3 !== void 0) throw refuse(ctx, "unsupported_option", refusal3);
|
|
14732
|
+
}
|
|
14733
|
+
function googleKey(ctx) {
|
|
14734
|
+
const key = ctx.keys.google;
|
|
14735
|
+
if (!key) throw refuse(ctx, "auth", "Missing Google API key");
|
|
14736
|
+
return key;
|
|
14737
|
+
}
|
|
14738
|
+
async function googleFetch(ctx, path, init) {
|
|
14739
|
+
throwIfAborted(ctx.signal);
|
|
14740
|
+
const request = {
|
|
14741
|
+
method: init.method,
|
|
14742
|
+
headers: { "x-goog-api-key": googleKey(ctx), "Content-Type": "application/json" }
|
|
14743
|
+
};
|
|
14744
|
+
if (init.body !== void 0) request.body = JSON.stringify(init.body);
|
|
14745
|
+
if (ctx.signal !== void 0) request.signal = ctx.signal;
|
|
14746
|
+
let res;
|
|
14747
|
+
try {
|
|
14748
|
+
res = await ctx.fetch(`${BASE_URL}${path}`, request);
|
|
14749
|
+
} catch (cause) {
|
|
14750
|
+
throw classifyThrown(PROVIDER, cause, ctx.model.id);
|
|
14751
|
+
}
|
|
14752
|
+
if (!res.ok) throw classifyHttpError(res.status, await readBody(res), PROVIDER, ctx.model.id);
|
|
14753
|
+
return res;
|
|
14754
|
+
}
|
|
14755
|
+
function usage4(ctx) {
|
|
14756
|
+
return {
|
|
14757
|
+
model: ctx.model.id,
|
|
14758
|
+
provider: PROVIDER,
|
|
14759
|
+
modality: "AUDIO",
|
|
14760
|
+
unit: ctx.model.usage.unit,
|
|
14761
|
+
quantity: 1
|
|
14762
|
+
};
|
|
14763
|
+
}
|
|
14764
|
+
var interactionSchema = z26.object({
|
|
14765
|
+
steps: z26.array(
|
|
14766
|
+
z26.looseObject({
|
|
14767
|
+
type: z26.string().optional(),
|
|
14768
|
+
content: z26.array(
|
|
14769
|
+
z26.looseObject({
|
|
14770
|
+
type: z26.string().optional(),
|
|
14771
|
+
data: z26.string().optional(),
|
|
14772
|
+
mime_type: z26.string().optional()
|
|
14773
|
+
})
|
|
14774
|
+
).optional()
|
|
14775
|
+
})
|
|
14776
|
+
).optional()
|
|
14777
|
+
});
|
|
14778
|
+
function geminiSpeechBody(req, providerModelId) {
|
|
14779
|
+
const text2 = { type: "text", text: req.text };
|
|
14780
|
+
const style = req.style?.trim();
|
|
14781
|
+
if (style) text2["annotations"] = [{ type: "speech_metadata", style }];
|
|
14782
|
+
return {
|
|
14783
|
+
model: providerModelId,
|
|
14784
|
+
input: [{ type: "user_input", content: [text2] }],
|
|
14785
|
+
response_format: { type: "audio" },
|
|
14786
|
+
// A prebuilt voice name or a replicated voice id go in the same field.
|
|
14787
|
+
generation_config: { speech_config: [{ voice: req.customVoice ?? req.voice ?? "" }] }
|
|
14788
|
+
};
|
|
14789
|
+
}
|
|
14790
|
+
async function generateGeminiSpeech(req, ctx) {
|
|
14791
|
+
checkRow3(ctx, "speech");
|
|
14792
|
+
if (req.customVoice !== void 0 && !VOICE_ID3.test(req.customVoice)) {
|
|
14793
|
+
throw refuse(ctx, "unsupported_option", "customVoice is not a Gemini voice id");
|
|
14794
|
+
}
|
|
14795
|
+
if ((req.customVoice ?? req.voice) === void 0) {
|
|
14796
|
+
throw refuse(ctx, "missing_input", "needs a voice");
|
|
14797
|
+
}
|
|
14798
|
+
if (req.text.trim().length === 0) throw refuse(ctx, "missing_input", "needs a script");
|
|
14799
|
+
const body = geminiSpeechBody(req, ctx.model.providerModelId);
|
|
14800
|
+
const raw = await withRetry(
|
|
14801
|
+
async () => readBody(await googleFetch(ctx, "/interactions", { method: "POST", body })),
|
|
14802
|
+
mediaRetryOptions(ctx.call, ctx.signal)
|
|
14803
|
+
);
|
|
14804
|
+
const parsed = interactionSchema.safeParse(raw);
|
|
14805
|
+
const blocks = parsed.success ? (parsed.data.steps ?? []).filter((step) => step.type === "model_output").flatMap((step) => step.content ?? []) : [];
|
|
14806
|
+
const block = blocks.find((b) => b.type === "audio" && b.data);
|
|
14807
|
+
if (block?.data === void 0) {
|
|
14808
|
+
throw refuse(ctx, "provider_rejected", "Gemini TTS returned no audio");
|
|
14809
|
+
}
|
|
14810
|
+
return {
|
|
14811
|
+
audio: {
|
|
14812
|
+
bytes: new Uint8Array(Buffer.from(block.data, "base64")),
|
|
14813
|
+
mime: block.mime_type ?? "audio/wav"
|
|
14814
|
+
},
|
|
14815
|
+
usage: usage4(ctx)
|
|
14816
|
+
};
|
|
14817
|
+
}
|
|
14818
|
+
async function inlineAudio(ref, ctx) {
|
|
14819
|
+
const { bytes, mime } = await mediaRefToBytes(ref, ctx.fetch, {
|
|
14820
|
+
signal: ctx.signal,
|
|
14821
|
+
provider: PROVIDER,
|
|
14822
|
+
model: ctx.model.id
|
|
14823
|
+
});
|
|
14824
|
+
const type = mime.startsWith("audio/") ? mime : "audio/wav";
|
|
14825
|
+
return { mime_type: type, data: Buffer.from(bytes).toString("base64") };
|
|
14826
|
+
}
|
|
14827
|
+
var createdVoiceSchema2 = z26.object({ id: z26.string().regex(VOICE_ID3) });
|
|
14828
|
+
async function onlyRateLimitRetries3(fn) {
|
|
14829
|
+
try {
|
|
14830
|
+
return await fn();
|
|
14831
|
+
} catch (cause) {
|
|
14832
|
+
if (!isModelKitError(cause) || !cause.retryable || cause.code === "rate_limited")
|
|
14833
|
+
throw cause;
|
|
14834
|
+
throw new ModelKitError({
|
|
14835
|
+
code: cause.code,
|
|
14836
|
+
message: cause.message,
|
|
14837
|
+
...cause.provider !== void 0 && { provider: cause.provider },
|
|
14838
|
+
...cause.model !== void 0 && { model: cause.model },
|
|
14839
|
+
...cause.status !== void 0 && { status: cause.status },
|
|
14840
|
+
...cause.body !== void 0 && { body: cause.body },
|
|
14841
|
+
cause,
|
|
14842
|
+
retryable: false
|
|
14843
|
+
});
|
|
14844
|
+
}
|
|
14845
|
+
}
|
|
14846
|
+
async function createGeminiVoice(req, ctx) {
|
|
14847
|
+
checkRow3(ctx, "voice-clone");
|
|
14848
|
+
const [sample, ...rest] = req.samples;
|
|
14849
|
+
if (sample === void 0) throw refuse(ctx, "missing_input", "needs a voice sample");
|
|
14850
|
+
if (rest.length > 0) throw refuse(ctx, "unsupported_option", "takes one voice sample");
|
|
14851
|
+
if (sample.designSignature?.trim()) {
|
|
14852
|
+
throw refuse(ctx, "unsupported_option", "Gemini cannot keep a voice design signature");
|
|
14853
|
+
}
|
|
14854
|
+
if (req.consent === void 0) {
|
|
14855
|
+
throw refuse(ctx, "missing_input", "needs the consent recording");
|
|
14856
|
+
}
|
|
14857
|
+
const body = {
|
|
14858
|
+
store: true,
|
|
14859
|
+
voice: {
|
|
14860
|
+
model: ctx.model.providerModelId,
|
|
14861
|
+
type: "replicated",
|
|
14862
|
+
display_name: req.title.trim(),
|
|
14863
|
+
replicated: {
|
|
14864
|
+
source_audio: await inlineAudio(sample.audio, ctx),
|
|
14865
|
+
consent_audio: await inlineAudio(req.consent, ctx)
|
|
14866
|
+
}
|
|
14867
|
+
}
|
|
14868
|
+
};
|
|
14869
|
+
const res = await withRetry(
|
|
14870
|
+
() => onlyRateLimitRetries3(() => googleFetch(ctx, "/voices", { method: "POST", body })),
|
|
14871
|
+
mediaRetryOptions(ctx.call, ctx.signal)
|
|
14872
|
+
);
|
|
14873
|
+
const raw = await readBody(res);
|
|
14874
|
+
const parsed = createdVoiceSchema2.safeParse(raw);
|
|
14875
|
+
if (!parsed.success) {
|
|
14876
|
+
throw new ModelKitError({
|
|
14877
|
+
code: "provider_rejected",
|
|
14878
|
+
message: "Gemini returned no voice id",
|
|
14879
|
+
provider: PROVIDER,
|
|
14880
|
+
model: ctx.model.id,
|
|
14881
|
+
status: res.status,
|
|
14882
|
+
body: raw,
|
|
14883
|
+
retryable: false
|
|
14884
|
+
});
|
|
14885
|
+
}
|
|
14886
|
+
return { voiceId: parsed.data.id, state: "trained", usage: usage4(ctx), raw };
|
|
14887
|
+
}
|
|
14888
|
+
async function deleteGeminiVoice(req, ctx) {
|
|
14889
|
+
checkRow3(ctx, "voice-clone");
|
|
14890
|
+
if (!VOICE_ID3.test(req.voiceId)) {
|
|
14891
|
+
throw refuse(ctx, "unsupported_option", "voiceId is not a Gemini voice id");
|
|
14892
|
+
}
|
|
14893
|
+
let attempts = 0;
|
|
14894
|
+
await withRetry(
|
|
14895
|
+
async () => {
|
|
14896
|
+
attempts += 1;
|
|
14897
|
+
try {
|
|
14898
|
+
await googleFetch(ctx, `/voices/${encodeURIComponent(req.voiceId)}`, {
|
|
14899
|
+
method: "DELETE"
|
|
14900
|
+
});
|
|
14901
|
+
} catch (cause) {
|
|
14902
|
+
if (!isModelKitError(cause) || cause.status !== 404) throw cause;
|
|
14903
|
+
if (attempts > 1) return;
|
|
14904
|
+
throw new ModelKitError({
|
|
14905
|
+
code: "provider_rejected",
|
|
14906
|
+
message: `Gemini has no voice ${req.voiceId} under this key set; delete with the tier that created it`,
|
|
14907
|
+
provider: PROVIDER,
|
|
14908
|
+
model: ctx.model.id,
|
|
14909
|
+
status: 404,
|
|
14910
|
+
cause,
|
|
14911
|
+
retryable: false
|
|
14912
|
+
});
|
|
14913
|
+
}
|
|
14914
|
+
},
|
|
14915
|
+
mediaRetryOptions(ctx.call, ctx.signal)
|
|
14916
|
+
);
|
|
14917
|
+
}
|
|
14918
|
+
|
|
14492
14919
|
// src/adapters/google-genai.ts
|
|
14493
|
-
import { z as
|
|
14920
|
+
import { z as z28 } from "zod";
|
|
14494
14921
|
import {
|
|
14495
14922
|
GoogleGenAI
|
|
14496
14923
|
} from "@google/genai";
|
|
14497
14924
|
|
|
14498
14925
|
// src/adapters/google-files.ts
|
|
14499
|
-
import { z as
|
|
14926
|
+
import { z as z27 } from "zod";
|
|
14500
14927
|
var GOOGLE_FILES_BASE = "https://generativelanguage.googleapis.com";
|
|
14501
14928
|
var GOOGLE_FILES_POLL_INTERVAL_MS = 2e3;
|
|
14502
14929
|
var GOOGLE_FILES_POLL_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
@@ -14506,17 +14933,17 @@ var GENERIC_MEDIA_TYPES = /* @__PURE__ */ new Set([
|
|
|
14506
14933
|
"binary/octet-stream",
|
|
14507
14934
|
"application/binary"
|
|
14508
14935
|
]);
|
|
14509
|
-
var uploadedFileSchema =
|
|
14510
|
-
file:
|
|
14511
|
-
uri:
|
|
14512
|
-
name:
|
|
14513
|
-
state:
|
|
14514
|
-
mimeType:
|
|
14936
|
+
var uploadedFileSchema = z27.object({
|
|
14937
|
+
file: z27.object({
|
|
14938
|
+
uri: z27.string().optional(),
|
|
14939
|
+
name: z27.string().optional(),
|
|
14940
|
+
state: z27.string().optional(),
|
|
14941
|
+
mimeType: z27.string().optional()
|
|
14515
14942
|
}).optional()
|
|
14516
14943
|
});
|
|
14517
|
-
var fileStateSchema =
|
|
14518
|
-
state:
|
|
14519
|
-
error:
|
|
14944
|
+
var fileStateSchema = z27.object({
|
|
14945
|
+
state: z27.string().optional(),
|
|
14946
|
+
error: z27.object({ message: z27.string().optional() }).optional()
|
|
14520
14947
|
});
|
|
14521
14948
|
function resolveMime(declared, fallback) {
|
|
14522
14949
|
const clean = declared?.split(";")[0]?.trim().toLowerCase();
|
|
@@ -14738,7 +15165,7 @@ var RESULT_TIMEOUT_MS4 = 15 * 60 * 1e3;
|
|
|
14738
15165
|
var OMNI_INLINE_LIMIT_BYTES = 4 * 1024 * 1024;
|
|
14739
15166
|
var OMNI_FRAMES_MAX_SECONDS = 10;
|
|
14740
15167
|
var MEDIA_PART_INLINE_LIMIT_BYTES = 10 * 1024 * 1024;
|
|
14741
|
-
var errorTextSchema =
|
|
15168
|
+
var errorTextSchema = z28.string();
|
|
14742
15169
|
function isGoogleGenaiVideoKnown(providerModelId) {
|
|
14743
15170
|
return providerModelId.startsWith("veo-") || providerModelId.startsWith("gemini-omni");
|
|
14744
15171
|
}
|
|
@@ -14775,13 +15202,16 @@ function createGoogleGenaiAdapter(deps = defaultDeps2) {
|
|
|
14775
15202
|
model: ctx.model.id
|
|
14776
15203
|
});
|
|
14777
15204
|
},
|
|
15205
|
+
generateSpeech: generateGeminiSpeech,
|
|
15206
|
+
createVoice: createGeminiVoice,
|
|
15207
|
+
deleteVoice: deleteGeminiVoice,
|
|
14778
15208
|
prepareMediaPart(ref, mediaType, ctx) {
|
|
14779
15209
|
return prepareGoogleMediaPart(ref, mediaType, ctx);
|
|
14780
15210
|
}
|
|
14781
15211
|
};
|
|
14782
15212
|
}
|
|
14783
15213
|
var googleGenaiAdapter = createGoogleGenaiAdapter();
|
|
14784
|
-
function
|
|
15214
|
+
function googleKey2(ctx) {
|
|
14785
15215
|
const key = ctx.keys.google;
|
|
14786
15216
|
if (!key) {
|
|
14787
15217
|
throw new ModelKitError({
|
|
@@ -14843,7 +15273,7 @@ function videoUsage2(ctx, duration, resolution) {
|
|
|
14843
15273
|
return event;
|
|
14844
15274
|
}
|
|
14845
15275
|
async function generateVeoVideo(req, ctx, createGenAIClient) {
|
|
14846
|
-
const apiKey =
|
|
15276
|
+
const apiKey = googleKey2(ctx);
|
|
14847
15277
|
const modelId = ctx.model.id;
|
|
14848
15278
|
const refs = req.referenceImages ?? [];
|
|
14849
15279
|
if (req.firstFrame && refs.length > 0) {
|
|
@@ -14933,7 +15363,7 @@ async function generateVeoVideo(req, ctx, createGenAIClient) {
|
|
|
14933
15363
|
}
|
|
14934
15364
|
};
|
|
14935
15365
|
const jobId = operation.name ?? crypto.randomUUID();
|
|
14936
|
-
const
|
|
15366
|
+
const usage6 = videoUsage2(ctx, duration, req.resolution ?? "720p");
|
|
14937
15367
|
return {
|
|
14938
15368
|
jobId,
|
|
14939
15369
|
async poll() {
|
|
@@ -14971,7 +15401,7 @@ async function generateVeoVideo(req, ctx, createGenAIClient) {
|
|
|
14971
15401
|
modelId
|
|
14972
15402
|
);
|
|
14973
15403
|
}
|
|
14974
|
-
return { video: await downloadVideo(ctx, uri, apiKey, signal), usage:
|
|
15404
|
+
return { video: await downloadVideo(ctx, uri, apiKey, signal), usage: usage6, raw: finished };
|
|
14975
15405
|
}
|
|
14976
15406
|
};
|
|
14977
15407
|
}
|
|
@@ -15008,7 +15438,7 @@ function extractOmniVideo(interaction, model) {
|
|
|
15008
15438
|
);
|
|
15009
15439
|
}
|
|
15010
15440
|
async function generateOmniVideo(req, ctx, createGenAIClient) {
|
|
15011
|
-
const apiKey =
|
|
15441
|
+
const apiKey = googleKey2(ctx);
|
|
15012
15442
|
const modelId = ctx.model.id;
|
|
15013
15443
|
const providerModelId = ctx.model.providerModelId;
|
|
15014
15444
|
const extend = req.taskType === "extend";
|
|
@@ -15183,7 +15613,7 @@ async function generateOmniVideo(req, ctx, createGenAIClient) {
|
|
|
15183
15613
|
if (!(extend && !chained)) await cleanupUploads();
|
|
15184
15614
|
}
|
|
15185
15615
|
const jobId = interaction.id ?? crypto.randomUUID();
|
|
15186
|
-
const
|
|
15616
|
+
const usage6 = videoUsage2(ctx, duration, omniResolution ?? "720p");
|
|
15187
15617
|
const getInteraction = async () => {
|
|
15188
15618
|
try {
|
|
15189
15619
|
const getParams = { stream: false };
|
|
@@ -15231,7 +15661,7 @@ async function generateOmniVideo(req, ctx, createGenAIClient) {
|
|
|
15231
15661
|
bytes: Buffer.from(video.data, "base64"),
|
|
15232
15662
|
mime: video.mime_type ?? "video/mp4"
|
|
15233
15663
|
},
|
|
15234
|
-
usage:
|
|
15664
|
+
usage: usage6,
|
|
15235
15665
|
raw: done,
|
|
15236
15666
|
providerRef
|
|
15237
15667
|
};
|
|
@@ -15239,7 +15669,7 @@ async function generateOmniVideo(req, ctx, createGenAIClient) {
|
|
|
15239
15669
|
if (video.uri)
|
|
15240
15670
|
return {
|
|
15241
15671
|
video: await downloadVideo(ctx, video.uri, apiKey, signal),
|
|
15242
|
-
usage:
|
|
15672
|
+
usage: usage6,
|
|
15243
15673
|
raw: done,
|
|
15244
15674
|
providerRef
|
|
15245
15675
|
};
|
|
@@ -15266,7 +15696,7 @@ function lyriaUsage(ctx, req, meta) {
|
|
|
15266
15696
|
return event;
|
|
15267
15697
|
}
|
|
15268
15698
|
async function generateLyriaAudio(req, ctx, createGenAIClient) {
|
|
15269
|
-
const apiKey =
|
|
15699
|
+
const apiKey = googleKey2(ctx);
|
|
15270
15700
|
const modelId = ctx.model.id;
|
|
15271
15701
|
const parts = [{ text: req.prompt }];
|
|
15272
15702
|
for (const ref of req.references ?? []) {
|
|
@@ -15328,7 +15758,7 @@ async function generateLyriaAudio(req, ctx, createGenAIClient) {
|
|
|
15328
15758
|
return result;
|
|
15329
15759
|
}
|
|
15330
15760
|
async function generateLyriaInteraction(req, ctx, createGenAIClient) {
|
|
15331
|
-
const apiKey =
|
|
15761
|
+
const apiKey = googleKey2(ctx);
|
|
15332
15762
|
const modelId = ctx.model.id;
|
|
15333
15763
|
const input = [{ type: "text", text: req.prompt }];
|
|
15334
15764
|
for (const ref of req.references ?? []) {
|
|
@@ -15388,7 +15818,7 @@ async function prepareGoogleMediaPart(ref, mediaType, ctx) {
|
|
|
15388
15818
|
if (ref.bytes.length <= MEDIA_PART_INLINE_LIMIT_BYTES) {
|
|
15389
15819
|
return { type: "file", data: ref.bytes, mediaType };
|
|
15390
15820
|
}
|
|
15391
|
-
const apiKey =
|
|
15821
|
+
const apiKey = googleKey2(ctx);
|
|
15392
15822
|
const uploadOptions = {
|
|
15393
15823
|
apiKey,
|
|
15394
15824
|
fetchImpl: ctx.fetch,
|
|
@@ -15409,15 +15839,15 @@ async function prepareGoogleMediaPart(ref, mediaType, ctx) {
|
|
|
15409
15839
|
// src/adapters/google-image.ts
|
|
15410
15840
|
import { createGoogleGenerativeAI as createGoogleGenerativeAI2 } from "@ai-sdk/google";
|
|
15411
15841
|
import { generateText } from "ai";
|
|
15412
|
-
import { z as
|
|
15842
|
+
import { z as z29 } from "zod";
|
|
15413
15843
|
var GEMINI_IMAGE_TIMEOUT_MS = 6e5;
|
|
15414
15844
|
var defaultGoogleImageDeps = {
|
|
15415
15845
|
createGoogleClient: (opts) => createGoogleGenerativeAI2(opts),
|
|
15416
15846
|
runTextGeneration: (opts) => generateText(opts)
|
|
15417
15847
|
};
|
|
15418
|
-
var causeChainNodeSchema =
|
|
15419
|
-
message:
|
|
15420
|
-
cause:
|
|
15848
|
+
var causeChainNodeSchema = z29.object({
|
|
15849
|
+
message: z29.string().optional(),
|
|
15850
|
+
cause: z29.unknown().optional()
|
|
15421
15851
|
});
|
|
15422
15852
|
function extractBlockReason(cause) {
|
|
15423
15853
|
let current = cause;
|
|
@@ -15437,9 +15867,9 @@ function extractBlockReason(cause) {
|
|
|
15437
15867
|
current = parsed.data.cause ?? null;
|
|
15438
15868
|
}
|
|
15439
15869
|
}
|
|
15440
|
-
function billedTokens(model,
|
|
15441
|
-
const inputTokens =
|
|
15442
|
-
const outputTokens =
|
|
15870
|
+
function billedTokens(model, usage6) {
|
|
15871
|
+
const inputTokens = usage6?.inputTokens;
|
|
15872
|
+
const outputTokens = usage6?.outputTokens;
|
|
15443
15873
|
if (inputTokens === void 0 && outputTokens === void 0) return void 0;
|
|
15444
15874
|
const event = {
|
|
15445
15875
|
model,
|
|
@@ -15540,7 +15970,7 @@ function createGoogleImageAdapter(deps = defaultGoogleImageDeps) {
|
|
|
15540
15970
|
if (billed !== void 0) init.usage = billed;
|
|
15541
15971
|
throw new ModelKitError(init);
|
|
15542
15972
|
}
|
|
15543
|
-
const
|
|
15973
|
+
const usage6 = {
|
|
15544
15974
|
model: ctx.model.id,
|
|
15545
15975
|
provider: "google-image",
|
|
15546
15976
|
modality: "IMAGE",
|
|
@@ -15548,19 +15978,19 @@ function createGoogleImageAdapter(deps = defaultGoogleImageDeps) {
|
|
|
15548
15978
|
quantity: images.length,
|
|
15549
15979
|
imageQuality: "auto"
|
|
15550
15980
|
};
|
|
15551
|
-
if (req.size !== void 0)
|
|
15981
|
+
if (req.size !== void 0) usage6.imageSize = req.size;
|
|
15552
15982
|
if (result.usage?.inputTokens !== void 0)
|
|
15553
|
-
|
|
15983
|
+
usage6.inputTokens = result.usage.inputTokens;
|
|
15554
15984
|
if (result.usage?.outputTokens !== void 0)
|
|
15555
|
-
|
|
15556
|
-
return { images, usage:
|
|
15985
|
+
usage6.outputTokens = result.usage.outputTokens;
|
|
15986
|
+
return { images, usage: usage6, raw: result };
|
|
15557
15987
|
}
|
|
15558
15988
|
};
|
|
15559
15989
|
}
|
|
15560
15990
|
var googleImageAdapter = createGoogleImageAdapter();
|
|
15561
15991
|
|
|
15562
15992
|
// src/adapters/higgsfield.ts
|
|
15563
|
-
import { z as
|
|
15993
|
+
import { z as z30 } from "zod";
|
|
15564
15994
|
|
|
15565
15995
|
// src/adapters/higgsfield-motions.ts
|
|
15566
15996
|
var MOTION_MAP = {
|
|
@@ -15779,14 +16209,14 @@ function klingEndpointFields(providerModelId) {
|
|
|
15779
16209
|
const path = (providerModelId.startsWith("/") ? providerModelId.slice(1) : providerModelId).toLowerCase();
|
|
15780
16210
|
return KLING_ENDPOINT_FIELDS.get(path) ?? UNLISTED_KLING_FIELDS;
|
|
15781
16211
|
}
|
|
15782
|
-
var klingCreateSchema =
|
|
15783
|
-
var klingStatusSchema =
|
|
15784
|
-
status:
|
|
15785
|
-
video:
|
|
16212
|
+
var klingCreateSchema = z30.object({ status_url: z30.string() });
|
|
16213
|
+
var klingStatusSchema = z30.object({
|
|
16214
|
+
status: z30.string().optional(),
|
|
16215
|
+
video: z30.object({ url: z30.string().optional() }).optional(),
|
|
15786
16216
|
error: JsonValueSchema.optional()
|
|
15787
16217
|
});
|
|
15788
|
-
var errorMessageSchema =
|
|
15789
|
-
var textValueSchema =
|
|
16218
|
+
var errorMessageSchema = z30.object({ message: z30.string().optional() });
|
|
16219
|
+
var textValueSchema = z30.string();
|
|
15790
16220
|
function klingErrorDetail(error) {
|
|
15791
16221
|
if (error === void 0) return "unknown_error";
|
|
15792
16222
|
const asText = textValueSchema.safeParse(error);
|
|
@@ -15942,8 +16372,8 @@ async function generateKlingVideo(req, ctx) {
|
|
|
15942
16372
|
}
|
|
15943
16373
|
};
|
|
15944
16374
|
}
|
|
15945
|
-
var dopMotionOptionsSchema =
|
|
15946
|
-
modelkit:
|
|
16375
|
+
var dopMotionOptionsSchema = z30.object({
|
|
16376
|
+
modelkit: z30.object({ motion: z30.string().optional() }).optional()
|
|
15947
16377
|
});
|
|
15948
16378
|
function dopMotionId(ctx) {
|
|
15949
16379
|
const parsed = dopMotionOptionsSchema.safeParse(ctx.model.providerOptions);
|
|
@@ -15959,7 +16389,7 @@ function dopMotionId(ctx) {
|
|
|
15959
16389
|
});
|
|
15960
16390
|
return id;
|
|
15961
16391
|
}
|
|
15962
|
-
var jsonRecordSchema =
|
|
16392
|
+
var jsonRecordSchema = z30.record(z30.string(), JsonValueSchema);
|
|
15963
16393
|
var DOP_URL_KEYS = ["url", "video_url", "output_url", "result_url", "download_url"];
|
|
15964
16394
|
var DOP_NESTED_KEYS = ["video", "result", "results"];
|
|
15965
16395
|
function dopUrl(body) {
|
|
@@ -15987,8 +16417,8 @@ function dopUrl(body) {
|
|
|
15987
16417
|
}
|
|
15988
16418
|
return void 0;
|
|
15989
16419
|
}
|
|
15990
|
-
var dopCreateSchema =
|
|
15991
|
-
var dopStatusSchema =
|
|
16420
|
+
var dopCreateSchema = z30.object({ id: z30.string() });
|
|
16421
|
+
var dopStatusSchema = z30.object({ status: z30.string().optional() });
|
|
15992
16422
|
async function generateDopVideo(req, ctx) {
|
|
15993
16423
|
const firstFrame = req.firstFrame ? refToUrl(req.firstFrame) : void 0;
|
|
15994
16424
|
if (!firstFrame) {
|
|
@@ -16115,7 +16545,7 @@ var higgsfieldAdapter = {
|
|
|
16115
16545
|
};
|
|
16116
16546
|
|
|
16117
16547
|
// src/adapters/luma.ts
|
|
16118
|
-
import { z as
|
|
16548
|
+
import { z as z31 } from "zod";
|
|
16119
16549
|
|
|
16120
16550
|
// src/adapters/mp4-duration.ts
|
|
16121
16551
|
function mp4DurationSeconds(bytes) {
|
|
@@ -16332,17 +16762,17 @@ function lumaReframeResolution(req, ctx) {
|
|
|
16332
16762
|
});
|
|
16333
16763
|
return "720p";
|
|
16334
16764
|
}
|
|
16335
|
-
var lumaGenerationSchema =
|
|
16336
|
-
id:
|
|
16337
|
-
state:
|
|
16338
|
-
output:
|
|
16339
|
-
|
|
16340
|
-
type:
|
|
16341
|
-
url:
|
|
16765
|
+
var lumaGenerationSchema = z31.looseObject({
|
|
16766
|
+
id: z31.string(),
|
|
16767
|
+
state: z31.string().optional(),
|
|
16768
|
+
output: z31.array(
|
|
16769
|
+
z31.looseObject({
|
|
16770
|
+
type: z31.string().optional(),
|
|
16771
|
+
url: z31.string().optional()
|
|
16342
16772
|
})
|
|
16343
16773
|
).optional(),
|
|
16344
|
-
failure_reason:
|
|
16345
|
-
failure_code:
|
|
16774
|
+
failure_reason: z31.string().optional().nullable(),
|
|
16775
|
+
failure_code: z31.string().optional().nullable()
|
|
16346
16776
|
});
|
|
16347
16777
|
function lumaFailure(ctx, code, reason) {
|
|
16348
16778
|
const detail = reason ?? code ?? "unknown_error";
|
|
@@ -16774,7 +17204,7 @@ var lumaAdapter = {
|
|
|
16774
17204
|
|
|
16775
17205
|
// src/adapters/openai-image.ts
|
|
16776
17206
|
import OpenAI from "openai";
|
|
16777
|
-
import { z as
|
|
17207
|
+
import { z as z32 } from "zod";
|
|
16778
17208
|
|
|
16779
17209
|
// src/adapters/svg-sanitize.ts
|
|
16780
17210
|
var BLOCK_ELEMENTS = /<(script|foreignObject|iframe|object|embed|audio|video|handler|listener)\b[\s\S]*?<\/\1\s*>/giu;
|
|
@@ -16887,9 +17317,9 @@ function toProviderError2(cause, ctx) {
|
|
|
16887
17317
|
ctx.model.id
|
|
16888
17318
|
);
|
|
16889
17319
|
}
|
|
16890
|
-
var openaiUsageSchema =
|
|
16891
|
-
input_tokens:
|
|
16892
|
-
output_tokens:
|
|
17320
|
+
var openaiUsageSchema = z32.object({
|
|
17321
|
+
input_tokens: z32.number().optional(),
|
|
17322
|
+
output_tokens: z32.number().optional()
|
|
16893
17323
|
});
|
|
16894
17324
|
var openaiImageAdapter = {
|
|
16895
17325
|
id: "openai-image",
|
|
@@ -17001,7 +17431,7 @@ var openaiImageAdapter = {
|
|
|
17001
17431
|
const usageParsed = openaiUsageSchema.safeParse(response.usage);
|
|
17002
17432
|
const inputTokens = usageParsed.success ? usageParsed.data.input_tokens : void 0;
|
|
17003
17433
|
const outputTokens = usageParsed.success ? usageParsed.data.output_tokens : void 0;
|
|
17004
|
-
const
|
|
17434
|
+
const usage6 = {
|
|
17005
17435
|
model: ctx.model.id,
|
|
17006
17436
|
provider: "openai-image",
|
|
17007
17437
|
modality: "IMAGE",
|
|
@@ -17009,10 +17439,10 @@ var openaiImageAdapter = {
|
|
|
17009
17439
|
quantity: images.length,
|
|
17010
17440
|
imageQuality: quality
|
|
17011
17441
|
};
|
|
17012
|
-
if (inputTokens !== void 0)
|
|
17013
|
-
if (outputTokens !== void 0)
|
|
17014
|
-
if (req.size !== void 0)
|
|
17015
|
-
return { images, usage:
|
|
17442
|
+
if (inputTokens !== void 0) usage6.inputTokens = inputTokens;
|
|
17443
|
+
if (outputTokens !== void 0) usage6.outputTokens = outputTokens;
|
|
17444
|
+
if (req.size !== void 0) usage6.imageSize = req.size;
|
|
17445
|
+
return { images, usage: usage6, raw: response };
|
|
17016
17446
|
}
|
|
17017
17447
|
};
|
|
17018
17448
|
|
|
@@ -17268,16 +17698,16 @@ async function generateProdiaImage(req, ctx) {
|
|
|
17268
17698
|
new Uint8Array(await res.arrayBuffer()),
|
|
17269
17699
|
res.headers.get("content-type")
|
|
17270
17700
|
);
|
|
17271
|
-
const
|
|
17701
|
+
const usage6 = {
|
|
17272
17702
|
model: ctx.model.id,
|
|
17273
17703
|
provider: "prodia",
|
|
17274
17704
|
modality: "IMAGE",
|
|
17275
17705
|
unit: "images",
|
|
17276
17706
|
quantity: 1
|
|
17277
17707
|
};
|
|
17278
|
-
if (req.size !== void 0)
|
|
17279
|
-
if (req.quality !== void 0)
|
|
17280
|
-
return { images: [{ bytes, mime }], usage:
|
|
17708
|
+
if (req.size !== void 0) usage6.imageSize = req.size;
|
|
17709
|
+
if (req.quality !== void 0) usage6.imageQuality = req.quality;
|
|
17710
|
+
return { images: [{ bytes, mime }], usage: usage6, raw: void 0 };
|
|
17281
17711
|
}
|
|
17282
17712
|
var prodiaAdapter = {
|
|
17283
17713
|
id: "prodia",
|
|
@@ -17288,13 +17718,13 @@ var prodiaAdapter = {
|
|
|
17288
17718
|
import Replicate from "replicate";
|
|
17289
17719
|
|
|
17290
17720
|
// src/adapters/replicate-http.ts
|
|
17291
|
-
import { z as
|
|
17292
|
-
var predictionSchema =
|
|
17293
|
-
id:
|
|
17294
|
-
status:
|
|
17721
|
+
import { z as z33 } from "zod";
|
|
17722
|
+
var predictionSchema = z33.object({
|
|
17723
|
+
id: z33.string(),
|
|
17724
|
+
status: z33.string(),
|
|
17295
17725
|
output: JsonValueSchema.optional(),
|
|
17296
17726
|
error: JsonValueSchema.optional(),
|
|
17297
|
-
metrics:
|
|
17727
|
+
metrics: z33.object({ predict_time: z33.number().optional() }).optional()
|
|
17298
17728
|
});
|
|
17299
17729
|
function createReplicateHttpClient(opts) {
|
|
17300
17730
|
async function request(path, body, signal) {
|
|
@@ -17345,7 +17775,7 @@ function createReplicateHttpClient(opts) {
|
|
|
17345
17775
|
}
|
|
17346
17776
|
|
|
17347
17777
|
// src/adapters/replicate.ts
|
|
17348
|
-
import { z as
|
|
17778
|
+
import { z as z34 } from "zod";
|
|
17349
17779
|
var POLL_INTERVAL_MS2 = 1e3;
|
|
17350
17780
|
var POLL_TIMEOUT_MS = 15 * 6e4;
|
|
17351
17781
|
var defaultReplicateDeps = {
|
|
@@ -17385,8 +17815,8 @@ function route(providerModelId) {
|
|
|
17385
17815
|
if (!providerModelId.includes("/")) return { version: providerModelId };
|
|
17386
17816
|
return { model: providerModelId };
|
|
17387
17817
|
}
|
|
17388
|
-
var replicateResponseStatusSchema =
|
|
17389
|
-
response:
|
|
17818
|
+
var replicateResponseStatusSchema = z34.object({
|
|
17819
|
+
response: z34.object({ status: z34.number() }).partial()
|
|
17390
17820
|
});
|
|
17391
17821
|
function replicateError(cause, ctx) {
|
|
17392
17822
|
if (isModelKitError(cause)) return cause;
|
|
@@ -17409,7 +17839,7 @@ function isUrlFn(value) {
|
|
|
17409
17839
|
function extractOutputUrl(output) {
|
|
17410
17840
|
const root = Array.isArray(output) ? output[0] : output;
|
|
17411
17841
|
if (root === void 0) throw noOutput();
|
|
17412
|
-
const asString =
|
|
17842
|
+
const asString = z34.string().safeParse(root);
|
|
17413
17843
|
if (asString.success && asString.data) return asString.data;
|
|
17414
17844
|
if (root instanceof URL) return root.href;
|
|
17415
17845
|
if (isObjectOutput(root)) {
|
|
@@ -17418,15 +17848,15 @@ function extractOutputUrl(output) {
|
|
|
17418
17848
|
if (urlValue !== void 0 && isUrlFn(urlValue)) {
|
|
17419
17849
|
const called = urlValue();
|
|
17420
17850
|
if (called instanceof URL) return called.href;
|
|
17421
|
-
const calledString =
|
|
17851
|
+
const calledString = z34.string().safeParse(called);
|
|
17422
17852
|
if (calledString.success && calledString.data) return calledString.data;
|
|
17423
17853
|
} else {
|
|
17424
|
-
const direct =
|
|
17854
|
+
const direct = z34.string().safeParse(urlValue);
|
|
17425
17855
|
if (direct.success && direct.data) return direct.data;
|
|
17426
17856
|
}
|
|
17427
17857
|
}
|
|
17428
17858
|
if ("default" in root) {
|
|
17429
|
-
const fallback =
|
|
17859
|
+
const fallback = z34.string().safeParse(root.default);
|
|
17430
17860
|
if (fallback.success && fallback.data) return fallback.data;
|
|
17431
17861
|
}
|
|
17432
17862
|
}
|
|
@@ -17487,7 +17917,7 @@ async function runPrediction(ctx, input, deps) {
|
|
|
17487
17917
|
}
|
|
17488
17918
|
return void 0;
|
|
17489
17919
|
}, pollOpts);
|
|
17490
|
-
const predictTime =
|
|
17920
|
+
const predictTime = z34.number().safeParse(done.metrics?.predict_time);
|
|
17491
17921
|
if (done.output === void 0) throw noOutput();
|
|
17492
17922
|
return {
|
|
17493
17923
|
url: extractOutputUrl(done.output),
|
|
@@ -17733,9 +18163,9 @@ async function generateReplicateImage(req, ctx, deps) {
|
|
|
17733
18163
|
}
|
|
17734
18164
|
const { url, predictTime, raw } = await runPrediction(ctx, input, deps);
|
|
17735
18165
|
const file = await download(ctx, url);
|
|
17736
|
-
const
|
|
17737
|
-
|
|
17738
|
-
return { images: [{ bytes: file.bytes, mime: file.mime }], usage:
|
|
18166
|
+
const usage6 = imageUsage3(ctx, req);
|
|
18167
|
+
usage6.quantity = predictTime;
|
|
18168
|
+
return { images: [{ bytes: file.bytes, mime: file.mime }], usage: usage6, raw, outputUrl: url };
|
|
17739
18169
|
}
|
|
17740
18170
|
function klingInput(req) {
|
|
17741
18171
|
const images = (req.firstFrame ? [req.firstFrame] : []).map(refToUrl);
|
|
@@ -17840,7 +18270,7 @@ async function generateReplicateVideo(req, ctx, deps) {
|
|
|
17840
18270
|
throw replicateError(cause, ctx);
|
|
17841
18271
|
}
|
|
17842
18272
|
if (current.status === "succeeded") {
|
|
17843
|
-
const predictTime =
|
|
18273
|
+
const predictTime = z34.number().safeParse(current.metrics?.predict_time);
|
|
17844
18274
|
if (current.output === void 0) throw noOutput();
|
|
17845
18275
|
return {
|
|
17846
18276
|
url: extractOutputUrl(current.output),
|
|
@@ -17859,9 +18289,9 @@ async function generateReplicateVideo(req, ctx, deps) {
|
|
|
17859
18289
|
return void 0;
|
|
17860
18290
|
};
|
|
17861
18291
|
const toResult = (done) => {
|
|
17862
|
-
const
|
|
17863
|
-
|
|
17864
|
-
return { video: { url: done.url }, usage:
|
|
18292
|
+
const usage6 = videoUsage5(ctx, req);
|
|
18293
|
+
usage6.quantity = done.predictTime;
|
|
18294
|
+
return { video: { url: done.url }, usage: usage6, raw: done.raw };
|
|
17865
18295
|
};
|
|
17866
18296
|
return {
|
|
17867
18297
|
jobId,
|
|
@@ -17968,21 +18398,21 @@ async function generateReplicateAudio(req, ctx, deps) {
|
|
|
17968
18398
|
input = specResult.input;
|
|
17969
18399
|
}
|
|
17970
18400
|
const { url, predictTime, raw } = await runPrediction(ctx, input, deps);
|
|
17971
|
-
const
|
|
18401
|
+
const usage6 = audioUsage(ctx, req);
|
|
17972
18402
|
if (ctx.model.usage.unit === "seconds") {
|
|
17973
18403
|
const seconds3 = elevenLabsMusicDuration(req.durationSeconds);
|
|
17974
|
-
|
|
17975
|
-
|
|
18404
|
+
usage6.quantity = seconds3;
|
|
18405
|
+
usage6.durationSeconds = seconds3;
|
|
17976
18406
|
} else {
|
|
17977
|
-
|
|
18407
|
+
usage6.quantity = predictTime;
|
|
17978
18408
|
}
|
|
17979
|
-
return { audio: { url }, usage:
|
|
18409
|
+
return { audio: { url }, usage: usage6, raw: predictionRaw(raw) };
|
|
17980
18410
|
}
|
|
17981
18411
|
|
|
17982
18412
|
// src/adapters/xai-video.ts
|
|
17983
18413
|
import { experimental_generateVideo } from "ai";
|
|
17984
18414
|
import { createXai as createXai2 } from "@ai-sdk/xai";
|
|
17985
|
-
import { z as
|
|
18415
|
+
import { z as z35 } from "zod";
|
|
17986
18416
|
var POLL_INTERVAL_MS3 = 1e4;
|
|
17987
18417
|
var POLL_TIMEOUT_MS2 = 15 * 6e4;
|
|
17988
18418
|
var defaultXaiDeps = {
|
|
@@ -17995,8 +18425,8 @@ function createXaiVideoAdapter(deps = defaultXaiDeps) {
|
|
|
17995
18425
|
};
|
|
17996
18426
|
}
|
|
17997
18427
|
var xaiVideoAdapter = createXaiVideoAdapter();
|
|
17998
|
-
var xaiResponseStatusSchema =
|
|
17999
|
-
response:
|
|
18428
|
+
var xaiResponseStatusSchema = z35.object({
|
|
18429
|
+
response: z35.object({ status: z35.number() }).partial()
|
|
18000
18430
|
});
|
|
18001
18431
|
function xaiError(cause, ctx) {
|
|
18002
18432
|
const info = describeThrown(cause);
|
|
@@ -18004,12 +18434,12 @@ function xaiError(cause, ctx) {
|
|
|
18004
18434
|
const status = info.status ?? (nested.success ? nested.data.response?.status : void 0);
|
|
18005
18435
|
return classifyThrown("xai-video", cause, ctx.model.id, { status, body: info.body });
|
|
18006
18436
|
}
|
|
18007
|
-
var xaiMetaSchema =
|
|
18437
|
+
var xaiMetaSchema = z35.object({
|
|
18008
18438
|
videoUrl: JsonValueSchema.optional(),
|
|
18009
18439
|
costInUsdTicks: JsonValueSchema.optional(),
|
|
18010
18440
|
duration: JsonValueSchema.optional()
|
|
18011
18441
|
});
|
|
18012
|
-
var xaiProviderMetadataSchema =
|
|
18442
|
+
var xaiProviderMetadataSchema = z35.object({ xai: xaiMetaSchema });
|
|
18013
18443
|
function metaOf(result) {
|
|
18014
18444
|
const parsed = xaiProviderMetadataSchema.partial().safeParse(result.providerMetadata);
|
|
18015
18445
|
if (!parsed.success) return {};
|
|
@@ -18121,12 +18551,12 @@ async function mapResult(ctx, req, result) {
|
|
|
18121
18551
|
if (first) {
|
|
18122
18552
|
return {
|
|
18123
18553
|
video: { bytes: Uint8Array.from(first.uint8Array), mime: first.mediaType },
|
|
18124
|
-
usage:
|
|
18554
|
+
usage: usage5(ctx, req, metaOf(result)),
|
|
18125
18555
|
raw: result.providerMetadata
|
|
18126
18556
|
};
|
|
18127
18557
|
}
|
|
18128
18558
|
const meta = metaOf(result);
|
|
18129
|
-
const videoUrl =
|
|
18559
|
+
const videoUrl = z35.string().safeParse(meta.videoUrl);
|
|
18130
18560
|
if (videoUrl.success && videoUrl.data) {
|
|
18131
18561
|
const res = await ctx.fetch(videoUrl.data);
|
|
18132
18562
|
if (!res.ok) {
|
|
@@ -18136,7 +18566,7 @@ async function mapResult(ctx, req, result) {
|
|
|
18136
18566
|
const mime = res.headers.get("content-type") ?? "video/mp4";
|
|
18137
18567
|
return {
|
|
18138
18568
|
video: { bytes: new Uint8Array(await res.arrayBuffer()), mime },
|
|
18139
|
-
usage:
|
|
18569
|
+
usage: usage5(ctx, req, meta),
|
|
18140
18570
|
raw: result.providerMetadata
|
|
18141
18571
|
};
|
|
18142
18572
|
}
|
|
@@ -18148,8 +18578,8 @@ async function mapResult(ctx, req, result) {
|
|
|
18148
18578
|
retryable: false
|
|
18149
18579
|
});
|
|
18150
18580
|
}
|
|
18151
|
-
function
|
|
18152
|
-
const costTicks =
|
|
18581
|
+
function usage5(ctx, req, meta) {
|
|
18582
|
+
const costTicks = z35.number().safeParse(meta.costInUsdTicks);
|
|
18153
18583
|
const cost = costTicks.success ? costTicks.data / 1e10 : void 0;
|
|
18154
18584
|
const event = {
|
|
18155
18585
|
model: ctx.model.id,
|
|
@@ -18230,15 +18660,17 @@ var FAL_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
|
18230
18660
|
"transcription",
|
|
18231
18661
|
"mask"
|
|
18232
18662
|
]);
|
|
18233
|
-
function
|
|
18234
|
-
|
|
18663
|
+
function directNode(row2) {
|
|
18664
|
+
if (row2.adapter === "elevenlabs" && row2.type === "sound-effect") return true;
|
|
18665
|
+
const speaks = row2.adapter === "fish" || row2.adapter === "elevenlabs" || row2.adapter === "google-genai";
|
|
18666
|
+
return speaks && row2.type === "speech";
|
|
18235
18667
|
}
|
|
18236
18668
|
function dataOnlyCapable(row2) {
|
|
18237
18669
|
const adapter = DEFAULT_ADAPTERS[row2.adapter];
|
|
18238
18670
|
if (!adapterServesType(adapter, row2.type)) {
|
|
18239
18671
|
return { ok: false, reason: `${row2.adapter} cannot serve ${row2.type} rows` };
|
|
18240
18672
|
}
|
|
18241
|
-
if (FAL_NODE_TYPES.has(row2.type) && row2.adapter !== "fal" && !
|
|
18673
|
+
if (FAL_NODE_TYPES.has(row2.type) && row2.adapter !== "fal" && !directNode(row2)) {
|
|
18242
18674
|
return { ok: false, reason: `only fal serves ${row2.type} rows` };
|
|
18243
18675
|
}
|
|
18244
18676
|
switch (row2.adapter) {
|
|
@@ -18265,6 +18697,10 @@ function dataOnlyCapable(row2) {
|
|
|
18265
18697
|
if (row2.type === "video") {
|
|
18266
18698
|
return isGoogleGenaiVideoKnown(row2.providerModelId) ? { ok: true } : { ok: false, reason: "google-genai video needs a veo- or gemini-omni id" };
|
|
18267
18699
|
}
|
|
18700
|
+
if (row2.type === "speech" || row2.type === "voice-clone") {
|
|
18701
|
+
const reason = googleVoiceRowRefusal(row2);
|
|
18702
|
+
return reason === void 0 ? { ok: true } : { ok: false, reason };
|
|
18703
|
+
}
|
|
18268
18704
|
return isGoogleGenaiAudioKnown(row2.providerModelId) ? { ok: true } : { ok: false, reason: "google-genai audio needs a lyria- id" };
|
|
18269
18705
|
}
|
|
18270
18706
|
case "replicate": {
|
|
@@ -18347,22 +18783,22 @@ var liveState = store[KEY] ??= {
|
|
|
18347
18783
|
var liveCatalog = liveState.catalog;
|
|
18348
18784
|
|
|
18349
18785
|
// src/catalog/load.ts
|
|
18350
|
-
import { z as
|
|
18786
|
+
import { z as z36 } from "zod";
|
|
18351
18787
|
function rowCount() {
|
|
18352
18788
|
return liveCatalog.list({ lifecycle: ["active", "deprecated", "retired"] }).length;
|
|
18353
18789
|
}
|
|
18354
18790
|
function authHeaders2(auth) {
|
|
18355
18791
|
return "bearer" in auth ? { Authorization: `Bearer ${auth.bearer}` } : { "x-api-key": auth.apiKey };
|
|
18356
18792
|
}
|
|
18357
|
-
var EnvelopeSchema =
|
|
18358
|
-
rows:
|
|
18359
|
-
revision:
|
|
18793
|
+
var EnvelopeSchema = z36.object({
|
|
18794
|
+
rows: z36.array(JsonValueSchema),
|
|
18795
|
+
revision: z36.string().optional()
|
|
18360
18796
|
});
|
|
18361
18797
|
function dropReason(path, message) {
|
|
18362
18798
|
return path.length === 0 ? message : `${path.map((part) => String(part)).join(".")} ${message}`;
|
|
18363
18799
|
}
|
|
18364
18800
|
function rowId(raw) {
|
|
18365
|
-
const parsed =
|
|
18801
|
+
const parsed = z36.object({ id: z36.string().min(1) }).loose().safeParse(raw);
|
|
18366
18802
|
if (!parsed.success) return "?";
|
|
18367
18803
|
return parsed.data.id;
|
|
18368
18804
|
}
|
|
@@ -18579,7 +19015,7 @@ function fileCatalogCache(path) {
|
|
|
18579
19015
|
}
|
|
18580
19016
|
|
|
18581
19017
|
// src/catalog/input-billing.ts
|
|
18582
|
-
import { z as
|
|
19018
|
+
import { z as z37 } from "zod";
|
|
18583
19019
|
var DATA_ONLY_INPUT_BILLING = /* @__PURE__ */ new Map([
|
|
18584
19020
|
["flux-3", "source-video-rate"]
|
|
18585
19021
|
]);
|
|
@@ -18588,7 +19024,7 @@ var KIT_INPUT_BILLING = new Map(
|
|
|
18588
19024
|
(row2) => row2.constraints.inputBilling ? [[row2.id, row2.constraints.inputBilling]] : []
|
|
18589
19025
|
)
|
|
18590
19026
|
);
|
|
18591
|
-
var ConstraintsReadView2 =
|
|
19027
|
+
var ConstraintsReadView2 = z37.looseObject({
|
|
18592
19028
|
inputBilling: InputBillingSchema.optional().catch(void 0)
|
|
18593
19029
|
});
|
|
18594
19030
|
function inputBillingOf(row2) {
|
|
@@ -18610,7 +19046,7 @@ function animationTier(model, frameSize) {
|
|
|
18610
19046
|
if (offered.includes(tier)) return tier;
|
|
18611
19047
|
return offered[offered.length - 1] ?? tier;
|
|
18612
19048
|
}
|
|
18613
|
-
function
|
|
19049
|
+
function refuse2(model, message) {
|
|
18614
19050
|
throw new ModelKitError({ code: "unsupported_option", message, model: model.id });
|
|
18615
19051
|
}
|
|
18616
19052
|
function clamp(value, min, max) {
|
|
@@ -18625,7 +19061,7 @@ function applyAnimation(model, req, onUnsupported, warnings) {
|
|
|
18625
19061
|
const fallback = sizes[0];
|
|
18626
19062
|
if (req.exactSize !== void 0) {
|
|
18627
19063
|
if (onUnsupported === "error") {
|
|
18628
|
-
|
|
19064
|
+
refuse2(
|
|
18629
19065
|
model,
|
|
18630
19066
|
`${model.id} makes GIF frames at ${sizes.map((s) => s.size).join(", ")}; got ${req.exactSize}`
|
|
18631
19067
|
);
|
|
@@ -18647,7 +19083,7 @@ function applyAnimation(model, req, onUnsupported, warnings) {
|
|
|
18647
19083
|
const frames = asked ?? clamp(limits.defaultFrameCount, frameSize.minFrames, frameSize.maxFrames);
|
|
18648
19084
|
if (frames < frameSize.minFrames || frames > frameSize.maxFrames || !Number.isInteger(frames)) {
|
|
18649
19085
|
if (onUnsupported === "error") {
|
|
18650
|
-
|
|
19086
|
+
refuse2(
|
|
18651
19087
|
model,
|
|
18652
19088
|
`${model.id} makes ${frameSize.minFrames} to ${frameSize.maxFrames} frames at ${frameSize.size}; got ${frames}`
|
|
18653
19089
|
);
|
|
@@ -18668,7 +19104,7 @@ function applyAnimation(model, req, onUnsupported, warnings) {
|
|
|
18668
19104
|
const duration = animation.frameDurationMs ?? limits.defaultFrameDurationMs;
|
|
18669
19105
|
if (duration < min || duration > max) {
|
|
18670
19106
|
if (onUnsupported === "error") {
|
|
18671
|
-
|
|
19107
|
+
refuse2(model, `${model.id} shows each GIF frame ${min} to ${max} ms; got ${duration}`);
|
|
18672
19108
|
}
|
|
18673
19109
|
const snapped = clamp(duration, min, max);
|
|
18674
19110
|
warnings.push({
|
|
@@ -18690,7 +19126,7 @@ function applyImageOutputRules(model, req, onUnsupported, warnings) {
|
|
|
18690
19126
|
const format = req.outputFormat;
|
|
18691
19127
|
if (format !== void 0 && !imageOutputFormats(model).includes(format)) {
|
|
18692
19128
|
if (onUnsupported === "error") {
|
|
18693
|
-
|
|
19129
|
+
refuse2(
|
|
18694
19130
|
model,
|
|
18695
19131
|
`${model.id} does not offer outputFormat ${format}. Supported: ${imageOutputFormats(model).join(", ")}.`
|
|
18696
19132
|
);
|
|
@@ -18705,7 +19141,7 @@ function applyImageOutputRules(model, req, onUnsupported, warnings) {
|
|
|
18705
19141
|
}
|
|
18706
19142
|
if (req.background !== void 0 && !(c.backgrounds ?? []).includes(req.background)) {
|
|
18707
19143
|
if (onUnsupported === "error") {
|
|
18708
|
-
|
|
19144
|
+
refuse2(model, `${model.id} does not offer background ${req.background}`);
|
|
18709
19145
|
}
|
|
18710
19146
|
warnings.push({
|
|
18711
19147
|
code: "option_ignored",
|
|
@@ -18726,10 +19162,10 @@ function applyImageOutputRules(model, req, onUnsupported, warnings) {
|
|
|
18726
19162
|
delete req.animation;
|
|
18727
19163
|
}
|
|
18728
19164
|
if (req.outputFormat === "svg") {
|
|
18729
|
-
if (!c.svgModel)
|
|
19165
|
+
if (!c.svgModel) refuse2(model, `${model.id} names no svgModel to write the SVG`);
|
|
18730
19166
|
if ((req.count ?? 1) > 1) {
|
|
18731
19167
|
if (onUnsupported === "error") {
|
|
18732
|
-
|
|
19168
|
+
refuse2(model, `${model.label} makes one SVG per call`);
|
|
18733
19169
|
}
|
|
18734
19170
|
warnings.push({
|
|
18735
19171
|
code: "option_ignored",
|
|
@@ -19391,7 +19827,13 @@ function resolveAudioOptions(model, request, onUnsupported = "error") {
|
|
|
19391
19827
|
model: model.id
|
|
19392
19828
|
});
|
|
19393
19829
|
}
|
|
19394
|
-
dropUnsupported(merged, model, warnings, [
|
|
19830
|
+
dropUnsupported(merged, model, warnings, [
|
|
19831
|
+
"seed",
|
|
19832
|
+
"negativePrompt",
|
|
19833
|
+
"instrumental",
|
|
19834
|
+
"lyrics",
|
|
19835
|
+
"loop"
|
|
19836
|
+
]);
|
|
19395
19837
|
applyFalAudioRules(model, merged);
|
|
19396
19838
|
const format = resolveOutputFormat(model, request.outputFormat, onUnsupported, warnings);
|
|
19397
19839
|
if (format !== void 0) merged.outputFormat = format;
|
|
@@ -19624,7 +20066,7 @@ function resolveTranscriptionOptions(model, request, onUnsupported = "error") {
|
|
|
19624
20066
|
}
|
|
19625
20067
|
|
|
19626
20068
|
// src/resolve-voice.ts
|
|
19627
|
-
function
|
|
20069
|
+
function refuse3(model, code, message) {
|
|
19628
20070
|
return new ModelKitError({ code, message: `${model.label} ${message}`, model: model.id });
|
|
19629
20071
|
}
|
|
19630
20072
|
function checkSample(model, sample, index) {
|
|
@@ -19633,7 +20075,7 @@ function checkSample(model, sample, index) {
|
|
|
19633
20075
|
if (limits === void 0 || length === void 0) return;
|
|
19634
20076
|
if (limits.min !== void 0 && length < limits.min || limits.max !== void 0 && length > limits.max) {
|
|
19635
20077
|
const range2 = `${limits.min ?? 0}-${limits.max ?? "any"} s`;
|
|
19636
|
-
throw
|
|
20078
|
+
throw refuse3(
|
|
19637
20079
|
model,
|
|
19638
20080
|
"unsupported_option",
|
|
19639
20081
|
`takes samples of ${range2}; sample ${index + 1} is ${length} s`
|
|
@@ -19642,11 +20084,11 @@ function checkSample(model, sample, index) {
|
|
|
19642
20084
|
}
|
|
19643
20085
|
function resolveVoiceCloneOptions(model, request) {
|
|
19644
20086
|
const title = request.title.trim();
|
|
19645
|
-
if (!title) throw
|
|
19646
|
-
if (request.samples.length === 0) throw
|
|
20087
|
+
if (!title) throw refuse3(model, "missing_input", "needs a title");
|
|
20088
|
+
if (request.samples.length === 0) throw refuse3(model, "missing_input", "needs a voice sample");
|
|
19647
20089
|
const max = model.constraints.references?.audios;
|
|
19648
20090
|
if (max !== void 0 && request.samples.length > max) {
|
|
19649
|
-
throw
|
|
20091
|
+
throw refuse3(
|
|
19650
20092
|
model,
|
|
19651
20093
|
"unsupported_option",
|
|
19652
20094
|
`takes up to ${max} samples; got ${request.samples.length}`
|
|
@@ -19656,7 +20098,7 @@ function resolveVoiceCloneOptions(model, request) {
|
|
|
19656
20098
|
const total = model.constraints.references?.audioSeconds?.total;
|
|
19657
20099
|
const seconds3 = request.samples.reduce((sum, s) => sum + (s.audio.durationSeconds ?? 0), 0);
|
|
19658
20100
|
if (total !== void 0 && seconds3 > total) {
|
|
19659
|
-
throw
|
|
20101
|
+
throw refuse3(
|
|
19660
20102
|
model,
|
|
19661
20103
|
"unsupported_option",
|
|
19662
20104
|
`takes up to ${total} s of samples; got ${seconds3} s`
|
|
@@ -19665,7 +20107,7 @@ function resolveVoiceCloneOptions(model, request) {
|
|
|
19665
20107
|
for (const field of ["transcript", "designSignature"]) {
|
|
19666
20108
|
const set = request.samples.filter((s) => s[field]?.trim()).length;
|
|
19667
20109
|
if (set !== 0 && set !== request.samples.length) {
|
|
19668
|
-
throw
|
|
20110
|
+
throw refuse3(model, "missing_input", `needs ${field} on every sample or on none`);
|
|
19669
20111
|
}
|
|
19670
20112
|
}
|
|
19671
20113
|
return { request: { ...request, model: model.id, title }, warnings: [] };
|
|
@@ -19673,10 +20115,10 @@ function resolveVoiceCloneOptions(model, request) {
|
|
|
19673
20115
|
function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
|
|
19674
20116
|
const warnings = [];
|
|
19675
20117
|
const prompt = request.prompt.trim();
|
|
19676
|
-
if (!prompt) throw
|
|
20118
|
+
if (!prompt) throw refuse3(model, "missing_input", "needs a voice description");
|
|
19677
20119
|
const maxChars = promptConventions(model).maxChars;
|
|
19678
20120
|
if (maxChars !== void 0 && prompt.length > maxChars) {
|
|
19679
|
-
throw
|
|
20121
|
+
throw refuse3(
|
|
19680
20122
|
model,
|
|
19681
20123
|
"unsupported_option",
|
|
19682
20124
|
`takes up to ${maxChars} characters; got ${prompt.length}`
|
|
@@ -19687,7 +20129,7 @@ function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
|
|
|
19687
20129
|
const preview2 = request.previewText?.trim();
|
|
19688
20130
|
if (preview2) {
|
|
19689
20131
|
if (limits !== void 0 && preview2.length > limits.previewMaxChars) {
|
|
19690
|
-
throw
|
|
20132
|
+
throw refuse3(
|
|
19691
20133
|
model,
|
|
19692
20134
|
"unsupported_option",
|
|
19693
20135
|
`takes a preview line of up to ${limits.previewMaxChars} characters; got ${preview2.length}`
|
|
@@ -19703,7 +20145,7 @@ function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
|
|
|
19703
20145
|
const cap = limits?.maxCandidates ?? count2;
|
|
19704
20146
|
if (!Number.isInteger(count2) || count2 < 1 || count2 > cap) {
|
|
19705
20147
|
if (onUnsupported === "error" || !Number.isInteger(count2)) {
|
|
19706
|
-
throw
|
|
20148
|
+
throw refuse3(
|
|
19707
20149
|
model,
|
|
19708
20150
|
"unsupported_option",
|
|
19709
20151
|
`returns 1-${cap} candidates; got ${count2}`
|
|
@@ -20073,7 +20515,7 @@ async function testProviderKey(provider, secret, opts = {}) {
|
|
|
20073
20515
|
|
|
20074
20516
|
// src/text.ts
|
|
20075
20517
|
import "ai";
|
|
20076
|
-
import { z as
|
|
20518
|
+
import { z as z38 } from "zod";
|
|
20077
20519
|
function mergeTextProviderOptions(catalog, caller) {
|
|
20078
20520
|
const merged = {};
|
|
20079
20521
|
const catalogOptions = catalog.providerOptions ?? {};
|
|
@@ -20112,17 +20554,17 @@ function passthroughTextModel(model) {
|
|
|
20112
20554
|
pricingKind: "token"
|
|
20113
20555
|
};
|
|
20114
20556
|
}
|
|
20115
|
-
var perplexityCostSchema =
|
|
20116
|
-
perplexity:
|
|
20557
|
+
var perplexityCostSchema = z38.object({
|
|
20558
|
+
perplexity: z38.object({ cost: z38.object({ totalCost: z38.number().finite().nonnegative() }) })
|
|
20117
20559
|
});
|
|
20118
20560
|
function reportedCostUsd(metadata) {
|
|
20119
20561
|
const parsed = perplexityCostSchema.safeParse(metadata);
|
|
20120
20562
|
return parsed.success ? parsed.data.perplexity.cost.totalCost : void 0;
|
|
20121
20563
|
}
|
|
20122
|
-
function textUsageEvent(model, provider,
|
|
20123
|
-
const inputTokens =
|
|
20124
|
-
const outputTokens =
|
|
20125
|
-
const total =
|
|
20564
|
+
function textUsageEvent(model, provider, usage6, providerMetadata) {
|
|
20565
|
+
const inputTokens = usage6.inputTokens ?? 0;
|
|
20566
|
+
const outputTokens = usage6.outputTokens ?? 0;
|
|
20567
|
+
const total = usage6.totalTokens ?? inputTokens + outputTokens;
|
|
20126
20568
|
const event = {
|
|
20127
20569
|
model: model.id,
|
|
20128
20570
|
provider,
|
|
@@ -20157,7 +20599,7 @@ function createTextSteps(initial, resolve, callerProviderOptions) {
|
|
|
20157
20599
|
return { ...prepared, providerOptions };
|
|
20158
20600
|
};
|
|
20159
20601
|
}
|
|
20160
|
-
function
|
|
20602
|
+
function usage6(results) {
|
|
20161
20603
|
const grouped = /* @__PURE__ */ new Map();
|
|
20162
20604
|
for (const [index, step] of results.entries()) {
|
|
20163
20605
|
const target = steps.get(index) ?? initial;
|
|
@@ -20179,7 +20621,7 @@ function createTextSteps(initial, resolve, callerProviderOptions) {
|
|
|
20179
20621
|
}
|
|
20180
20622
|
return [...grouped.values()];
|
|
20181
20623
|
}
|
|
20182
|
-
return { wrap, usage:
|
|
20624
|
+
return { wrap, usage: usage6 };
|
|
20183
20625
|
}
|
|
20184
20626
|
|
|
20185
20627
|
// src/client.ts
|
|
@@ -20191,7 +20633,7 @@ import {
|
|
|
20191
20633
|
streamObject as aiStreamObject2,
|
|
20192
20634
|
streamText as aiStreamText2
|
|
20193
20635
|
} from "ai";
|
|
20194
|
-
import { z as
|
|
20636
|
+
import { z as z39 } from "zod";
|
|
20195
20637
|
|
|
20196
20638
|
// src/generated-image.ts
|
|
20197
20639
|
function toGeneratedImage(image) {
|
|
@@ -20313,9 +20755,9 @@ function providerJobMethods(kind, deps) {
|
|
|
20313
20755
|
const { methods, adapter, ctx } = target(sub.model, rest);
|
|
20314
20756
|
if (!methods.result) throw missing3(adapter, ctx.model);
|
|
20315
20757
|
const result = await methods.result(sub, ctx, webhook);
|
|
20316
|
-
const
|
|
20317
|
-
await deps.emit(
|
|
20318
|
-
return { ...result, usage:
|
|
20758
|
+
const usage6 = deps.rowUsage(ctx, result.usage, sub.submittedAt);
|
|
20759
|
+
await deps.emit(usage6);
|
|
20760
|
+
return { ...result, usage: usage6 };
|
|
20319
20761
|
},
|
|
20320
20762
|
async cancel(sub, call = {}) {
|
|
20321
20763
|
const { methods, adapter, ctx } = target(sub.model, call);
|
|
@@ -20555,10 +20997,10 @@ function audioNodeMethods(deps) {
|
|
|
20555
20997
|
const startedAt = Date.now();
|
|
20556
20998
|
const outcome = await adapter.dub(resolved, ctx);
|
|
20557
20999
|
if (outcome.kind === "audio") {
|
|
20558
|
-
const { audio, usage:
|
|
21000
|
+
const { audio, usage: usage6, raw } = outcome.result;
|
|
20559
21001
|
return {
|
|
20560
21002
|
audio,
|
|
20561
|
-
usage: await deps.settle(ctx,
|
|
21003
|
+
usage: await deps.settle(ctx, usage6, startedAt),
|
|
20562
21004
|
...raw !== void 0 && { raw }
|
|
20563
21005
|
};
|
|
20564
21006
|
}
|
|
@@ -20610,10 +21052,10 @@ function textAbortOptions(sdk, context) {
|
|
|
20610
21052
|
if (abortSignal) return { abortSignal };
|
|
20611
21053
|
return {};
|
|
20612
21054
|
}
|
|
20613
|
-
var catalogId =
|
|
20614
|
-
var exactSize =
|
|
20615
|
-
var sdkRatio =
|
|
20616
|
-
var sizeTier =
|
|
21055
|
+
var catalogId = z39.string();
|
|
21056
|
+
var exactSize = z39.templateLiteral([z39.number(), "x", z39.number()]);
|
|
21057
|
+
var sdkRatio = z39.templateLiteral([z39.number(), ":", z39.number()]);
|
|
21058
|
+
var sizeTier = z39.enum(["512", "1K", "2K", "4K", "8K"]);
|
|
20617
21059
|
function isCatalogId(model) {
|
|
20618
21060
|
return catalogId.safeParse(model).success;
|
|
20619
21061
|
}
|
|
@@ -20856,7 +21298,7 @@ function createModelKit(config, adapters) {
|
|
|
20856
21298
|
const images = result.images.map(
|
|
20857
21299
|
(file) => toGeneratedImage({ bytes: file.uint8Array, mime: file.mediaType })
|
|
20858
21300
|
);
|
|
20859
|
-
const
|
|
21301
|
+
const usage6 = timed(
|
|
20860
21302
|
{
|
|
20861
21303
|
model: model.modelId,
|
|
20862
21304
|
provider: model.provider,
|
|
@@ -20866,8 +21308,8 @@ function createModelKit(config, adapters) {
|
|
|
20866
21308
|
},
|
|
20867
21309
|
startedAt
|
|
20868
21310
|
);
|
|
20869
|
-
await emit(
|
|
20870
|
-
return { image: images[0], images, usage:
|
|
21311
|
+
await emit(usage6);
|
|
21312
|
+
return { image: images[0], images, usage: usage6, raw: result, warnings };
|
|
20871
21313
|
}
|
|
20872
21314
|
function passthroughVideo(req, call) {
|
|
20873
21315
|
const {
|
|
@@ -20885,7 +21327,7 @@ function createModelKit(config, adapters) {
|
|
|
20885
21327
|
referenceVideos,
|
|
20886
21328
|
referenceAudios,
|
|
20887
21329
|
resolution,
|
|
20888
|
-
generateAudio:
|
|
21330
|
+
generateAudio: generateAudio3,
|
|
20889
21331
|
negativePrompt: _negativePrompt,
|
|
20890
21332
|
cfgScale: _cfgScale,
|
|
20891
21333
|
promptExpansion: _promptExpansion,
|
|
@@ -20902,7 +21344,7 @@ function createModelKit(config, adapters) {
|
|
|
20902
21344
|
pushIgnored(warnings, "aspectRatio", aspectRatio, model.modelId);
|
|
20903
21345
|
if (seconds3 !== void 0) options.duration = seconds3;
|
|
20904
21346
|
if (seed !== void 0) options.seed = seed;
|
|
20905
|
-
if (
|
|
21347
|
+
if (generateAudio3 !== void 0) options.generateAudio = generateAudio3;
|
|
20906
21348
|
const frames = [
|
|
20907
21349
|
...firstFrame ? [{ image: sdkDataContent(firstFrame), frameType: "first_frame" }] : [],
|
|
20908
21350
|
...lastFrame ? [{ image: sdkDataContent(lastFrame), frameType: "last_frame" }] : []
|
|
@@ -20943,7 +21385,7 @@ function createModelKit(config, adapters) {
|
|
|
20943
21385
|
let settled;
|
|
20944
21386
|
let failed = false;
|
|
20945
21387
|
const done = pending.then(async (result) => {
|
|
20946
|
-
const
|
|
21388
|
+
const usage6 = timed(
|
|
20947
21389
|
{
|
|
20948
21390
|
model: model.modelId,
|
|
20949
21391
|
provider: model.provider,
|
|
@@ -20956,10 +21398,10 @@ function createModelKit(config, adapters) {
|
|
|
20956
21398
|
);
|
|
20957
21399
|
settled = {
|
|
20958
21400
|
video: { bytes: result.video.uint8Array, mime: result.video.mediaType },
|
|
20959
|
-
usage:
|
|
21401
|
+
usage: usage6,
|
|
20960
21402
|
raw: result
|
|
20961
21403
|
};
|
|
20962
|
-
await emit(
|
|
21404
|
+
await emit(usage6);
|
|
20963
21405
|
return settled;
|
|
20964
21406
|
});
|
|
20965
21407
|
done.catch(() => {
|
|
@@ -20986,9 +21428,9 @@ function createModelKit(config, adapters) {
|
|
|
20986
21428
|
if (settled) return settled;
|
|
20987
21429
|
const pending = result(opts).then(
|
|
20988
21430
|
async (out) => {
|
|
20989
|
-
const
|
|
20990
|
-
await emit(
|
|
20991
|
-
return { ...out, usage:
|
|
21431
|
+
const usage6 = rowUsage(ctx, out.usage, startedAt);
|
|
21432
|
+
await emit(usage6);
|
|
21433
|
+
return { ...out, usage: usage6 };
|
|
20992
21434
|
},
|
|
20993
21435
|
(cause) => {
|
|
20994
21436
|
settled = void 0;
|
|
@@ -21008,9 +21450,9 @@ function createModelKit(config, adapters) {
|
|
|
21008
21450
|
return context(model, signal ? { ...call, signal } : call, warnings);
|
|
21009
21451
|
},
|
|
21010
21452
|
async settle(ctx, event, startedAt) {
|
|
21011
|
-
const
|
|
21012
|
-
await emit(
|
|
21013
|
-
return
|
|
21453
|
+
const usage6 = rowUsage(ctx, event, startedAt);
|
|
21454
|
+
await emit(usage6);
|
|
21455
|
+
return usage6;
|
|
21014
21456
|
},
|
|
21015
21457
|
wrapVideoJob
|
|
21016
21458
|
});
|
|
@@ -21055,8 +21497,8 @@ function createModelKit(config, adapters) {
|
|
|
21055
21497
|
throw billedFailure(ctx, err, err.usage, startedAt);
|
|
21056
21498
|
throw err;
|
|
21057
21499
|
}
|
|
21058
|
-
const
|
|
21059
|
-
await emit(
|
|
21500
|
+
const usage6 = rowUsage(ctx, result.usage, startedAt);
|
|
21501
|
+
await emit(usage6);
|
|
21060
21502
|
const images = result.images.map(toGeneratedImage);
|
|
21061
21503
|
const first = images[0];
|
|
21062
21504
|
if (!first)
|
|
@@ -21065,7 +21507,7 @@ function createModelKit(config, adapters) {
|
|
|
21065
21507
|
message: `${model.id} returned no image`,
|
|
21066
21508
|
model: model.id
|
|
21067
21509
|
});
|
|
21068
|
-
return { ...result, usage:
|
|
21510
|
+
return { ...result, usage: usage6, image: first, images, warnings };
|
|
21069
21511
|
},
|
|
21070
21512
|
async generateVideo(req, call = {}) {
|
|
21071
21513
|
mediaRetryOptions(call);
|
|
@@ -21166,9 +21608,9 @@ function createModelKit(config, adapters) {
|
|
|
21166
21608
|
}
|
|
21167
21609
|
const startedAt = Date.now();
|
|
21168
21610
|
const result = await adapter.generateAudio(resolved, ctx);
|
|
21169
|
-
const
|
|
21170
|
-
await emit(
|
|
21171
|
-
return { ...result, usage:
|
|
21611
|
+
const usage6 = rowUsage(ctx, result.usage, startedAt);
|
|
21612
|
+
await emit(usage6);
|
|
21613
|
+
return { ...result, usage: usage6 };
|
|
21172
21614
|
},
|
|
21173
21615
|
async prepareMediaPart(modelId, ref, mediaType, call = {}) {
|
|
21174
21616
|
mediaRetryOptions(call);
|
|
@@ -21249,8 +21691,8 @@ function createModelKit(config, adapters) {
|
|
|
21249
21691
|
options.prepareStep ?? options.experimental_prepareStep
|
|
21250
21692
|
),
|
|
21251
21693
|
onFinish: async (event) => {
|
|
21252
|
-
for (const
|
|
21253
|
-
await emit(textTimed(withRowUnit(
|
|
21694
|
+
for (const usage6 of steps.usage(event.steps))
|
|
21695
|
+
await emit(textTimed(withRowUnit(usage6), event.steps.length, startedAt));
|
|
21254
21696
|
await callerOnFinish?.(event);
|
|
21255
21697
|
}
|
|
21256
21698
|
});
|
|
@@ -21330,7 +21772,7 @@ var generateObject = (options, call) => createDefaultModelKit().generateObject(o
|
|
|
21330
21772
|
var streamObject = (options, call) => createDefaultModelKit().streamObject(options, call);
|
|
21331
21773
|
var generateImage = (req, call) => createDefaultModelKit().generateImage(req, call);
|
|
21332
21774
|
var generateVideo = (req, call) => createDefaultModelKit().generateVideo(req, call);
|
|
21333
|
-
var
|
|
21775
|
+
var generateAudio2 = (req, call) => createDefaultModelKit().generateAudio(req, call);
|
|
21334
21776
|
var prepareMediaPart = (modelId, ref, mediaType, call) => createDefaultModelKit().prepareMediaPart(modelId, ref, mediaType, call);
|
|
21335
21777
|
var languageModel = (modelId, call) => createDefaultModelKit().languageModel(modelId, call);
|
|
21336
21778
|
var describe = (modelId) => createDefaultModelKit().describe(modelId);
|
|
@@ -21346,6 +21788,7 @@ export {
|
|
|
21346
21788
|
CatalogSchema,
|
|
21347
21789
|
DEFAULT_ADAPTERS,
|
|
21348
21790
|
ExposureSchema,
|
|
21791
|
+
GEMINI_VOICE_CONSENT,
|
|
21349
21792
|
IMAGE_INPUT_SPEC_KEYS,
|
|
21350
21793
|
INPUT_BILLINGS,
|
|
21351
21794
|
INPUT_SPEC_SUPPORTS_KEYS,
|
|
@@ -21382,7 +21825,7 @@ export {
|
|
|
21382
21825
|
falWebhookBodySchema,
|
|
21383
21826
|
fileCatalogCache,
|
|
21384
21827
|
fishAdapter,
|
|
21385
|
-
generateAudio,
|
|
21828
|
+
generateAudio2 as generateAudio,
|
|
21386
21829
|
generateImage,
|
|
21387
21830
|
generateObject,
|
|
21388
21831
|
generateText2 as generateText,
|