@fungi.computer/darkroom 0.6.0 → 0.7.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/README.md +129 -0
- package/dist/app-media-contracts.d.ts +4 -0
- package/dist/browser-failure.d.ts +2 -0
- package/dist/browser-failure.js +2 -0
- package/dist/cloudflare/provider.js +3 -3
- package/dist/cloudflare/reference-images.d.ts +6 -0
- package/dist/cloudflare/reference-images.js +25 -7
- package/dist/cost-estimate.js +2 -2
- package/dist/daily-media-meter.d.ts +55 -0
- package/dist/daily-media-meter.js +81 -0
- package/dist/execution-error.d.ts +1 -1
- package/dist/gateway-models.d.ts +8 -2
- package/dist/gateway-models.js +24 -7
- package/dist/gateway-wire.d.ts +1 -0
- package/dist/gateway-wire.js +2 -0
- package/dist/index.d.ts +49 -12
- package/dist/index.js +31 -21
- package/dist/media-binding.js +3 -3
- package/dist/media-generation.js +9 -5
- package/dist/media-operation-contract.d.ts +3 -1
- package/dist/media-operation-do.d.ts +13 -2
- package/dist/media-operation-do.js +26 -1
- package/dist/media-operation-owner.d.ts +8 -0
- package/dist/media-operation-owner.js +8 -5
- package/dist/media-operation.js +2 -2
- package/dist/media-quote.d.ts +14 -0
- package/dist/media-quote.js +17 -0
- package/dist/model-catalog.d.ts +435 -4
- package/dist/model-catalog.js +130 -6
- package/dist/reference-image-size.d.ts +4 -3
- package/dist/reference-image-size.js +9 -9
- package/dist/server.d.ts +17 -1
- package/dist/server.js +44 -6
- package/docs/api/app-media-contracts.md +4 -0
- package/docs/api/browser.md +4 -2
- package/docs/api/cloudflare.md +53 -0
- package/docs/api/index.md +461 -54
- package/docs/api/server.md +194 -5
- package/package.json +2 -2
package/docs/api/index.md
CHANGED
|
@@ -333,7 +333,7 @@ Caller video selection before defaults and model-specific refinements.
|
|
|
333
333
|
|
|
334
334
|
```ts
|
|
335
335
|
type MediaVideoSelection = Readonly<{
|
|
336
|
-
model:
|
|
336
|
+
model: string;
|
|
337
337
|
prompt: string;
|
|
338
338
|
width: number;
|
|
339
339
|
height: number;
|
|
@@ -583,6 +583,26 @@ type MediaModel = z.output<typeof mediaModelSchema>;
|
|
|
583
583
|
|
|
584
584
|
One immutable provider catalog entry.
|
|
585
585
|
|
|
586
|
+
---
|
|
587
|
+
|
|
588
|
+
### MediaCatalogueModel
|
|
589
|
+
|
|
590
|
+
```ts
|
|
591
|
+
type MediaCatalogueModel = z.output<typeof mediaCatalogueModelSchema>;
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
One provider's catalogue entry.
|
|
595
|
+
|
|
596
|
+
---
|
|
597
|
+
|
|
598
|
+
### MediaCatalogue
|
|
599
|
+
|
|
600
|
+
```ts
|
|
601
|
+
type MediaCatalogue = readonly MediaCatalogueModel[];
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
One provider's model list: the typed bounds every request is checked against.
|
|
605
|
+
|
|
586
606
|
## Variables
|
|
587
607
|
|
|
588
608
|
### mediaFailureStageSchema
|
|
@@ -1257,7 +1277,257 @@ Public wire grammar for a catalog entry returned by the Media owner.
|
|
|
1257
1277
|
const mediaModels: readonly MediaModel[] = models;
|
|
1258
1278
|
```
|
|
1259
1279
|
|
|
1260
|
-
The immutable image and video model catalog.
|
|
1280
|
+
The Fungi gateway provider's own immutable image and video model catalog.
|
|
1281
|
+
|
|
1282
|
+
---
|
|
1283
|
+
|
|
1284
|
+
### mediaCatalogueModelSchema
|
|
1285
|
+
|
|
1286
|
+
```ts
|
|
1287
|
+
const mediaCatalogueModelSchema: ZodReadonly<ZodObject<{
|
|
1288
|
+
id: ZodString;
|
|
1289
|
+
label: ZodString;
|
|
1290
|
+
kind: ZodEnum<{
|
|
1291
|
+
image: "image";
|
|
1292
|
+
video: "video";
|
|
1293
|
+
}>;
|
|
1294
|
+
tier: ZodEnum<{
|
|
1295
|
+
draft: "draft";
|
|
1296
|
+
balanced: "balanced";
|
|
1297
|
+
premium: "premium";
|
|
1298
|
+
max: "max";
|
|
1299
|
+
}>;
|
|
1300
|
+
outputFormats: ZodReadonly<ZodArray<ZodEnum<{
|
|
1301
|
+
png: "png";
|
|
1302
|
+
jpeg: "jpeg";
|
|
1303
|
+
webp: "webp";
|
|
1304
|
+
}>>>;
|
|
1305
|
+
maxPromptLength: ZodNumber;
|
|
1306
|
+
input: ZodLazy<ZodReadonly<ZodObject<{
|
|
1307
|
+
transport: ZodEnum<{
|
|
1308
|
+
json: "json";
|
|
1309
|
+
multipart: "multipart";
|
|
1310
|
+
}>;
|
|
1311
|
+
dimensions: ZodEnum<{
|
|
1312
|
+
none: "none";
|
|
1313
|
+
own: "own";
|
|
1314
|
+
}>;
|
|
1315
|
+
maxDimension: ZodNullable<ZodNumber>;
|
|
1316
|
+
maxDimensionDocumented: ZodBoolean;
|
|
1317
|
+
defaultWidth: ZodNumber;
|
|
1318
|
+
defaultHeight: ZodNumber;
|
|
1319
|
+
steps: ZodEnum<{
|
|
1320
|
+
steps: "steps";
|
|
1321
|
+
num_steps: "num_steps";
|
|
1322
|
+
fixed: "fixed";
|
|
1323
|
+
}>;
|
|
1324
|
+
maxSteps: ZodNullable<ZodNumber>;
|
|
1325
|
+
defaultSteps: ZodNullable<ZodNumber>;
|
|
1326
|
+
referenceField: ZodNullable<ZodString>;
|
|
1327
|
+
maxReferences: ZodNumber;
|
|
1328
|
+
referenceDimension: ZodNullable<ZodNumber>;
|
|
1329
|
+
referenceFormat: ZodEnum<{
|
|
1330
|
+
png: "png";
|
|
1331
|
+
webp: "webp";
|
|
1332
|
+
}>;
|
|
1333
|
+
}, $strict>>>;
|
|
1334
|
+
sizes: ZodNullable<ZodReadonly<ZodArray<ZodString>>>;
|
|
1335
|
+
video: ZodNullable<ZodReadonly<ZodObject<{
|
|
1336
|
+
minSeconds: ZodNumber;
|
|
1337
|
+
maxSeconds: ZodNumber;
|
|
1338
|
+
defaultSeconds: ZodNumber;
|
|
1339
|
+
durations: ZodReadonly<ZodArray<ZodNumber>>;
|
|
1340
|
+
formats: ZodReadonly<ZodArray<ZodLazy<ZodReadonly<...>>>>;
|
|
1341
|
+
defaultResolution: ZodEnum<{
|
|
1342
|
+
p480: "480p";
|
|
1343
|
+
p720: "720p";
|
|
1344
|
+
p768: "768p";
|
|
1345
|
+
p1080: "1080p";
|
|
1346
|
+
p4k: "4k";
|
|
1347
|
+
}>;
|
|
1348
|
+
defaultAspectRatio: ZodEnum<{
|
|
1349
|
+
wide: "16:9";
|
|
1350
|
+
landscape: "4:3";
|
|
1351
|
+
square: "1:1";
|
|
1352
|
+
portrait: "3:4";
|
|
1353
|
+
tall: "9:16";
|
|
1354
|
+
ultrawide: "21:9";
|
|
1355
|
+
ultratall: "9:21";
|
|
1356
|
+
}>;
|
|
1357
|
+
supportsAudio: ZodBoolean;
|
|
1358
|
+
defaultGenerateAudio: ZodNullable<ZodBoolean>;
|
|
1359
|
+
referenceRoles: ZodReadonly<ZodArray<ZodEnum<{
|
|
1360
|
+
first: ...;
|
|
1361
|
+
last: ...;
|
|
1362
|
+
reference: ...;
|
|
1363
|
+
}>>>;
|
|
1364
|
+
maxReferenceImages: ZodNumber;
|
|
1365
|
+
referenceResolutions: ZodReadonly<ZodArray<ZodEnum<{
|
|
1366
|
+
p480: ...;
|
|
1367
|
+
p720: ...;
|
|
1368
|
+
p768: ...;
|
|
1369
|
+
p1080: ...;
|
|
1370
|
+
p4k: ...;
|
|
1371
|
+
}>>>;
|
|
1372
|
+
prices: ZodReadonly<ZodArray<ZodReadonly<ZodObject<..., ...>>>>;
|
|
1373
|
+
provider: ZodEnum<{
|
|
1374
|
+
seedance: "seedance";
|
|
1375
|
+
veo: "veo";
|
|
1376
|
+
minimax: "minimax";
|
|
1377
|
+
host: "host";
|
|
1378
|
+
}>;
|
|
1379
|
+
}, $strict>>>;
|
|
1380
|
+
}, $strict>>;
|
|
1381
|
+
```
|
|
1382
|
+
|
|
1383
|
+
One catalogue entry. Same grammar as the gateway's wire entry, except that a
|
|
1384
|
+
video model may name `host` as its provider family: the injected provider owns
|
|
1385
|
+
that model's wire grammar and Darkroom builds no gateway request for it.
|
|
1386
|
+
|
|
1387
|
+
---
|
|
1388
|
+
|
|
1389
|
+
### mediaCatalogueSchema
|
|
1390
|
+
|
|
1391
|
+
```ts
|
|
1392
|
+
const mediaCatalogueSchema: ZodPipe<ZodArray<ZodReadonly<ZodObject<{
|
|
1393
|
+
id: ZodString;
|
|
1394
|
+
label: ZodString;
|
|
1395
|
+
kind: ZodEnum<{
|
|
1396
|
+
image: "image";
|
|
1397
|
+
video: "video";
|
|
1398
|
+
}>;
|
|
1399
|
+
tier: ZodEnum<{
|
|
1400
|
+
draft: "draft";
|
|
1401
|
+
balanced: "balanced";
|
|
1402
|
+
premium: "premium";
|
|
1403
|
+
max: "max";
|
|
1404
|
+
}>;
|
|
1405
|
+
outputFormats: ZodReadonly<ZodArray<ZodEnum<{
|
|
1406
|
+
png: "png";
|
|
1407
|
+
jpeg: "jpeg";
|
|
1408
|
+
webp: "webp";
|
|
1409
|
+
}>>>;
|
|
1410
|
+
maxPromptLength: ZodNumber;
|
|
1411
|
+
input: ZodLazy<ZodReadonly<ZodObject<{
|
|
1412
|
+
transport: ZodEnum<{
|
|
1413
|
+
json: ...;
|
|
1414
|
+
multipart: ...;
|
|
1415
|
+
}>;
|
|
1416
|
+
dimensions: ZodEnum<{
|
|
1417
|
+
none: ...;
|
|
1418
|
+
own: ...;
|
|
1419
|
+
}>;
|
|
1420
|
+
maxDimension: ZodNullable<ZodNumber>;
|
|
1421
|
+
maxDimensionDocumented: ZodBoolean;
|
|
1422
|
+
defaultWidth: ZodNumber;
|
|
1423
|
+
defaultHeight: ZodNumber;
|
|
1424
|
+
steps: ZodEnum<{
|
|
1425
|
+
steps: ...;
|
|
1426
|
+
num_steps: ...;
|
|
1427
|
+
fixed: ...;
|
|
1428
|
+
}>;
|
|
1429
|
+
maxSteps: ZodNullable<ZodNumber>;
|
|
1430
|
+
defaultSteps: ZodNullable<ZodNumber>;
|
|
1431
|
+
referenceField: ZodNullable<ZodString>;
|
|
1432
|
+
maxReferences: ZodNumber;
|
|
1433
|
+
referenceDimension: ZodNullable<ZodNumber>;
|
|
1434
|
+
referenceFormat: ZodEnum<{
|
|
1435
|
+
png: ...;
|
|
1436
|
+
webp: ...;
|
|
1437
|
+
}>;
|
|
1438
|
+
}, $strict>>>;
|
|
1439
|
+
sizes: ZodNullable<ZodReadonly<ZodArray<ZodString>>>;
|
|
1440
|
+
video: ZodNullable<ZodReadonly<ZodObject<{
|
|
1441
|
+
minSeconds: ZodNumber;
|
|
1442
|
+
maxSeconds: ZodNumber;
|
|
1443
|
+
defaultSeconds: ZodNumber;
|
|
1444
|
+
durations: ZodReadonly<ZodArray<...>>;
|
|
1445
|
+
formats: ZodReadonly<ZodArray<...>>;
|
|
1446
|
+
defaultResolution: ZodEnum<{
|
|
1447
|
+
p480: ...;
|
|
1448
|
+
p720: ...;
|
|
1449
|
+
p768: ...;
|
|
1450
|
+
p1080: ...;
|
|
1451
|
+
p4k: ...;
|
|
1452
|
+
}>;
|
|
1453
|
+
defaultAspectRatio: ZodEnum<{
|
|
1454
|
+
wide: ...;
|
|
1455
|
+
landscape: ...;
|
|
1456
|
+
square: ...;
|
|
1457
|
+
portrait: ...;
|
|
1458
|
+
tall: ...;
|
|
1459
|
+
ultrawide: ...;
|
|
1460
|
+
ultratall: ...;
|
|
1461
|
+
}>;
|
|
1462
|
+
supportsAudio: ZodBoolean;
|
|
1463
|
+
defaultGenerateAudio: ZodNullable<ZodBoolean>;
|
|
1464
|
+
referenceRoles: ZodReadonly<ZodArray<...>>;
|
|
1465
|
+
maxReferenceImages: ZodNumber;
|
|
1466
|
+
referenceResolutions: ZodReadonly<ZodArray<...>>;
|
|
1467
|
+
prices: ZodReadonly<ZodArray<...>>;
|
|
1468
|
+
provider: ZodEnum<{
|
|
1469
|
+
seedance: ...;
|
|
1470
|
+
veo: ...;
|
|
1471
|
+
minimax: ...;
|
|
1472
|
+
host: ...;
|
|
1473
|
+
}>;
|
|
1474
|
+
}, $strict>>>;
|
|
1475
|
+
}, $strict>>>, ZodTransform<MediaCatalogue, Readonly<{
|
|
1476
|
+
id: string;
|
|
1477
|
+
label: string;
|
|
1478
|
+
kind: "image" | "video";
|
|
1479
|
+
tier: "draft" | "balanced" | "premium" | "max";
|
|
1480
|
+
outputFormats: readonly ("png" | "jpeg" | "webp")[];
|
|
1481
|
+
maxPromptLength: number;
|
|
1482
|
+
input: Readonly<{
|
|
1483
|
+
transport: "json" | "multipart";
|
|
1484
|
+
dimensions: "none" | "own";
|
|
1485
|
+
maxDimension: number | null;
|
|
1486
|
+
maxDimensionDocumented: boolean;
|
|
1487
|
+
defaultWidth: number;
|
|
1488
|
+
defaultHeight: number;
|
|
1489
|
+
steps: "steps" | "num_steps" | "fixed";
|
|
1490
|
+
maxSteps: number | null;
|
|
1491
|
+
defaultSteps: number | null;
|
|
1492
|
+
referenceField: string | null;
|
|
1493
|
+
maxReferences: number;
|
|
1494
|
+
referenceDimension: number | null;
|
|
1495
|
+
referenceFormat: "png" | "webp";
|
|
1496
|
+
}>;
|
|
1497
|
+
sizes: readonly string[] | null;
|
|
1498
|
+
video: | Readonly<{
|
|
1499
|
+
minSeconds: number;
|
|
1500
|
+
maxSeconds: number;
|
|
1501
|
+
defaultSeconds: number;
|
|
1502
|
+
durations: readonly number[];
|
|
1503
|
+
formats: readonly Readonly<{
|
|
1504
|
+
resolution: ...;
|
|
1505
|
+
aspectRatio: ...;
|
|
1506
|
+
width: ...;
|
|
1507
|
+
height: ...;
|
|
1508
|
+
}>[];
|
|
1509
|
+
defaultResolution: "480p" | "720p" | "768p" | "1080p" | "4k";
|
|
1510
|
+
defaultAspectRatio: "16:9" | "4:3" | "1:1" | "3:4" | "9:16" | "21:9" | "9:21";
|
|
1511
|
+
supportsAudio: boolean;
|
|
1512
|
+
defaultGenerateAudio: boolean | null;
|
|
1513
|
+
referenceRoles: readonly ("first-frame" | "last-frame" | "reference")[];
|
|
1514
|
+
maxReferenceImages: number;
|
|
1515
|
+
referenceResolutions: readonly ("480p" | "720p" | "768p" | "1080p" | "4k")[];
|
|
1516
|
+
prices: readonly Readonly<{
|
|
1517
|
+
resolution: ...;
|
|
1518
|
+
silentMilliunitsPerSecond: ...;
|
|
1519
|
+
audioMilliunitsPerSecond: ...;
|
|
1520
|
+
}>[];
|
|
1521
|
+
provider: "seedance" | "veo" | "minimax" | "host";
|
|
1522
|
+
}>
|
|
1523
|
+
| null;
|
|
1524
|
+
}>[]>>;
|
|
1525
|
+
```
|
|
1526
|
+
|
|
1527
|
+
Decode a host-supplied provider catalogue. Each entry is the same typed wire
|
|
1528
|
+
grammar the built-in catalogue uses; this adds the cross-field facts the
|
|
1529
|
+
validator relies on (unique ids, video metadata iff `kind` is video, defaults
|
|
1530
|
+
inside their own bounds).
|
|
1261
1531
|
|
|
1262
1532
|
---
|
|
1263
1533
|
|
|
@@ -1316,26 +1586,31 @@ Quote the same estimate in milliunits (1 cent = 1,000 milliunits).
|
|
|
1316
1586
|
### validateMediaGenerationSettings()
|
|
1317
1587
|
|
|
1318
1588
|
```ts
|
|
1319
|
-
function validateMediaGenerationSettings(
|
|
1589
|
+
function validateMediaGenerationSettings(
|
|
1590
|
+
raw,
|
|
1591
|
+
catalogue?,
|
|
1592
|
+
): MediaGenerationSettings;
|
|
1320
1593
|
```
|
|
1321
1594
|
|
|
1322
|
-
Validate caller settings
|
|
1595
|
+
Validate caller settings against `catalogue`, the active provider's model list
|
|
1596
|
+
(the Fungi gateway's by default), and apply that model's defaults.
|
|
1323
1597
|
|
|
1324
1598
|
#### Parameters
|
|
1325
1599
|
|
|
1326
|
-
| Parameter | Type | Description |
|
|
1327
|
-
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
|
|
1328
|
-
| `raw` | \{ `model`: `string`; `prompt`: `string`; `width`: `number`; `height`: `number`; `steps?`: `number`; `durationSeconds?`: `number`; `resolution?`: `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `generateAudio?`: `boolean`; `references?`: `object`[]; \} | - |
|
|
1329
|
-
| `raw.model` | `string` | Provider catalog model identifier. |
|
|
1330
|
-
| `raw.prompt` | `string` | Generation prompt; each model's `maxPromptLength` is enforced on top of this ceiling. |
|
|
1331
|
-
| `raw.width` | `number` | Requested image width or nominal video selector, not decoded MP4 dimensions. |
|
|
1332
|
-
| `raw.height` | `number` | Requested image height or nominal video selector, not decoded MP4 dimensions. |
|
|
1333
|
-
| `raw.steps?` | `number` | Model-specific inference step count. |
|
|
1334
|
-
| `raw.durationSeconds?` | `number` | Requested video length in whole seconds. |
|
|
1335
|
-
| `raw.resolution?` | `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"` | Video resolution; must match the nominal width/height selector. |
|
|
1336
|
-
| `raw.aspectRatio?` | `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"` | Video aspect; must match the nominal width/height selector. |
|
|
1337
|
-
| `raw.generateAudio?` | `boolean` | Video audio selection. |
|
|
1338
|
-
| `raw.references?` | `object`[] | Host-authorized reference images. |
|
|
1600
|
+
| Parameter | Type | Default value | Description |
|
|
1601
|
+
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | ------------------------------------------------------------------------------------- |
|
|
1602
|
+
| `raw` | \{ `model`: `string`; `prompt`: `string`; `width`: `number`; `height`: `number`; `steps?`: `number`; `durationSeconds?`: `number`; `resolution?`: `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `generateAudio?`: `boolean`; `references?`: `object`[]; \} | `undefined` | - |
|
|
1603
|
+
| `raw.model` | `string` | `...` | Provider catalog model identifier. |
|
|
1604
|
+
| `raw.prompt` | `string` | `...` | Generation prompt; each model's `maxPromptLength` is enforced on top of this ceiling. |
|
|
1605
|
+
| `raw.width` | `number` | `...` | Requested image width or nominal video selector, not decoded MP4 dimensions. |
|
|
1606
|
+
| `raw.height` | `number` | `...` | Requested image height or nominal video selector, not decoded MP4 dimensions. |
|
|
1607
|
+
| `raw.steps?` | `number` | `...` | Model-specific inference step count. |
|
|
1608
|
+
| `raw.durationSeconds?` | `number` | `...` | Requested video length in whole seconds. |
|
|
1609
|
+
| `raw.resolution?` | `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"` | `...` | Video resolution; must match the nominal width/height selector. |
|
|
1610
|
+
| `raw.aspectRatio?` | `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"` | `...` | Video aspect; must match the nominal width/height selector. |
|
|
1611
|
+
| `raw.generateAudio?` | `boolean` | `...` | Video audio selection. |
|
|
1612
|
+
| `raw.references?` | `object`[] | `...` | Host-authorized reference images. |
|
|
1613
|
+
| `catalogue` | [`MediaCatalogue`](#mediacatalogue) | `mediaModels` | - |
|
|
1339
1614
|
|
|
1340
1615
|
#### Returns
|
|
1341
1616
|
|
|
@@ -1348,6 +1623,7 @@ Validate caller settings and apply retained model defaults.
|
|
|
1348
1623
|
```ts
|
|
1349
1624
|
function validateMediaGenerationSelection(
|
|
1350
1625
|
raw,
|
|
1626
|
+
catalogue?,
|
|
1351
1627
|
): Readonly<Omit<MediaGenerationSettings, "references"> & object>;
|
|
1352
1628
|
```
|
|
1353
1629
|
|
|
@@ -1355,19 +1631,20 @@ Validate selections without granting Computer authority.
|
|
|
1355
1631
|
|
|
1356
1632
|
#### Parameters
|
|
1357
1633
|
|
|
1358
|
-
| Parameter | Type | Description |
|
|
1359
|
-
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
|
|
1360
|
-
| `raw` | \{ `model`: `string`; `prompt`: `string`; `width`: `number`; `height`: `number`; `steps?`: `number`; `durationSeconds?`: `number`; `resolution?`: `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `generateAudio?`: `boolean`; `references?`: `object`[]; \} | - |
|
|
1361
|
-
| `raw.model` | `string` | Provider catalog model identifier. |
|
|
1362
|
-
| `raw.prompt` | `string` | Generation prompt; each model's `maxPromptLength` is enforced on top of this ceiling. |
|
|
1363
|
-
| `raw.width` | `number` | Requested image width or nominal video selector, not decoded MP4 dimensions. |
|
|
1364
|
-
| `raw.height` | `number` | Requested image height or nominal video selector, not decoded MP4 dimensions. |
|
|
1365
|
-
| `raw.steps?` | `number` | Model-specific inference step count. |
|
|
1366
|
-
| `raw.durationSeconds?` | `number` | Requested video length in whole seconds. |
|
|
1367
|
-
| `raw.resolution?` | `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"` | Video resolution; must match the nominal width/height selector. |
|
|
1368
|
-
| `raw.aspectRatio?` | `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"` | Video aspect; must match the nominal width/height selector. |
|
|
1369
|
-
| `raw.generateAudio?` | `boolean` | Video audio selection. |
|
|
1370
|
-
| `raw.references?` | `object`[] | Host-authorized reference images. |
|
|
1634
|
+
| Parameter | Type | Default value | Description |
|
|
1635
|
+
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | ------------------------------------------------------------------------------------- |
|
|
1636
|
+
| `raw` | \{ `model`: `string`; `prompt`: `string`; `width`: `number`; `height`: `number`; `steps?`: `number`; `durationSeconds?`: `number`; `resolution?`: `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `generateAudio?`: `boolean`; `references?`: `object`[]; \} | `undefined` | - |
|
|
1637
|
+
| `raw.model` | `string` | `...` | Provider catalog model identifier. |
|
|
1638
|
+
| `raw.prompt` | `string` | `...` | Generation prompt; each model's `maxPromptLength` is enforced on top of this ceiling. |
|
|
1639
|
+
| `raw.width` | `number` | `...` | Requested image width or nominal video selector, not decoded MP4 dimensions. |
|
|
1640
|
+
| `raw.height` | `number` | `...` | Requested image height or nominal video selector, not decoded MP4 dimensions. |
|
|
1641
|
+
| `raw.steps?` | `number` | `...` | Model-specific inference step count. |
|
|
1642
|
+
| `raw.durationSeconds?` | `number` | `...` | Requested video length in whole seconds. |
|
|
1643
|
+
| `raw.resolution?` | `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"` | `...` | Video resolution; must match the nominal width/height selector. |
|
|
1644
|
+
| `raw.aspectRatio?` | `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"` | `...` | Video aspect; must match the nominal width/height selector. |
|
|
1645
|
+
| `raw.generateAudio?` | `boolean` | `...` | Video audio selection. |
|
|
1646
|
+
| `raw.references?` | `object`[] | `...` | Host-authorized reference images. |
|
|
1647
|
+
| `catalogue` | [`MediaCatalogue`](#mediacatalogue) | `mediaModels` | - |
|
|
1371
1648
|
|
|
1372
1649
|
#### Returns
|
|
1373
1650
|
|
|
@@ -1379,7 +1656,7 @@ Validate selections without granting Computer authority.
|
|
|
1379
1656
|
### validateMediaVideoSelection()
|
|
1380
1657
|
|
|
1381
1658
|
```ts
|
|
1382
|
-
function validateMediaVideoSelection(raw): MediaVideoSelection;
|
|
1659
|
+
function validateMediaVideoSelection(raw, catalogue?): MediaVideoSelection;
|
|
1383
1660
|
```
|
|
1384
1661
|
|
|
1385
1662
|
Validate supported model/size/duration/reference combinations before authority
|
|
@@ -1387,16 +1664,17 @@ or billing admission.
|
|
|
1387
1664
|
|
|
1388
1665
|
#### Parameters
|
|
1389
1666
|
|
|
1390
|
-
| Parameter | Type
|
|
1391
|
-
| ---------------------- |
|
|
1392
|
-
| `raw` | \{ `
|
|
1393
|
-
| `raw.
|
|
1394
|
-
| `raw.
|
|
1395
|
-
| `raw.
|
|
1396
|
-
| `raw.
|
|
1397
|
-
| `raw.
|
|
1398
|
-
| `raw.
|
|
1399
|
-
| `raw.
|
|
1667
|
+
| Parameter | Type | Default value | Description |
|
|
1668
|
+
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
1669
|
+
| `raw` | \{ `prompt`: `string`; `resolution?`: `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `durationSeconds?`: `number`; `generateAudio?`: `boolean`; `references?`: `object`[]; `model`: `string`; \} | `undefined` | - |
|
|
1670
|
+
| `raw.prompt` | `string` | `...` | Trimmed prompt; the selected model's `maxPromptLength` is enforced on top of this ceiling. |
|
|
1671
|
+
| `raw.resolution?` | `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"` | `...` | Model-specific resolution, default 720p. |
|
|
1672
|
+
| `raw.aspectRatio?` | `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"` | `...` | Model-specific aspect, default 16:9. |
|
|
1673
|
+
| `raw.durationSeconds?` | `number` | `...` | Whole seconds; Seedance 2.0 4–12, Seedance 2.5 4–30, Veo exactly 4/6/8, MiniMax H3 Max 5–15. |
|
|
1674
|
+
| `raw.generateAudio?` | `boolean` | `...` | Veo defaults true; Seedance omits the provider option when unset; MiniMax H3 Max has no audio field and refuses an explicit choice. |
|
|
1675
|
+
| `raw.references?` | `object`[] | `...` | Up to four references, with provider-specific roles and mode limits. |
|
|
1676
|
+
| `raw.model` | `string` | `...` | - |
|
|
1677
|
+
| `catalogue` | [`MediaCatalogue`](#mediacatalogue) | `mediaModels` | - |
|
|
1400
1678
|
|
|
1401
1679
|
#### Returns
|
|
1402
1680
|
|
|
@@ -1410,6 +1688,7 @@ or billing admission.
|
|
|
1410
1688
|
function resolveMediaReferences(
|
|
1411
1689
|
settings,
|
|
1412
1690
|
reader,
|
|
1691
|
+
catalogue?,
|
|
1413
1692
|
): Promise<
|
|
1414
1693
|
readonly Readonly<{
|
|
1415
1694
|
bytes: Uint8Array;
|
|
@@ -1425,10 +1704,11 @@ Resolve only provider-accepted references through the caller's reader.
|
|
|
1425
1704
|
|
|
1426
1705
|
#### Parameters
|
|
1427
1706
|
|
|
1428
|
-
| Parameter
|
|
1429
|
-
|
|
|
1430
|
-
| `settings`
|
|
1431
|
-
| `reader`
|
|
1707
|
+
| Parameter | Type | Default value |
|
|
1708
|
+
| ----------- | ----------------------------------------------------- | ------------- |
|
|
1709
|
+
| `settings` | [`MediaGenerationSettings`](#mediagenerationsettings) | `undefined` |
|
|
1710
|
+
| `reader` | [`MediaReferenceReader`](#mediareferencereader) | `undefined` |
|
|
1711
|
+
| `catalogue` | [`MediaCatalogue`](#mediacatalogue) | `mediaModels` |
|
|
1432
1712
|
|
|
1433
1713
|
#### Returns
|
|
1434
1714
|
|
|
@@ -1537,17 +1817,18 @@ Normalize all retained provider envelopes into bounded image bytes.
|
|
|
1537
1817
|
### estimateVideoMilliunits()
|
|
1538
1818
|
|
|
1539
1819
|
```ts
|
|
1540
|
-
function estimateVideoMilliunits(settings): number;
|
|
1820
|
+
function estimateVideoMilliunits(settings, catalogue?): number;
|
|
1541
1821
|
```
|
|
1542
1822
|
|
|
1543
|
-
Provider video cost from
|
|
1823
|
+
Provider video cost from `catalogue`, in milliunits (1 cent = 1,000).
|
|
1544
1824
|
Video-input references are unsupported.
|
|
1545
1825
|
|
|
1546
1826
|
#### Parameters
|
|
1547
1827
|
|
|
1548
|
-
| Parameter
|
|
1549
|
-
|
|
|
1550
|
-
| `settings`
|
|
1828
|
+
| Parameter | Type | Default value |
|
|
1829
|
+
| ----------- | ----------------------------------------------------- | ------------- |
|
|
1830
|
+
| `settings` | [`MediaVideoQuoteSettings`](#mediavideoquotesettings) | `undefined` |
|
|
1831
|
+
| `catalogue` | [`MediaCatalogue`](#mediacatalogue) | `mediaModels` |
|
|
1551
1832
|
|
|
1552
1833
|
#### Returns
|
|
1553
1834
|
|
|
@@ -1555,6 +1836,27 @@ Video-input references are unsupported.
|
|
|
1555
1836
|
|
|
1556
1837
|
---
|
|
1557
1838
|
|
|
1839
|
+
### parseMediaCatalogue()
|
|
1840
|
+
|
|
1841
|
+
```ts
|
|
1842
|
+
function parseMediaCatalogue(raw): MediaCatalogue;
|
|
1843
|
+
```
|
|
1844
|
+
|
|
1845
|
+
Decode untrusted catalogue data, throwing a MediaSettingsError that names the
|
|
1846
|
+
first problem.
|
|
1847
|
+
|
|
1848
|
+
#### Parameters
|
|
1849
|
+
|
|
1850
|
+
| Parameter | Type |
|
|
1851
|
+
| --------- | --------- |
|
|
1852
|
+
| `raw` | `unknown` |
|
|
1853
|
+
|
|
1854
|
+
#### Returns
|
|
1855
|
+
|
|
1856
|
+
[`MediaCatalogue`](#mediacatalogue)
|
|
1857
|
+
|
|
1858
|
+
---
|
|
1859
|
+
|
|
1558
1860
|
### listMediaModels()
|
|
1559
1861
|
|
|
1560
1862
|
```ts
|
|
@@ -1612,7 +1914,7 @@ function listMediaModels(): readonly Readonly<{
|
|
|
1612
1914
|
}>[];
|
|
1613
1915
|
```
|
|
1614
1916
|
|
|
1615
|
-
List
|
|
1917
|
+
List the gateway provider's models in catalog order.
|
|
1616
1918
|
|
|
1617
1919
|
#### Returns
|
|
1618
1920
|
|
|
@@ -1645,10 +1947,10 @@ readonly (`"first-frame"` \| `"last-frame"` \| `"reference"`)[];
|
|
|
1645
1947
|
|
|
1646
1948
|
---
|
|
1647
1949
|
|
|
1648
|
-
###
|
|
1950
|
+
### getGatewayModel()
|
|
1649
1951
|
|
|
1650
1952
|
```ts
|
|
1651
|
-
function
|
|
1953
|
+
function getGatewayModel(id):
|
|
1652
1954
|
| Readonly<{
|
|
1653
1955
|
id: string;
|
|
1654
1956
|
label: string;
|
|
@@ -1705,7 +2007,8 @@ function getMediaModel(id):
|
|
|
1705
2007
|
| undefined;
|
|
1706
2008
|
```
|
|
1707
2009
|
|
|
1708
|
-
Find a model
|
|
2010
|
+
Find a model in the Fungi gateway's own catalogue; gateway-internal code never
|
|
2011
|
+
sees a custom provider's models.
|
|
1709
2012
|
|
|
1710
2013
|
#### Parameters
|
|
1711
2014
|
|
|
@@ -1744,6 +2047,110 @@ readonly (`"first-frame"` \| `"last-frame"` \| `"reference"`)[];
|
|
|
1744
2047
|
|
|
1745
2048
|
---
|
|
1746
2049
|
|
|
2050
|
+
### getMediaModel()
|
|
2051
|
+
|
|
2052
|
+
```ts
|
|
2053
|
+
function getMediaModel(
|
|
2054
|
+
id,
|
|
2055
|
+
catalogue?,
|
|
2056
|
+
):
|
|
2057
|
+
| Readonly<{
|
|
2058
|
+
id: string;
|
|
2059
|
+
label: string;
|
|
2060
|
+
kind: "image" | "video";
|
|
2061
|
+
tier: "draft" | "balanced" | "premium" | "max";
|
|
2062
|
+
outputFormats: readonly ("png" | "jpeg" | "webp")[];
|
|
2063
|
+
maxPromptLength: number;
|
|
2064
|
+
input: Readonly<{
|
|
2065
|
+
transport: "json" | "multipart";
|
|
2066
|
+
dimensions: "none" | "own";
|
|
2067
|
+
maxDimension: number | null;
|
|
2068
|
+
maxDimensionDocumented: boolean;
|
|
2069
|
+
defaultWidth: number;
|
|
2070
|
+
defaultHeight: number;
|
|
2071
|
+
steps: "steps" | "num_steps" | "fixed";
|
|
2072
|
+
maxSteps: number | null;
|
|
2073
|
+
defaultSteps: number | null;
|
|
2074
|
+
referenceField: string | null;
|
|
2075
|
+
maxReferences: number;
|
|
2076
|
+
referenceDimension: number | null;
|
|
2077
|
+
referenceFormat: "png" | "webp";
|
|
2078
|
+
}>;
|
|
2079
|
+
sizes: readonly string[] | null;
|
|
2080
|
+
video: Readonly<{
|
|
2081
|
+
minSeconds: number;
|
|
2082
|
+
maxSeconds: number;
|
|
2083
|
+
defaultSeconds: number;
|
|
2084
|
+
durations: readonly number[];
|
|
2085
|
+
formats: readonly Readonly<{
|
|
2086
|
+
resolution: "480p" | "720p" | "768p" | "1080p" | "4k";
|
|
2087
|
+
aspectRatio:
|
|
2088
|
+
"16:9" | "4:3" | "1:1" | "3:4" | "9:16" | "21:9" | "9:21";
|
|
2089
|
+
width: number;
|
|
2090
|
+
height: number;
|
|
2091
|
+
}>[];
|
|
2092
|
+
defaultResolution: "480p" | "720p" | "768p" | "1080p" | "4k";
|
|
2093
|
+
defaultAspectRatio:
|
|
2094
|
+
"16:9" | "4:3" | "1:1" | "3:4" | "9:16" | "21:9" | "9:21";
|
|
2095
|
+
supportsAudio: boolean;
|
|
2096
|
+
defaultGenerateAudio: boolean | null;
|
|
2097
|
+
referenceRoles: readonly ("first-frame" | "last-frame" | "reference")[];
|
|
2098
|
+
maxReferenceImages: number;
|
|
2099
|
+
referenceResolutions: readonly (
|
|
2100
|
+
"480p" | "720p" | "768p" | "1080p" | "4k"
|
|
2101
|
+
)[];
|
|
2102
|
+
prices: readonly Readonly<{
|
|
2103
|
+
resolution: "480p" | "720p" | "768p" | "1080p" | "4k";
|
|
2104
|
+
silentMilliunitsPerSecond: number;
|
|
2105
|
+
audioMilliunitsPerSecond: number;
|
|
2106
|
+
}>[];
|
|
2107
|
+
provider: "seedance" | "veo" | "minimax" | "host";
|
|
2108
|
+
}> | null;
|
|
2109
|
+
}>
|
|
2110
|
+
| undefined;
|
|
2111
|
+
```
|
|
2112
|
+
|
|
2113
|
+
Find a model in `catalogue` (the gateway's by default), or undefined when
|
|
2114
|
+
absent.
|
|
2115
|
+
|
|
2116
|
+
#### Parameters
|
|
2117
|
+
|
|
2118
|
+
| Parameter | Type | Default value |
|
|
2119
|
+
| ----------- | ----------------------------------- | ------------- |
|
|
2120
|
+
| `id` | `string` | `undefined` |
|
|
2121
|
+
| `catalogue` | [`MediaCatalogue`](#mediacatalogue) | `mediaModels` |
|
|
2122
|
+
|
|
2123
|
+
#### Returns
|
|
2124
|
+
|
|
2125
|
+
\| `Readonly`\<\{ `id`: `string`; `label`: `string`; `kind`: `"image"` \|
|
|
2126
|
+
`"video"`; `tier`: `"draft"` \| `"balanced"` \| `"premium"` \| `"max"`;
|
|
2127
|
+
`outputFormats`: readonly (`"png"` \| `"jpeg"` \| `"webp"`)[];
|
|
2128
|
+
`maxPromptLength`: `number`; `input`: `Readonly`\<\{ `transport`: `"json"` \|
|
|
2129
|
+
`"multipart"`; `dimensions`: `"none"` \| `"own"`; `maxDimension`: `number` \|
|
|
2130
|
+
`null`; `maxDimensionDocumented`: `boolean`; `defaultWidth`: `number`;
|
|
2131
|
+
`defaultHeight`: `number`; `steps`: `"steps"` \| `"num_steps"` \| `"fixed"`;
|
|
2132
|
+
`maxSteps`: `number` \| `null`; `defaultSteps`: `number` \| `null`;
|
|
2133
|
+
`referenceField`: `string` \| `null`; `maxReferences`: `number`;
|
|
2134
|
+
`referenceDimension`: `number` \| `null`; `referenceFormat`: `"png"` \|
|
|
2135
|
+
`"webp"`; \}\>; `sizes`: readonly `string`[] \| `null`; `video`: \|
|
|
2136
|
+
`Readonly`\<\{ `minSeconds`: `number`; `maxSeconds`: `number`; `defaultSeconds`:
|
|
2137
|
+
`number`; `durations`: readonly `number`[]; `formats`: readonly `Readonly`\<\{
|
|
2138
|
+
`resolution`: `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`;
|
|
2139
|
+
`aspectRatio`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"`
|
|
2140
|
+
\| `"9:21"`; `width`: `number`; `height`: `number`; \}\>[]; `defaultResolution`:
|
|
2141
|
+
`"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`; `defaultAspectRatio`:
|
|
2142
|
+
`"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`;
|
|
2143
|
+
`supportsAudio`: `boolean`; `defaultGenerateAudio`: `boolean` \| `null`;
|
|
2144
|
+
`referenceRoles`: readonly (`"first-frame"` \| `"last-frame"` \|
|
|
2145
|
+
`"reference"`)[]; `maxReferenceImages`: `number`; `referenceResolutions`:
|
|
2146
|
+
readonly (`"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`)[]; `prices`:
|
|
2147
|
+
readonly `Readonly`\<\{ `resolution`: `"480p"` \| `"720p"` \| `"768p"` \|
|
|
2148
|
+
`"1080p"` \| `"4k"`; `silentMilliunitsPerSecond`: `number`;
|
|
2149
|
+
`audioMilliunitsPerSecond`: `number`; \}\>[]; `provider`: `"seedance"` \|
|
|
2150
|
+
`"veo"` \| `"minimax"` \| `"host"`; \}\> \| `null`; \}\> \| `undefined`
|
|
2151
|
+
|
|
2152
|
+
---
|
|
2153
|
+
|
|
1747
2154
|
### neuronsToMilliunits()
|
|
1748
2155
|
|
|
1749
2156
|
```ts
|