@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.cjs
CHANGED
|
@@ -42,6 +42,7 @@ __export(index_exports, {
|
|
|
42
42
|
CatalogSchema: () => CatalogSchema,
|
|
43
43
|
DEFAULT_ADAPTERS: () => DEFAULT_ADAPTERS,
|
|
44
44
|
ExposureSchema: () => ExposureSchema,
|
|
45
|
+
GEMINI_VOICE_CONSENT: () => GEMINI_VOICE_CONSENT,
|
|
45
46
|
IMAGE_INPUT_SPEC_KEYS: () => IMAGE_INPUT_SPEC_KEYS,
|
|
46
47
|
INPUT_BILLINGS: () => INPUT_BILLINGS,
|
|
47
48
|
INPUT_SPEC_SUPPORTS_KEYS: () => INPUT_SPEC_SUPPORTS_KEYS,
|
|
@@ -78,7 +79,7 @@ __export(index_exports, {
|
|
|
78
79
|
falWebhookBodySchema: () => falWebhookBodySchema,
|
|
79
80
|
fileCatalogCache: () => fileCatalogCache,
|
|
80
81
|
fishAdapter: () => fishAdapter,
|
|
81
|
-
generateAudio: () =>
|
|
82
|
+
generateAudio: () => generateAudio2,
|
|
82
83
|
generateImage: () => generateImage,
|
|
83
84
|
generateObject: () => generateObject,
|
|
84
85
|
generateText: () => generateText2,
|
|
@@ -188,13 +189,13 @@ var ModelKitError = class _ModelKitError extends Error {
|
|
|
188
189
|
this.finishReason = init.finishReason;
|
|
189
190
|
this.usage = init.usage;
|
|
190
191
|
}
|
|
191
|
-
withUsage(
|
|
192
|
+
withUsage(usage6) {
|
|
192
193
|
const init = {
|
|
193
194
|
code: this.code,
|
|
194
195
|
message: this.message,
|
|
195
196
|
cause: this.cause,
|
|
196
197
|
retryable: this.retryable,
|
|
197
|
-
usage:
|
|
198
|
+
usage: usage6
|
|
198
199
|
};
|
|
199
200
|
if (this.provider !== void 0) init.provider = this.provider;
|
|
200
201
|
if (this.model !== void 0) init.model = this.model;
|
|
@@ -534,7 +535,8 @@ var FAL_IMAGE_MODELS = [
|
|
|
534
535
|
constraints: {
|
|
535
536
|
aspectRatios: [...KLING_RATIOS, "adaptive"],
|
|
536
537
|
sizes: ["2K", "4K", "8K"],
|
|
537
|
-
|
|
538
|
+
// fal refuses a reference under 300x300 (422 image_too_small, prod COWORK-5S).
|
|
539
|
+
references: { images: 10, imagePixels: { minWidth: 300, minHeight: 300 } },
|
|
538
540
|
supports: ["count"],
|
|
539
541
|
prompt: { referenceSyntax: "numbered", maxChars: 21e3 }
|
|
540
542
|
},
|
|
@@ -2557,6 +2559,94 @@ var GEMINI_TTS_VOICES = [
|
|
|
2557
2559
|
{ id: "Zubenelgenubi", name: "Zubenelgenubi" }
|
|
2558
2560
|
];
|
|
2559
2561
|
|
|
2562
|
+
// src/catalog/speech-gemini-direct.ts
|
|
2563
|
+
var GOOGLE_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png";
|
|
2564
|
+
var GEMINI_VOICE_CONSENT = {
|
|
2565
|
+
"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.",
|
|
2566
|
+
"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",
|
|
2567
|
+
"de-DE": "Ich bin der Eigent\xFCmer dieser Stimme und bin damit einverstanden, dass Google diese Stimme zur Erstellung eines synthetischen Stimmmodells verwendet.",
|
|
2568
|
+
"en-AU": "I am the owner of this voice and I consent to Google using this voice to create a synthetic voice model.",
|
|
2569
|
+
"en-GB": "I am the owner of this voice and I consent to Google using this voice to create a synthetic voice model.",
|
|
2570
|
+
"en-IN": "I am the owner of this voice and I consent to Google using this voice to create a synthetic voice model.",
|
|
2571
|
+
"en-US": "I am the owner of this voice and I consent to Google using this voice to create a synthetic voice model.",
|
|
2572
|
+
"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.",
|
|
2573
|
+
"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.",
|
|
2574
|
+
"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.",
|
|
2575
|
+
"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.",
|
|
2576
|
+
"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",
|
|
2577
|
+
"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",
|
|
2578
|
+
"id-ID": "Saya pemilik suara ini dan saya menyetujui Google menggunakan suara ini untuk membuat model suara sintetis.",
|
|
2579
|
+
"it-IT": "Sono il proprietario di questa voce e acconsento che Google la utilizzi per creare un modello di voce sintetica.",
|
|
2580
|
+
"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",
|
|
2581
|
+
"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.",
|
|
2582
|
+
"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.",
|
|
2583
|
+
"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.",
|
|
2584
|
+
"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",
|
|
2585
|
+
"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.",
|
|
2586
|
+
"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.",
|
|
2587
|
+
"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.",
|
|
2588
|
+
"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.",
|
|
2589
|
+
"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.",
|
|
2590
|
+
"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.",
|
|
2591
|
+
"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",
|
|
2592
|
+
"tr-TR": "Bu sesin sahibi benim ve Google'\u0131n bu sesi kullanarak sentetik bir ses modeli olu\u015Fturmas\u0131na izin veriyorum.",
|
|
2593
|
+
"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.",
|
|
2594
|
+
"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"
|
|
2595
|
+
};
|
|
2596
|
+
var GEMINI_DIRECT_MODELS = [
|
|
2597
|
+
{
|
|
2598
|
+
id: "gemini-3.8-flash-tts-direct",
|
|
2599
|
+
aliases: [],
|
|
2600
|
+
label: "Gemini 3.8 Flash TTS",
|
|
2601
|
+
type: "speech",
|
|
2602
|
+
adapter: "google-genai",
|
|
2603
|
+
providerModelId: "gemini-3.8-flash-tts",
|
|
2604
|
+
lifecycle: "active",
|
|
2605
|
+
exposure: ["cowork"],
|
|
2606
|
+
constraints: {
|
|
2607
|
+
voices: GEMINI_TTS_VOICES,
|
|
2608
|
+
// Returns a 24 kHz mono WAV; the language is detected from the script.
|
|
2609
|
+
supports: ["style"],
|
|
2610
|
+
// Google's docs state no script limit; fal gives 8,192 input tokens for this model
|
|
2611
|
+
// (a token is at least one character), so the same cap is kept here.
|
|
2612
|
+
prompt: { referenceSyntax: "numbered", maxChars: 8192 }
|
|
2613
|
+
},
|
|
2614
|
+
defaults: { voice: "Kore" },
|
|
2615
|
+
usage: { unit: "images" },
|
|
2616
|
+
pricingKind: "flat",
|
|
2617
|
+
display: {
|
|
2618
|
+
provider: "google",
|
|
2619
|
+
logo: GOOGLE_LOGO,
|
|
2620
|
+
description: "Google Gemini 3.8 Flash text to speech in 30 prebuilt voices or your own replicated voice, with separate style instructions."
|
|
2621
|
+
},
|
|
2622
|
+
capabilities: { customVoices: true }
|
|
2623
|
+
},
|
|
2624
|
+
{
|
|
2625
|
+
id: "gemini-voice-clone",
|
|
2626
|
+
aliases: [],
|
|
2627
|
+
label: "Gemini Voice Replication",
|
|
2628
|
+
type: "voice-clone",
|
|
2629
|
+
adapter: "google-genai",
|
|
2630
|
+
providerModelId: "gemini-3.8-flash-tts",
|
|
2631
|
+
lifecycle: "active",
|
|
2632
|
+
exposure: ["cowork"],
|
|
2633
|
+
constraints: {
|
|
2634
|
+
// One 10-30 s recording, plus the consent recording. Google's samples are WAV.
|
|
2635
|
+
references: { audios: 1, audioFormats: ["wav"], audioSeconds: { min: 10, max: 30 } },
|
|
2636
|
+
supports: []
|
|
2637
|
+
},
|
|
2638
|
+
defaults: {},
|
|
2639
|
+
usage: { unit: "requests" },
|
|
2640
|
+
pricingKind: "flat",
|
|
2641
|
+
display: {
|
|
2642
|
+
provider: "google",
|
|
2643
|
+
logo: GOOGLE_LOGO,
|
|
2644
|
+
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."
|
|
2645
|
+
},
|
|
2646
|
+
capabilities: {}
|
|
2647
|
+
}
|
|
2648
|
+
];
|
|
2649
|
+
|
|
2560
2650
|
// src/catalog/voices-minimax.ts
|
|
2561
2651
|
var MINIMAX_VOICES = [
|
|
2562
2652
|
{ id: "Wise_Woman", name: "Wise Woman" },
|
|
@@ -4057,7 +4147,7 @@ var MINIMAX_VOICES = [
|
|
|
4057
4147
|
|
|
4058
4148
|
// src/catalog/media-nodes.ts
|
|
4059
4149
|
var ELEVENLABS_LOGO2 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/elevenlabs.png";
|
|
4060
|
-
var
|
|
4150
|
+
var GOOGLE_LOGO2 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png";
|
|
4061
4151
|
var MINIMAX_LOGO2 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
|
|
4062
4152
|
var SYNC_LOGO = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/sync.png";
|
|
4063
4153
|
var PER_CALL3 = { unit: "images" };
|
|
@@ -4107,7 +4197,7 @@ function geminiTts(id, label, description) {
|
|
|
4107
4197
|
defaults: { voice: "Kore" },
|
|
4108
4198
|
usage: PER_CALL3,
|
|
4109
4199
|
pricingKind: "flat",
|
|
4110
|
-
display: { provider: "google", logo:
|
|
4200
|
+
display: { provider: "google", logo: GOOGLE_LOGO2, description },
|
|
4111
4201
|
capabilities: {}
|
|
4112
4202
|
};
|
|
4113
4203
|
}
|
|
@@ -4353,7 +4443,8 @@ var MEDIA_NODE_MODELS = [
|
|
|
4353
4443
|
},
|
|
4354
4444
|
SAM_3_IMAGE,
|
|
4355
4445
|
...FISH_MODELS,
|
|
4356
|
-
...ELEVENLABS_DIRECT_MODELS
|
|
4446
|
+
...ELEVENLABS_DIRECT_MODELS,
|
|
4447
|
+
...GEMINI_DIRECT_MODELS
|
|
4357
4448
|
];
|
|
4358
4449
|
|
|
4359
4450
|
// src/catalog/model3d.ts
|
|
@@ -4547,9 +4638,67 @@ var MODEL3D_MODELS = [
|
|
|
4547
4638
|
)
|
|
4548
4639
|
];
|
|
4549
4640
|
|
|
4550
|
-
// src/catalog/
|
|
4551
|
-
var GOOGLE_LOGO2 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png";
|
|
4641
|
+
// src/catalog/audio-elevenlabs-direct.ts
|
|
4552
4642
|
var ELEVENLABS_LOGO3 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/elevenlabs.png";
|
|
4643
|
+
var ELEVENLABS_DIRECT_AUDIO_MODELS = [
|
|
4644
|
+
{
|
|
4645
|
+
id: "elevenlabs-music-direct",
|
|
4646
|
+
aliases: [],
|
|
4647
|
+
label: "Eleven Music",
|
|
4648
|
+
type: "audio",
|
|
4649
|
+
adapter: "elevenlabs",
|
|
4650
|
+
providerModelId: "music_v2_5",
|
|
4651
|
+
lifecycle: "active",
|
|
4652
|
+
exposure: ["cowork"],
|
|
4653
|
+
constraints: {
|
|
4654
|
+
// The API takes 3 s to 10 min; ElevenLabs' overview says 5 min, so stop there.
|
|
4655
|
+
durations: { min: 3, max: 300 },
|
|
4656
|
+
durationPresets: [30, 60, 120, 180],
|
|
4657
|
+
// No `seed`: the API refuses it with a prompt (composition plans only).
|
|
4658
|
+
supports: ["instrumental"],
|
|
4659
|
+
outputFormats: ELEVENLABS_MUSIC_FORMATS
|
|
4660
|
+
},
|
|
4661
|
+
defaults: { durationSeconds: 60, outputFormat: "mp3_48000_192" },
|
|
4662
|
+
usage: { unit: "seconds" },
|
|
4663
|
+
pricingKind: "flat",
|
|
4664
|
+
display: {
|
|
4665
|
+
provider: "elevenlabs",
|
|
4666
|
+
logo: ELEVENLABS_LOGO3,
|
|
4667
|
+
description: "Songs and instrumentals in any genre, from 3 seconds to 5 minutes."
|
|
4668
|
+
},
|
|
4669
|
+
capabilities: {}
|
|
4670
|
+
},
|
|
4671
|
+
{
|
|
4672
|
+
id: "elevenlabs-sound-effects-direct",
|
|
4673
|
+
aliases: [],
|
|
4674
|
+
label: "Eleven Sound Effects",
|
|
4675
|
+
type: "sound-effect",
|
|
4676
|
+
adapter: "elevenlabs",
|
|
4677
|
+
providerModelId: "eleven_text_to_sound_v3",
|
|
4678
|
+
lifecycle: "active",
|
|
4679
|
+
exposure: ["cowork"],
|
|
4680
|
+
constraints: {
|
|
4681
|
+
durations: { min: 0.5, max: 30 },
|
|
4682
|
+
durationPresets: [2, 5, 10, 22],
|
|
4683
|
+
supports: ["loop"],
|
|
4684
|
+
outputFormats: ELEVENLABS_MP3_FORMATS
|
|
4685
|
+
},
|
|
4686
|
+
// No default length: a request without one gets ElevenLabs' auto length.
|
|
4687
|
+
defaults: { outputFormat: "mp3_44100_128" },
|
|
4688
|
+
usage: { unit: "seconds" },
|
|
4689
|
+
pricingKind: "flat",
|
|
4690
|
+
display: {
|
|
4691
|
+
provider: "elevenlabs",
|
|
4692
|
+
logo: ELEVENLABS_LOGO3,
|
|
4693
|
+
description: "Any sound from a text description, up to 30 seconds, at a set or automatic length; can loop."
|
|
4694
|
+
},
|
|
4695
|
+
capabilities: {}
|
|
4696
|
+
}
|
|
4697
|
+
];
|
|
4698
|
+
|
|
4699
|
+
// src/catalog/other.ts
|
|
4700
|
+
var GOOGLE_LOGO3 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png";
|
|
4701
|
+
var ELEVENLABS_LOGO4 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/elevenlabs.png";
|
|
4553
4702
|
var MINIMAX_LOGO3 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
|
|
4554
4703
|
var OTHER_MODELS = [
|
|
4555
4704
|
{
|
|
@@ -4571,7 +4720,7 @@ var OTHER_MODELS = [
|
|
|
4571
4720
|
pricingKind: "flat",
|
|
4572
4721
|
display: {
|
|
4573
4722
|
provider: "google",
|
|
4574
|
-
logo:
|
|
4723
|
+
logo: GOOGLE_LOGO3,
|
|
4575
4724
|
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."
|
|
4576
4725
|
},
|
|
4577
4726
|
capabilities: {}
|
|
@@ -4594,7 +4743,7 @@ var OTHER_MODELS = [
|
|
|
4594
4743
|
pricingKind: "flat",
|
|
4595
4744
|
display: {
|
|
4596
4745
|
provider: "google",
|
|
4597
|
-
logo:
|
|
4746
|
+
logo: GOOGLE_LOGO3,
|
|
4598
4747
|
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."
|
|
4599
4748
|
},
|
|
4600
4749
|
capabilities: {}
|
|
@@ -4686,7 +4835,7 @@ var OTHER_MODELS = [
|
|
|
4686
4835
|
pricingKind: "flat",
|
|
4687
4836
|
display: {
|
|
4688
4837
|
provider: "google",
|
|
4689
|
-
logo:
|
|
4838
|
+
logo: GOOGLE_LOGO3,
|
|
4690
4839
|
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."
|
|
4691
4840
|
},
|
|
4692
4841
|
capabilities: {}
|
|
@@ -4714,7 +4863,7 @@ var OTHER_MODELS = [
|
|
|
4714
4863
|
pricingKind: "flat",
|
|
4715
4864
|
display: {
|
|
4716
4865
|
provider: "elevenlabs",
|
|
4717
|
-
logo:
|
|
4866
|
+
logo: ELEVENLABS_LOGO4,
|
|
4718
4867
|
description: "ElevenLabs Music v2.5 text-to-music; full songs or instrumentals from 3 seconds to 1 minute."
|
|
4719
4868
|
},
|
|
4720
4869
|
capabilities: {}
|
|
@@ -4766,7 +4915,7 @@ var OTHER_MODELS = [
|
|
|
4766
4915
|
pricingKind: "flat",
|
|
4767
4916
|
display: {
|
|
4768
4917
|
provider: "elevenlabs",
|
|
4769
|
-
logo:
|
|
4918
|
+
logo: ELEVENLABS_LOGO4,
|
|
4770
4919
|
description: "ElevenLabs Sound Effects v2; a sound effect from a text description, up to 22 seconds."
|
|
4771
4920
|
},
|
|
4772
4921
|
capabilities: {}
|
|
@@ -4902,7 +5051,8 @@ var OTHER_MODELS = [
|
|
|
4902
5051
|
provider: "prodia",
|
|
4903
5052
|
description: "Background removal; takes one input image and returns a PNG cut-out of the subject plus an optional black-and-white mask."
|
|
4904
5053
|
}
|
|
4905
|
-
}
|
|
5054
|
+
},
|
|
5055
|
+
...ELEVENLABS_DIRECT_AUDIO_MODELS
|
|
4906
5056
|
];
|
|
4907
5057
|
|
|
4908
5058
|
// src/catalog/text.ts
|
|
@@ -6174,7 +6324,7 @@ var H3_PROMPT2 = { referenceSyntax: "numbered", maxChars: 5e4 };
|
|
|
6174
6324
|
var WAN_PROMPT = { referenceSyntax: "numbered", maxChars: 2e4 };
|
|
6175
6325
|
var OMNI_PROMPT = { referenceSyntax: "caption", maxChars: 5e4 };
|
|
6176
6326
|
var BYTEDANCE_LOGO2 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/3bba5d81-4e57-4e71-911b-cdfa05acca2c_compressed.png";
|
|
6177
|
-
var
|
|
6327
|
+
var GOOGLE_LOGO4 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png";
|
|
6178
6328
|
var VIDEO_MODELS = [
|
|
6179
6329
|
// Google shuts down the Veo 3.1 previews and Omni Flash 1.0 on 2026-10-22.
|
|
6180
6330
|
{
|
|
@@ -6210,7 +6360,7 @@ var VIDEO_MODELS = [
|
|
|
6210
6360
|
display: {
|
|
6211
6361
|
provider: "google",
|
|
6212
6362
|
description: "Google's highest-quality video generation model. Supports up to 4K resolution and 8-second clips with reference image conditioning.",
|
|
6213
|
-
logo:
|
|
6363
|
+
logo: GOOGLE_LOGO4
|
|
6214
6364
|
},
|
|
6215
6365
|
// Veo's lastFrame "must be used in combination with the image parameter".
|
|
6216
6366
|
capabilities: { ...FRAMES_EXCLUDE_REFERENCES, lastFrameRequiresFirstFrame: true }
|
|
@@ -6311,7 +6461,7 @@ var VIDEO_MODELS = [
|
|
|
6311
6461
|
display: {
|
|
6312
6462
|
provider: "google",
|
|
6313
6463
|
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.",
|
|
6314
|
-
logo:
|
|
6464
|
+
logo: GOOGLE_LOGO4
|
|
6315
6465
|
},
|
|
6316
6466
|
capabilities: { acceptsSourceVideo: true, videoEdit: true }
|
|
6317
6467
|
},
|
|
@@ -6348,7 +6498,7 @@ var VIDEO_MODELS = [
|
|
|
6348
6498
|
pricingKind: "video_per_second",
|
|
6349
6499
|
display: {
|
|
6350
6500
|
provider: "google",
|
|
6351
|
-
logo:
|
|
6501
|
+
logo: GOOGLE_LOGO4,
|
|
6352
6502
|
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."
|
|
6353
6503
|
},
|
|
6354
6504
|
capabilities: {
|
|
@@ -6387,7 +6537,7 @@ var VIDEO_MODELS = [
|
|
|
6387
6537
|
pricingKind: "video_per_second",
|
|
6388
6538
|
display: {
|
|
6389
6539
|
provider: "google",
|
|
6390
|
-
logo:
|
|
6540
|
+
logo: GOOGLE_LOGO4,
|
|
6391
6541
|
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."
|
|
6392
6542
|
},
|
|
6393
6543
|
capabilities: {
|
|
@@ -8403,6 +8553,7 @@ var SupportedOptionSchema = import_zod3.z.enum([
|
|
|
8403
8553
|
"videoExtension",
|
|
8404
8554
|
"instrumental",
|
|
8405
8555
|
"lyrics",
|
|
8556
|
+
"loop",
|
|
8406
8557
|
"style",
|
|
8407
8558
|
"insertWindow",
|
|
8408
8559
|
"points",
|
|
@@ -10039,7 +10190,7 @@ async function generateAlibabaImage(req, ctx) {
|
|
|
10039
10190
|
return { bytes: new Uint8Array(await res.arrayBuffer()), mime };
|
|
10040
10191
|
})
|
|
10041
10192
|
);
|
|
10042
|
-
const
|
|
10193
|
+
const usage6 = {
|
|
10043
10194
|
model: modelId,
|
|
10044
10195
|
provider: "alibaba",
|
|
10045
10196
|
modality: "IMAGE",
|
|
@@ -10047,9 +10198,9 @@ async function generateAlibabaImage(req, ctx) {
|
|
|
10047
10198
|
quantity: data.usage?.output_image_count ?? images.length
|
|
10048
10199
|
};
|
|
10049
10200
|
const tier = billedTier(data.usage?.output_image_type, req.size);
|
|
10050
|
-
if (tier !== void 0)
|
|
10051
|
-
if (req.quality !== void 0)
|
|
10052
|
-
return { images, usage:
|
|
10201
|
+
if (tier !== void 0) usage6.imageSize = tier;
|
|
10202
|
+
if (req.quality !== void 0) usage6.imageQuality = req.quality;
|
|
10203
|
+
return { images, usage: usage6, raw: data };
|
|
10053
10204
|
}
|
|
10054
10205
|
|
|
10055
10206
|
// src/adapters/alibaba-video.ts
|
|
@@ -10457,17 +10608,17 @@ var RENDERED = /* @__PURE__ */ new Map([
|
|
|
10457
10608
|
[720, "720p"],
|
|
10458
10609
|
[1080, "1080p"]
|
|
10459
10610
|
]);
|
|
10460
|
-
function settleUsage(
|
|
10611
|
+
function settleUsage(usage6, task) {
|
|
10461
10612
|
const reported = task.usage;
|
|
10462
10613
|
if (reported?.duration !== void 0 && reported.duration > 0) {
|
|
10463
|
-
|
|
10614
|
+
usage6.quantity = reported.duration;
|
|
10464
10615
|
}
|
|
10465
10616
|
const output = reported?.output_video_duration;
|
|
10466
|
-
if (output !== void 0 && output > 0)
|
|
10617
|
+
if (output !== void 0 && output > 0) usage6.durationSeconds = output;
|
|
10467
10618
|
const rendered = reported?.SR === void 0 ? void 0 : RENDERED.get(reported.SR);
|
|
10468
|
-
if (rendered !== void 0)
|
|
10619
|
+
if (rendered !== void 0) usage6.resolution = rendered;
|
|
10469
10620
|
}
|
|
10470
|
-
function alibabaVideoJob(ctx, jobId,
|
|
10621
|
+
function alibabaVideoJob(ctx, jobId, usage6) {
|
|
10471
10622
|
const { key } = alibabaCredentials(ctx);
|
|
10472
10623
|
const modelId = ctx.model.id;
|
|
10473
10624
|
const fetchTask = async () => {
|
|
@@ -10511,10 +10662,10 @@ function alibabaVideoJob(ctx, jobId, usage5) {
|
|
|
10511
10662
|
if (!url) {
|
|
10512
10663
|
throw alibabaError(void 0, "task succeeded with no video_url", modelId);
|
|
10513
10664
|
}
|
|
10514
|
-
settleUsage(
|
|
10665
|
+
settleUsage(usage6, task);
|
|
10515
10666
|
return {
|
|
10516
10667
|
video: { url, expiresAt: new Date(Date.now() + VIDEO_URL_TTL_MS) },
|
|
10517
|
-
usage:
|
|
10668
|
+
usage: usage6,
|
|
10518
10669
|
raw: task
|
|
10519
10670
|
};
|
|
10520
10671
|
}
|
|
@@ -10816,16 +10967,16 @@ async function generateSeedreamImage(req, ctx) {
|
|
|
10816
10967
|
} else {
|
|
10817
10968
|
throwArkError(void 0, "Seedream returned no image URL or base64 data", modelId);
|
|
10818
10969
|
}
|
|
10819
|
-
const
|
|
10970
|
+
const usage6 = {
|
|
10820
10971
|
model: modelId,
|
|
10821
10972
|
provider: "ark",
|
|
10822
10973
|
modality: "IMAGE",
|
|
10823
10974
|
unit: "images",
|
|
10824
10975
|
quantity: 1
|
|
10825
10976
|
};
|
|
10826
|
-
if (req.size !== void 0)
|
|
10827
|
-
if (req.quality !== void 0)
|
|
10828
|
-
return { images: [{ bytes, mime: sniffedImageMime(bytes) }], usage:
|
|
10977
|
+
if (req.size !== void 0) usage6.imageSize = req.size;
|
|
10978
|
+
if (req.quality !== void 0) usage6.imageQuality = req.quality;
|
|
10979
|
+
return { images: [{ bytes, mime: sniffedImageMime(bytes) }], usage: usage6, raw: data };
|
|
10829
10980
|
}
|
|
10830
10981
|
var SeedanceUsageSchema = import_zod10.z.object({
|
|
10831
10982
|
total_tokens: import_zod10.z.number().optional(),
|
|
@@ -10880,7 +11031,7 @@ function seedanceErrorCode(error) {
|
|
|
10880
11031
|
const parsed = SeedanceErrorSchema.safeParse(error);
|
|
10881
11032
|
return parsed.success ? parsed.data.code : void 0;
|
|
10882
11033
|
}
|
|
10883
|
-
function seedanceJob(ctx, key, jobId,
|
|
11034
|
+
function seedanceJob(ctx, key, jobId, usage6) {
|
|
10884
11035
|
const modelId = ctx.model.id;
|
|
10885
11036
|
const fetchStatus = async () => {
|
|
10886
11037
|
const res = await arkFetch(ctx, `${arkBaseUrl(ctx)}${SUBMIT_PATH2}/${jobId}`, {
|
|
@@ -10930,21 +11081,21 @@ function seedanceJob(ctx, key, jobId, usage5) {
|
|
|
10930
11081
|
modelId
|
|
10931
11082
|
);
|
|
10932
11083
|
if (polled.duration !== void 0 && polled.duration > 0) {
|
|
10933
|
-
|
|
10934
|
-
|
|
11084
|
+
usage6.quantity = polled.duration;
|
|
11085
|
+
usage6.durationSeconds = polled.duration;
|
|
10935
11086
|
}
|
|
10936
11087
|
const rendered = VideoResolutionSchema.safeParse(
|
|
10937
11088
|
polled.resolution?.toLowerCase()
|
|
10938
11089
|
);
|
|
10939
|
-
if (rendered.success)
|
|
11090
|
+
if (rendered.success) usage6.resolution = rendered.data;
|
|
10940
11091
|
const tokens = polled.usage;
|
|
10941
11092
|
if (tokens?.total_tokens !== void 0 && tokens.completion_tokens !== void 0) {
|
|
10942
|
-
|
|
10943
|
-
|
|
11093
|
+
usage6.inputTokens = tokens.total_tokens - tokens.completion_tokens;
|
|
11094
|
+
usage6.outputTokens = tokens.completion_tokens;
|
|
10944
11095
|
}
|
|
10945
11096
|
return {
|
|
10946
11097
|
video: { url, expiresAt: new Date(Date.now() + VIDEO_URL_TTL_MS2) },
|
|
10947
|
-
usage:
|
|
11098
|
+
usage: usage6,
|
|
10948
11099
|
raw: polled
|
|
10949
11100
|
};
|
|
10950
11101
|
}
|
|
@@ -11097,8 +11248,8 @@ async function generateSeedanceVideo(req, ctx) {
|
|
|
11097
11248
|
if (req.watermark !== void 0) body.watermark = req.watermark;
|
|
11098
11249
|
if (ctx.model.constraints.draft) body.draft = true;
|
|
11099
11250
|
const jobId = await submitSeedanceTask(ctx, key, body);
|
|
11100
|
-
const
|
|
11101
|
-
return seedanceJob(ctx, key, jobId,
|
|
11251
|
+
const usage6 = seedanceUsage(ctx, req, taskType === "edit" ? requestedDuration : duration);
|
|
11252
|
+
return seedanceJob(ctx, key, jobId, usage6);
|
|
11102
11253
|
}
|
|
11103
11254
|
|
|
11104
11255
|
// src/adapters/fal.ts
|
|
@@ -12241,7 +12392,7 @@ async function collectFalPlanImages(payload, plan4, ctx, req) {
|
|
|
12241
12392
|
return { bytes, mime: mime || "image/png" };
|
|
12242
12393
|
})
|
|
12243
12394
|
);
|
|
12244
|
-
const
|
|
12395
|
+
const usage6 = {
|
|
12245
12396
|
model: ctx.model.id,
|
|
12246
12397
|
provider: "fal",
|
|
12247
12398
|
modality: "IMAGE",
|
|
@@ -12249,9 +12400,9 @@ async function collectFalPlanImages(payload, plan4, ctx, req) {
|
|
|
12249
12400
|
quantity: images.length
|
|
12250
12401
|
};
|
|
12251
12402
|
const billedSize = plan4.imageSize ?? req.size;
|
|
12252
|
-
if (billedSize !== void 0 && ctx.model.type === "image")
|
|
12253
|
-
if (plan4.imageQuality !== void 0)
|
|
12254
|
-
const result = { images, usage:
|
|
12403
|
+
if (billedSize !== void 0 && ctx.model.type === "image") usage6.imageSize = billedSize;
|
|
12404
|
+
if (plan4.imageQuality !== void 0) usage6.imageQuality = plan4.imageQuality;
|
|
12405
|
+
const result = { images, usage: usage6, raw: payload };
|
|
12255
12406
|
const remote = files.find((f) => !f.url.startsWith("data:"));
|
|
12256
12407
|
if (remote !== void 0) result.outputUrl = remote.url;
|
|
12257
12408
|
return result;
|
|
@@ -14098,6 +14249,11 @@ var DEFAULT_BASE_URL = "https://api.elevenlabs.io";
|
|
|
14098
14249
|
var DEFAULT_FORMAT = "mp3_44100_128";
|
|
14099
14250
|
var ELEVENLABS_TTS_MODEL_IDS = /* @__PURE__ */ new Set(["eleven_v4"]);
|
|
14100
14251
|
var ELEVENLABS_IVC = "ivc";
|
|
14252
|
+
var ELEVENLABS_MUSIC_MODEL_IDS = /* @__PURE__ */ new Set(["music_v2_5", "music_v2"]);
|
|
14253
|
+
var ELEVENLABS_SFX_MODEL_IDS = /* @__PURE__ */ new Set([
|
|
14254
|
+
"eleven_text_to_sound_v3",
|
|
14255
|
+
"eleven_text_to_sound_v2"
|
|
14256
|
+
]);
|
|
14101
14257
|
var VOICE_ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
14102
14258
|
function elevenLabsRowRefusal(row2) {
|
|
14103
14259
|
const id = row2.providerModelId;
|
|
@@ -14107,6 +14263,12 @@ function elevenLabsRowRefusal(row2) {
|
|
|
14107
14263
|
if (row2.type === "voice-clone") {
|
|
14108
14264
|
return id === ELEVENLABS_IVC ? void 0 : `elevenlabs voice-clone rows need providerModelId ${ELEVENLABS_IVC}`;
|
|
14109
14265
|
}
|
|
14266
|
+
if (row2.type === "audio") {
|
|
14267
|
+
return ELEVENLABS_MUSIC_MODEL_IDS.has(id) ? void 0 : `elevenlabs music rows need providerModelId ${[...ELEVENLABS_MUSIC_MODEL_IDS].join(", ")}`;
|
|
14268
|
+
}
|
|
14269
|
+
if (row2.type === "sound-effect") {
|
|
14270
|
+
return ELEVENLABS_SFX_MODEL_IDS.has(id) ? void 0 : `elevenlabs sound-effect rows need providerModelId ${[...ELEVENLABS_SFX_MODEL_IDS].join(", ")}`;
|
|
14271
|
+
}
|
|
14110
14272
|
return `elevenlabs has no ${row2.type} rows`;
|
|
14111
14273
|
}
|
|
14112
14274
|
function elevenLabsError(ctx, code, message) {
|
|
@@ -14237,6 +14399,57 @@ async function generateSpeech(req, ctx) {
|
|
|
14237
14399
|
throw elevenLabsError(ctx, "provider_rejected", "ElevenLabs TTS returned no audio");
|
|
14238
14400
|
return { audio: { bytes, mime }, usage: usage2(ctx) };
|
|
14239
14401
|
}
|
|
14402
|
+
function mp3Seconds(format, byteLength) {
|
|
14403
|
+
const kbps = /^mp3_\d+_(\d+)$/.exec(format)?.[1];
|
|
14404
|
+
if (kbps === void 0 || byteLength <= 0) return void 0;
|
|
14405
|
+
return Math.round(byteLength * 8 / (Number(kbps) * 1e3) * 10) / 10;
|
|
14406
|
+
}
|
|
14407
|
+
function audioCall(req, ctx) {
|
|
14408
|
+
const prompt = req.prompt.trim();
|
|
14409
|
+
if (prompt.length === 0) throw elevenLabsError(ctx, "missing_input", "needs a prompt");
|
|
14410
|
+
const format = encodeURIComponent(req.outputFormat ?? DEFAULT_FORMAT);
|
|
14411
|
+
const model_id = ctx.model.providerModelId;
|
|
14412
|
+
if (ctx.model.type === "audio") {
|
|
14413
|
+
const body2 = { prompt, model_id };
|
|
14414
|
+
if (req.durationSeconds !== void 0)
|
|
14415
|
+
body2["music_length_ms"] = Math.round(req.durationSeconds * 1e3);
|
|
14416
|
+
if (req.instrumental !== void 0) body2["force_instrumental"] = req.instrumental;
|
|
14417
|
+
return { path: `/v1/music?output_format=${format}`, body: body2 };
|
|
14418
|
+
}
|
|
14419
|
+
const body = { text: prompt, model_id };
|
|
14420
|
+
if (req.durationSeconds !== void 0) body["duration_seconds"] = req.durationSeconds;
|
|
14421
|
+
if (req.loop !== void 0) body["loop"] = req.loop;
|
|
14422
|
+
return { path: `/v1/sound-generation?output_format=${format}`, body };
|
|
14423
|
+
}
|
|
14424
|
+
async function generateAudio(req, ctx) {
|
|
14425
|
+
checkRow(ctx, ctx.model.type === "sound-effect" ? "sound-effect" : "audio");
|
|
14426
|
+
const { path, body } = audioCall(req, ctx);
|
|
14427
|
+
const { bytes, mime } = await withRetry(
|
|
14428
|
+
async () => {
|
|
14429
|
+
const res = await elevenLabsFetch(ctx, path, {
|
|
14430
|
+
method: "POST",
|
|
14431
|
+
headers: { "Content-Type": "application/json" },
|
|
14432
|
+
body: JSON.stringify(body)
|
|
14433
|
+
});
|
|
14434
|
+
let audio;
|
|
14435
|
+
try {
|
|
14436
|
+
audio = new Uint8Array(await res.arrayBuffer());
|
|
14437
|
+
} catch (cause) {
|
|
14438
|
+
throw classifyThrown("elevenlabs", cause, ctx.model.id);
|
|
14439
|
+
}
|
|
14440
|
+
return { bytes: audio, mime: audioMime(res) };
|
|
14441
|
+
},
|
|
14442
|
+
mediaRetryOptions(ctx.call, ctx.signal)
|
|
14443
|
+
);
|
|
14444
|
+
if (bytes.byteLength === 0)
|
|
14445
|
+
throw elevenLabsError(ctx, "provider_rejected", "ElevenLabs returned no audio");
|
|
14446
|
+
const seconds3 = mp3Seconds(req.outputFormat ?? DEFAULT_FORMAT, bytes.byteLength) ?? req.durationSeconds;
|
|
14447
|
+
const perSecond = ctx.model.usage.unit === "seconds";
|
|
14448
|
+
return {
|
|
14449
|
+
audio: { bytes, mime },
|
|
14450
|
+
usage: { ...usage2(ctx), quantity: perSecond ? seconds3 ?? 0 : 1 }
|
|
14451
|
+
};
|
|
14452
|
+
}
|
|
14240
14453
|
var createdVoiceSchema = import_zod24.z.object({
|
|
14241
14454
|
voice_id: import_zod24.z.string().min(1),
|
|
14242
14455
|
requires_verification: import_zod24.z.boolean().optional().catch(void 0)
|
|
@@ -14360,6 +14573,7 @@ async function deleteVoice(req, ctx) {
|
|
|
14360
14573
|
}
|
|
14361
14574
|
var elevenLabsAdapter = {
|
|
14362
14575
|
id: "elevenlabs",
|
|
14576
|
+
generateAudio,
|
|
14363
14577
|
generateSpeech,
|
|
14364
14578
|
createVoice,
|
|
14365
14579
|
deleteVoice
|
|
@@ -14645,12 +14859,226 @@ var fishAdapter = {
|
|
|
14645
14859
|
deleteVoice: deleteVoice2
|
|
14646
14860
|
};
|
|
14647
14861
|
|
|
14862
|
+
// src/adapters/google-voice.ts
|
|
14863
|
+
var import_zod26 = require("zod");
|
|
14864
|
+
var BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
|
|
14865
|
+
var PROVIDER = "google-genai";
|
|
14866
|
+
var GEMINI_TTS_MODEL_IDS = /* @__PURE__ */ new Set([
|
|
14867
|
+
"gemini-3.8-flash-tts",
|
|
14868
|
+
"gemini-3.8-flash-lite-tts"
|
|
14869
|
+
]);
|
|
14870
|
+
var VOICE_ID3 = /^voice_[A-Za-z0-9_-]{1,128}$/;
|
|
14871
|
+
function googleVoiceRowRefusal(row2) {
|
|
14872
|
+
if (row2.type !== "speech" && row2.type !== "voice-clone") {
|
|
14873
|
+
return `google-genai has no ${row2.type} rows`;
|
|
14874
|
+
}
|
|
14875
|
+
return GEMINI_TTS_MODEL_IDS.has(row2.providerModelId) ? void 0 : `google-genai ${row2.type} rows need providerModelId ${[...GEMINI_TTS_MODEL_IDS].join(", ")}`;
|
|
14876
|
+
}
|
|
14877
|
+
function refuse(ctx, code, message) {
|
|
14878
|
+
return new ModelKitError({
|
|
14879
|
+
code,
|
|
14880
|
+
message,
|
|
14881
|
+
provider: PROVIDER,
|
|
14882
|
+
model: ctx.model.id,
|
|
14883
|
+
retryable: false
|
|
14884
|
+
});
|
|
14885
|
+
}
|
|
14886
|
+
function checkRow3(ctx, type) {
|
|
14887
|
+
const refusal3 = ctx.model.type === type ? googleVoiceRowRefusal(ctx.model) : `${ctx.model.id} is not a ${type} row`;
|
|
14888
|
+
if (refusal3 !== void 0) throw refuse(ctx, "unsupported_option", refusal3);
|
|
14889
|
+
}
|
|
14890
|
+
function googleKey(ctx) {
|
|
14891
|
+
const key = ctx.keys.google;
|
|
14892
|
+
if (!key) throw refuse(ctx, "auth", "Missing Google API key");
|
|
14893
|
+
return key;
|
|
14894
|
+
}
|
|
14895
|
+
async function googleFetch(ctx, path, init) {
|
|
14896
|
+
throwIfAborted(ctx.signal);
|
|
14897
|
+
const request = {
|
|
14898
|
+
method: init.method,
|
|
14899
|
+
headers: { "x-goog-api-key": googleKey(ctx), "Content-Type": "application/json" }
|
|
14900
|
+
};
|
|
14901
|
+
if (init.body !== void 0) request.body = JSON.stringify(init.body);
|
|
14902
|
+
if (ctx.signal !== void 0) request.signal = ctx.signal;
|
|
14903
|
+
let res;
|
|
14904
|
+
try {
|
|
14905
|
+
res = await ctx.fetch(`${BASE_URL}${path}`, request);
|
|
14906
|
+
} catch (cause) {
|
|
14907
|
+
throw classifyThrown(PROVIDER, cause, ctx.model.id);
|
|
14908
|
+
}
|
|
14909
|
+
if (!res.ok) throw classifyHttpError(res.status, await readBody(res), PROVIDER, ctx.model.id);
|
|
14910
|
+
return res;
|
|
14911
|
+
}
|
|
14912
|
+
function usage4(ctx) {
|
|
14913
|
+
return {
|
|
14914
|
+
model: ctx.model.id,
|
|
14915
|
+
provider: PROVIDER,
|
|
14916
|
+
modality: "AUDIO",
|
|
14917
|
+
unit: ctx.model.usage.unit,
|
|
14918
|
+
quantity: 1
|
|
14919
|
+
};
|
|
14920
|
+
}
|
|
14921
|
+
var interactionSchema = import_zod26.z.object({
|
|
14922
|
+
steps: import_zod26.z.array(
|
|
14923
|
+
import_zod26.z.looseObject({
|
|
14924
|
+
type: import_zod26.z.string().optional(),
|
|
14925
|
+
content: import_zod26.z.array(
|
|
14926
|
+
import_zod26.z.looseObject({
|
|
14927
|
+
type: import_zod26.z.string().optional(),
|
|
14928
|
+
data: import_zod26.z.string().optional(),
|
|
14929
|
+
mime_type: import_zod26.z.string().optional()
|
|
14930
|
+
})
|
|
14931
|
+
).optional()
|
|
14932
|
+
})
|
|
14933
|
+
).optional()
|
|
14934
|
+
});
|
|
14935
|
+
function geminiSpeechBody(req, providerModelId) {
|
|
14936
|
+
const text2 = { type: "text", text: req.text };
|
|
14937
|
+
const style = req.style?.trim();
|
|
14938
|
+
if (style) text2["annotations"] = [{ type: "speech_metadata", style }];
|
|
14939
|
+
return {
|
|
14940
|
+
model: providerModelId,
|
|
14941
|
+
input: [{ type: "user_input", content: [text2] }],
|
|
14942
|
+
response_format: { type: "audio" },
|
|
14943
|
+
// A prebuilt voice name or a replicated voice id go in the same field.
|
|
14944
|
+
generation_config: { speech_config: [{ voice: req.customVoice ?? req.voice ?? "" }] }
|
|
14945
|
+
};
|
|
14946
|
+
}
|
|
14947
|
+
async function generateGeminiSpeech(req, ctx) {
|
|
14948
|
+
checkRow3(ctx, "speech");
|
|
14949
|
+
if (req.customVoice !== void 0 && !VOICE_ID3.test(req.customVoice)) {
|
|
14950
|
+
throw refuse(ctx, "unsupported_option", "customVoice is not a Gemini voice id");
|
|
14951
|
+
}
|
|
14952
|
+
if ((req.customVoice ?? req.voice) === void 0) {
|
|
14953
|
+
throw refuse(ctx, "missing_input", "needs a voice");
|
|
14954
|
+
}
|
|
14955
|
+
if (req.text.trim().length === 0) throw refuse(ctx, "missing_input", "needs a script");
|
|
14956
|
+
const body = geminiSpeechBody(req, ctx.model.providerModelId);
|
|
14957
|
+
const raw = await withRetry(
|
|
14958
|
+
async () => readBody(await googleFetch(ctx, "/interactions", { method: "POST", body })),
|
|
14959
|
+
mediaRetryOptions(ctx.call, ctx.signal)
|
|
14960
|
+
);
|
|
14961
|
+
const parsed = interactionSchema.safeParse(raw);
|
|
14962
|
+
const blocks = parsed.success ? (parsed.data.steps ?? []).filter((step) => step.type === "model_output").flatMap((step) => step.content ?? []) : [];
|
|
14963
|
+
const block = blocks.find((b) => b.type === "audio" && b.data);
|
|
14964
|
+
if (block?.data === void 0) {
|
|
14965
|
+
throw refuse(ctx, "provider_rejected", "Gemini TTS returned no audio");
|
|
14966
|
+
}
|
|
14967
|
+
return {
|
|
14968
|
+
audio: {
|
|
14969
|
+
bytes: new Uint8Array(Buffer.from(block.data, "base64")),
|
|
14970
|
+
mime: block.mime_type ?? "audio/wav"
|
|
14971
|
+
},
|
|
14972
|
+
usage: usage4(ctx)
|
|
14973
|
+
};
|
|
14974
|
+
}
|
|
14975
|
+
async function inlineAudio(ref, ctx) {
|
|
14976
|
+
const { bytes, mime } = await mediaRefToBytes(ref, ctx.fetch, {
|
|
14977
|
+
signal: ctx.signal,
|
|
14978
|
+
provider: PROVIDER,
|
|
14979
|
+
model: ctx.model.id
|
|
14980
|
+
});
|
|
14981
|
+
const type = mime.startsWith("audio/") ? mime : "audio/wav";
|
|
14982
|
+
return { mime_type: type, data: Buffer.from(bytes).toString("base64") };
|
|
14983
|
+
}
|
|
14984
|
+
var createdVoiceSchema2 = import_zod26.z.object({ id: import_zod26.z.string().regex(VOICE_ID3) });
|
|
14985
|
+
async function onlyRateLimitRetries3(fn) {
|
|
14986
|
+
try {
|
|
14987
|
+
return await fn();
|
|
14988
|
+
} catch (cause) {
|
|
14989
|
+
if (!isModelKitError(cause) || !cause.retryable || cause.code === "rate_limited")
|
|
14990
|
+
throw cause;
|
|
14991
|
+
throw new ModelKitError({
|
|
14992
|
+
code: cause.code,
|
|
14993
|
+
message: cause.message,
|
|
14994
|
+
...cause.provider !== void 0 && { provider: cause.provider },
|
|
14995
|
+
...cause.model !== void 0 && { model: cause.model },
|
|
14996
|
+
...cause.status !== void 0 && { status: cause.status },
|
|
14997
|
+
...cause.body !== void 0 && { body: cause.body },
|
|
14998
|
+
cause,
|
|
14999
|
+
retryable: false
|
|
15000
|
+
});
|
|
15001
|
+
}
|
|
15002
|
+
}
|
|
15003
|
+
async function createGeminiVoice(req, ctx) {
|
|
15004
|
+
checkRow3(ctx, "voice-clone");
|
|
15005
|
+
const [sample, ...rest] = req.samples;
|
|
15006
|
+
if (sample === void 0) throw refuse(ctx, "missing_input", "needs a voice sample");
|
|
15007
|
+
if (rest.length > 0) throw refuse(ctx, "unsupported_option", "takes one voice sample");
|
|
15008
|
+
if (sample.designSignature?.trim()) {
|
|
15009
|
+
throw refuse(ctx, "unsupported_option", "Gemini cannot keep a voice design signature");
|
|
15010
|
+
}
|
|
15011
|
+
if (req.consent === void 0) {
|
|
15012
|
+
throw refuse(ctx, "missing_input", "needs the consent recording");
|
|
15013
|
+
}
|
|
15014
|
+
const body = {
|
|
15015
|
+
store: true,
|
|
15016
|
+
voice: {
|
|
15017
|
+
model: ctx.model.providerModelId,
|
|
15018
|
+
type: "replicated",
|
|
15019
|
+
display_name: req.title.trim(),
|
|
15020
|
+
replicated: {
|
|
15021
|
+
source_audio: await inlineAudio(sample.audio, ctx),
|
|
15022
|
+
consent_audio: await inlineAudio(req.consent, ctx)
|
|
15023
|
+
}
|
|
15024
|
+
}
|
|
15025
|
+
};
|
|
15026
|
+
const res = await withRetry(
|
|
15027
|
+
() => onlyRateLimitRetries3(() => googleFetch(ctx, "/voices", { method: "POST", body })),
|
|
15028
|
+
mediaRetryOptions(ctx.call, ctx.signal)
|
|
15029
|
+
);
|
|
15030
|
+
const raw = await readBody(res);
|
|
15031
|
+
const parsed = createdVoiceSchema2.safeParse(raw);
|
|
15032
|
+
if (!parsed.success) {
|
|
15033
|
+
throw new ModelKitError({
|
|
15034
|
+
code: "provider_rejected",
|
|
15035
|
+
message: "Gemini returned no voice id",
|
|
15036
|
+
provider: PROVIDER,
|
|
15037
|
+
model: ctx.model.id,
|
|
15038
|
+
status: res.status,
|
|
15039
|
+
body: raw,
|
|
15040
|
+
retryable: false
|
|
15041
|
+
});
|
|
15042
|
+
}
|
|
15043
|
+
return { voiceId: parsed.data.id, state: "trained", usage: usage4(ctx), raw };
|
|
15044
|
+
}
|
|
15045
|
+
async function deleteGeminiVoice(req, ctx) {
|
|
15046
|
+
checkRow3(ctx, "voice-clone");
|
|
15047
|
+
if (!VOICE_ID3.test(req.voiceId)) {
|
|
15048
|
+
throw refuse(ctx, "unsupported_option", "voiceId is not a Gemini voice id");
|
|
15049
|
+
}
|
|
15050
|
+
let attempts = 0;
|
|
15051
|
+
await withRetry(
|
|
15052
|
+
async () => {
|
|
15053
|
+
attempts += 1;
|
|
15054
|
+
try {
|
|
15055
|
+
await googleFetch(ctx, `/voices/${encodeURIComponent(req.voiceId)}`, {
|
|
15056
|
+
method: "DELETE"
|
|
15057
|
+
});
|
|
15058
|
+
} catch (cause) {
|
|
15059
|
+
if (!isModelKitError(cause) || cause.status !== 404) throw cause;
|
|
15060
|
+
if (attempts > 1) return;
|
|
15061
|
+
throw new ModelKitError({
|
|
15062
|
+
code: "provider_rejected",
|
|
15063
|
+
message: `Gemini has no voice ${req.voiceId} under this key set; delete with the tier that created it`,
|
|
15064
|
+
provider: PROVIDER,
|
|
15065
|
+
model: ctx.model.id,
|
|
15066
|
+
status: 404,
|
|
15067
|
+
cause,
|
|
15068
|
+
retryable: false
|
|
15069
|
+
});
|
|
15070
|
+
}
|
|
15071
|
+
},
|
|
15072
|
+
mediaRetryOptions(ctx.call, ctx.signal)
|
|
15073
|
+
);
|
|
15074
|
+
}
|
|
15075
|
+
|
|
14648
15076
|
// src/adapters/google-genai.ts
|
|
14649
|
-
var
|
|
15077
|
+
var import_zod28 = require("zod");
|
|
14650
15078
|
var import_genai = require("@google/genai");
|
|
14651
15079
|
|
|
14652
15080
|
// src/adapters/google-files.ts
|
|
14653
|
-
var
|
|
15081
|
+
var import_zod27 = require("zod");
|
|
14654
15082
|
var GOOGLE_FILES_BASE = "https://generativelanguage.googleapis.com";
|
|
14655
15083
|
var GOOGLE_FILES_POLL_INTERVAL_MS = 2e3;
|
|
14656
15084
|
var GOOGLE_FILES_POLL_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
@@ -14660,17 +15088,17 @@ var GENERIC_MEDIA_TYPES = /* @__PURE__ */ new Set([
|
|
|
14660
15088
|
"binary/octet-stream",
|
|
14661
15089
|
"application/binary"
|
|
14662
15090
|
]);
|
|
14663
|
-
var uploadedFileSchema =
|
|
14664
|
-
file:
|
|
14665
|
-
uri:
|
|
14666
|
-
name:
|
|
14667
|
-
state:
|
|
14668
|
-
mimeType:
|
|
15091
|
+
var uploadedFileSchema = import_zod27.z.object({
|
|
15092
|
+
file: import_zod27.z.object({
|
|
15093
|
+
uri: import_zod27.z.string().optional(),
|
|
15094
|
+
name: import_zod27.z.string().optional(),
|
|
15095
|
+
state: import_zod27.z.string().optional(),
|
|
15096
|
+
mimeType: import_zod27.z.string().optional()
|
|
14669
15097
|
}).optional()
|
|
14670
15098
|
});
|
|
14671
|
-
var fileStateSchema =
|
|
14672
|
-
state:
|
|
14673
|
-
error:
|
|
15099
|
+
var fileStateSchema = import_zod27.z.object({
|
|
15100
|
+
state: import_zod27.z.string().optional(),
|
|
15101
|
+
error: import_zod27.z.object({ message: import_zod27.z.string().optional() }).optional()
|
|
14674
15102
|
});
|
|
14675
15103
|
function resolveMime(declared, fallback) {
|
|
14676
15104
|
const clean = declared?.split(";")[0]?.trim().toLowerCase();
|
|
@@ -14892,7 +15320,7 @@ var RESULT_TIMEOUT_MS4 = 15 * 60 * 1e3;
|
|
|
14892
15320
|
var OMNI_INLINE_LIMIT_BYTES = 4 * 1024 * 1024;
|
|
14893
15321
|
var OMNI_FRAMES_MAX_SECONDS = 10;
|
|
14894
15322
|
var MEDIA_PART_INLINE_LIMIT_BYTES = 10 * 1024 * 1024;
|
|
14895
|
-
var errorTextSchema =
|
|
15323
|
+
var errorTextSchema = import_zod28.z.string();
|
|
14896
15324
|
function isGoogleGenaiVideoKnown(providerModelId) {
|
|
14897
15325
|
return providerModelId.startsWith("veo-") || providerModelId.startsWith("gemini-omni");
|
|
14898
15326
|
}
|
|
@@ -14929,13 +15357,16 @@ function createGoogleGenaiAdapter(deps = defaultDeps2) {
|
|
|
14929
15357
|
model: ctx.model.id
|
|
14930
15358
|
});
|
|
14931
15359
|
},
|
|
15360
|
+
generateSpeech: generateGeminiSpeech,
|
|
15361
|
+
createVoice: createGeminiVoice,
|
|
15362
|
+
deleteVoice: deleteGeminiVoice,
|
|
14932
15363
|
prepareMediaPart(ref, mediaType, ctx) {
|
|
14933
15364
|
return prepareGoogleMediaPart(ref, mediaType, ctx);
|
|
14934
15365
|
}
|
|
14935
15366
|
};
|
|
14936
15367
|
}
|
|
14937
15368
|
var googleGenaiAdapter = createGoogleGenaiAdapter();
|
|
14938
|
-
function
|
|
15369
|
+
function googleKey2(ctx) {
|
|
14939
15370
|
const key = ctx.keys.google;
|
|
14940
15371
|
if (!key) {
|
|
14941
15372
|
throw new ModelKitError({
|
|
@@ -14997,7 +15428,7 @@ function videoUsage2(ctx, duration, resolution) {
|
|
|
14997
15428
|
return event;
|
|
14998
15429
|
}
|
|
14999
15430
|
async function generateVeoVideo(req, ctx, createGenAIClient) {
|
|
15000
|
-
const apiKey =
|
|
15431
|
+
const apiKey = googleKey2(ctx);
|
|
15001
15432
|
const modelId = ctx.model.id;
|
|
15002
15433
|
const refs = req.referenceImages ?? [];
|
|
15003
15434
|
if (req.firstFrame && refs.length > 0) {
|
|
@@ -15087,7 +15518,7 @@ async function generateVeoVideo(req, ctx, createGenAIClient) {
|
|
|
15087
15518
|
}
|
|
15088
15519
|
};
|
|
15089
15520
|
const jobId = operation.name ?? crypto.randomUUID();
|
|
15090
|
-
const
|
|
15521
|
+
const usage6 = videoUsage2(ctx, duration, req.resolution ?? "720p");
|
|
15091
15522
|
return {
|
|
15092
15523
|
jobId,
|
|
15093
15524
|
async poll() {
|
|
@@ -15125,7 +15556,7 @@ async function generateVeoVideo(req, ctx, createGenAIClient) {
|
|
|
15125
15556
|
modelId
|
|
15126
15557
|
);
|
|
15127
15558
|
}
|
|
15128
|
-
return { video: await downloadVideo(ctx, uri, apiKey, signal), usage:
|
|
15559
|
+
return { video: await downloadVideo(ctx, uri, apiKey, signal), usage: usage6, raw: finished };
|
|
15129
15560
|
}
|
|
15130
15561
|
};
|
|
15131
15562
|
}
|
|
@@ -15162,7 +15593,7 @@ function extractOmniVideo(interaction, model) {
|
|
|
15162
15593
|
);
|
|
15163
15594
|
}
|
|
15164
15595
|
async function generateOmniVideo(req, ctx, createGenAIClient) {
|
|
15165
|
-
const apiKey =
|
|
15596
|
+
const apiKey = googleKey2(ctx);
|
|
15166
15597
|
const modelId = ctx.model.id;
|
|
15167
15598
|
const providerModelId = ctx.model.providerModelId;
|
|
15168
15599
|
const extend = req.taskType === "extend";
|
|
@@ -15337,7 +15768,7 @@ async function generateOmniVideo(req, ctx, createGenAIClient) {
|
|
|
15337
15768
|
if (!(extend && !chained)) await cleanupUploads();
|
|
15338
15769
|
}
|
|
15339
15770
|
const jobId = interaction.id ?? crypto.randomUUID();
|
|
15340
|
-
const
|
|
15771
|
+
const usage6 = videoUsage2(ctx, duration, omniResolution ?? "720p");
|
|
15341
15772
|
const getInteraction = async () => {
|
|
15342
15773
|
try {
|
|
15343
15774
|
const getParams = { stream: false };
|
|
@@ -15385,7 +15816,7 @@ async function generateOmniVideo(req, ctx, createGenAIClient) {
|
|
|
15385
15816
|
bytes: Buffer.from(video.data, "base64"),
|
|
15386
15817
|
mime: video.mime_type ?? "video/mp4"
|
|
15387
15818
|
},
|
|
15388
|
-
usage:
|
|
15819
|
+
usage: usage6,
|
|
15389
15820
|
raw: done,
|
|
15390
15821
|
providerRef
|
|
15391
15822
|
};
|
|
@@ -15393,7 +15824,7 @@ async function generateOmniVideo(req, ctx, createGenAIClient) {
|
|
|
15393
15824
|
if (video.uri)
|
|
15394
15825
|
return {
|
|
15395
15826
|
video: await downloadVideo(ctx, video.uri, apiKey, signal),
|
|
15396
|
-
usage:
|
|
15827
|
+
usage: usage6,
|
|
15397
15828
|
raw: done,
|
|
15398
15829
|
providerRef
|
|
15399
15830
|
};
|
|
@@ -15420,7 +15851,7 @@ function lyriaUsage(ctx, req, meta) {
|
|
|
15420
15851
|
return event;
|
|
15421
15852
|
}
|
|
15422
15853
|
async function generateLyriaAudio(req, ctx, createGenAIClient) {
|
|
15423
|
-
const apiKey =
|
|
15854
|
+
const apiKey = googleKey2(ctx);
|
|
15424
15855
|
const modelId = ctx.model.id;
|
|
15425
15856
|
const parts = [{ text: req.prompt }];
|
|
15426
15857
|
for (const ref of req.references ?? []) {
|
|
@@ -15482,7 +15913,7 @@ async function generateLyriaAudio(req, ctx, createGenAIClient) {
|
|
|
15482
15913
|
return result;
|
|
15483
15914
|
}
|
|
15484
15915
|
async function generateLyriaInteraction(req, ctx, createGenAIClient) {
|
|
15485
|
-
const apiKey =
|
|
15916
|
+
const apiKey = googleKey2(ctx);
|
|
15486
15917
|
const modelId = ctx.model.id;
|
|
15487
15918
|
const input = [{ type: "text", text: req.prompt }];
|
|
15488
15919
|
for (const ref of req.references ?? []) {
|
|
@@ -15542,7 +15973,7 @@ async function prepareGoogleMediaPart(ref, mediaType, ctx) {
|
|
|
15542
15973
|
if (ref.bytes.length <= MEDIA_PART_INLINE_LIMIT_BYTES) {
|
|
15543
15974
|
return { type: "file", data: ref.bytes, mediaType };
|
|
15544
15975
|
}
|
|
15545
|
-
const apiKey =
|
|
15976
|
+
const apiKey = googleKey2(ctx);
|
|
15546
15977
|
const uploadOptions = {
|
|
15547
15978
|
apiKey,
|
|
15548
15979
|
fetchImpl: ctx.fetch,
|
|
@@ -15563,15 +15994,15 @@ async function prepareGoogleMediaPart(ref, mediaType, ctx) {
|
|
|
15563
15994
|
// src/adapters/google-image.ts
|
|
15564
15995
|
var import_google2 = require("@ai-sdk/google");
|
|
15565
15996
|
var import_ai2 = require("ai");
|
|
15566
|
-
var
|
|
15997
|
+
var import_zod29 = require("zod");
|
|
15567
15998
|
var GEMINI_IMAGE_TIMEOUT_MS = 6e5;
|
|
15568
15999
|
var defaultGoogleImageDeps = {
|
|
15569
16000
|
createGoogleClient: (opts) => (0, import_google2.createGoogleGenerativeAI)(opts),
|
|
15570
16001
|
runTextGeneration: (opts) => (0, import_ai2.generateText)(opts)
|
|
15571
16002
|
};
|
|
15572
|
-
var causeChainNodeSchema =
|
|
15573
|
-
message:
|
|
15574
|
-
cause:
|
|
16003
|
+
var causeChainNodeSchema = import_zod29.z.object({
|
|
16004
|
+
message: import_zod29.z.string().optional(),
|
|
16005
|
+
cause: import_zod29.z.unknown().optional()
|
|
15575
16006
|
});
|
|
15576
16007
|
function extractBlockReason(cause) {
|
|
15577
16008
|
let current = cause;
|
|
@@ -15591,9 +16022,9 @@ function extractBlockReason(cause) {
|
|
|
15591
16022
|
current = parsed.data.cause ?? null;
|
|
15592
16023
|
}
|
|
15593
16024
|
}
|
|
15594
|
-
function billedTokens(model,
|
|
15595
|
-
const inputTokens =
|
|
15596
|
-
const outputTokens =
|
|
16025
|
+
function billedTokens(model, usage6) {
|
|
16026
|
+
const inputTokens = usage6?.inputTokens;
|
|
16027
|
+
const outputTokens = usage6?.outputTokens;
|
|
15597
16028
|
if (inputTokens === void 0 && outputTokens === void 0) return void 0;
|
|
15598
16029
|
const event = {
|
|
15599
16030
|
model,
|
|
@@ -15694,7 +16125,7 @@ function createGoogleImageAdapter(deps = defaultGoogleImageDeps) {
|
|
|
15694
16125
|
if (billed !== void 0) init.usage = billed;
|
|
15695
16126
|
throw new ModelKitError(init);
|
|
15696
16127
|
}
|
|
15697
|
-
const
|
|
16128
|
+
const usage6 = {
|
|
15698
16129
|
model: ctx.model.id,
|
|
15699
16130
|
provider: "google-image",
|
|
15700
16131
|
modality: "IMAGE",
|
|
@@ -15702,19 +16133,19 @@ function createGoogleImageAdapter(deps = defaultGoogleImageDeps) {
|
|
|
15702
16133
|
quantity: images.length,
|
|
15703
16134
|
imageQuality: "auto"
|
|
15704
16135
|
};
|
|
15705
|
-
if (req.size !== void 0)
|
|
16136
|
+
if (req.size !== void 0) usage6.imageSize = req.size;
|
|
15706
16137
|
if (result.usage?.inputTokens !== void 0)
|
|
15707
|
-
|
|
16138
|
+
usage6.inputTokens = result.usage.inputTokens;
|
|
15708
16139
|
if (result.usage?.outputTokens !== void 0)
|
|
15709
|
-
|
|
15710
|
-
return { images, usage:
|
|
16140
|
+
usage6.outputTokens = result.usage.outputTokens;
|
|
16141
|
+
return { images, usage: usage6, raw: result };
|
|
15711
16142
|
}
|
|
15712
16143
|
};
|
|
15713
16144
|
}
|
|
15714
16145
|
var googleImageAdapter = createGoogleImageAdapter();
|
|
15715
16146
|
|
|
15716
16147
|
// src/adapters/higgsfield.ts
|
|
15717
|
-
var
|
|
16148
|
+
var import_zod30 = require("zod");
|
|
15718
16149
|
|
|
15719
16150
|
// src/adapters/higgsfield-motions.ts
|
|
15720
16151
|
var MOTION_MAP = {
|
|
@@ -15933,14 +16364,14 @@ function klingEndpointFields(providerModelId) {
|
|
|
15933
16364
|
const path = (providerModelId.startsWith("/") ? providerModelId.slice(1) : providerModelId).toLowerCase();
|
|
15934
16365
|
return KLING_ENDPOINT_FIELDS.get(path) ?? UNLISTED_KLING_FIELDS;
|
|
15935
16366
|
}
|
|
15936
|
-
var klingCreateSchema =
|
|
15937
|
-
var klingStatusSchema =
|
|
15938
|
-
status:
|
|
15939
|
-
video:
|
|
16367
|
+
var klingCreateSchema = import_zod30.z.object({ status_url: import_zod30.z.string() });
|
|
16368
|
+
var klingStatusSchema = import_zod30.z.object({
|
|
16369
|
+
status: import_zod30.z.string().optional(),
|
|
16370
|
+
video: import_zod30.z.object({ url: import_zod30.z.string().optional() }).optional(),
|
|
15940
16371
|
error: JsonValueSchema.optional()
|
|
15941
16372
|
});
|
|
15942
|
-
var errorMessageSchema =
|
|
15943
|
-
var textValueSchema =
|
|
16373
|
+
var errorMessageSchema = import_zod30.z.object({ message: import_zod30.z.string().optional() });
|
|
16374
|
+
var textValueSchema = import_zod30.z.string();
|
|
15944
16375
|
function klingErrorDetail(error) {
|
|
15945
16376
|
if (error === void 0) return "unknown_error";
|
|
15946
16377
|
const asText = textValueSchema.safeParse(error);
|
|
@@ -16096,8 +16527,8 @@ async function generateKlingVideo(req, ctx) {
|
|
|
16096
16527
|
}
|
|
16097
16528
|
};
|
|
16098
16529
|
}
|
|
16099
|
-
var dopMotionOptionsSchema =
|
|
16100
|
-
modelkit:
|
|
16530
|
+
var dopMotionOptionsSchema = import_zod30.z.object({
|
|
16531
|
+
modelkit: import_zod30.z.object({ motion: import_zod30.z.string().optional() }).optional()
|
|
16101
16532
|
});
|
|
16102
16533
|
function dopMotionId(ctx) {
|
|
16103
16534
|
const parsed = dopMotionOptionsSchema.safeParse(ctx.model.providerOptions);
|
|
@@ -16113,7 +16544,7 @@ function dopMotionId(ctx) {
|
|
|
16113
16544
|
});
|
|
16114
16545
|
return id;
|
|
16115
16546
|
}
|
|
16116
|
-
var jsonRecordSchema =
|
|
16547
|
+
var jsonRecordSchema = import_zod30.z.record(import_zod30.z.string(), JsonValueSchema);
|
|
16117
16548
|
var DOP_URL_KEYS = ["url", "video_url", "output_url", "result_url", "download_url"];
|
|
16118
16549
|
var DOP_NESTED_KEYS = ["video", "result", "results"];
|
|
16119
16550
|
function dopUrl(body) {
|
|
@@ -16141,8 +16572,8 @@ function dopUrl(body) {
|
|
|
16141
16572
|
}
|
|
16142
16573
|
return void 0;
|
|
16143
16574
|
}
|
|
16144
|
-
var dopCreateSchema =
|
|
16145
|
-
var dopStatusSchema =
|
|
16575
|
+
var dopCreateSchema = import_zod30.z.object({ id: import_zod30.z.string() });
|
|
16576
|
+
var dopStatusSchema = import_zod30.z.object({ status: import_zod30.z.string().optional() });
|
|
16146
16577
|
async function generateDopVideo(req, ctx) {
|
|
16147
16578
|
const firstFrame = req.firstFrame ? refToUrl(req.firstFrame) : void 0;
|
|
16148
16579
|
if (!firstFrame) {
|
|
@@ -16269,7 +16700,7 @@ var higgsfieldAdapter = {
|
|
|
16269
16700
|
};
|
|
16270
16701
|
|
|
16271
16702
|
// src/adapters/luma.ts
|
|
16272
|
-
var
|
|
16703
|
+
var import_zod31 = require("zod");
|
|
16273
16704
|
|
|
16274
16705
|
// src/adapters/mp4-duration.ts
|
|
16275
16706
|
function mp4DurationSeconds(bytes) {
|
|
@@ -16486,17 +16917,17 @@ function lumaReframeResolution(req, ctx) {
|
|
|
16486
16917
|
});
|
|
16487
16918
|
return "720p";
|
|
16488
16919
|
}
|
|
16489
|
-
var lumaGenerationSchema =
|
|
16490
|
-
id:
|
|
16491
|
-
state:
|
|
16492
|
-
output:
|
|
16493
|
-
|
|
16494
|
-
type:
|
|
16495
|
-
url:
|
|
16920
|
+
var lumaGenerationSchema = import_zod31.z.looseObject({
|
|
16921
|
+
id: import_zod31.z.string(),
|
|
16922
|
+
state: import_zod31.z.string().optional(),
|
|
16923
|
+
output: import_zod31.z.array(
|
|
16924
|
+
import_zod31.z.looseObject({
|
|
16925
|
+
type: import_zod31.z.string().optional(),
|
|
16926
|
+
url: import_zod31.z.string().optional()
|
|
16496
16927
|
})
|
|
16497
16928
|
).optional(),
|
|
16498
|
-
failure_reason:
|
|
16499
|
-
failure_code:
|
|
16929
|
+
failure_reason: import_zod31.z.string().optional().nullable(),
|
|
16930
|
+
failure_code: import_zod31.z.string().optional().nullable()
|
|
16500
16931
|
});
|
|
16501
16932
|
function lumaFailure(ctx, code, reason) {
|
|
16502
16933
|
const detail = reason ?? code ?? "unknown_error";
|
|
@@ -16928,7 +17359,7 @@ var lumaAdapter = {
|
|
|
16928
17359
|
|
|
16929
17360
|
// src/adapters/openai-image.ts
|
|
16930
17361
|
var import_openai2 = __toESM(require("openai"), 1);
|
|
16931
|
-
var
|
|
17362
|
+
var import_zod32 = require("zod");
|
|
16932
17363
|
|
|
16933
17364
|
// src/adapters/svg-sanitize.ts
|
|
16934
17365
|
var BLOCK_ELEMENTS = /<(script|foreignObject|iframe|object|embed|audio|video|handler|listener)\b[\s\S]*?<\/\1\s*>/giu;
|
|
@@ -17041,9 +17472,9 @@ function toProviderError2(cause, ctx) {
|
|
|
17041
17472
|
ctx.model.id
|
|
17042
17473
|
);
|
|
17043
17474
|
}
|
|
17044
|
-
var openaiUsageSchema =
|
|
17045
|
-
input_tokens:
|
|
17046
|
-
output_tokens:
|
|
17475
|
+
var openaiUsageSchema = import_zod32.z.object({
|
|
17476
|
+
input_tokens: import_zod32.z.number().optional(),
|
|
17477
|
+
output_tokens: import_zod32.z.number().optional()
|
|
17047
17478
|
});
|
|
17048
17479
|
var openaiImageAdapter = {
|
|
17049
17480
|
id: "openai-image",
|
|
@@ -17155,7 +17586,7 @@ var openaiImageAdapter = {
|
|
|
17155
17586
|
const usageParsed = openaiUsageSchema.safeParse(response.usage);
|
|
17156
17587
|
const inputTokens = usageParsed.success ? usageParsed.data.input_tokens : void 0;
|
|
17157
17588
|
const outputTokens = usageParsed.success ? usageParsed.data.output_tokens : void 0;
|
|
17158
|
-
const
|
|
17589
|
+
const usage6 = {
|
|
17159
17590
|
model: ctx.model.id,
|
|
17160
17591
|
provider: "openai-image",
|
|
17161
17592
|
modality: "IMAGE",
|
|
@@ -17163,10 +17594,10 @@ var openaiImageAdapter = {
|
|
|
17163
17594
|
quantity: images.length,
|
|
17164
17595
|
imageQuality: quality
|
|
17165
17596
|
};
|
|
17166
|
-
if (inputTokens !== void 0)
|
|
17167
|
-
if (outputTokens !== void 0)
|
|
17168
|
-
if (req.size !== void 0)
|
|
17169
|
-
return { images, usage:
|
|
17597
|
+
if (inputTokens !== void 0) usage6.inputTokens = inputTokens;
|
|
17598
|
+
if (outputTokens !== void 0) usage6.outputTokens = outputTokens;
|
|
17599
|
+
if (req.size !== void 0) usage6.imageSize = req.size;
|
|
17600
|
+
return { images, usage: usage6, raw: response };
|
|
17170
17601
|
}
|
|
17171
17602
|
};
|
|
17172
17603
|
|
|
@@ -17422,16 +17853,16 @@ async function generateProdiaImage(req, ctx) {
|
|
|
17422
17853
|
new Uint8Array(await res.arrayBuffer()),
|
|
17423
17854
|
res.headers.get("content-type")
|
|
17424
17855
|
);
|
|
17425
|
-
const
|
|
17856
|
+
const usage6 = {
|
|
17426
17857
|
model: ctx.model.id,
|
|
17427
17858
|
provider: "prodia",
|
|
17428
17859
|
modality: "IMAGE",
|
|
17429
17860
|
unit: "images",
|
|
17430
17861
|
quantity: 1
|
|
17431
17862
|
};
|
|
17432
|
-
if (req.size !== void 0)
|
|
17433
|
-
if (req.quality !== void 0)
|
|
17434
|
-
return { images: [{ bytes, mime }], usage:
|
|
17863
|
+
if (req.size !== void 0) usage6.imageSize = req.size;
|
|
17864
|
+
if (req.quality !== void 0) usage6.imageQuality = req.quality;
|
|
17865
|
+
return { images: [{ bytes, mime }], usage: usage6, raw: void 0 };
|
|
17435
17866
|
}
|
|
17436
17867
|
var prodiaAdapter = {
|
|
17437
17868
|
id: "prodia",
|
|
@@ -17442,13 +17873,13 @@ var prodiaAdapter = {
|
|
|
17442
17873
|
var import_replicate = __toESM(require("replicate"), 1);
|
|
17443
17874
|
|
|
17444
17875
|
// src/adapters/replicate-http.ts
|
|
17445
|
-
var
|
|
17446
|
-
var predictionSchema =
|
|
17447
|
-
id:
|
|
17448
|
-
status:
|
|
17876
|
+
var import_zod33 = require("zod");
|
|
17877
|
+
var predictionSchema = import_zod33.z.object({
|
|
17878
|
+
id: import_zod33.z.string(),
|
|
17879
|
+
status: import_zod33.z.string(),
|
|
17449
17880
|
output: JsonValueSchema.optional(),
|
|
17450
17881
|
error: JsonValueSchema.optional(),
|
|
17451
|
-
metrics:
|
|
17882
|
+
metrics: import_zod33.z.object({ predict_time: import_zod33.z.number().optional() }).optional()
|
|
17452
17883
|
});
|
|
17453
17884
|
function createReplicateHttpClient(opts) {
|
|
17454
17885
|
async function request(path, body, signal) {
|
|
@@ -17499,7 +17930,7 @@ function createReplicateHttpClient(opts) {
|
|
|
17499
17930
|
}
|
|
17500
17931
|
|
|
17501
17932
|
// src/adapters/replicate.ts
|
|
17502
|
-
var
|
|
17933
|
+
var import_zod34 = require("zod");
|
|
17503
17934
|
var POLL_INTERVAL_MS2 = 1e3;
|
|
17504
17935
|
var POLL_TIMEOUT_MS = 15 * 6e4;
|
|
17505
17936
|
var defaultReplicateDeps = {
|
|
@@ -17539,8 +17970,8 @@ function route(providerModelId) {
|
|
|
17539
17970
|
if (!providerModelId.includes("/")) return { version: providerModelId };
|
|
17540
17971
|
return { model: providerModelId };
|
|
17541
17972
|
}
|
|
17542
|
-
var replicateResponseStatusSchema =
|
|
17543
|
-
response:
|
|
17973
|
+
var replicateResponseStatusSchema = import_zod34.z.object({
|
|
17974
|
+
response: import_zod34.z.object({ status: import_zod34.z.number() }).partial()
|
|
17544
17975
|
});
|
|
17545
17976
|
function replicateError(cause, ctx) {
|
|
17546
17977
|
if (isModelKitError(cause)) return cause;
|
|
@@ -17563,7 +17994,7 @@ function isUrlFn(value) {
|
|
|
17563
17994
|
function extractOutputUrl(output) {
|
|
17564
17995
|
const root = Array.isArray(output) ? output[0] : output;
|
|
17565
17996
|
if (root === void 0) throw noOutput();
|
|
17566
|
-
const asString =
|
|
17997
|
+
const asString = import_zod34.z.string().safeParse(root);
|
|
17567
17998
|
if (asString.success && asString.data) return asString.data;
|
|
17568
17999
|
if (root instanceof URL) return root.href;
|
|
17569
18000
|
if (isObjectOutput(root)) {
|
|
@@ -17572,15 +18003,15 @@ function extractOutputUrl(output) {
|
|
|
17572
18003
|
if (urlValue !== void 0 && isUrlFn(urlValue)) {
|
|
17573
18004
|
const called = urlValue();
|
|
17574
18005
|
if (called instanceof URL) return called.href;
|
|
17575
|
-
const calledString =
|
|
18006
|
+
const calledString = import_zod34.z.string().safeParse(called);
|
|
17576
18007
|
if (calledString.success && calledString.data) return calledString.data;
|
|
17577
18008
|
} else {
|
|
17578
|
-
const direct =
|
|
18009
|
+
const direct = import_zod34.z.string().safeParse(urlValue);
|
|
17579
18010
|
if (direct.success && direct.data) return direct.data;
|
|
17580
18011
|
}
|
|
17581
18012
|
}
|
|
17582
18013
|
if ("default" in root) {
|
|
17583
|
-
const fallback =
|
|
18014
|
+
const fallback = import_zod34.z.string().safeParse(root.default);
|
|
17584
18015
|
if (fallback.success && fallback.data) return fallback.data;
|
|
17585
18016
|
}
|
|
17586
18017
|
}
|
|
@@ -17641,7 +18072,7 @@ async function runPrediction(ctx, input, deps) {
|
|
|
17641
18072
|
}
|
|
17642
18073
|
return void 0;
|
|
17643
18074
|
}, pollOpts);
|
|
17644
|
-
const predictTime =
|
|
18075
|
+
const predictTime = import_zod34.z.number().safeParse(done.metrics?.predict_time);
|
|
17645
18076
|
if (done.output === void 0) throw noOutput();
|
|
17646
18077
|
return {
|
|
17647
18078
|
url: extractOutputUrl(done.output),
|
|
@@ -17887,9 +18318,9 @@ async function generateReplicateImage(req, ctx, deps) {
|
|
|
17887
18318
|
}
|
|
17888
18319
|
const { url, predictTime, raw } = await runPrediction(ctx, input, deps);
|
|
17889
18320
|
const file = await download(ctx, url);
|
|
17890
|
-
const
|
|
17891
|
-
|
|
17892
|
-
return { images: [{ bytes: file.bytes, mime: file.mime }], usage:
|
|
18321
|
+
const usage6 = imageUsage3(ctx, req);
|
|
18322
|
+
usage6.quantity = predictTime;
|
|
18323
|
+
return { images: [{ bytes: file.bytes, mime: file.mime }], usage: usage6, raw, outputUrl: url };
|
|
17893
18324
|
}
|
|
17894
18325
|
function klingInput(req) {
|
|
17895
18326
|
const images = (req.firstFrame ? [req.firstFrame] : []).map(refToUrl);
|
|
@@ -17994,7 +18425,7 @@ async function generateReplicateVideo(req, ctx, deps) {
|
|
|
17994
18425
|
throw replicateError(cause, ctx);
|
|
17995
18426
|
}
|
|
17996
18427
|
if (current.status === "succeeded") {
|
|
17997
|
-
const predictTime =
|
|
18428
|
+
const predictTime = import_zod34.z.number().safeParse(current.metrics?.predict_time);
|
|
17998
18429
|
if (current.output === void 0) throw noOutput();
|
|
17999
18430
|
return {
|
|
18000
18431
|
url: extractOutputUrl(current.output),
|
|
@@ -18013,9 +18444,9 @@ async function generateReplicateVideo(req, ctx, deps) {
|
|
|
18013
18444
|
return void 0;
|
|
18014
18445
|
};
|
|
18015
18446
|
const toResult = (done) => {
|
|
18016
|
-
const
|
|
18017
|
-
|
|
18018
|
-
return { video: { url: done.url }, usage:
|
|
18447
|
+
const usage6 = videoUsage5(ctx, req);
|
|
18448
|
+
usage6.quantity = done.predictTime;
|
|
18449
|
+
return { video: { url: done.url }, usage: usage6, raw: done.raw };
|
|
18019
18450
|
};
|
|
18020
18451
|
return {
|
|
18021
18452
|
jobId,
|
|
@@ -18122,21 +18553,21 @@ async function generateReplicateAudio(req, ctx, deps) {
|
|
|
18122
18553
|
input = specResult.input;
|
|
18123
18554
|
}
|
|
18124
18555
|
const { url, predictTime, raw } = await runPrediction(ctx, input, deps);
|
|
18125
|
-
const
|
|
18556
|
+
const usage6 = audioUsage(ctx, req);
|
|
18126
18557
|
if (ctx.model.usage.unit === "seconds") {
|
|
18127
18558
|
const seconds3 = elevenLabsMusicDuration(req.durationSeconds);
|
|
18128
|
-
|
|
18129
|
-
|
|
18559
|
+
usage6.quantity = seconds3;
|
|
18560
|
+
usage6.durationSeconds = seconds3;
|
|
18130
18561
|
} else {
|
|
18131
|
-
|
|
18562
|
+
usage6.quantity = predictTime;
|
|
18132
18563
|
}
|
|
18133
|
-
return { audio: { url }, usage:
|
|
18564
|
+
return { audio: { url }, usage: usage6, raw: predictionRaw(raw) };
|
|
18134
18565
|
}
|
|
18135
18566
|
|
|
18136
18567
|
// src/adapters/xai-video.ts
|
|
18137
18568
|
var import_ai3 = require("ai");
|
|
18138
18569
|
var import_xai2 = require("@ai-sdk/xai");
|
|
18139
|
-
var
|
|
18570
|
+
var import_zod35 = require("zod");
|
|
18140
18571
|
var POLL_INTERVAL_MS3 = 1e4;
|
|
18141
18572
|
var POLL_TIMEOUT_MS2 = 15 * 6e4;
|
|
18142
18573
|
var defaultXaiDeps = {
|
|
@@ -18149,8 +18580,8 @@ function createXaiVideoAdapter(deps = defaultXaiDeps) {
|
|
|
18149
18580
|
};
|
|
18150
18581
|
}
|
|
18151
18582
|
var xaiVideoAdapter = createXaiVideoAdapter();
|
|
18152
|
-
var xaiResponseStatusSchema =
|
|
18153
|
-
response:
|
|
18583
|
+
var xaiResponseStatusSchema = import_zod35.z.object({
|
|
18584
|
+
response: import_zod35.z.object({ status: import_zod35.z.number() }).partial()
|
|
18154
18585
|
});
|
|
18155
18586
|
function xaiError(cause, ctx) {
|
|
18156
18587
|
const info = describeThrown(cause);
|
|
@@ -18158,12 +18589,12 @@ function xaiError(cause, ctx) {
|
|
|
18158
18589
|
const status = info.status ?? (nested.success ? nested.data.response?.status : void 0);
|
|
18159
18590
|
return classifyThrown("xai-video", cause, ctx.model.id, { status, body: info.body });
|
|
18160
18591
|
}
|
|
18161
|
-
var xaiMetaSchema =
|
|
18592
|
+
var xaiMetaSchema = import_zod35.z.object({
|
|
18162
18593
|
videoUrl: JsonValueSchema.optional(),
|
|
18163
18594
|
costInUsdTicks: JsonValueSchema.optional(),
|
|
18164
18595
|
duration: JsonValueSchema.optional()
|
|
18165
18596
|
});
|
|
18166
|
-
var xaiProviderMetadataSchema =
|
|
18597
|
+
var xaiProviderMetadataSchema = import_zod35.z.object({ xai: xaiMetaSchema });
|
|
18167
18598
|
function metaOf(result) {
|
|
18168
18599
|
const parsed = xaiProviderMetadataSchema.partial().safeParse(result.providerMetadata);
|
|
18169
18600
|
if (!parsed.success) return {};
|
|
@@ -18275,12 +18706,12 @@ async function mapResult(ctx, req, result) {
|
|
|
18275
18706
|
if (first) {
|
|
18276
18707
|
return {
|
|
18277
18708
|
video: { bytes: Uint8Array.from(first.uint8Array), mime: first.mediaType },
|
|
18278
|
-
usage:
|
|
18709
|
+
usage: usage5(ctx, req, metaOf(result)),
|
|
18279
18710
|
raw: result.providerMetadata
|
|
18280
18711
|
};
|
|
18281
18712
|
}
|
|
18282
18713
|
const meta = metaOf(result);
|
|
18283
|
-
const videoUrl =
|
|
18714
|
+
const videoUrl = import_zod35.z.string().safeParse(meta.videoUrl);
|
|
18284
18715
|
if (videoUrl.success && videoUrl.data) {
|
|
18285
18716
|
const res = await ctx.fetch(videoUrl.data);
|
|
18286
18717
|
if (!res.ok) {
|
|
@@ -18290,7 +18721,7 @@ async function mapResult(ctx, req, result) {
|
|
|
18290
18721
|
const mime = res.headers.get("content-type") ?? "video/mp4";
|
|
18291
18722
|
return {
|
|
18292
18723
|
video: { bytes: new Uint8Array(await res.arrayBuffer()), mime },
|
|
18293
|
-
usage:
|
|
18724
|
+
usage: usage5(ctx, req, meta),
|
|
18294
18725
|
raw: result.providerMetadata
|
|
18295
18726
|
};
|
|
18296
18727
|
}
|
|
@@ -18302,8 +18733,8 @@ async function mapResult(ctx, req, result) {
|
|
|
18302
18733
|
retryable: false
|
|
18303
18734
|
});
|
|
18304
18735
|
}
|
|
18305
|
-
function
|
|
18306
|
-
const costTicks =
|
|
18736
|
+
function usage5(ctx, req, meta) {
|
|
18737
|
+
const costTicks = import_zod35.z.number().safeParse(meta.costInUsdTicks);
|
|
18307
18738
|
const cost = costTicks.success ? costTicks.data / 1e10 : void 0;
|
|
18308
18739
|
const event = {
|
|
18309
18740
|
model: ctx.model.id,
|
|
@@ -18384,15 +18815,17 @@ var FAL_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
|
18384
18815
|
"transcription",
|
|
18385
18816
|
"mask"
|
|
18386
18817
|
]);
|
|
18387
|
-
function
|
|
18388
|
-
|
|
18818
|
+
function directNode(row2) {
|
|
18819
|
+
if (row2.adapter === "elevenlabs" && row2.type === "sound-effect") return true;
|
|
18820
|
+
const speaks = row2.adapter === "fish" || row2.adapter === "elevenlabs" || row2.adapter === "google-genai";
|
|
18821
|
+
return speaks && row2.type === "speech";
|
|
18389
18822
|
}
|
|
18390
18823
|
function dataOnlyCapable(row2) {
|
|
18391
18824
|
const adapter = DEFAULT_ADAPTERS[row2.adapter];
|
|
18392
18825
|
if (!adapterServesType(adapter, row2.type)) {
|
|
18393
18826
|
return { ok: false, reason: `${row2.adapter} cannot serve ${row2.type} rows` };
|
|
18394
18827
|
}
|
|
18395
|
-
if (FAL_NODE_TYPES.has(row2.type) && row2.adapter !== "fal" && !
|
|
18828
|
+
if (FAL_NODE_TYPES.has(row2.type) && row2.adapter !== "fal" && !directNode(row2)) {
|
|
18396
18829
|
return { ok: false, reason: `only fal serves ${row2.type} rows` };
|
|
18397
18830
|
}
|
|
18398
18831
|
switch (row2.adapter) {
|
|
@@ -18419,6 +18852,10 @@ function dataOnlyCapable(row2) {
|
|
|
18419
18852
|
if (row2.type === "video") {
|
|
18420
18853
|
return isGoogleGenaiVideoKnown(row2.providerModelId) ? { ok: true } : { ok: false, reason: "google-genai video needs a veo- or gemini-omni id" };
|
|
18421
18854
|
}
|
|
18855
|
+
if (row2.type === "speech" || row2.type === "voice-clone") {
|
|
18856
|
+
const reason = googleVoiceRowRefusal(row2);
|
|
18857
|
+
return reason === void 0 ? { ok: true } : { ok: false, reason };
|
|
18858
|
+
}
|
|
18422
18859
|
return isGoogleGenaiAudioKnown(row2.providerModelId) ? { ok: true } : { ok: false, reason: "google-genai audio needs a lyria- id" };
|
|
18423
18860
|
}
|
|
18424
18861
|
case "replicate": {
|
|
@@ -18501,22 +18938,22 @@ var liveState = store[KEY] ??= {
|
|
|
18501
18938
|
var liveCatalog = liveState.catalog;
|
|
18502
18939
|
|
|
18503
18940
|
// src/catalog/load.ts
|
|
18504
|
-
var
|
|
18941
|
+
var import_zod36 = require("zod");
|
|
18505
18942
|
function rowCount() {
|
|
18506
18943
|
return liveCatalog.list({ lifecycle: ["active", "deprecated", "retired"] }).length;
|
|
18507
18944
|
}
|
|
18508
18945
|
function authHeaders2(auth) {
|
|
18509
18946
|
return "bearer" in auth ? { Authorization: `Bearer ${auth.bearer}` } : { "x-api-key": auth.apiKey };
|
|
18510
18947
|
}
|
|
18511
|
-
var EnvelopeSchema =
|
|
18512
|
-
rows:
|
|
18513
|
-
revision:
|
|
18948
|
+
var EnvelopeSchema = import_zod36.z.object({
|
|
18949
|
+
rows: import_zod36.z.array(JsonValueSchema),
|
|
18950
|
+
revision: import_zod36.z.string().optional()
|
|
18514
18951
|
});
|
|
18515
18952
|
function dropReason(path, message) {
|
|
18516
18953
|
return path.length === 0 ? message : `${path.map((part) => String(part)).join(".")} ${message}`;
|
|
18517
18954
|
}
|
|
18518
18955
|
function rowId(raw) {
|
|
18519
|
-
const parsed =
|
|
18956
|
+
const parsed = import_zod36.z.object({ id: import_zod36.z.string().min(1) }).loose().safeParse(raw);
|
|
18520
18957
|
if (!parsed.success) return "?";
|
|
18521
18958
|
return parsed.data.id;
|
|
18522
18959
|
}
|
|
@@ -18733,7 +19170,7 @@ function fileCatalogCache(path) {
|
|
|
18733
19170
|
}
|
|
18734
19171
|
|
|
18735
19172
|
// src/catalog/input-billing.ts
|
|
18736
|
-
var
|
|
19173
|
+
var import_zod37 = require("zod");
|
|
18737
19174
|
var DATA_ONLY_INPUT_BILLING = /* @__PURE__ */ new Map([
|
|
18738
19175
|
["flux-3", "source-video-rate"]
|
|
18739
19176
|
]);
|
|
@@ -18742,7 +19179,7 @@ var KIT_INPUT_BILLING = new Map(
|
|
|
18742
19179
|
(row2) => row2.constraints.inputBilling ? [[row2.id, row2.constraints.inputBilling]] : []
|
|
18743
19180
|
)
|
|
18744
19181
|
);
|
|
18745
|
-
var ConstraintsReadView2 =
|
|
19182
|
+
var ConstraintsReadView2 = import_zod37.z.looseObject({
|
|
18746
19183
|
inputBilling: InputBillingSchema.optional().catch(void 0)
|
|
18747
19184
|
});
|
|
18748
19185
|
function inputBillingOf(row2) {
|
|
@@ -18764,7 +19201,7 @@ function animationTier(model, frameSize) {
|
|
|
18764
19201
|
if (offered.includes(tier)) return tier;
|
|
18765
19202
|
return offered[offered.length - 1] ?? tier;
|
|
18766
19203
|
}
|
|
18767
|
-
function
|
|
19204
|
+
function refuse2(model, message) {
|
|
18768
19205
|
throw new ModelKitError({ code: "unsupported_option", message, model: model.id });
|
|
18769
19206
|
}
|
|
18770
19207
|
function clamp(value, min, max) {
|
|
@@ -18779,7 +19216,7 @@ function applyAnimation(model, req, onUnsupported, warnings) {
|
|
|
18779
19216
|
const fallback = sizes[0];
|
|
18780
19217
|
if (req.exactSize !== void 0) {
|
|
18781
19218
|
if (onUnsupported === "error") {
|
|
18782
|
-
|
|
19219
|
+
refuse2(
|
|
18783
19220
|
model,
|
|
18784
19221
|
`${model.id} makes GIF frames at ${sizes.map((s) => s.size).join(", ")}; got ${req.exactSize}`
|
|
18785
19222
|
);
|
|
@@ -18801,7 +19238,7 @@ function applyAnimation(model, req, onUnsupported, warnings) {
|
|
|
18801
19238
|
const frames = asked ?? clamp(limits.defaultFrameCount, frameSize.minFrames, frameSize.maxFrames);
|
|
18802
19239
|
if (frames < frameSize.minFrames || frames > frameSize.maxFrames || !Number.isInteger(frames)) {
|
|
18803
19240
|
if (onUnsupported === "error") {
|
|
18804
|
-
|
|
19241
|
+
refuse2(
|
|
18805
19242
|
model,
|
|
18806
19243
|
`${model.id} makes ${frameSize.minFrames} to ${frameSize.maxFrames} frames at ${frameSize.size}; got ${frames}`
|
|
18807
19244
|
);
|
|
@@ -18822,7 +19259,7 @@ function applyAnimation(model, req, onUnsupported, warnings) {
|
|
|
18822
19259
|
const duration = animation.frameDurationMs ?? limits.defaultFrameDurationMs;
|
|
18823
19260
|
if (duration < min || duration > max) {
|
|
18824
19261
|
if (onUnsupported === "error") {
|
|
18825
|
-
|
|
19262
|
+
refuse2(model, `${model.id} shows each GIF frame ${min} to ${max} ms; got ${duration}`);
|
|
18826
19263
|
}
|
|
18827
19264
|
const snapped = clamp(duration, min, max);
|
|
18828
19265
|
warnings.push({
|
|
@@ -18844,7 +19281,7 @@ function applyImageOutputRules(model, req, onUnsupported, warnings) {
|
|
|
18844
19281
|
const format = req.outputFormat;
|
|
18845
19282
|
if (format !== void 0 && !imageOutputFormats(model).includes(format)) {
|
|
18846
19283
|
if (onUnsupported === "error") {
|
|
18847
|
-
|
|
19284
|
+
refuse2(
|
|
18848
19285
|
model,
|
|
18849
19286
|
`${model.id} does not offer outputFormat ${format}. Supported: ${imageOutputFormats(model).join(", ")}.`
|
|
18850
19287
|
);
|
|
@@ -18859,7 +19296,7 @@ function applyImageOutputRules(model, req, onUnsupported, warnings) {
|
|
|
18859
19296
|
}
|
|
18860
19297
|
if (req.background !== void 0 && !(c.backgrounds ?? []).includes(req.background)) {
|
|
18861
19298
|
if (onUnsupported === "error") {
|
|
18862
|
-
|
|
19299
|
+
refuse2(model, `${model.id} does not offer background ${req.background}`);
|
|
18863
19300
|
}
|
|
18864
19301
|
warnings.push({
|
|
18865
19302
|
code: "option_ignored",
|
|
@@ -18880,10 +19317,10 @@ function applyImageOutputRules(model, req, onUnsupported, warnings) {
|
|
|
18880
19317
|
delete req.animation;
|
|
18881
19318
|
}
|
|
18882
19319
|
if (req.outputFormat === "svg") {
|
|
18883
|
-
if (!c.svgModel)
|
|
19320
|
+
if (!c.svgModel) refuse2(model, `${model.id} names no svgModel to write the SVG`);
|
|
18884
19321
|
if ((req.count ?? 1) > 1) {
|
|
18885
19322
|
if (onUnsupported === "error") {
|
|
18886
|
-
|
|
19323
|
+
refuse2(model, `${model.label} makes one SVG per call`);
|
|
18887
19324
|
}
|
|
18888
19325
|
warnings.push({
|
|
18889
19326
|
code: "option_ignored",
|
|
@@ -19545,7 +19982,13 @@ function resolveAudioOptions(model, request, onUnsupported = "error") {
|
|
|
19545
19982
|
model: model.id
|
|
19546
19983
|
});
|
|
19547
19984
|
}
|
|
19548
|
-
dropUnsupported(merged, model, warnings, [
|
|
19985
|
+
dropUnsupported(merged, model, warnings, [
|
|
19986
|
+
"seed",
|
|
19987
|
+
"negativePrompt",
|
|
19988
|
+
"instrumental",
|
|
19989
|
+
"lyrics",
|
|
19990
|
+
"loop"
|
|
19991
|
+
]);
|
|
19549
19992
|
applyFalAudioRules(model, merged);
|
|
19550
19993
|
const format = resolveOutputFormat(model, request.outputFormat, onUnsupported, warnings);
|
|
19551
19994
|
if (format !== void 0) merged.outputFormat = format;
|
|
@@ -19778,7 +20221,7 @@ function resolveTranscriptionOptions(model, request, onUnsupported = "error") {
|
|
|
19778
20221
|
}
|
|
19779
20222
|
|
|
19780
20223
|
// src/resolve-voice.ts
|
|
19781
|
-
function
|
|
20224
|
+
function refuse3(model, code, message) {
|
|
19782
20225
|
return new ModelKitError({ code, message: `${model.label} ${message}`, model: model.id });
|
|
19783
20226
|
}
|
|
19784
20227
|
function checkSample(model, sample, index) {
|
|
@@ -19787,7 +20230,7 @@ function checkSample(model, sample, index) {
|
|
|
19787
20230
|
if (limits === void 0 || length === void 0) return;
|
|
19788
20231
|
if (limits.min !== void 0 && length < limits.min || limits.max !== void 0 && length > limits.max) {
|
|
19789
20232
|
const range2 = `${limits.min ?? 0}-${limits.max ?? "any"} s`;
|
|
19790
|
-
throw
|
|
20233
|
+
throw refuse3(
|
|
19791
20234
|
model,
|
|
19792
20235
|
"unsupported_option",
|
|
19793
20236
|
`takes samples of ${range2}; sample ${index + 1} is ${length} s`
|
|
@@ -19796,11 +20239,11 @@ function checkSample(model, sample, index) {
|
|
|
19796
20239
|
}
|
|
19797
20240
|
function resolveVoiceCloneOptions(model, request) {
|
|
19798
20241
|
const title = request.title.trim();
|
|
19799
|
-
if (!title) throw
|
|
19800
|
-
if (request.samples.length === 0) throw
|
|
20242
|
+
if (!title) throw refuse3(model, "missing_input", "needs a title");
|
|
20243
|
+
if (request.samples.length === 0) throw refuse3(model, "missing_input", "needs a voice sample");
|
|
19801
20244
|
const max = model.constraints.references?.audios;
|
|
19802
20245
|
if (max !== void 0 && request.samples.length > max) {
|
|
19803
|
-
throw
|
|
20246
|
+
throw refuse3(
|
|
19804
20247
|
model,
|
|
19805
20248
|
"unsupported_option",
|
|
19806
20249
|
`takes up to ${max} samples; got ${request.samples.length}`
|
|
@@ -19810,7 +20253,7 @@ function resolveVoiceCloneOptions(model, request) {
|
|
|
19810
20253
|
const total = model.constraints.references?.audioSeconds?.total;
|
|
19811
20254
|
const seconds3 = request.samples.reduce((sum, s) => sum + (s.audio.durationSeconds ?? 0), 0);
|
|
19812
20255
|
if (total !== void 0 && seconds3 > total) {
|
|
19813
|
-
throw
|
|
20256
|
+
throw refuse3(
|
|
19814
20257
|
model,
|
|
19815
20258
|
"unsupported_option",
|
|
19816
20259
|
`takes up to ${total} s of samples; got ${seconds3} s`
|
|
@@ -19819,7 +20262,7 @@ function resolveVoiceCloneOptions(model, request) {
|
|
|
19819
20262
|
for (const field of ["transcript", "designSignature"]) {
|
|
19820
20263
|
const set = request.samples.filter((s) => s[field]?.trim()).length;
|
|
19821
20264
|
if (set !== 0 && set !== request.samples.length) {
|
|
19822
|
-
throw
|
|
20265
|
+
throw refuse3(model, "missing_input", `needs ${field} on every sample or on none`);
|
|
19823
20266
|
}
|
|
19824
20267
|
}
|
|
19825
20268
|
return { request: { ...request, model: model.id, title }, warnings: [] };
|
|
@@ -19827,10 +20270,10 @@ function resolveVoiceCloneOptions(model, request) {
|
|
|
19827
20270
|
function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
|
|
19828
20271
|
const warnings = [];
|
|
19829
20272
|
const prompt = request.prompt.trim();
|
|
19830
|
-
if (!prompt) throw
|
|
20273
|
+
if (!prompt) throw refuse3(model, "missing_input", "needs a voice description");
|
|
19831
20274
|
const maxChars = promptConventions(model).maxChars;
|
|
19832
20275
|
if (maxChars !== void 0 && prompt.length > maxChars) {
|
|
19833
|
-
throw
|
|
20276
|
+
throw refuse3(
|
|
19834
20277
|
model,
|
|
19835
20278
|
"unsupported_option",
|
|
19836
20279
|
`takes up to ${maxChars} characters; got ${prompt.length}`
|
|
@@ -19841,7 +20284,7 @@ function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
|
|
|
19841
20284
|
const preview2 = request.previewText?.trim();
|
|
19842
20285
|
if (preview2) {
|
|
19843
20286
|
if (limits !== void 0 && preview2.length > limits.previewMaxChars) {
|
|
19844
|
-
throw
|
|
20287
|
+
throw refuse3(
|
|
19845
20288
|
model,
|
|
19846
20289
|
"unsupported_option",
|
|
19847
20290
|
`takes a preview line of up to ${limits.previewMaxChars} characters; got ${preview2.length}`
|
|
@@ -19857,7 +20300,7 @@ function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
|
|
|
19857
20300
|
const cap = limits?.maxCandidates ?? count2;
|
|
19858
20301
|
if (!Number.isInteger(count2) || count2 < 1 || count2 > cap) {
|
|
19859
20302
|
if (onUnsupported === "error" || !Number.isInteger(count2)) {
|
|
19860
|
-
throw
|
|
20303
|
+
throw refuse3(
|
|
19861
20304
|
model,
|
|
19862
20305
|
"unsupported_option",
|
|
19863
20306
|
`returns 1-${cap} candidates; got ${count2}`
|
|
@@ -20227,7 +20670,7 @@ async function testProviderKey(provider, secret, opts = {}) {
|
|
|
20227
20670
|
|
|
20228
20671
|
// src/text.ts
|
|
20229
20672
|
var import_ai4 = require("ai");
|
|
20230
|
-
var
|
|
20673
|
+
var import_zod38 = require("zod");
|
|
20231
20674
|
function mergeTextProviderOptions(catalog, caller) {
|
|
20232
20675
|
const merged = {};
|
|
20233
20676
|
const catalogOptions = catalog.providerOptions ?? {};
|
|
@@ -20266,17 +20709,17 @@ function passthroughTextModel(model) {
|
|
|
20266
20709
|
pricingKind: "token"
|
|
20267
20710
|
};
|
|
20268
20711
|
}
|
|
20269
|
-
var perplexityCostSchema =
|
|
20270
|
-
perplexity:
|
|
20712
|
+
var perplexityCostSchema = import_zod38.z.object({
|
|
20713
|
+
perplexity: import_zod38.z.object({ cost: import_zod38.z.object({ totalCost: import_zod38.z.number().finite().nonnegative() }) })
|
|
20271
20714
|
});
|
|
20272
20715
|
function reportedCostUsd(metadata) {
|
|
20273
20716
|
const parsed = perplexityCostSchema.safeParse(metadata);
|
|
20274
20717
|
return parsed.success ? parsed.data.perplexity.cost.totalCost : void 0;
|
|
20275
20718
|
}
|
|
20276
|
-
function textUsageEvent(model, provider,
|
|
20277
|
-
const inputTokens =
|
|
20278
|
-
const outputTokens =
|
|
20279
|
-
const total =
|
|
20719
|
+
function textUsageEvent(model, provider, usage6, providerMetadata) {
|
|
20720
|
+
const inputTokens = usage6.inputTokens ?? 0;
|
|
20721
|
+
const outputTokens = usage6.outputTokens ?? 0;
|
|
20722
|
+
const total = usage6.totalTokens ?? inputTokens + outputTokens;
|
|
20280
20723
|
const event = {
|
|
20281
20724
|
model: model.id,
|
|
20282
20725
|
provider,
|
|
@@ -20311,7 +20754,7 @@ function createTextSteps(initial, resolve, callerProviderOptions) {
|
|
|
20311
20754
|
return { ...prepared, providerOptions };
|
|
20312
20755
|
};
|
|
20313
20756
|
}
|
|
20314
|
-
function
|
|
20757
|
+
function usage6(results) {
|
|
20315
20758
|
const grouped = /* @__PURE__ */ new Map();
|
|
20316
20759
|
for (const [index, step] of results.entries()) {
|
|
20317
20760
|
const target = steps.get(index) ?? initial;
|
|
@@ -20333,12 +20776,12 @@ function createTextSteps(initial, resolve, callerProviderOptions) {
|
|
|
20333
20776
|
}
|
|
20334
20777
|
return [...grouped.values()];
|
|
20335
20778
|
}
|
|
20336
|
-
return { wrap, usage:
|
|
20779
|
+
return { wrap, usage: usage6 };
|
|
20337
20780
|
}
|
|
20338
20781
|
|
|
20339
20782
|
// src/client.ts
|
|
20340
20783
|
var import_ai5 = require("ai");
|
|
20341
|
-
var
|
|
20784
|
+
var import_zod39 = require("zod");
|
|
20342
20785
|
|
|
20343
20786
|
// src/generated-image.ts
|
|
20344
20787
|
function toGeneratedImage(image) {
|
|
@@ -20460,9 +20903,9 @@ function providerJobMethods(kind, deps) {
|
|
|
20460
20903
|
const { methods, adapter, ctx } = target(sub.model, rest);
|
|
20461
20904
|
if (!methods.result) throw missing3(adapter, ctx.model);
|
|
20462
20905
|
const result = await methods.result(sub, ctx, webhook);
|
|
20463
|
-
const
|
|
20464
|
-
await deps.emit(
|
|
20465
|
-
return { ...result, usage:
|
|
20906
|
+
const usage6 = deps.rowUsage(ctx, result.usage, sub.submittedAt);
|
|
20907
|
+
await deps.emit(usage6);
|
|
20908
|
+
return { ...result, usage: usage6 };
|
|
20466
20909
|
},
|
|
20467
20910
|
async cancel(sub, call = {}) {
|
|
20468
20911
|
const { methods, adapter, ctx } = target(sub.model, call);
|
|
@@ -20702,10 +21145,10 @@ function audioNodeMethods(deps) {
|
|
|
20702
21145
|
const startedAt = Date.now();
|
|
20703
21146
|
const outcome = await adapter.dub(resolved, ctx);
|
|
20704
21147
|
if (outcome.kind === "audio") {
|
|
20705
|
-
const { audio, usage:
|
|
21148
|
+
const { audio, usage: usage6, raw } = outcome.result;
|
|
20706
21149
|
return {
|
|
20707
21150
|
audio,
|
|
20708
|
-
usage: await deps.settle(ctx,
|
|
21151
|
+
usage: await deps.settle(ctx, usage6, startedAt),
|
|
20709
21152
|
...raw !== void 0 && { raw }
|
|
20710
21153
|
};
|
|
20711
21154
|
}
|
|
@@ -20757,10 +21200,10 @@ function textAbortOptions(sdk, context) {
|
|
|
20757
21200
|
if (abortSignal) return { abortSignal };
|
|
20758
21201
|
return {};
|
|
20759
21202
|
}
|
|
20760
|
-
var catalogId =
|
|
20761
|
-
var exactSize =
|
|
20762
|
-
var sdkRatio =
|
|
20763
|
-
var sizeTier =
|
|
21203
|
+
var catalogId = import_zod39.z.string();
|
|
21204
|
+
var exactSize = import_zod39.z.templateLiteral([import_zod39.z.number(), "x", import_zod39.z.number()]);
|
|
21205
|
+
var sdkRatio = import_zod39.z.templateLiteral([import_zod39.z.number(), ":", import_zod39.z.number()]);
|
|
21206
|
+
var sizeTier = import_zod39.z.enum(["512", "1K", "2K", "4K", "8K"]);
|
|
20764
21207
|
function isCatalogId(model) {
|
|
20765
21208
|
return catalogId.safeParse(model).success;
|
|
20766
21209
|
}
|
|
@@ -21003,7 +21446,7 @@ function createModelKit(config, adapters) {
|
|
|
21003
21446
|
const images = result.images.map(
|
|
21004
21447
|
(file) => toGeneratedImage({ bytes: file.uint8Array, mime: file.mediaType })
|
|
21005
21448
|
);
|
|
21006
|
-
const
|
|
21449
|
+
const usage6 = timed(
|
|
21007
21450
|
{
|
|
21008
21451
|
model: model.modelId,
|
|
21009
21452
|
provider: model.provider,
|
|
@@ -21013,8 +21456,8 @@ function createModelKit(config, adapters) {
|
|
|
21013
21456
|
},
|
|
21014
21457
|
startedAt
|
|
21015
21458
|
);
|
|
21016
|
-
await emit(
|
|
21017
|
-
return { image: images[0], images, usage:
|
|
21459
|
+
await emit(usage6);
|
|
21460
|
+
return { image: images[0], images, usage: usage6, raw: result, warnings };
|
|
21018
21461
|
}
|
|
21019
21462
|
function passthroughVideo(req, call) {
|
|
21020
21463
|
const {
|
|
@@ -21032,7 +21475,7 @@ function createModelKit(config, adapters) {
|
|
|
21032
21475
|
referenceVideos,
|
|
21033
21476
|
referenceAudios,
|
|
21034
21477
|
resolution,
|
|
21035
|
-
generateAudio:
|
|
21478
|
+
generateAudio: generateAudio3,
|
|
21036
21479
|
negativePrompt: _negativePrompt,
|
|
21037
21480
|
cfgScale: _cfgScale,
|
|
21038
21481
|
promptExpansion: _promptExpansion,
|
|
@@ -21049,7 +21492,7 @@ function createModelKit(config, adapters) {
|
|
|
21049
21492
|
pushIgnored(warnings, "aspectRatio", aspectRatio, model.modelId);
|
|
21050
21493
|
if (seconds3 !== void 0) options.duration = seconds3;
|
|
21051
21494
|
if (seed !== void 0) options.seed = seed;
|
|
21052
|
-
if (
|
|
21495
|
+
if (generateAudio3 !== void 0) options.generateAudio = generateAudio3;
|
|
21053
21496
|
const frames = [
|
|
21054
21497
|
...firstFrame ? [{ image: sdkDataContent(firstFrame), frameType: "first_frame" }] : [],
|
|
21055
21498
|
...lastFrame ? [{ image: sdkDataContent(lastFrame), frameType: "last_frame" }] : []
|
|
@@ -21090,7 +21533,7 @@ function createModelKit(config, adapters) {
|
|
|
21090
21533
|
let settled;
|
|
21091
21534
|
let failed = false;
|
|
21092
21535
|
const done = pending.then(async (result) => {
|
|
21093
|
-
const
|
|
21536
|
+
const usage6 = timed(
|
|
21094
21537
|
{
|
|
21095
21538
|
model: model.modelId,
|
|
21096
21539
|
provider: model.provider,
|
|
@@ -21103,10 +21546,10 @@ function createModelKit(config, adapters) {
|
|
|
21103
21546
|
);
|
|
21104
21547
|
settled = {
|
|
21105
21548
|
video: { bytes: result.video.uint8Array, mime: result.video.mediaType },
|
|
21106
|
-
usage:
|
|
21549
|
+
usage: usage6,
|
|
21107
21550
|
raw: result
|
|
21108
21551
|
};
|
|
21109
|
-
await emit(
|
|
21552
|
+
await emit(usage6);
|
|
21110
21553
|
return settled;
|
|
21111
21554
|
});
|
|
21112
21555
|
done.catch(() => {
|
|
@@ -21133,9 +21576,9 @@ function createModelKit(config, adapters) {
|
|
|
21133
21576
|
if (settled) return settled;
|
|
21134
21577
|
const pending = result(opts).then(
|
|
21135
21578
|
async (out) => {
|
|
21136
|
-
const
|
|
21137
|
-
await emit(
|
|
21138
|
-
return { ...out, usage:
|
|
21579
|
+
const usage6 = rowUsage(ctx, out.usage, startedAt);
|
|
21580
|
+
await emit(usage6);
|
|
21581
|
+
return { ...out, usage: usage6 };
|
|
21139
21582
|
},
|
|
21140
21583
|
(cause) => {
|
|
21141
21584
|
settled = void 0;
|
|
@@ -21155,9 +21598,9 @@ function createModelKit(config, adapters) {
|
|
|
21155
21598
|
return context(model, signal ? { ...call, signal } : call, warnings);
|
|
21156
21599
|
},
|
|
21157
21600
|
async settle(ctx, event, startedAt) {
|
|
21158
|
-
const
|
|
21159
|
-
await emit(
|
|
21160
|
-
return
|
|
21601
|
+
const usage6 = rowUsage(ctx, event, startedAt);
|
|
21602
|
+
await emit(usage6);
|
|
21603
|
+
return usage6;
|
|
21161
21604
|
},
|
|
21162
21605
|
wrapVideoJob
|
|
21163
21606
|
});
|
|
@@ -21202,8 +21645,8 @@ function createModelKit(config, adapters) {
|
|
|
21202
21645
|
throw billedFailure(ctx, err, err.usage, startedAt);
|
|
21203
21646
|
throw err;
|
|
21204
21647
|
}
|
|
21205
|
-
const
|
|
21206
|
-
await emit(
|
|
21648
|
+
const usage6 = rowUsage(ctx, result.usage, startedAt);
|
|
21649
|
+
await emit(usage6);
|
|
21207
21650
|
const images = result.images.map(toGeneratedImage);
|
|
21208
21651
|
const first = images[0];
|
|
21209
21652
|
if (!first)
|
|
@@ -21212,7 +21655,7 @@ function createModelKit(config, adapters) {
|
|
|
21212
21655
|
message: `${model.id} returned no image`,
|
|
21213
21656
|
model: model.id
|
|
21214
21657
|
});
|
|
21215
|
-
return { ...result, usage:
|
|
21658
|
+
return { ...result, usage: usage6, image: first, images, warnings };
|
|
21216
21659
|
},
|
|
21217
21660
|
async generateVideo(req, call = {}) {
|
|
21218
21661
|
mediaRetryOptions(call);
|
|
@@ -21313,9 +21756,9 @@ function createModelKit(config, adapters) {
|
|
|
21313
21756
|
}
|
|
21314
21757
|
const startedAt = Date.now();
|
|
21315
21758
|
const result = await adapter.generateAudio(resolved, ctx);
|
|
21316
|
-
const
|
|
21317
|
-
await emit(
|
|
21318
|
-
return { ...result, usage:
|
|
21759
|
+
const usage6 = rowUsage(ctx, result.usage, startedAt);
|
|
21760
|
+
await emit(usage6);
|
|
21761
|
+
return { ...result, usage: usage6 };
|
|
21319
21762
|
},
|
|
21320
21763
|
async prepareMediaPart(modelId, ref, mediaType, call = {}) {
|
|
21321
21764
|
mediaRetryOptions(call);
|
|
@@ -21396,8 +21839,8 @@ function createModelKit(config, adapters) {
|
|
|
21396
21839
|
options.prepareStep ?? options.experimental_prepareStep
|
|
21397
21840
|
),
|
|
21398
21841
|
onFinish: async (event) => {
|
|
21399
|
-
for (const
|
|
21400
|
-
await emit(textTimed(withRowUnit(
|
|
21842
|
+
for (const usage6 of steps.usage(event.steps))
|
|
21843
|
+
await emit(textTimed(withRowUnit(usage6), event.steps.length, startedAt));
|
|
21401
21844
|
await callerOnFinish?.(event);
|
|
21402
21845
|
}
|
|
21403
21846
|
});
|
|
@@ -21477,7 +21920,7 @@ var generateObject = (options, call) => createDefaultModelKit().generateObject(o
|
|
|
21477
21920
|
var streamObject = (options, call) => createDefaultModelKit().streamObject(options, call);
|
|
21478
21921
|
var generateImage = (req, call) => createDefaultModelKit().generateImage(req, call);
|
|
21479
21922
|
var generateVideo = (req, call) => createDefaultModelKit().generateVideo(req, call);
|
|
21480
|
-
var
|
|
21923
|
+
var generateAudio2 = (req, call) => createDefaultModelKit().generateAudio(req, call);
|
|
21481
21924
|
var prepareMediaPart = (modelId, ref, mediaType, call) => createDefaultModelKit().prepareMediaPart(modelId, ref, mediaType, call);
|
|
21482
21925
|
var languageModel = (modelId, call) => createDefaultModelKit().languageModel(modelId, call);
|
|
21483
21926
|
var describe = (modelId) => createDefaultModelKit().describe(modelId);
|
|
@@ -21494,6 +21937,7 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
|
|
|
21494
21937
|
CatalogSchema,
|
|
21495
21938
|
DEFAULT_ADAPTERS,
|
|
21496
21939
|
ExposureSchema,
|
|
21940
|
+
GEMINI_VOICE_CONSENT,
|
|
21497
21941
|
IMAGE_INPUT_SPEC_KEYS,
|
|
21498
21942
|
INPUT_BILLINGS,
|
|
21499
21943
|
INPUT_SPEC_SUPPORTS_KEYS,
|