@fungi.computer/darkroom 0.5.12 → 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 +35 -10
- package/dist/gateway-wire.d.ts +1 -0
- package/dist/gateway-wire.js +2 -0
- package/dist/index.d.ts +50 -12
- package/dist/index.js +33 -23
- package/dist/media-binding.d.ts +3 -0
- 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 +438 -5
- package/dist/model-catalog.js +232 -30
- 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 +464 -55
- package/docs/api/server.md +214 -22
- 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
|
|
@@ -817,6 +837,7 @@ const mediaVideoSelectionSchema: ZodLazy<
|
|
|
817
837
|
ZodObject<
|
|
818
838
|
{
|
|
819
839
|
model: ZodEnum<{
|
|
840
|
+
seedance25: "bytedance/seedance-2.5";
|
|
820
841
|
seedance: "bytedance/seedance-2.0";
|
|
821
842
|
seedanceFast: "bytedance/seedance-2.0-fast";
|
|
822
843
|
seedanceMini: "bytedance/seedance-2.0-mini";
|
|
@@ -969,7 +990,7 @@ Media's provider catalog: Workers AI images plus gateway image and video models.
|
|
|
969
990
|
### MAX\_REFERENCE\_COUNT
|
|
970
991
|
|
|
971
992
|
```ts
|
|
972
|
-
const MAX_REFERENCE_COUNT:
|
|
993
|
+
const MAX_REFERENCE_COUNT: 30 = 30;
|
|
973
994
|
```
|
|
974
995
|
|
|
975
996
|
Schema ceiling for reference lists: the largest per-model limit. Each model's
|
|
@@ -981,6 +1002,7 @@ own `maxReferences` / `maxReferenceImages` is enforced after parsing.
|
|
|
981
1002
|
|
|
982
1003
|
```ts
|
|
983
1004
|
const mediaVideoModelIdSchema: ZodEnum<{
|
|
1005
|
+
seedance25: "bytedance/seedance-2.5";
|
|
984
1006
|
seedance: "bytedance/seedance-2.0";
|
|
985
1007
|
seedanceFast: "bytedance/seedance-2.0-fast";
|
|
986
1008
|
seedanceMini: "bytedance/seedance-2.0-mini";
|
|
@@ -1255,7 +1277,257 @@ Public wire grammar for a catalog entry returned by the Media owner.
|
|
|
1255
1277
|
const mediaModels: readonly MediaModel[] = models;
|
|
1256
1278
|
```
|
|
1257
1279
|
|
|
1258
|
-
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).
|
|
1259
1531
|
|
|
1260
1532
|
---
|
|
1261
1533
|
|
|
@@ -1314,26 +1586,31 @@ Quote the same estimate in milliunits (1 cent = 1,000 milliunits).
|
|
|
1314
1586
|
### validateMediaGenerationSettings()
|
|
1315
1587
|
|
|
1316
1588
|
```ts
|
|
1317
|
-
function validateMediaGenerationSettings(
|
|
1589
|
+
function validateMediaGenerationSettings(
|
|
1590
|
+
raw,
|
|
1591
|
+
catalogue?,
|
|
1592
|
+
): MediaGenerationSettings;
|
|
1318
1593
|
```
|
|
1319
1594
|
|
|
1320
|
-
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.
|
|
1321
1597
|
|
|
1322
1598
|
#### Parameters
|
|
1323
1599
|
|
|
1324
|
-
| Parameter | Type | Description |
|
|
1325
|
-
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
|
|
1326
|
-
| `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`[]; \} | - |
|
|
1327
|
-
| `raw.model` | `string` | Provider catalog model identifier. |
|
|
1328
|
-
| `raw.prompt` | `string` | Generation prompt; each model's `maxPromptLength` is enforced on top of this ceiling. |
|
|
1329
|
-
| `raw.width` | `number` | Requested image width or nominal video selector, not decoded MP4 dimensions. |
|
|
1330
|
-
| `raw.height` | `number` | Requested image height or nominal video selector, not decoded MP4 dimensions. |
|
|
1331
|
-
| `raw.steps?` | `number` | Model-specific inference step count. |
|
|
1332
|
-
| `raw.durationSeconds?` | `number` | Requested video length in whole seconds. |
|
|
1333
|
-
| `raw.resolution?` | `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"` | Video resolution; must match the nominal width/height selector. |
|
|
1334
|
-
| `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. |
|
|
1335
|
-
| `raw.generateAudio?` | `boolean` | Video audio selection. |
|
|
1336
|
-
| `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` | - |
|
|
1337
1614
|
|
|
1338
1615
|
#### Returns
|
|
1339
1616
|
|
|
@@ -1346,6 +1623,7 @@ Validate caller settings and apply retained model defaults.
|
|
|
1346
1623
|
```ts
|
|
1347
1624
|
function validateMediaGenerationSelection(
|
|
1348
1625
|
raw,
|
|
1626
|
+
catalogue?,
|
|
1349
1627
|
): Readonly<Omit<MediaGenerationSettings, "references"> & object>;
|
|
1350
1628
|
```
|
|
1351
1629
|
|
|
@@ -1353,19 +1631,20 @@ Validate selections without granting Computer authority.
|
|
|
1353
1631
|
|
|
1354
1632
|
#### Parameters
|
|
1355
1633
|
|
|
1356
|
-
| Parameter | Type | Description |
|
|
1357
|
-
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
|
|
1358
|
-
| `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`[]; \} | - |
|
|
1359
|
-
| `raw.model` | `string` | Provider catalog model identifier. |
|
|
1360
|
-
| `raw.prompt` | `string` | Generation prompt; each model's `maxPromptLength` is enforced on top of this ceiling. |
|
|
1361
|
-
| `raw.width` | `number` | Requested image width or nominal video selector, not decoded MP4 dimensions. |
|
|
1362
|
-
| `raw.height` | `number` | Requested image height or nominal video selector, not decoded MP4 dimensions. |
|
|
1363
|
-
| `raw.steps?` | `number` | Model-specific inference step count. |
|
|
1364
|
-
| `raw.durationSeconds?` | `number` | Requested video length in whole seconds. |
|
|
1365
|
-
| `raw.resolution?` | `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"` | Video resolution; must match the nominal width/height selector. |
|
|
1366
|
-
| `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. |
|
|
1367
|
-
| `raw.generateAudio?` | `boolean` | Video audio selection. |
|
|
1368
|
-
| `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` | - |
|
|
1369
1648
|
|
|
1370
1649
|
#### Returns
|
|
1371
1650
|
|
|
@@ -1377,7 +1656,7 @@ Validate selections without granting Computer authority.
|
|
|
1377
1656
|
### validateMediaVideoSelection()
|
|
1378
1657
|
|
|
1379
1658
|
```ts
|
|
1380
|
-
function validateMediaVideoSelection(raw): MediaVideoSelection;
|
|
1659
|
+
function validateMediaVideoSelection(raw, catalogue?): MediaVideoSelection;
|
|
1381
1660
|
```
|
|
1382
1661
|
|
|
1383
1662
|
Validate supported model/size/duration/reference combinations before authority
|
|
@@ -1385,16 +1664,17 @@ or billing admission.
|
|
|
1385
1664
|
|
|
1386
1665
|
#### Parameters
|
|
1387
1666
|
|
|
1388
|
-
| Parameter | Type
|
|
1389
|
-
| ---------------------- |
|
|
1390
|
-
| `raw` | \{ `
|
|
1391
|
-
| `raw.
|
|
1392
|
-
| `raw.
|
|
1393
|
-
| `raw.
|
|
1394
|
-
| `raw.
|
|
1395
|
-
| `raw.
|
|
1396
|
-
| `raw.
|
|
1397
|
-
| `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` | - |
|
|
1398
1678
|
|
|
1399
1679
|
#### Returns
|
|
1400
1680
|
|
|
@@ -1408,6 +1688,7 @@ or billing admission.
|
|
|
1408
1688
|
function resolveMediaReferences(
|
|
1409
1689
|
settings,
|
|
1410
1690
|
reader,
|
|
1691
|
+
catalogue?,
|
|
1411
1692
|
): Promise<
|
|
1412
1693
|
readonly Readonly<{
|
|
1413
1694
|
bytes: Uint8Array;
|
|
@@ -1423,10 +1704,11 @@ Resolve only provider-accepted references through the caller's reader.
|
|
|
1423
1704
|
|
|
1424
1705
|
#### Parameters
|
|
1425
1706
|
|
|
1426
|
-
| Parameter
|
|
1427
|
-
|
|
|
1428
|
-
| `settings`
|
|
1429
|
-
| `reader`
|
|
1707
|
+
| Parameter | Type | Default value |
|
|
1708
|
+
| ----------- | ----------------------------------------------------- | ------------- |
|
|
1709
|
+
| `settings` | [`MediaGenerationSettings`](#mediagenerationsettings) | `undefined` |
|
|
1710
|
+
| `reader` | [`MediaReferenceReader`](#mediareferencereader) | `undefined` |
|
|
1711
|
+
| `catalogue` | [`MediaCatalogue`](#mediacatalogue) | `mediaModels` |
|
|
1430
1712
|
|
|
1431
1713
|
#### Returns
|
|
1432
1714
|
|
|
@@ -1535,17 +1817,18 @@ Normalize all retained provider envelopes into bounded image bytes.
|
|
|
1535
1817
|
### estimateVideoMilliunits()
|
|
1536
1818
|
|
|
1537
1819
|
```ts
|
|
1538
|
-
function estimateVideoMilliunits(settings): number;
|
|
1820
|
+
function estimateVideoMilliunits(settings, catalogue?): number;
|
|
1539
1821
|
```
|
|
1540
1822
|
|
|
1541
|
-
Provider video cost from
|
|
1823
|
+
Provider video cost from `catalogue`, in milliunits (1 cent = 1,000).
|
|
1542
1824
|
Video-input references are unsupported.
|
|
1543
1825
|
|
|
1544
1826
|
#### Parameters
|
|
1545
1827
|
|
|
1546
|
-
| Parameter
|
|
1547
|
-
|
|
|
1548
|
-
| `settings`
|
|
1828
|
+
| Parameter | Type | Default value |
|
|
1829
|
+
| ----------- | ----------------------------------------------------- | ------------- |
|
|
1830
|
+
| `settings` | [`MediaVideoQuoteSettings`](#mediavideoquotesettings) | `undefined` |
|
|
1831
|
+
| `catalogue` | [`MediaCatalogue`](#mediacatalogue) | `mediaModels` |
|
|
1549
1832
|
|
|
1550
1833
|
#### Returns
|
|
1551
1834
|
|
|
@@ -1553,6 +1836,27 @@ Video-input references are unsupported.
|
|
|
1553
1836
|
|
|
1554
1837
|
---
|
|
1555
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
|
+
|
|
1556
1860
|
### listMediaModels()
|
|
1557
1861
|
|
|
1558
1862
|
```ts
|
|
@@ -1610,7 +1914,7 @@ function listMediaModels(): readonly Readonly<{
|
|
|
1610
1914
|
}>[];
|
|
1611
1915
|
```
|
|
1612
1916
|
|
|
1613
|
-
List
|
|
1917
|
+
List the gateway provider's models in catalog order.
|
|
1614
1918
|
|
|
1615
1919
|
#### Returns
|
|
1616
1920
|
|
|
@@ -1643,10 +1947,10 @@ readonly (`"first-frame"` \| `"last-frame"` \| `"reference"`)[];
|
|
|
1643
1947
|
|
|
1644
1948
|
---
|
|
1645
1949
|
|
|
1646
|
-
###
|
|
1950
|
+
### getGatewayModel()
|
|
1647
1951
|
|
|
1648
1952
|
```ts
|
|
1649
|
-
function
|
|
1953
|
+
function getGatewayModel(id):
|
|
1650
1954
|
| Readonly<{
|
|
1651
1955
|
id: string;
|
|
1652
1956
|
label: string;
|
|
@@ -1703,7 +2007,8 @@ function getMediaModel(id):
|
|
|
1703
2007
|
| undefined;
|
|
1704
2008
|
```
|
|
1705
2009
|
|
|
1706
|
-
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.
|
|
1707
2012
|
|
|
1708
2013
|
#### Parameters
|
|
1709
2014
|
|
|
@@ -1742,6 +2047,110 @@ readonly (`"first-frame"` \| `"last-frame"` \| `"reference"`)[];
|
|
|
1742
2047
|
|
|
1743
2048
|
---
|
|
1744
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
|
+
|
|
1745
2154
|
### neuronsToMilliunits()
|
|
1746
2155
|
|
|
1747
2156
|
```ts
|