getaiapi 1.0.0-alpha.0 → 1.0.0-alpha.2
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/README.md +52 -40
- package/dist/chunk-34X3VRM3.js +72083 -0
- package/dist/chunk-34X3VRM3.js.map +1 -0
- package/dist/cli.js +38 -20
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +82 -39
- package/dist/index.js +25 -8
- package/dist/index.js.map +1 -1
- package/package.json +4 -8
- package/dist/chunk-LHDSEV4H.js +0 -1479
- package/dist/chunk-LHDSEV4H.js.map +0 -1
- package/dist/chunk-P7XV6JOH.js +0 -1046
- package/dist/chunk-P7XV6JOH.js.map +0 -1
- package/dist/v2/index.d.ts +0 -125
- package/dist/v2/index.js +0 -368
- package/dist/v2/index.js.map +0 -1
- package/registry/.gitkeep +0 -0
- package/registry/catalog.json +0 -4108
- package/registry/categories.json +0 -27
- package/registry/registry.json +0 -56128
- package/registry/v2/registry.json +0 -70024
package/dist/chunk-LHDSEV4H.js
DELETED
|
@@ -1,1479 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AuthManager,
|
|
3
|
-
ModelNotFoundError,
|
|
4
|
-
NoProviderError,
|
|
5
|
-
ProviderError,
|
|
6
|
-
ValidationError,
|
|
7
|
-
configureAuth,
|
|
8
|
-
configureStorage,
|
|
9
|
-
falAiAdapter,
|
|
10
|
-
openRouterAdapter,
|
|
11
|
-
processParamsForUpload,
|
|
12
|
-
replicateAdapter,
|
|
13
|
-
wavespeedAdapter,
|
|
14
|
-
withRetry
|
|
15
|
-
} from "./chunk-P7XV6JOH.js";
|
|
16
|
-
|
|
17
|
-
// src/gateway.ts
|
|
18
|
-
import { randomUUID } from "crypto";
|
|
19
|
-
|
|
20
|
-
// src/resolver.ts
|
|
21
|
-
import { readFileSync } from "fs";
|
|
22
|
-
import { resolve, dirname } from "path";
|
|
23
|
-
import { fileURLToPath } from "url";
|
|
24
|
-
var __filename = fileURLToPath(import.meta.url);
|
|
25
|
-
var __dirname = dirname(__filename);
|
|
26
|
-
var registryCache = null;
|
|
27
|
-
function loadRegistry() {
|
|
28
|
-
if (registryCache) {
|
|
29
|
-
return registryCache;
|
|
30
|
-
}
|
|
31
|
-
let dir = __dirname;
|
|
32
|
-
for (let i = 0; i < 5; i++) {
|
|
33
|
-
const candidate = resolve(dir, "registry", "registry.json");
|
|
34
|
-
try {
|
|
35
|
-
const raw = readFileSync(candidate, "utf-8");
|
|
36
|
-
registryCache = JSON.parse(raw);
|
|
37
|
-
return registryCache;
|
|
38
|
-
} catch {
|
|
39
|
-
dir = dirname(dir);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
throw new Error(
|
|
43
|
-
"Could not find registry/registry.json. Searched upward from: " + __dirname
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
function normalizeModelName(input) {
|
|
47
|
-
return input.toLowerCase().replace(/[^a-z0-9]/g, "").replace(/(?<=\d)v(?=\d)/g, "").replace(/v(?=\d)/g, "");
|
|
48
|
-
}
|
|
49
|
-
function resolveModel(query, availableProviders) {
|
|
50
|
-
if (!query || typeof query !== "string" || query.trim() === "") {
|
|
51
|
-
throw new ModelNotFoundError("Model name is required");
|
|
52
|
-
}
|
|
53
|
-
const trimmedQuery = query.trim();
|
|
54
|
-
const registry = loadRegistry();
|
|
55
|
-
let matched;
|
|
56
|
-
matched = registry.find((e) => e.canonical_name === trimmedQuery);
|
|
57
|
-
if (!matched) {
|
|
58
|
-
matched = registry.find(
|
|
59
|
-
(e) => e.aliases.some((a) => a === trimmedQuery)
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
if (!matched) {
|
|
63
|
-
const normalizedQuery = normalizeModelName(trimmedQuery);
|
|
64
|
-
matched = registry.find(
|
|
65
|
-
(e) => normalizeModelName(e.canonical_name) === normalizedQuery
|
|
66
|
-
);
|
|
67
|
-
if (!matched) {
|
|
68
|
-
matched = registry.find(
|
|
69
|
-
(e) => e.aliases.some((a) => normalizeModelName(a) === normalizedQuery)
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (!matched) {
|
|
74
|
-
const suggestions = findSuggestions(trimmedQuery, registry);
|
|
75
|
-
throw new ModelNotFoundError(trimmedQuery, suggestions);
|
|
76
|
-
}
|
|
77
|
-
if (availableProviders && availableProviders.length > 0) {
|
|
78
|
-
const filteredProviders = matched.providers.filter(
|
|
79
|
-
(p) => availableProviders.includes(p.provider)
|
|
80
|
-
);
|
|
81
|
-
if (filteredProviders.length === 0) {
|
|
82
|
-
throw new NoProviderError(
|
|
83
|
-
trimmedQuery,
|
|
84
|
-
matched.canonical_name,
|
|
85
|
-
matched.providers.map((p) => p.provider),
|
|
86
|
-
availableProviders
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
return { ...matched, providers: filteredProviders };
|
|
90
|
-
}
|
|
91
|
-
return matched;
|
|
92
|
-
}
|
|
93
|
-
function findSuggestions(query, registry) {
|
|
94
|
-
const normalizedQuery = normalizeModelName(query);
|
|
95
|
-
if (normalizedQuery === "") {
|
|
96
|
-
return [];
|
|
97
|
-
}
|
|
98
|
-
const matches = registry.filter((e) => {
|
|
99
|
-
const normalizedCanonical = normalizeModelName(e.canonical_name);
|
|
100
|
-
if (normalizedCanonical.startsWith(normalizedQuery) || normalizedCanonical.includes(normalizedQuery) || normalizedQuery.startsWith(normalizedCanonical)) {
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
const minLen = Math.min(normalizedQuery.length, normalizedCanonical.length);
|
|
104
|
-
let shared = 0;
|
|
105
|
-
for (let i = 0; i < minLen; i++) {
|
|
106
|
-
if (normalizedQuery[i] === normalizedCanonical[i]) {
|
|
107
|
-
shared++;
|
|
108
|
-
} else {
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return shared >= 3 && shared >= normalizedQuery.length * 0.3;
|
|
113
|
-
});
|
|
114
|
-
return matches.sort((a, b) => a.canonical_name.length - b.canonical_name.length).slice(0, 5).map((e) => e.canonical_name);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// src/mapper.ts
|
|
118
|
-
function mapInput(request, binding, template) {
|
|
119
|
-
const result = {};
|
|
120
|
-
const provider = binding.provider;
|
|
121
|
-
for (const mapping of template.input_mappings) {
|
|
122
|
-
const value = getUniversalValue(request, mapping.universal);
|
|
123
|
-
if (value === void 0 || value === null) {
|
|
124
|
-
if (mapping.required) {
|
|
125
|
-
throw new ValidationError(
|
|
126
|
-
mapping.universal,
|
|
127
|
-
`"${mapping.universal}" is required but was not provided.`
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
const providerKey = mapping.providers[provider];
|
|
133
|
-
if (providerKey === void 0) {
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
const transformed = applyTransform(value, mapping, provider);
|
|
137
|
-
if (Array.isArray(providerKey)) {
|
|
138
|
-
if (typeof transformed === "object" && transformed !== null && !Array.isArray(transformed)) {
|
|
139
|
-
const obj = transformed;
|
|
140
|
-
for (const key of providerKey) {
|
|
141
|
-
if (obj[key] !== void 0) {
|
|
142
|
-
result[key] = obj[key];
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
} else {
|
|
147
|
-
result[providerKey] = transformed;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
if (request.options) {
|
|
151
|
-
for (const [key, val] of Object.entries(request.options)) {
|
|
152
|
-
result[key] = val;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return result;
|
|
156
|
-
}
|
|
157
|
-
function getUniversalValue(request, field) {
|
|
158
|
-
return request[field];
|
|
159
|
-
}
|
|
160
|
-
function applyTransform(value, mapping, provider) {
|
|
161
|
-
const transform = mapping.transform;
|
|
162
|
-
if (!transform || transform === "none") {
|
|
163
|
-
return value;
|
|
164
|
-
}
|
|
165
|
-
if (transform === "flip_boolean") {
|
|
166
|
-
if (provider === "replicate") {
|
|
167
|
-
return !value;
|
|
168
|
-
}
|
|
169
|
-
return value;
|
|
170
|
-
}
|
|
171
|
-
if (transform === "parse_size") {
|
|
172
|
-
return parseSizeForProvider(value, mapping, provider);
|
|
173
|
-
}
|
|
174
|
-
return value;
|
|
175
|
-
}
|
|
176
|
-
function parseSizeForProvider(value, mapping, provider) {
|
|
177
|
-
if (provider === "fal-ai") {
|
|
178
|
-
if (typeof value === "string") {
|
|
179
|
-
const [w, h] = value.split("x").map(Number);
|
|
180
|
-
return { width: w, height: h };
|
|
181
|
-
}
|
|
182
|
-
return value;
|
|
183
|
-
}
|
|
184
|
-
if (provider === "replicate") {
|
|
185
|
-
if (typeof value === "string") {
|
|
186
|
-
const [w, h] = value.split("x").map(Number);
|
|
187
|
-
return { width: w, height: h };
|
|
188
|
-
}
|
|
189
|
-
if (typeof value === "object" && value !== null) {
|
|
190
|
-
return value;
|
|
191
|
-
}
|
|
192
|
-
return value;
|
|
193
|
-
}
|
|
194
|
-
return value;
|
|
195
|
-
}
|
|
196
|
-
function mapOutput(raw, outputMapping) {
|
|
197
|
-
const { type, extract_path, content_type } = outputMapping;
|
|
198
|
-
const defaultContentType = content_type || "image/jpeg";
|
|
199
|
-
const data = raw;
|
|
200
|
-
if (extract_path === "images[].url") {
|
|
201
|
-
const images = data?.images ?? [];
|
|
202
|
-
return images.map((img) => ({
|
|
203
|
-
type,
|
|
204
|
-
url: img.url,
|
|
205
|
-
content_type: img.content_type || defaultContentType
|
|
206
|
-
}));
|
|
207
|
-
}
|
|
208
|
-
if (extract_path === "output[]") {
|
|
209
|
-
const arr = Array.isArray(data) ? data : data?.output ?? [];
|
|
210
|
-
return arr.map((url) => ({
|
|
211
|
-
type,
|
|
212
|
-
url,
|
|
213
|
-
content_type: defaultContentType
|
|
214
|
-
}));
|
|
215
|
-
}
|
|
216
|
-
if (extract_path === "data.outputs[]") {
|
|
217
|
-
const outputs = data?.data?.outputs ?? [];
|
|
218
|
-
return outputs.map((url) => ({
|
|
219
|
-
type,
|
|
220
|
-
url,
|
|
221
|
-
content_type: defaultContentType
|
|
222
|
-
}));
|
|
223
|
-
}
|
|
224
|
-
if (extract_path === "video.url") {
|
|
225
|
-
return [{
|
|
226
|
-
type: "video",
|
|
227
|
-
url: data?.video?.url,
|
|
228
|
-
content_type: "video/mp4"
|
|
229
|
-
}];
|
|
230
|
-
}
|
|
231
|
-
if (extract_path === "audio.url") {
|
|
232
|
-
return [{
|
|
233
|
-
type: "audio",
|
|
234
|
-
url: data?.audio?.url,
|
|
235
|
-
content_type: "audio/mpeg"
|
|
236
|
-
}];
|
|
237
|
-
}
|
|
238
|
-
return genericExtract(data, extract_path, type, defaultContentType);
|
|
239
|
-
}
|
|
240
|
-
function genericExtract(data, path, type, contentType) {
|
|
241
|
-
const segments = path.split(".");
|
|
242
|
-
let current = data;
|
|
243
|
-
for (const seg of segments) {
|
|
244
|
-
if (current === null || current === void 0) return [];
|
|
245
|
-
const indexMatch = seg.match(/^(.+)\[(\d+)\]$/);
|
|
246
|
-
if (indexMatch) {
|
|
247
|
-
const key = indexMatch[1];
|
|
248
|
-
const index = parseInt(indexMatch[2], 10);
|
|
249
|
-
const arr = current[key];
|
|
250
|
-
if (!Array.isArray(arr) || index >= arr.length) return [];
|
|
251
|
-
current = arr[index];
|
|
252
|
-
continue;
|
|
253
|
-
}
|
|
254
|
-
const arrayMatch = seg.match(/^(.+)\[\]$/);
|
|
255
|
-
if (arrayMatch) {
|
|
256
|
-
const key = arrayMatch[1];
|
|
257
|
-
current = current[key];
|
|
258
|
-
if (Array.isArray(current)) {
|
|
259
|
-
const remaining = segments.slice(segments.indexOf(seg) + 1).join(".");
|
|
260
|
-
if (remaining) {
|
|
261
|
-
return current.map((item) => ({
|
|
262
|
-
type,
|
|
263
|
-
url: getNestedValue(item, remaining),
|
|
264
|
-
content_type: contentType
|
|
265
|
-
}));
|
|
266
|
-
}
|
|
267
|
-
return current.map((item) => ({
|
|
268
|
-
type,
|
|
269
|
-
url: typeof item === "string" ? item : item?.url,
|
|
270
|
-
content_type: contentType
|
|
271
|
-
}));
|
|
272
|
-
}
|
|
273
|
-
return [];
|
|
274
|
-
}
|
|
275
|
-
current = current[seg];
|
|
276
|
-
}
|
|
277
|
-
if (typeof current === "string") {
|
|
278
|
-
if (type === "text") {
|
|
279
|
-
return [{ type, content: current, content_type: contentType }];
|
|
280
|
-
}
|
|
281
|
-
return [{ type, url: current, content_type: contentType }];
|
|
282
|
-
}
|
|
283
|
-
return [];
|
|
284
|
-
}
|
|
285
|
-
function getNestedValue(obj, path) {
|
|
286
|
-
let current = obj;
|
|
287
|
-
for (const key of path.split(".")) {
|
|
288
|
-
if (current === null || current === void 0) return void 0;
|
|
289
|
-
current = current[key];
|
|
290
|
-
}
|
|
291
|
-
return current;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// src/categories/text-to-image.ts
|
|
295
|
-
var textToImageTemplate = {
|
|
296
|
-
category: "text-to-image",
|
|
297
|
-
input_mappings: [
|
|
298
|
-
{
|
|
299
|
-
universal: "prompt",
|
|
300
|
-
providers: {
|
|
301
|
-
"fal-ai": "prompt",
|
|
302
|
-
"replicate": "prompt",
|
|
303
|
-
"wavespeed": "prompt"
|
|
304
|
-
},
|
|
305
|
-
required: true
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
universal: "negative_prompt",
|
|
309
|
-
providers: {
|
|
310
|
-
"fal-ai": "negative_prompt",
|
|
311
|
-
"replicate": "negative_prompt",
|
|
312
|
-
"wavespeed": "negative_prompt"
|
|
313
|
-
}
|
|
314
|
-
},
|
|
315
|
-
{
|
|
316
|
-
universal: "count",
|
|
317
|
-
providers: {
|
|
318
|
-
"fal-ai": "num_images",
|
|
319
|
-
"replicate": "num_outputs",
|
|
320
|
-
"wavespeed": "num_outputs"
|
|
321
|
-
}
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
universal: "size",
|
|
325
|
-
providers: {
|
|
326
|
-
"fal-ai": "image_size",
|
|
327
|
-
"replicate": ["width", "height"],
|
|
328
|
-
"wavespeed": "resolution"
|
|
329
|
-
},
|
|
330
|
-
transform: "parse_size"
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
universal: "guidance",
|
|
334
|
-
providers: {
|
|
335
|
-
"fal-ai": "guidance_scale",
|
|
336
|
-
"replicate": "guidance",
|
|
337
|
-
"wavespeed": "guidance_scale"
|
|
338
|
-
}
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
universal: "steps",
|
|
342
|
-
providers: {
|
|
343
|
-
"fal-ai": "num_inference_steps",
|
|
344
|
-
"replicate": "num_inference_steps",
|
|
345
|
-
"wavespeed": "num_inference_steps"
|
|
346
|
-
}
|
|
347
|
-
},
|
|
348
|
-
{
|
|
349
|
-
universal: "seed",
|
|
350
|
-
providers: {
|
|
351
|
-
"fal-ai": "seed",
|
|
352
|
-
"replicate": "seed",
|
|
353
|
-
"wavespeed": "seed"
|
|
354
|
-
}
|
|
355
|
-
},
|
|
356
|
-
{
|
|
357
|
-
universal: "format",
|
|
358
|
-
providers: {
|
|
359
|
-
"fal-ai": "output_format",
|
|
360
|
-
"replicate": "output_format",
|
|
361
|
-
"wavespeed": "output_format"
|
|
362
|
-
}
|
|
363
|
-
},
|
|
364
|
-
{
|
|
365
|
-
universal: "quality",
|
|
366
|
-
providers: {
|
|
367
|
-
"fal-ai": "quality",
|
|
368
|
-
"replicate": "output_quality",
|
|
369
|
-
"wavespeed": "quality"
|
|
370
|
-
}
|
|
371
|
-
},
|
|
372
|
-
{
|
|
373
|
-
universal: "safety",
|
|
374
|
-
providers: {
|
|
375
|
-
"fal-ai": "enable_safety_checker",
|
|
376
|
-
"replicate": "disable_safety_checker",
|
|
377
|
-
"wavespeed": "enable_safety_checker"
|
|
378
|
-
},
|
|
379
|
-
transform: "flip_boolean"
|
|
380
|
-
}
|
|
381
|
-
],
|
|
382
|
-
output_type: "image",
|
|
383
|
-
output_extract: {
|
|
384
|
-
"fal-ai": "images[].url",
|
|
385
|
-
"replicate": "output[]",
|
|
386
|
-
"wavespeed": "data.outputs[]"
|
|
387
|
-
},
|
|
388
|
-
default_timeout_ms: 6e4
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
// src/categories/image-edit.ts
|
|
392
|
-
var imageEditTemplate = {
|
|
393
|
-
category: "image-edit",
|
|
394
|
-
input_mappings: [
|
|
395
|
-
{
|
|
396
|
-
universal: "image",
|
|
397
|
-
providers: {
|
|
398
|
-
"fal-ai": "image_url",
|
|
399
|
-
"replicate": "image",
|
|
400
|
-
"wavespeed": "image_url"
|
|
401
|
-
},
|
|
402
|
-
required: true
|
|
403
|
-
},
|
|
404
|
-
{
|
|
405
|
-
universal: "images",
|
|
406
|
-
providers: {
|
|
407
|
-
"fal-ai": "image_urls",
|
|
408
|
-
"replicate": "image_urls",
|
|
409
|
-
"wavespeed": "image_urls"
|
|
410
|
-
}
|
|
411
|
-
},
|
|
412
|
-
{
|
|
413
|
-
universal: "prompt",
|
|
414
|
-
providers: {
|
|
415
|
-
"fal-ai": "prompt",
|
|
416
|
-
"replicate": "prompt",
|
|
417
|
-
"wavespeed": "prompt"
|
|
418
|
-
},
|
|
419
|
-
required: true
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
universal: "strength",
|
|
423
|
-
providers: {
|
|
424
|
-
"fal-ai": "strength",
|
|
425
|
-
"replicate": "strength",
|
|
426
|
-
"wavespeed": "strength"
|
|
427
|
-
}
|
|
428
|
-
},
|
|
429
|
-
{
|
|
430
|
-
universal: "mask",
|
|
431
|
-
providers: {
|
|
432
|
-
"fal-ai": "mask_url",
|
|
433
|
-
"replicate": "mask",
|
|
434
|
-
"wavespeed": "mask_url"
|
|
435
|
-
}
|
|
436
|
-
},
|
|
437
|
-
{
|
|
438
|
-
universal: "seed",
|
|
439
|
-
providers: {
|
|
440
|
-
"fal-ai": "seed",
|
|
441
|
-
"replicate": "seed",
|
|
442
|
-
"wavespeed": "seed"
|
|
443
|
-
}
|
|
444
|
-
},
|
|
445
|
-
{
|
|
446
|
-
universal: "format",
|
|
447
|
-
providers: {
|
|
448
|
-
"fal-ai": "output_format",
|
|
449
|
-
"replicate": "output_format",
|
|
450
|
-
"wavespeed": "output_format"
|
|
451
|
-
}
|
|
452
|
-
},
|
|
453
|
-
{
|
|
454
|
-
universal: "quality",
|
|
455
|
-
providers: {
|
|
456
|
-
"fal-ai": "quality",
|
|
457
|
-
"replicate": "output_quality",
|
|
458
|
-
"wavespeed": "quality"
|
|
459
|
-
}
|
|
460
|
-
},
|
|
461
|
-
{
|
|
462
|
-
universal: "safety",
|
|
463
|
-
providers: {
|
|
464
|
-
"fal-ai": "enable_safety_checker",
|
|
465
|
-
"replicate": "disable_safety_checker",
|
|
466
|
-
"wavespeed": "enable_safety_checker"
|
|
467
|
-
},
|
|
468
|
-
transform: "flip_boolean"
|
|
469
|
-
}
|
|
470
|
-
],
|
|
471
|
-
output_type: "image",
|
|
472
|
-
output_extract: {
|
|
473
|
-
"fal-ai": "images[].url",
|
|
474
|
-
"replicate": "output[]",
|
|
475
|
-
"wavespeed": "data.outputs[]"
|
|
476
|
-
},
|
|
477
|
-
default_timeout_ms: 6e4
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
// src/categories/text-to-video.ts
|
|
481
|
-
var textToVideoTemplate = {
|
|
482
|
-
category: "text-to-video",
|
|
483
|
-
input_mappings: [
|
|
484
|
-
{
|
|
485
|
-
universal: "prompt",
|
|
486
|
-
providers: {
|
|
487
|
-
"fal-ai": "prompt",
|
|
488
|
-
"replicate": "prompt",
|
|
489
|
-
"wavespeed": "prompt"
|
|
490
|
-
},
|
|
491
|
-
required: true
|
|
492
|
-
},
|
|
493
|
-
{
|
|
494
|
-
universal: "negative_prompt",
|
|
495
|
-
providers: {
|
|
496
|
-
"fal-ai": "negative_prompt",
|
|
497
|
-
"replicate": "negative_prompt",
|
|
498
|
-
"wavespeed": "negative_prompt"
|
|
499
|
-
}
|
|
500
|
-
},
|
|
501
|
-
{
|
|
502
|
-
universal: "count",
|
|
503
|
-
providers: {
|
|
504
|
-
"fal-ai": "num_videos",
|
|
505
|
-
"replicate": "num_outputs",
|
|
506
|
-
"wavespeed": "num_outputs"
|
|
507
|
-
}
|
|
508
|
-
},
|
|
509
|
-
{
|
|
510
|
-
universal: "size",
|
|
511
|
-
providers: {
|
|
512
|
-
"fal-ai": "video_size",
|
|
513
|
-
"replicate": ["width", "height"],
|
|
514
|
-
"wavespeed": "resolution"
|
|
515
|
-
},
|
|
516
|
-
transform: "parse_size"
|
|
517
|
-
},
|
|
518
|
-
{
|
|
519
|
-
universal: "guidance",
|
|
520
|
-
providers: {
|
|
521
|
-
"fal-ai": "guidance_scale",
|
|
522
|
-
"replicate": "guidance",
|
|
523
|
-
"wavespeed": "guidance_scale"
|
|
524
|
-
}
|
|
525
|
-
},
|
|
526
|
-
{
|
|
527
|
-
universal: "steps",
|
|
528
|
-
providers: {
|
|
529
|
-
"fal-ai": "num_inference_steps",
|
|
530
|
-
"replicate": "num_inference_steps",
|
|
531
|
-
"wavespeed": "num_inference_steps"
|
|
532
|
-
}
|
|
533
|
-
},
|
|
534
|
-
{
|
|
535
|
-
universal: "seed",
|
|
536
|
-
providers: {
|
|
537
|
-
"fal-ai": "seed",
|
|
538
|
-
"replicate": "seed",
|
|
539
|
-
"wavespeed": "seed"
|
|
540
|
-
}
|
|
541
|
-
},
|
|
542
|
-
{
|
|
543
|
-
universal: "format",
|
|
544
|
-
providers: {
|
|
545
|
-
"fal-ai": "output_format",
|
|
546
|
-
"replicate": "output_format",
|
|
547
|
-
"wavespeed": "output_format"
|
|
548
|
-
}
|
|
549
|
-
},
|
|
550
|
-
{
|
|
551
|
-
universal: "safety",
|
|
552
|
-
providers: {
|
|
553
|
-
"fal-ai": "enable_safety_checker",
|
|
554
|
-
"replicate": "disable_safety_checker",
|
|
555
|
-
"wavespeed": "enable_safety_checker"
|
|
556
|
-
},
|
|
557
|
-
transform: "flip_boolean"
|
|
558
|
-
}
|
|
559
|
-
],
|
|
560
|
-
output_type: "video",
|
|
561
|
-
output_extract: {
|
|
562
|
-
"fal-ai": "video.url",
|
|
563
|
-
"replicate": "output",
|
|
564
|
-
"wavespeed": "data.outputs[]"
|
|
565
|
-
},
|
|
566
|
-
default_timeout_ms: 3e5
|
|
567
|
-
};
|
|
568
|
-
|
|
569
|
-
// src/categories/image-to-video.ts
|
|
570
|
-
var imageToVideoTemplate = {
|
|
571
|
-
category: "image-to-video",
|
|
572
|
-
input_mappings: [
|
|
573
|
-
{
|
|
574
|
-
universal: "image",
|
|
575
|
-
providers: {
|
|
576
|
-
"fal-ai": "image_url",
|
|
577
|
-
"replicate": "image",
|
|
578
|
-
"wavespeed": "image_url"
|
|
579
|
-
},
|
|
580
|
-
required: true
|
|
581
|
-
},
|
|
582
|
-
{
|
|
583
|
-
universal: "prompt",
|
|
584
|
-
providers: {
|
|
585
|
-
"fal-ai": "prompt",
|
|
586
|
-
"replicate": "prompt",
|
|
587
|
-
"wavespeed": "prompt"
|
|
588
|
-
}
|
|
589
|
-
},
|
|
590
|
-
{
|
|
591
|
-
universal: "negative_prompt",
|
|
592
|
-
providers: {
|
|
593
|
-
"fal-ai": "negative_prompt",
|
|
594
|
-
"replicate": "negative_prompt",
|
|
595
|
-
"wavespeed": "negative_prompt"
|
|
596
|
-
}
|
|
597
|
-
},
|
|
598
|
-
{
|
|
599
|
-
universal: "seed",
|
|
600
|
-
providers: {
|
|
601
|
-
"fal-ai": "seed",
|
|
602
|
-
"replicate": "seed",
|
|
603
|
-
"wavespeed": "seed"
|
|
604
|
-
}
|
|
605
|
-
},
|
|
606
|
-
{
|
|
607
|
-
universal: "guidance",
|
|
608
|
-
providers: {
|
|
609
|
-
"fal-ai": "guidance_scale",
|
|
610
|
-
"replicate": "guidance",
|
|
611
|
-
"wavespeed": "guidance_scale"
|
|
612
|
-
}
|
|
613
|
-
},
|
|
614
|
-
{
|
|
615
|
-
universal: "steps",
|
|
616
|
-
providers: {
|
|
617
|
-
"fal-ai": "num_inference_steps",
|
|
618
|
-
"replicate": "num_inference_steps",
|
|
619
|
-
"wavespeed": "num_inference_steps"
|
|
620
|
-
}
|
|
621
|
-
},
|
|
622
|
-
{
|
|
623
|
-
universal: "format",
|
|
624
|
-
providers: {
|
|
625
|
-
"fal-ai": "output_format",
|
|
626
|
-
"replicate": "output_format",
|
|
627
|
-
"wavespeed": "output_format"
|
|
628
|
-
}
|
|
629
|
-
},
|
|
630
|
-
{
|
|
631
|
-
universal: "safety",
|
|
632
|
-
providers: {
|
|
633
|
-
"fal-ai": "enable_safety_checker",
|
|
634
|
-
"replicate": "disable_safety_checker",
|
|
635
|
-
"wavespeed": "enable_safety_checker"
|
|
636
|
-
},
|
|
637
|
-
transform: "flip_boolean"
|
|
638
|
-
}
|
|
639
|
-
],
|
|
640
|
-
output_type: "video",
|
|
641
|
-
output_extract: {
|
|
642
|
-
"fal-ai": "video.url",
|
|
643
|
-
"replicate": "output",
|
|
644
|
-
"wavespeed": "data.outputs[]"
|
|
645
|
-
},
|
|
646
|
-
default_timeout_ms: 3e5
|
|
647
|
-
};
|
|
648
|
-
|
|
649
|
-
// src/categories/upscale-image.ts
|
|
650
|
-
var upscaleImageTemplate = {
|
|
651
|
-
category: "upscale-image",
|
|
652
|
-
input_mappings: [
|
|
653
|
-
{
|
|
654
|
-
universal: "image",
|
|
655
|
-
providers: {
|
|
656
|
-
"fal-ai": "image_url",
|
|
657
|
-
"replicate": "image",
|
|
658
|
-
"wavespeed": "image_url"
|
|
659
|
-
},
|
|
660
|
-
required: true
|
|
661
|
-
},
|
|
662
|
-
{
|
|
663
|
-
universal: "strength",
|
|
664
|
-
providers: {
|
|
665
|
-
"fal-ai": "scale",
|
|
666
|
-
"replicate": "scale",
|
|
667
|
-
"wavespeed": "scale"
|
|
668
|
-
}
|
|
669
|
-
},
|
|
670
|
-
{
|
|
671
|
-
universal: "format",
|
|
672
|
-
providers: {
|
|
673
|
-
"fal-ai": "output_format",
|
|
674
|
-
"replicate": "output_format",
|
|
675
|
-
"wavespeed": "output_format"
|
|
676
|
-
}
|
|
677
|
-
},
|
|
678
|
-
{
|
|
679
|
-
universal: "quality",
|
|
680
|
-
providers: {
|
|
681
|
-
"fal-ai": "quality",
|
|
682
|
-
"replicate": "output_quality",
|
|
683
|
-
"wavespeed": "quality"
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
],
|
|
687
|
-
output_type: "image",
|
|
688
|
-
output_extract: {
|
|
689
|
-
"fal-ai": "images[].url",
|
|
690
|
-
"replicate": "output[]",
|
|
691
|
-
"wavespeed": "data.outputs[]"
|
|
692
|
-
},
|
|
693
|
-
default_timeout_ms: 12e4
|
|
694
|
-
};
|
|
695
|
-
|
|
696
|
-
// src/categories/text-to-audio.ts
|
|
697
|
-
var textToAudioTemplate = {
|
|
698
|
-
category: "text-to-audio",
|
|
699
|
-
input_mappings: [
|
|
700
|
-
{
|
|
701
|
-
universal: "prompt",
|
|
702
|
-
providers: {
|
|
703
|
-
"fal-ai": "text",
|
|
704
|
-
"replicate": "prompt",
|
|
705
|
-
"wavespeed": "prompt"
|
|
706
|
-
},
|
|
707
|
-
required: true
|
|
708
|
-
},
|
|
709
|
-
{
|
|
710
|
-
universal: "count",
|
|
711
|
-
providers: {
|
|
712
|
-
"fal-ai": "num_outputs",
|
|
713
|
-
"replicate": "num_outputs",
|
|
714
|
-
"wavespeed": "num_outputs"
|
|
715
|
-
}
|
|
716
|
-
},
|
|
717
|
-
{
|
|
718
|
-
universal: "format",
|
|
719
|
-
providers: {
|
|
720
|
-
"fal-ai": "output_format",
|
|
721
|
-
"replicate": "output_format",
|
|
722
|
-
"wavespeed": "output_format"
|
|
723
|
-
}
|
|
724
|
-
},
|
|
725
|
-
{
|
|
726
|
-
universal: "seed",
|
|
727
|
-
providers: {
|
|
728
|
-
"fal-ai": "seed",
|
|
729
|
-
"replicate": "seed",
|
|
730
|
-
"wavespeed": "seed"
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
],
|
|
734
|
-
output_type: "audio",
|
|
735
|
-
output_extract: {
|
|
736
|
-
"fal-ai": "audio.url",
|
|
737
|
-
"replicate": "output",
|
|
738
|
-
"wavespeed": "data.outputs[]"
|
|
739
|
-
},
|
|
740
|
-
default_timeout_ms: 6e4
|
|
741
|
-
};
|
|
742
|
-
|
|
743
|
-
// src/categories/audio-to-text.ts
|
|
744
|
-
var audioToTextTemplate = {
|
|
745
|
-
category: "audio-to-text",
|
|
746
|
-
input_mappings: [
|
|
747
|
-
{
|
|
748
|
-
universal: "audio",
|
|
749
|
-
providers: {
|
|
750
|
-
"fal-ai": "audio_url",
|
|
751
|
-
"replicate": "audio",
|
|
752
|
-
"wavespeed": "audio_url"
|
|
753
|
-
},
|
|
754
|
-
required: true
|
|
755
|
-
}
|
|
756
|
-
],
|
|
757
|
-
output_type: "text",
|
|
758
|
-
output_extract: {
|
|
759
|
-
"fal-ai": "text",
|
|
760
|
-
"replicate": "output.text",
|
|
761
|
-
"wavespeed": "data.outputs[]"
|
|
762
|
-
},
|
|
763
|
-
default_timeout_ms: 12e4
|
|
764
|
-
};
|
|
765
|
-
|
|
766
|
-
// src/categories/remove-background.ts
|
|
767
|
-
var removeBackgroundTemplate = {
|
|
768
|
-
category: "remove-background",
|
|
769
|
-
input_mappings: [
|
|
770
|
-
{
|
|
771
|
-
universal: "image",
|
|
772
|
-
providers: {
|
|
773
|
-
"fal-ai": "image_url",
|
|
774
|
-
"replicate": "image",
|
|
775
|
-
"wavespeed": "image_url"
|
|
776
|
-
},
|
|
777
|
-
required: true
|
|
778
|
-
},
|
|
779
|
-
{
|
|
780
|
-
universal: "format",
|
|
781
|
-
providers: {
|
|
782
|
-
"fal-ai": "output_format",
|
|
783
|
-
"replicate": "output_format",
|
|
784
|
-
"wavespeed": "output_format"
|
|
785
|
-
}
|
|
786
|
-
},
|
|
787
|
-
{
|
|
788
|
-
universal: "quality",
|
|
789
|
-
providers: {
|
|
790
|
-
"fal-ai": "quality",
|
|
791
|
-
"replicate": "output_quality",
|
|
792
|
-
"wavespeed": "quality"
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
],
|
|
796
|
-
output_type: "image",
|
|
797
|
-
output_extract: {
|
|
798
|
-
"fal-ai": "images[].url",
|
|
799
|
-
"replicate": "output[]",
|
|
800
|
-
"wavespeed": "data.outputs[]"
|
|
801
|
-
},
|
|
802
|
-
default_timeout_ms: 6e4
|
|
803
|
-
};
|
|
804
|
-
|
|
805
|
-
// src/categories/text-generation.ts
|
|
806
|
-
var textGenerationTemplate = {
|
|
807
|
-
category: "text-generation",
|
|
808
|
-
input_mappings: [
|
|
809
|
-
{
|
|
810
|
-
universal: "prompt",
|
|
811
|
-
providers: {
|
|
812
|
-
openrouter: "prompt"
|
|
813
|
-
},
|
|
814
|
-
required: true
|
|
815
|
-
}
|
|
816
|
-
],
|
|
817
|
-
output_type: "text",
|
|
818
|
-
output_extract: {
|
|
819
|
-
openrouter: "choices[0].message.content"
|
|
820
|
-
},
|
|
821
|
-
default_timeout_ms: 12e4
|
|
822
|
-
};
|
|
823
|
-
|
|
824
|
-
// src/categories/image-to-image.ts
|
|
825
|
-
var imageToImageTemplate = {
|
|
826
|
-
category: "image-to-image",
|
|
827
|
-
input_mappings: [
|
|
828
|
-
{
|
|
829
|
-
universal: "image",
|
|
830
|
-
providers: {
|
|
831
|
-
"fal-ai": "image_url",
|
|
832
|
-
"replicate": "image",
|
|
833
|
-
"wavespeed": "image"
|
|
834
|
-
},
|
|
835
|
-
required: true
|
|
836
|
-
},
|
|
837
|
-
{
|
|
838
|
-
universal: "prompt",
|
|
839
|
-
providers: {
|
|
840
|
-
"fal-ai": "prompt",
|
|
841
|
-
"replicate": "prompt",
|
|
842
|
-
"wavespeed": "prompt"
|
|
843
|
-
}
|
|
844
|
-
},
|
|
845
|
-
{
|
|
846
|
-
universal: "strength",
|
|
847
|
-
providers: {
|
|
848
|
-
"fal-ai": "strength",
|
|
849
|
-
"replicate": "prompt_strength",
|
|
850
|
-
"wavespeed": "strength"
|
|
851
|
-
}
|
|
852
|
-
},
|
|
853
|
-
{
|
|
854
|
-
universal: "seed",
|
|
855
|
-
providers: {
|
|
856
|
-
"fal-ai": "seed",
|
|
857
|
-
"replicate": "seed",
|
|
858
|
-
"wavespeed": "seed"
|
|
859
|
-
}
|
|
860
|
-
},
|
|
861
|
-
{
|
|
862
|
-
universal: "guidance",
|
|
863
|
-
providers: {
|
|
864
|
-
"fal-ai": "guidance_scale",
|
|
865
|
-
"replicate": "guidance",
|
|
866
|
-
"wavespeed": "guidance_scale"
|
|
867
|
-
}
|
|
868
|
-
},
|
|
869
|
-
{
|
|
870
|
-
universal: "format",
|
|
871
|
-
providers: {
|
|
872
|
-
"fal-ai": "output_format",
|
|
873
|
-
"replicate": "output_format",
|
|
874
|
-
"wavespeed": "output_format"
|
|
875
|
-
}
|
|
876
|
-
},
|
|
877
|
-
{
|
|
878
|
-
universal: "quality",
|
|
879
|
-
providers: {
|
|
880
|
-
"fal-ai": "quality",
|
|
881
|
-
"replicate": "output_quality",
|
|
882
|
-
"wavespeed": "quality"
|
|
883
|
-
}
|
|
884
|
-
},
|
|
885
|
-
{
|
|
886
|
-
universal: "safety",
|
|
887
|
-
providers: {
|
|
888
|
-
"fal-ai": "enable_safety_checker",
|
|
889
|
-
"replicate": "disable_safety_checker",
|
|
890
|
-
"wavespeed": "enable_safety_checker"
|
|
891
|
-
},
|
|
892
|
-
transform: "flip_boolean"
|
|
893
|
-
}
|
|
894
|
-
],
|
|
895
|
-
output_type: "image",
|
|
896
|
-
output_extract: {
|
|
897
|
-
"fal-ai": "images[].url",
|
|
898
|
-
"replicate": "output[]",
|
|
899
|
-
"wavespeed": "data.outputs[]"
|
|
900
|
-
},
|
|
901
|
-
default_timeout_ms: 6e4
|
|
902
|
-
};
|
|
903
|
-
|
|
904
|
-
// src/categories/text-to-3d.ts
|
|
905
|
-
var textTo3dTemplate = {
|
|
906
|
-
category: "text-to-3d",
|
|
907
|
-
input_mappings: [
|
|
908
|
-
{
|
|
909
|
-
universal: "prompt",
|
|
910
|
-
providers: {
|
|
911
|
-
"fal-ai": "prompt",
|
|
912
|
-
"replicate": "prompt",
|
|
913
|
-
"wavespeed": "prompt"
|
|
914
|
-
},
|
|
915
|
-
required: true
|
|
916
|
-
},
|
|
917
|
-
{
|
|
918
|
-
universal: "seed",
|
|
919
|
-
providers: {
|
|
920
|
-
"fal-ai": "seed",
|
|
921
|
-
"replicate": "seed",
|
|
922
|
-
"wavespeed": "seed"
|
|
923
|
-
}
|
|
924
|
-
},
|
|
925
|
-
{
|
|
926
|
-
universal: "format",
|
|
927
|
-
providers: {
|
|
928
|
-
"fal-ai": "output_format",
|
|
929
|
-
"replicate": "output_format",
|
|
930
|
-
"wavespeed": "output_format"
|
|
931
|
-
}
|
|
932
|
-
},
|
|
933
|
-
{
|
|
934
|
-
universal: "quality",
|
|
935
|
-
providers: {
|
|
936
|
-
"fal-ai": "quality",
|
|
937
|
-
"replicate": "output_quality",
|
|
938
|
-
"wavespeed": "quality"
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
],
|
|
942
|
-
output_type: "3d",
|
|
943
|
-
output_extract: {
|
|
944
|
-
"fal-ai": "output.url",
|
|
945
|
-
"replicate": "output",
|
|
946
|
-
"wavespeed": "data.output"
|
|
947
|
-
},
|
|
948
|
-
default_timeout_ms: 6e5
|
|
949
|
-
};
|
|
950
|
-
|
|
951
|
-
// src/categories/image-to-3d.ts
|
|
952
|
-
var imageTo3dTemplate = {
|
|
953
|
-
category: "image-to-3d",
|
|
954
|
-
input_mappings: [
|
|
955
|
-
{
|
|
956
|
-
universal: "image",
|
|
957
|
-
providers: {
|
|
958
|
-
"fal-ai": "image_url",
|
|
959
|
-
"replicate": "image",
|
|
960
|
-
"wavespeed": "image"
|
|
961
|
-
},
|
|
962
|
-
required: true
|
|
963
|
-
},
|
|
964
|
-
{
|
|
965
|
-
universal: "prompt",
|
|
966
|
-
providers: {
|
|
967
|
-
"fal-ai": "prompt",
|
|
968
|
-
"replicate": "prompt",
|
|
969
|
-
"wavespeed": "prompt"
|
|
970
|
-
}
|
|
971
|
-
},
|
|
972
|
-
{
|
|
973
|
-
universal: "seed",
|
|
974
|
-
providers: {
|
|
975
|
-
"fal-ai": "seed",
|
|
976
|
-
"replicate": "seed",
|
|
977
|
-
"wavespeed": "seed"
|
|
978
|
-
}
|
|
979
|
-
},
|
|
980
|
-
{
|
|
981
|
-
universal: "format",
|
|
982
|
-
providers: {
|
|
983
|
-
"fal-ai": "output_format",
|
|
984
|
-
"replicate": "output_format",
|
|
985
|
-
"wavespeed": "output_format"
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
],
|
|
989
|
-
output_type: "3d",
|
|
990
|
-
output_extract: {
|
|
991
|
-
"fal-ai": "output.url",
|
|
992
|
-
"replicate": "output",
|
|
993
|
-
"wavespeed": "data.output"
|
|
994
|
-
},
|
|
995
|
-
default_timeout_ms: 6e5
|
|
996
|
-
};
|
|
997
|
-
|
|
998
|
-
// src/categories/upscale-video.ts
|
|
999
|
-
var upscaleVideoTemplate = {
|
|
1000
|
-
category: "upscale-video",
|
|
1001
|
-
input_mappings: [
|
|
1002
|
-
{
|
|
1003
|
-
universal: "video",
|
|
1004
|
-
providers: {
|
|
1005
|
-
"fal-ai": "video_url",
|
|
1006
|
-
"replicate": "video",
|
|
1007
|
-
"wavespeed": "video"
|
|
1008
|
-
},
|
|
1009
|
-
required: true
|
|
1010
|
-
},
|
|
1011
|
-
{
|
|
1012
|
-
universal: "strength",
|
|
1013
|
-
providers: {
|
|
1014
|
-
"fal-ai": "scale",
|
|
1015
|
-
"replicate": "scale",
|
|
1016
|
-
"wavespeed": "scale"
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
],
|
|
1020
|
-
output_type: "video",
|
|
1021
|
-
output_extract: {
|
|
1022
|
-
"fal-ai": "video.url",
|
|
1023
|
-
"replicate": "output",
|
|
1024
|
-
"wavespeed": "data.output"
|
|
1025
|
-
},
|
|
1026
|
-
default_timeout_ms: 6e5
|
|
1027
|
-
};
|
|
1028
|
-
|
|
1029
|
-
// src/categories/video-to-audio.ts
|
|
1030
|
-
var videoToAudioTemplate = {
|
|
1031
|
-
category: "video-to-audio",
|
|
1032
|
-
input_mappings: [
|
|
1033
|
-
{
|
|
1034
|
-
universal: "video",
|
|
1035
|
-
providers: {
|
|
1036
|
-
"fal-ai": "video_url",
|
|
1037
|
-
"replicate": "video",
|
|
1038
|
-
"wavespeed": "video"
|
|
1039
|
-
},
|
|
1040
|
-
required: true
|
|
1041
|
-
},
|
|
1042
|
-
{
|
|
1043
|
-
universal: "prompt",
|
|
1044
|
-
providers: {
|
|
1045
|
-
"fal-ai": "prompt",
|
|
1046
|
-
"replicate": "prompt",
|
|
1047
|
-
"wavespeed": "prompt"
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
],
|
|
1051
|
-
output_type: "audio",
|
|
1052
|
-
output_extract: {
|
|
1053
|
-
"fal-ai": "audio.url",
|
|
1054
|
-
"replicate": "output",
|
|
1055
|
-
"wavespeed": "data.output"
|
|
1056
|
-
},
|
|
1057
|
-
default_timeout_ms: 12e4
|
|
1058
|
-
};
|
|
1059
|
-
|
|
1060
|
-
// src/categories/video-to-video.ts
|
|
1061
|
-
var videoToVideoTemplate = {
|
|
1062
|
-
category: "video-to-video",
|
|
1063
|
-
input_mappings: [
|
|
1064
|
-
{
|
|
1065
|
-
universal: "video",
|
|
1066
|
-
providers: {
|
|
1067
|
-
"fal-ai": "video_url",
|
|
1068
|
-
"replicate": "video",
|
|
1069
|
-
"wavespeed": "video"
|
|
1070
|
-
},
|
|
1071
|
-
required: true
|
|
1072
|
-
},
|
|
1073
|
-
{
|
|
1074
|
-
universal: "image",
|
|
1075
|
-
providers: {
|
|
1076
|
-
"fal-ai": "image_url",
|
|
1077
|
-
"replicate": "character_image",
|
|
1078
|
-
"wavespeed": "image"
|
|
1079
|
-
}
|
|
1080
|
-
},
|
|
1081
|
-
{
|
|
1082
|
-
universal: "prompt",
|
|
1083
|
-
providers: {
|
|
1084
|
-
"fal-ai": "prompt",
|
|
1085
|
-
"replicate": "prompt",
|
|
1086
|
-
"wavespeed": "prompt"
|
|
1087
|
-
}
|
|
1088
|
-
},
|
|
1089
|
-
{
|
|
1090
|
-
universal: "resolution",
|
|
1091
|
-
providers: {
|
|
1092
|
-
"fal-ai": "resolution",
|
|
1093
|
-
"replicate": "resolution",
|
|
1094
|
-
"wavespeed": "resolution"
|
|
1095
|
-
}
|
|
1096
|
-
},
|
|
1097
|
-
{
|
|
1098
|
-
universal: "seed",
|
|
1099
|
-
providers: {
|
|
1100
|
-
"fal-ai": "seed",
|
|
1101
|
-
"replicate": "seed",
|
|
1102
|
-
"wavespeed": "seed"
|
|
1103
|
-
}
|
|
1104
|
-
},
|
|
1105
|
-
{
|
|
1106
|
-
universal: "guidance",
|
|
1107
|
-
providers: {
|
|
1108
|
-
"fal-ai": "guidance_scale",
|
|
1109
|
-
"replicate": "guidance_scale",
|
|
1110
|
-
"wavespeed": "guidance_scale"
|
|
1111
|
-
}
|
|
1112
|
-
},
|
|
1113
|
-
{
|
|
1114
|
-
universal: "steps",
|
|
1115
|
-
providers: {
|
|
1116
|
-
"fal-ai": "num_inference_steps",
|
|
1117
|
-
"replicate": "num_inference_steps",
|
|
1118
|
-
"wavespeed": "num_inference_steps"
|
|
1119
|
-
}
|
|
1120
|
-
},
|
|
1121
|
-
{
|
|
1122
|
-
universal: "safety",
|
|
1123
|
-
providers: {
|
|
1124
|
-
"fal-ai": "enable_safety_checker",
|
|
1125
|
-
"replicate": "enable_safety_checker",
|
|
1126
|
-
"wavespeed": "enable_safety_checker"
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
],
|
|
1130
|
-
output_type: "video",
|
|
1131
|
-
output_extract: {
|
|
1132
|
-
"fal-ai": "video.url",
|
|
1133
|
-
"replicate": "output[]",
|
|
1134
|
-
"wavespeed": "data.outputs[]"
|
|
1135
|
-
},
|
|
1136
|
-
default_timeout_ms: 3e5
|
|
1137
|
-
};
|
|
1138
|
-
|
|
1139
|
-
// src/categories/segmentation.ts
|
|
1140
|
-
var segmentationTemplate = {
|
|
1141
|
-
category: "segmentation",
|
|
1142
|
-
input_mappings: [
|
|
1143
|
-
{
|
|
1144
|
-
universal: "image",
|
|
1145
|
-
providers: {
|
|
1146
|
-
"fal-ai": "image_url",
|
|
1147
|
-
"replicate": "image",
|
|
1148
|
-
"wavespeed": "image"
|
|
1149
|
-
},
|
|
1150
|
-
required: true
|
|
1151
|
-
},
|
|
1152
|
-
{
|
|
1153
|
-
universal: "prompt",
|
|
1154
|
-
providers: {
|
|
1155
|
-
"fal-ai": "prompt",
|
|
1156
|
-
"replicate": "prompt",
|
|
1157
|
-
"wavespeed": "prompt"
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
],
|
|
1161
|
-
output_type: "segmentation",
|
|
1162
|
-
output_extract: {
|
|
1163
|
-
"fal-ai": "output.url",
|
|
1164
|
-
"replicate": "output",
|
|
1165
|
-
"wavespeed": "data.output"
|
|
1166
|
-
},
|
|
1167
|
-
default_timeout_ms: 6e4
|
|
1168
|
-
};
|
|
1169
|
-
|
|
1170
|
-
// src/categories/moderation.ts
|
|
1171
|
-
var moderationTemplate = {
|
|
1172
|
-
category: "moderation",
|
|
1173
|
-
input_mappings: [
|
|
1174
|
-
{
|
|
1175
|
-
universal: "prompt",
|
|
1176
|
-
providers: {
|
|
1177
|
-
"fal-ai": "prompt",
|
|
1178
|
-
"replicate": "prompt",
|
|
1179
|
-
"wavespeed": "prompt"
|
|
1180
|
-
}
|
|
1181
|
-
},
|
|
1182
|
-
{
|
|
1183
|
-
universal: "image",
|
|
1184
|
-
providers: {
|
|
1185
|
-
"fal-ai": "image_url",
|
|
1186
|
-
"replicate": "image",
|
|
1187
|
-
"wavespeed": "image"
|
|
1188
|
-
}
|
|
1189
|
-
},
|
|
1190
|
-
{
|
|
1191
|
-
universal: "video",
|
|
1192
|
-
providers: {
|
|
1193
|
-
"fal-ai": "video_url",
|
|
1194
|
-
"replicate": "video",
|
|
1195
|
-
"wavespeed": "video"
|
|
1196
|
-
}
|
|
1197
|
-
},
|
|
1198
|
-
{
|
|
1199
|
-
universal: "audio",
|
|
1200
|
-
providers: {
|
|
1201
|
-
"fal-ai": "audio_url",
|
|
1202
|
-
"replicate": "audio",
|
|
1203
|
-
"wavespeed": "audio"
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
|
-
],
|
|
1207
|
-
output_type: "text",
|
|
1208
|
-
output_extract: {
|
|
1209
|
-
"fal-ai": "output",
|
|
1210
|
-
"replicate": "output",
|
|
1211
|
-
"wavespeed": "data.output"
|
|
1212
|
-
},
|
|
1213
|
-
default_timeout_ms: 3e4
|
|
1214
|
-
};
|
|
1215
|
-
|
|
1216
|
-
// src/categories/training.ts
|
|
1217
|
-
var trainingTemplate = {
|
|
1218
|
-
category: "training",
|
|
1219
|
-
input_mappings: [
|
|
1220
|
-
{
|
|
1221
|
-
universal: "image",
|
|
1222
|
-
providers: {
|
|
1223
|
-
"fal-ai": "images_data_url",
|
|
1224
|
-
"replicate": "input_images",
|
|
1225
|
-
"wavespeed": "images"
|
|
1226
|
-
},
|
|
1227
|
-
required: true
|
|
1228
|
-
}
|
|
1229
|
-
],
|
|
1230
|
-
output_type: "text",
|
|
1231
|
-
output_extract: {
|
|
1232
|
-
"fal-ai": "output",
|
|
1233
|
-
"replicate": "output",
|
|
1234
|
-
"wavespeed": "data.output"
|
|
1235
|
-
},
|
|
1236
|
-
default_timeout_ms: 18e5
|
|
1237
|
-
};
|
|
1238
|
-
|
|
1239
|
-
// src/categories/doc-to-text.ts
|
|
1240
|
-
var docToTextTemplate = {
|
|
1241
|
-
category: "doc-to-text",
|
|
1242
|
-
input_mappings: [
|
|
1243
|
-
{
|
|
1244
|
-
universal: "file",
|
|
1245
|
-
providers: {
|
|
1246
|
-
"fal-ai": "file_url",
|
|
1247
|
-
"replicate": "file",
|
|
1248
|
-
"wavespeed": "file"
|
|
1249
|
-
},
|
|
1250
|
-
required: true
|
|
1251
|
-
},
|
|
1252
|
-
{
|
|
1253
|
-
universal: "pages",
|
|
1254
|
-
providers: {
|
|
1255
|
-
"fal-ai": "max_pages",
|
|
1256
|
-
"replicate": "max_pages",
|
|
1257
|
-
"wavespeed": "max_pages"
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
],
|
|
1261
|
-
output_type: "text",
|
|
1262
|
-
output_extract: {
|
|
1263
|
-
"fal-ai": "text",
|
|
1264
|
-
"replicate": "output",
|
|
1265
|
-
"wavespeed": "data.outputs[]",
|
|
1266
|
-
"openrouter": "choices[0].message.content"
|
|
1267
|
-
},
|
|
1268
|
-
default_timeout_ms: 12e4
|
|
1269
|
-
};
|
|
1270
|
-
|
|
1271
|
-
// src/categories/image-to-text.ts
|
|
1272
|
-
var imageToTextTemplate = {
|
|
1273
|
-
category: "image-to-text",
|
|
1274
|
-
input_mappings: [
|
|
1275
|
-
{
|
|
1276
|
-
universal: "image",
|
|
1277
|
-
providers: {
|
|
1278
|
-
"fal-ai": "image_url",
|
|
1279
|
-
"replicate": "image",
|
|
1280
|
-
"wavespeed": "image"
|
|
1281
|
-
},
|
|
1282
|
-
required: true
|
|
1283
|
-
},
|
|
1284
|
-
{
|
|
1285
|
-
universal: "prompt",
|
|
1286
|
-
providers: {
|
|
1287
|
-
"fal-ai": "prompt",
|
|
1288
|
-
"replicate": "prompt",
|
|
1289
|
-
"wavespeed": "prompt"
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
],
|
|
1293
|
-
output_type: "text",
|
|
1294
|
-
output_extract: {
|
|
1295
|
-
"fal-ai": "output",
|
|
1296
|
-
"replicate": "output",
|
|
1297
|
-
"wavespeed": "data.outputs[]",
|
|
1298
|
-
"openrouter": "choices[0].message.content"
|
|
1299
|
-
},
|
|
1300
|
-
default_timeout_ms: 6e4
|
|
1301
|
-
};
|
|
1302
|
-
|
|
1303
|
-
// src/categories/video-to-text.ts
|
|
1304
|
-
var videoToTextTemplate = {
|
|
1305
|
-
category: "video-to-text",
|
|
1306
|
-
input_mappings: [
|
|
1307
|
-
{
|
|
1308
|
-
universal: "video",
|
|
1309
|
-
providers: {
|
|
1310
|
-
"fal-ai": "video_url",
|
|
1311
|
-
"replicate": "video",
|
|
1312
|
-
"wavespeed": "video"
|
|
1313
|
-
},
|
|
1314
|
-
required: true
|
|
1315
|
-
},
|
|
1316
|
-
{
|
|
1317
|
-
universal: "prompt",
|
|
1318
|
-
providers: {
|
|
1319
|
-
"fal-ai": "prompt",
|
|
1320
|
-
"replicate": "prompt",
|
|
1321
|
-
"wavespeed": "prompt"
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
],
|
|
1325
|
-
output_type: "text",
|
|
1326
|
-
output_extract: {
|
|
1327
|
-
"fal-ai": "output",
|
|
1328
|
-
"replicate": "output",
|
|
1329
|
-
"wavespeed": "data.outputs[]",
|
|
1330
|
-
"openrouter": "choices[0].message.content"
|
|
1331
|
-
},
|
|
1332
|
-
default_timeout_ms: 12e4
|
|
1333
|
-
};
|
|
1334
|
-
|
|
1335
|
-
// src/categories/index.ts
|
|
1336
|
-
var templates = {
|
|
1337
|
-
"text-to-image": textToImageTemplate,
|
|
1338
|
-
"image-edit": imageEditTemplate,
|
|
1339
|
-
"text-to-video": textToVideoTemplate,
|
|
1340
|
-
"image-to-video": imageToVideoTemplate,
|
|
1341
|
-
"upscale-image": upscaleImageTemplate,
|
|
1342
|
-
"text-to-audio": textToAudioTemplate,
|
|
1343
|
-
"audio-to-text": audioToTextTemplate,
|
|
1344
|
-
"remove-background": removeBackgroundTemplate,
|
|
1345
|
-
"text-generation": textGenerationTemplate,
|
|
1346
|
-
"image-to-image": imageToImageTemplate,
|
|
1347
|
-
"text-to-3d": textTo3dTemplate,
|
|
1348
|
-
"image-to-3d": imageTo3dTemplate,
|
|
1349
|
-
"upscale-video": upscaleVideoTemplate,
|
|
1350
|
-
"video-to-audio": videoToAudioTemplate,
|
|
1351
|
-
"video-to-video": videoToVideoTemplate,
|
|
1352
|
-
"segmentation": segmentationTemplate,
|
|
1353
|
-
"moderation": moderationTemplate,
|
|
1354
|
-
"training": trainingTemplate,
|
|
1355
|
-
"doc-to-text": docToTextTemplate,
|
|
1356
|
-
"image-to-text": imageToTextTemplate,
|
|
1357
|
-
"video-to-text": videoToTextTemplate
|
|
1358
|
-
};
|
|
1359
|
-
function getCategoryTemplate(category) {
|
|
1360
|
-
return templates[category];
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
|
-
// src/gateway.ts
|
|
1364
|
-
var adapters = {
|
|
1365
|
-
"fal-ai": falAiAdapter,
|
|
1366
|
-
"replicate": replicateAdapter,
|
|
1367
|
-
"wavespeed": wavespeedAdapter,
|
|
1368
|
-
"openrouter": openRouterAdapter
|
|
1369
|
-
};
|
|
1370
|
-
async function generate(request) {
|
|
1371
|
-
const startTime = Date.now();
|
|
1372
|
-
if (!request.model) throw new ValidationError("model", "model is required");
|
|
1373
|
-
const auth = new AuthManager();
|
|
1374
|
-
const model = resolveModel(request.model, auth.availableProviders());
|
|
1375
|
-
const availableBindings = model.providers.filter(
|
|
1376
|
-
(p) => auth.availableProviders().includes(p.provider) && adapters[p.provider]
|
|
1377
|
-
);
|
|
1378
|
-
if (availableBindings.length === 0) {
|
|
1379
|
-
throw new ValidationError(
|
|
1380
|
-
"model",
|
|
1381
|
-
`No adapter available for model "${model.canonical_name}". Available providers: ${model.providers.map((p) => p.provider).join(", ")}`
|
|
1382
|
-
);
|
|
1383
|
-
}
|
|
1384
|
-
const binding = availableBindings[0];
|
|
1385
|
-
const template = getCategoryTemplate(model.category);
|
|
1386
|
-
if (!template) {
|
|
1387
|
-
throw new ValidationError("model", `No category template for "${model.category}" yet`);
|
|
1388
|
-
}
|
|
1389
|
-
const providerParams = mapInput(request, binding, template);
|
|
1390
|
-
const finalParams = await processParamsForUpload(providerParams, {
|
|
1391
|
-
reupload: request.options?.reupload
|
|
1392
|
-
});
|
|
1393
|
-
const adapter = adapters[binding.provider];
|
|
1394
|
-
const apiKey = auth.getKey(binding.provider);
|
|
1395
|
-
const timeoutMs = request.options?.timeout ?? template.default_timeout_ms;
|
|
1396
|
-
const submitted = await withRetry(
|
|
1397
|
-
() => adapter.submit(binding.endpoint, finalParams, apiKey),
|
|
1398
|
-
{ timeoutMs }
|
|
1399
|
-
);
|
|
1400
|
-
let result = submitted;
|
|
1401
|
-
while (result.status === "processing" || result.status === "pending") {
|
|
1402
|
-
await new Promise((resolve2) => setTimeout(resolve2, 1e3));
|
|
1403
|
-
result = await adapter.poll(submitted.id, apiKey, binding.endpoint);
|
|
1404
|
-
}
|
|
1405
|
-
if (result.status === "failed") {
|
|
1406
|
-
throw new ProviderError(
|
|
1407
|
-
binding.provider,
|
|
1408
|
-
model.canonical_name,
|
|
1409
|
-
0,
|
|
1410
|
-
result.error || "Generation failed"
|
|
1411
|
-
);
|
|
1412
|
-
}
|
|
1413
|
-
const outputs = mapOutput(result.output, binding.output_map);
|
|
1414
|
-
const rawOutput = typeof result.output === "object" && result.output !== null ? result.output : void 0;
|
|
1415
|
-
const metadata = {
|
|
1416
|
-
inference_time_ms: Date.now() - startTime,
|
|
1417
|
-
seed: rawOutput?.seed,
|
|
1418
|
-
safety_flagged: rawOutput ? Array.isArray(rawOutput.has_nsfw_concepts) ? rawOutput.has_nsfw_concepts.some((v) => v) : void 0 : void 0
|
|
1419
|
-
};
|
|
1420
|
-
if (rawOutput?.usage) {
|
|
1421
|
-
const usage = rawOutput.usage;
|
|
1422
|
-
metadata.tokens = usage.total_tokens;
|
|
1423
|
-
metadata.prompt_tokens = usage.prompt_tokens;
|
|
1424
|
-
metadata.completion_tokens = usage.completion_tokens;
|
|
1425
|
-
}
|
|
1426
|
-
return {
|
|
1427
|
-
id: randomUUID(),
|
|
1428
|
-
model: model.canonical_name,
|
|
1429
|
-
provider: binding.provider,
|
|
1430
|
-
status: "completed",
|
|
1431
|
-
outputs,
|
|
1432
|
-
metadata
|
|
1433
|
-
};
|
|
1434
|
-
}
|
|
1435
|
-
|
|
1436
|
-
// src/configure.ts
|
|
1437
|
-
function configure(options) {
|
|
1438
|
-
if (options.keys) {
|
|
1439
|
-
configureAuth(options.keys);
|
|
1440
|
-
}
|
|
1441
|
-
if (options.storage) {
|
|
1442
|
-
configureStorage(options.storage);
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
|
-
// src/discovery.ts
|
|
1447
|
-
function listModels(filters) {
|
|
1448
|
-
let models = loadRegistry();
|
|
1449
|
-
if (filters?.accessible) {
|
|
1450
|
-
const auth = new AuthManager();
|
|
1451
|
-
models = auth.listAvailableModels(models);
|
|
1452
|
-
}
|
|
1453
|
-
if (filters?.category) {
|
|
1454
|
-
models = models.filter((m) => m.category === filters.category);
|
|
1455
|
-
}
|
|
1456
|
-
if (filters?.provider) {
|
|
1457
|
-
models = models.filter(
|
|
1458
|
-
(m) => m.providers.some((p) => p.provider === filters.provider)
|
|
1459
|
-
);
|
|
1460
|
-
}
|
|
1461
|
-
if (filters?.query) {
|
|
1462
|
-
const q = filters.query.toLowerCase();
|
|
1463
|
-
models = models.filter(
|
|
1464
|
-
(m) => m.canonical_name.includes(q) || m.aliases.some((a) => a.includes(q))
|
|
1465
|
-
);
|
|
1466
|
-
}
|
|
1467
|
-
return models;
|
|
1468
|
-
}
|
|
1469
|
-
function getModel(name) {
|
|
1470
|
-
return resolveModel(name);
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
export {
|
|
1474
|
-
generate,
|
|
1475
|
-
configure,
|
|
1476
|
-
listModels,
|
|
1477
|
-
getModel
|
|
1478
|
-
};
|
|
1479
|
-
//# sourceMappingURL=chunk-LHDSEV4H.js.map
|