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