@fungi.computer/darkroom 0.0.0-stage → 0.1.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.
Files changed (80) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +315 -2
  3. package/dist/app-media-contracts.d.ts +499 -0
  4. package/dist/app-media-contracts.js +96 -0
  5. package/dist/browser-failure.d.ts +40 -0
  6. package/dist/browser-failure.js +39 -0
  7. package/dist/browser.d.ts +2 -0
  8. package/dist/browser.js +1 -0
  9. package/dist/cloudflare/provider.d.ts +13 -0
  10. package/dist/cloudflare/provider.js +140 -0
  11. package/dist/cloudflare/reference-images.d.ts +42 -0
  12. package/dist/cloudflare/reference-images.js +102 -0
  13. package/dist/cloudflare.d.ts +6 -0
  14. package/dist/cloudflare.js +4 -0
  15. package/dist/cost-estimate.d.ts +22 -0
  16. package/dist/cost-estimate.js +76 -0
  17. package/dist/effect.d.ts +2 -0
  18. package/dist/effect.js +2 -0
  19. package/dist/execution-error.d.ts +54 -0
  20. package/dist/execution-error.js +62 -0
  21. package/dist/failure.d.ts +2 -0
  22. package/dist/failure.js +8 -0
  23. package/dist/gateway-models.d.ts +23 -0
  24. package/dist/gateway-models.js +77 -0
  25. package/dist/gateway-wire.d.ts +16 -0
  26. package/dist/gateway-wire.js +22 -0
  27. package/dist/index.d.ts +361 -0
  28. package/dist/index.js +607 -0
  29. package/dist/media-binding.d.ts +291 -0
  30. package/dist/media-binding.js +149 -0
  31. package/dist/media-generation.d.ts +10 -0
  32. package/dist/media-generation.js +110 -0
  33. package/dist/media-operation-contract.d.ts +104 -0
  34. package/dist/media-operation-contract.js +29 -0
  35. package/dist/media-operation-do.d.ts +55 -0
  36. package/dist/media-operation-do.js +105 -0
  37. package/dist/media-operation-owner.d.ts +301 -0
  38. package/dist/media-operation-owner.js +903 -0
  39. package/dist/media-operation-storage.d.ts +81 -0
  40. package/dist/media-operation-storage.js +1 -0
  41. package/dist/media-operation.d.ts +33 -0
  42. package/dist/media-operation.js +230 -0
  43. package/dist/model-catalog.d.ts +456 -0
  44. package/dist/model-catalog.js +565 -0
  45. package/dist/neurons.d.ts +4 -0
  46. package/dist/neurons.js +4 -0
  47. package/dist/provenance-bytes.d.ts +3 -0
  48. package/dist/provenance-bytes.js +15 -0
  49. package/dist/provenance-export.d.ts +23 -0
  50. package/dist/provenance-export.js +103 -0
  51. package/dist/provenance-jpeg.d.ts +3 -0
  52. package/dist/provenance-jpeg.js +76 -0
  53. package/dist/provenance-png.d.ts +1 -0
  54. package/dist/provenance-png.js +21 -0
  55. package/dist/provenance-xmp.d.ts +2 -0
  56. package/dist/provenance-xmp.js +54 -0
  57. package/dist/provenance.d.ts +20 -0
  58. package/dist/provenance.js +58 -0
  59. package/dist/server.d.ts +158 -0
  60. package/dist/server.js +207 -0
  61. package/dist/video-providers/index.d.ts +14 -0
  62. package/dist/video-providers/index.js +14 -0
  63. package/dist/video-providers/minimax.d.ts +25 -0
  64. package/dist/video-providers/minimax.js +63 -0
  65. package/dist/video-providers/reference-encoding.d.ts +4 -0
  66. package/dist/video-providers/reference-encoding.js +11 -0
  67. package/dist/video-providers/types.d.ts +28 -0
  68. package/dist/video-providers/types.js +1 -0
  69. package/dist/video-providers/unified.d.ts +18 -0
  70. package/dist/video-providers/unified.js +52 -0
  71. package/docs/api/README.md +16 -0
  72. package/docs/api/app-media-contracts.md +507 -0
  73. package/docs/api/browser.md +126 -0
  74. package/docs/api/cloudflare.md +678 -0
  75. package/docs/api/effect.md +39 -0
  76. package/docs/api/index.md +1775 -0
  77. package/docs/api/modules.md +19 -0
  78. package/docs/api/provenance-export.md +114 -0
  79. package/docs/api/server.md +1672 -0
  80. package/package.json +110 -3
@@ -0,0 +1,1775 @@
1
+ <!-- Generated by Botanical API docs (TypeDoc + typedoc-plugin-markdown). Do not edit. -->
2
+
3
+ [**@fungi.computer/darkroom**](README.md)
4
+
5
+ ---
6
+
7
+ [@fungi.computer/darkroom](modules.md) / index
8
+
9
+ # index
10
+
11
+ ## Classes
12
+
13
+ ### MediaSettingsError
14
+
15
+ Invalid generation settings or unsupported model parameters.
16
+
17
+ #### Extends
18
+
19
+ - `Error`
20
+
21
+ #### Constructors
22
+
23
+ ##### Constructor
24
+
25
+ ```ts
26
+ new MediaSettingsError(message): MediaSettingsError;
27
+ ```
28
+
29
+ ###### Parameters
30
+
31
+ | Parameter | Type |
32
+ | --------- | -------- |
33
+ | `message` | `string` |
34
+
35
+ ###### Returns
36
+
37
+ [`MediaSettingsError`](#mediasettingserror)
38
+
39
+ ###### Overrides
40
+
41
+ ```ts
42
+ Error.constructor;
43
+ ```
44
+
45
+ ## Type Aliases
46
+
47
+ ### ImageParams
48
+
49
+ ```ts
50
+ type ImageParams = object;
51
+ ```
52
+
53
+ Dimensions and optional settings used by the deterministic image quote.
54
+
55
+ #### Properties
56
+
57
+ ##### height
58
+
59
+ ```ts
60
+ readonly height: number;
61
+ ```
62
+
63
+ Output height in pixels.
64
+
65
+ ##### references?
66
+
67
+ ```ts
68
+ readonly optional references?: readonly ImageReference[];
69
+ ```
70
+
71
+ Reference dimensions counted in the quote.
72
+
73
+ ##### steps?
74
+
75
+ ```ts
76
+ readonly optional steps?: number;
77
+ ```
78
+
79
+ Inference steps, using catalog defaults when omitted.
80
+
81
+ ##### width
82
+
83
+ ```ts
84
+ readonly width: number;
85
+ ```
86
+
87
+ Output width in pixels.
88
+
89
+ ---
90
+
91
+ ### ImageReference
92
+
93
+ ```ts
94
+ type ImageReference = object;
95
+ ```
96
+
97
+ Reference-image dimensions used to estimate provider work.
98
+
99
+ #### Properties
100
+
101
+ ##### height
102
+
103
+ ```ts
104
+ readonly height: number;
105
+ ```
106
+
107
+ Reference height in pixels.
108
+
109
+ ##### width
110
+
111
+ ```ts
112
+ readonly width: number;
113
+ ```
114
+
115
+ Reference width in pixels.
116
+
117
+ ---
118
+
119
+ ### MediaReference
120
+
121
+ ```ts
122
+ type MediaReference = Readonly<{
123
+ computerId: string;
124
+ path: string;
125
+ role?: MediaVideoReferenceRole;
126
+ }>;
127
+ ```
128
+
129
+ A reference file selected by the host, with its destination identity and path.
130
+
131
+ ---
132
+
133
+ ### ImageFormat
134
+
135
+ ```ts
136
+ type ImageFormat = "png" | "jpeg" | "gif" | "webp";
137
+ ```
138
+
139
+ Supported still-image encodings.
140
+
141
+ ---
142
+
143
+ ### ImageMimeType
144
+
145
+ ```ts
146
+ type ImageMimeType = `image/${ImageFormat}`;
147
+ ```
148
+
149
+ MIME type corresponding to a supported image encoding.
150
+
151
+ ---
152
+
153
+ ### MediaOutputFormat
154
+
155
+ ```ts
156
+ type MediaOutputFormat = ImageFormat | "mp4";
157
+ ```
158
+
159
+ A saved generation: an image, or an MP4 from a video model.
160
+
161
+ ---
162
+
163
+ ### MediaReferenceBytes
164
+
165
+ ```ts
166
+ type MediaReferenceBytes = Readonly<{
167
+ bytes: Uint8Array;
168
+ format: ImageFormat;
169
+ width: number;
170
+ height: number;
171
+ filename?: string;
172
+ }>;
173
+ ```
174
+
175
+ Decoded reference bytes and the dimensions sent to the provider.
176
+
177
+ ---
178
+
179
+ ### MediaGenerationSettings
180
+
181
+ ```ts
182
+ type MediaGenerationSettings = Readonly<{
183
+ model: string;
184
+ prompt: string;
185
+ width: number;
186
+ height: number;
187
+ steps?: number;
188
+ durationSeconds?: number;
189
+ resolution?: MediaVideoResolution;
190
+ aspectRatio?: MediaVideoAspectRatio;
191
+ generateAudio?: boolean;
192
+ references?: readonly MediaReference[];
193
+ }>;
194
+ ```
195
+
196
+ Normalized model settings, including bounded host-selected references.
197
+
198
+ ---
199
+
200
+ ### MediaProvider
201
+
202
+ ```ts
203
+ type MediaProvider = (
204
+ settings,
205
+ references,
206
+ signal?,
207
+ outputFormat?,
208
+ ) => Promise<
209
+ Readonly<{
210
+ bytes: Uint8Array;
211
+ format: string;
212
+ }>
213
+ >;
214
+ ```
215
+
216
+ One Media provider call: validated settings and reference bytes in, output bytes
217
+ out. Hosts may bind it to Workers AI or their own transport.
218
+
219
+ #### Parameters
220
+
221
+ | Parameter | Type |
222
+ | --------------- | -------------------------------------------------------- |
223
+ | `settings` | [`MediaGenerationSettings`](#mediagenerationsettings) |
224
+ | `references` | readonly [`MediaReferenceBytes`](#mediareferencebytes)[] |
225
+ | `signal?` | `AbortSignal` |
226
+ | `outputFormat?` | `"png"` \| `"jpeg"` \| `"webp"` |
227
+
228
+ #### Returns
229
+
230
+ `Promise`\<`Readonly`\<\{ `bytes`: `Uint8Array`; `format`: `string`; \}\>\>
231
+
232
+ ---
233
+
234
+ ### FittedReferenceImage
235
+
236
+ ```ts
237
+ type FittedReferenceImage = Omit<MediaReferenceBytes, "filename">;
238
+ ```
239
+
240
+ A decoded reference image, scaled within MAX_REFERENCE_DIMENSION.
241
+
242
+ ---
243
+
244
+ ### ReferenceImageFitter
245
+
246
+ ```ts
247
+ type ReferenceImageFitter = (bytes) => Promise<FittedReferenceImage>;
248
+ ```
249
+
250
+ Decode one reference image and scale it within Media's dimension bound.
251
+
252
+ #### Parameters
253
+
254
+ | Parameter | Type |
255
+ | --------- | ------------ |
256
+ | `bytes` | `Uint8Array` |
257
+
258
+ #### Returns
259
+
260
+ `Promise`\<[`FittedReferenceImage`](#fittedreferenceimage)\>
261
+
262
+ ---
263
+
264
+ ### ImageViewFitter
265
+
266
+ ```ts
267
+ type ImageViewFitter = (bytes, maxDimension) => Promise<FittedReferenceImage>;
268
+ ```
269
+
270
+ Decode one image and re-encode it for a model to look at: scaled within
271
+ `maxDimension` on the long edge (bounded by
272
+ [viewDimensionSchema](#viewdimensionschema)) as a lossy JPEG, so a viewer can
273
+ step the dimension down to meet a byte budget.
274
+
275
+ #### Parameters
276
+
277
+ | Parameter | Type |
278
+ | -------------- | ------------ |
279
+ | `bytes` | `Uint8Array` |
280
+ | `maxDimension` | `number` |
281
+
282
+ #### Returns
283
+
284
+ `Promise`\<[`FittedReferenceImage`](#fittedreferenceimage)\>
285
+
286
+ ---
287
+
288
+ ### MediaGenerationSettingsInput
289
+
290
+ ```ts
291
+ type MediaGenerationSettingsInput = z.input<
292
+ typeof mediaGenerationSettingsSchema
293
+ >;
294
+ ```
295
+
296
+ Caller settings before model defaults and refinements are applied.
297
+
298
+ ---
299
+
300
+ ### MediaGenerationSelection
301
+
302
+ ```ts
303
+ type MediaGenerationSelection = z.output<typeof mediaGenerationSelectionSchema>;
304
+ ```
305
+
306
+ Generation settings with reference paths resolved by an admitting host.
307
+
308
+ ---
309
+
310
+ ### MediaVideoReference
311
+
312
+ ```ts
313
+ type MediaVideoReference = z.output<typeof mediaVideoReferenceSchema>;
314
+ ```
315
+
316
+ One path-only video reference.
317
+
318
+ ---
319
+
320
+ ### MediaVideoSelectionInput
321
+
322
+ ```ts
323
+ type MediaVideoSelectionInput = z.input<typeof mediaVideoSelectionSchema>;
324
+ ```
325
+
326
+ Caller video selection before defaults and model-specific refinements.
327
+
328
+ ---
329
+
330
+ ### MediaVideoSelection
331
+
332
+ ```ts
333
+ type MediaVideoSelection = Readonly<{
334
+ model: MediaVideoModelId;
335
+ prompt: string;
336
+ width: number;
337
+ height: number;
338
+ resolution: MediaVideoResolution;
339
+ aspectRatio: MediaVideoAspectRatio;
340
+ durationSeconds: number;
341
+ generateAudio?: boolean;
342
+ references?: readonly Readonly<MediaVideoReference>[];
343
+ }>;
344
+ ```
345
+
346
+ Normalized path-only video settings, ready for host-authorized reference
347
+ hydration.
348
+
349
+ ---
350
+
351
+ ### MediaReferenceReader
352
+
353
+ ```ts
354
+ type MediaReferenceReader = Readonly<{
355
+ read: (reference) => Promise<MediaReferenceBytes>;
356
+ }>;
357
+ ```
358
+
359
+ Host-authorized reader for decoded reference images.
360
+
361
+ ---
362
+
363
+ ### MediaJsonBody
364
+
365
+ ```ts
366
+ type MediaJsonBody = Readonly<{
367
+ prompt: string;
368
+ width?: number;
369
+ height?: number;
370
+ steps?: number;
371
+ num_steps?: number;
372
+ }>;
373
+ ```
374
+
375
+ Provider JSON image input for models without multipart references.
376
+
377
+ ---
378
+
379
+ ### MediaProviderPayload
380
+
381
+ ```ts
382
+ type MediaProviderPayload =
383
+ | Readonly<{
384
+ transport: "json";
385
+ body: MediaJsonBody;
386
+ }>
387
+ | Readonly<{
388
+ transport: "multipart";
389
+ body: FormData;
390
+ }>;
391
+ ```
392
+
393
+ A model-specific JSON body or multipart form ready for transport.
394
+
395
+ ---
396
+
397
+ ### MediaProviderImageEntry
398
+
399
+ ```ts
400
+ type MediaProviderImageEntry = Readonly<{
401
+ base64?: string;
402
+ data?: string;
403
+ url?: string;
404
+ }>;
405
+ ```
406
+
407
+ One image in a provider envelope, encoded inline or available at a URL.
408
+
409
+ ---
410
+
411
+ ### MediaProviderOutput
412
+
413
+ ```ts
414
+ type MediaProviderOutput =
415
+ | Readonly<{
416
+ kind: "bytes";
417
+ bytes: Uint8Array;
418
+ }>
419
+ | Readonly<{
420
+ kind: "response";
421
+ response: Response;
422
+ }>
423
+ | Readonly<{
424
+ kind: "encoded";
425
+ encoded: string;
426
+ }>
427
+ | Readonly<{
428
+ kind: "entries";
429
+ entries: readonly MediaProviderImageEntry[];
430
+ }>;
431
+ ```
432
+
433
+ Parsed provider representation before conversion to bounded image bytes.
434
+
435
+ ---
436
+
437
+ ### MediaProviderWire
438
+
439
+ ```ts
440
+ type MediaProviderWire = z.output<typeof mediaProviderWireSchema>;
441
+ ```
442
+
443
+ Supported raw provider representations, decoded by mediaProviderWireSchema.
444
+
445
+ ---
446
+
447
+ ### MediaProviderOutputOptions
448
+
449
+ ```ts
450
+ type MediaProviderOutputOptions = Readonly<{
451
+ fetchUrl?: (url) => Promise<Response>;
452
+ maxBytes?: number;
453
+ }>;
454
+ ```
455
+
456
+ Host-supplied URL fetching and maximum output bytes for normalization.
457
+
458
+ ---
459
+
460
+ ### MediaImageOutput
461
+
462
+ ```ts
463
+ type MediaImageOutput = Readonly<{
464
+ bytes: Uint8Array;
465
+ format: ImageFormat;
466
+ }>;
467
+ ```
468
+
469
+ Normalized bytes and their supported still-image encoding.
470
+
471
+ ---
472
+
473
+ ### MediaVideoQuoteSettings
474
+
475
+ ```ts
476
+ type MediaVideoQuoteSettings = ReturnType<
477
+ typeof validateMediaGenerationSelection
478
+ >;
479
+ ```
480
+
481
+ Authority-free video quote settings; hydrated host settings are structurally
482
+ compatible.
483
+
484
+ ---
485
+
486
+ ### MediaModelTier
487
+
488
+ ```ts
489
+ type MediaModelTier = z.output<typeof mediaModelTierSchema>;
490
+ ```
491
+
492
+ A model selection tier, independent of billing price.
493
+
494
+ ---
495
+
496
+ ### MediaVideoModelId
497
+
498
+ ```ts
499
+ type MediaVideoModelId = z.output<typeof mediaVideoModelIdSchema>;
500
+ ```
501
+
502
+ Verified video model identifier.
503
+
504
+ ---
505
+
506
+ ### MediaVideoResolution
507
+
508
+ ```ts
509
+ type MediaVideoResolution = z.output<typeof mediaVideoResolutionSchema>;
510
+ ```
511
+
512
+ A video resolution selector.
513
+
514
+ ---
515
+
516
+ ### MediaVideoAspectRatio
517
+
518
+ ```ts
519
+ type MediaVideoAspectRatio = z.output<typeof mediaVideoAspectRatioSchema>;
520
+ ```
521
+
522
+ A video aspect selector.
523
+
524
+ ---
525
+
526
+ ### MediaVideoReferenceRole
527
+
528
+ ```ts
529
+ type MediaVideoReferenceRole = z.output<typeof mediaVideoReferenceRoleSchema>;
530
+ ```
531
+
532
+ The role of a selected reference image in a video request.
533
+
534
+ ---
535
+
536
+ ### MediaVideoFormat
537
+
538
+ ```ts
539
+ type MediaVideoFormat = z.output<typeof mediaVideoFormatSchema>;
540
+ ```
541
+
542
+ One immutable nominal video format.
543
+
544
+ ---
545
+
546
+ ### MediaVideoModel
547
+
548
+ ```ts
549
+ type MediaVideoModel = z.output<typeof mediaVideoSchema>;
550
+ ```
551
+
552
+ Immutable video capability and price metadata.
553
+
554
+ ---
555
+
556
+ ### MediaModelInput
557
+
558
+ ```ts
559
+ type MediaModelInput = z.output<typeof mediaModelInputSchema>;
560
+ ```
561
+
562
+ Model-specific dimensions, steps, transport and reference limits.
563
+
564
+ ---
565
+
566
+ ### MediaModel
567
+
568
+ ```ts
569
+ type MediaModel = z.output<typeof mediaModelSchema>;
570
+ ```
571
+
572
+ One immutable provider catalog entry.
573
+
574
+ ## Variables
575
+
576
+ ### mediaFailureStageSchema
577
+
578
+ ```ts
579
+ const mediaFailureStageSchema: ZodEnum<{
580
+ admission: "admission";
581
+ generation-authorization: "generation-authorization";
582
+ settings: "settings";
583
+ estimate: "estimate";
584
+ billing: "billing";
585
+ operation: "operation";
586
+ provider: "provider";
587
+ normalization: "normalization";
588
+ artifact: "artifact";
589
+ destination-authorization: "destination-authorization";
590
+ destination-write: "destination-write";
591
+ }>;
592
+ ```
593
+
594
+ Public diagnostic labels only; never provider messages or request data.
595
+
596
+ ---
597
+
598
+ ### MIN\_VIEW\_DIMENSION
599
+
600
+ ```ts
601
+ const MIN_VIEW_DIMENSION: 256 = 256;
602
+ ```
603
+
604
+ The long-edge bounds a viewer may ask for when fitting an image to look at.
605
+
606
+ ---
607
+
608
+ ### MAX\_VIEW\_DIMENSION
609
+
610
+ ```ts
611
+ const MAX_VIEW_DIMENSION: 512 = 512;
612
+ ```
613
+
614
+ Maximum long-edge size accepted by an image viewer, in pixels.
615
+
616
+ ---
617
+
618
+ ### viewDimensionSchema
619
+
620
+ ```ts
621
+ const viewDimensionSchema: ZodNumber;
622
+ ```
623
+
624
+ Decode a viewer long-edge size within the supported pixel bounds.
625
+
626
+ ---
627
+
628
+ ### MAX\_REFERENCE\_COUNT
629
+
630
+ ```ts
631
+ const MAX_REFERENCE_COUNT: 4 = 4;
632
+ ```
633
+
634
+ Maximum reference files in one generation request.
635
+
636
+ ---
637
+
638
+ ### MAX\_REFERENCE\_DIMENSION
639
+
640
+ ```ts
641
+ const MAX_REFERENCE_DIMENSION: 512 = 512;
642
+ ```
643
+
644
+ Maximum reference width and height sent to inference, in pixels.
645
+
646
+ ---
647
+
648
+ ### MAX\_REFERENCE\_BYTES
649
+
650
+ ```ts
651
+ const MAX_REFERENCE_BYTES: number;
652
+ ```
653
+
654
+ Maximum decoded bytes per reference image.
655
+
656
+ ---
657
+
658
+ ### MAX\_OUTPUT\_BYTES
659
+
660
+ ```ts
661
+ const MAX_OUTPUT_BYTES: number;
662
+ ```
663
+
664
+ Maximum retained still-image output bytes.
665
+
666
+ ---
667
+
668
+ ### mediaGenerationSettingsSchema
669
+
670
+ ```ts
671
+ const mediaGenerationSettingsSchema: ZodObject<
672
+ {
673
+ model: ZodString;
674
+ prompt: ZodString;
675
+ width: ZodNumber;
676
+ height: ZodNumber;
677
+ steps: ZodOptional<ZodNumber>;
678
+ durationSeconds: ZodOptional<ZodNumber>;
679
+ resolution: ZodOptional<
680
+ ZodEnum<{
681
+ p480: "480p";
682
+ p720: "720p";
683
+ p1080: "1080p";
684
+ p4k: "4k";
685
+ }>
686
+ >;
687
+ aspectRatio: ZodOptional<
688
+ ZodEnum<{
689
+ wide: "16:9";
690
+ landscape: "4:3";
691
+ square: "1:1";
692
+ portrait: "3:4";
693
+ tall: "9:16";
694
+ ultrawide: "21:9";
695
+ ultratall: "9:21";
696
+ }>
697
+ >;
698
+ generateAudio: ZodOptional<ZodBoolean>;
699
+ references: ZodOptional<
700
+ ZodArray<
701
+ ZodObject<
702
+ {
703
+ computerId: ZodString;
704
+ path: ZodString;
705
+ role: ZodOptional<
706
+ ZodEnum<{
707
+ first: "first-frame";
708
+ last: "last-frame";
709
+ reference: "reference";
710
+ }>
711
+ >;
712
+ },
713
+ $strict
714
+ >
715
+ >
716
+ >;
717
+ },
718
+ $strict
719
+ >;
720
+ ```
721
+
722
+ Structural wire grammar for one Media generation request.
723
+
724
+ ---
725
+
726
+ ### mediaGenerationSelectionSchema
727
+
728
+ ```ts
729
+ const mediaGenerationSelectionSchema: ZodObject<
730
+ {
731
+ model: ZodString;
732
+ prompt: ZodString;
733
+ width: ZodNumber;
734
+ height: ZodNumber;
735
+ steps: ZodOptional<ZodNumber>;
736
+ durationSeconds: ZodOptional<ZodNumber>;
737
+ resolution: ZodOptional<
738
+ ZodEnum<{
739
+ p480: "480p";
740
+ p720: "720p";
741
+ p1080: "1080p";
742
+ p4k: "4k";
743
+ }>
744
+ >;
745
+ aspectRatio: ZodOptional<
746
+ ZodEnum<{
747
+ wide: "16:9";
748
+ landscape: "4:3";
749
+ square: "1:1";
750
+ portrait: "3:4";
751
+ tall: "9:16";
752
+ ultrawide: "21:9";
753
+ ultratall: "9:21";
754
+ }>
755
+ >;
756
+ generateAudio: ZodOptional<ZodBoolean>;
757
+ references: ZodOptional<
758
+ ZodArray<
759
+ ZodObject<
760
+ {
761
+ path: ZodString;
762
+ role: ZodOptional<
763
+ ZodEnum<{
764
+ first: "first-frame";
765
+ last: "last-frame";
766
+ reference: "reference";
767
+ }>
768
+ >;
769
+ },
770
+ $strict
771
+ >
772
+ >
773
+ >;
774
+ },
775
+ $strict
776
+ >;
777
+ ```
778
+
779
+ App selections contain paths; the host supplies the admitted Computer.
780
+
781
+ ---
782
+
783
+ ### mediaVideoReferenceSchema
784
+
785
+ ```ts
786
+ const mediaVideoReferenceSchema: ZodObject<
787
+ {
788
+ path: ZodString;
789
+ role: ZodEnum<{
790
+ first: "first-frame";
791
+ last: "last-frame";
792
+ reference: "reference";
793
+ }>;
794
+ },
795
+ $strict
796
+ >;
797
+ ```
798
+
799
+ Path-only video reference; the host supplies authority and reads its bytes.
800
+
801
+ ---
802
+
803
+ ### mediaVideoSelectionSchema
804
+
805
+ ```ts
806
+ const mediaVideoSelectionSchema: ZodObject<
807
+ {
808
+ model: ZodEnum<{
809
+ seedance: "bytedance/seedance-2.0";
810
+ seedanceFast: "bytedance/seedance-2.0-fast";
811
+ seedanceMini: "bytedance/seedance-2.0-mini";
812
+ veo: "google/veo-3.1";
813
+ veoFast: "google/veo-3.1-fast";
814
+ }>;
815
+ prompt: ZodString;
816
+ resolution: ZodOptional<
817
+ ZodEnum<{
818
+ p480: "480p";
819
+ p720: "720p";
820
+ p1080: "1080p";
821
+ p4k: "4k";
822
+ }>
823
+ >;
824
+ aspectRatio: ZodOptional<
825
+ ZodEnum<{
826
+ wide: "16:9";
827
+ landscape: "4:3";
828
+ square: "1:1";
829
+ portrait: "3:4";
830
+ tall: "9:16";
831
+ ultrawide: "21:9";
832
+ ultratall: "9:21";
833
+ }>
834
+ >;
835
+ durationSeconds: ZodOptional<ZodNumber>;
836
+ generateAudio: ZodOptional<ZodBoolean>;
837
+ references: ZodOptional<
838
+ ZodArray<
839
+ ZodObject<
840
+ {
841
+ path: ZodString;
842
+ role: ZodEnum<{
843
+ first: "first-frame";
844
+ last: "last-frame";
845
+ reference: "reference";
846
+ }>;
847
+ },
848
+ $strict
849
+ >
850
+ >
851
+ >;
852
+ },
853
+ $strict
854
+ >;
855
+ ```
856
+
857
+ Neutral video selection; model-specific combinations are checked by
858
+ validateMediaVideoSelection.
859
+
860
+ ---
861
+
862
+ ### mediaProviderWireSchema
863
+
864
+ ```ts
865
+ const mediaProviderWireSchema: ZodUnion<
866
+ readonly [
867
+ ZodUnion<
868
+ readonly [
869
+ ZodObject<
870
+ {
871
+ image: ZodString;
872
+ },
873
+ $strip
874
+ >,
875
+ ZodObject<
876
+ {
877
+ image: ZodArray<
878
+ ZodObject<
879
+ {
880
+ base64: ZodOptional<ZodString>;
881
+ data: ZodOptional<ZodString>;
882
+ url: ZodOptional<ZodURL>;
883
+ },
884
+ $strict
885
+ >
886
+ >;
887
+ },
888
+ $strip
889
+ >,
890
+ ZodObject<
891
+ {
892
+ images: ZodArray<
893
+ ZodObject<
894
+ {
895
+ base64: ZodOptional<ZodString>;
896
+ data: ZodOptional<ZodString>;
897
+ url: ZodOptional<ZodURL>;
898
+ },
899
+ $strict
900
+ >
901
+ >;
902
+ },
903
+ $strip
904
+ >,
905
+ ]
906
+ >,
907
+ ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>,
908
+ ZodCustom<Response, Response>,
909
+ ZodCustom<
910
+ ReadableStream<Uint8Array<ArrayBufferLike>>,
911
+ ReadableStream<Uint8Array<ArrayBufferLike>>
912
+ >,
913
+ ]
914
+ >;
915
+ ```
916
+
917
+ Decode the Workers AI binding's raw output at the provider boundary.
918
+
919
+ ---
920
+
921
+ ### mediaRequestedImageFormatSchema
922
+
923
+ ```ts
924
+ const mediaRequestedImageFormatSchema: ZodEnum<{
925
+ png: "png";
926
+ jpeg: "jpeg";
927
+ webp: "webp";
928
+ }>;
929
+ ```
930
+
931
+ An explicitly requested image encoding; video is outside this contract.
932
+
933
+ ---
934
+
935
+ ### mediaModelTierSchema
936
+
937
+ ```ts
938
+ const mediaModelTierSchema: ZodEnum<{
939
+ draft: "draft";
940
+ balanced: "balanced";
941
+ premium: "premium";
942
+ max: "max";
943
+ }>;
944
+ ```
945
+
946
+ Agent-facing selection tier: cheap/fast draft work, the balanced default,
947
+ premium for art the user will see, and max for the most expensive models. One
948
+ value per model; never a price.
949
+
950
+ ---
951
+
952
+ ### mediaModelInputSchema
953
+
954
+ ```ts
955
+ const mediaModelInputSchema: ZodReadonly<
956
+ ZodObject<
957
+ {
958
+ transport: ZodEnum<{
959
+ json: "json";
960
+ multipart: "multipart";
961
+ }>;
962
+ dimensions: ZodEnum<{
963
+ none: "none";
964
+ own: "own";
965
+ }>;
966
+ maxDimension: ZodNullable<ZodNumber>;
967
+ defaultWidth: ZodNumber;
968
+ defaultHeight: ZodNumber;
969
+ steps: ZodEnum<{
970
+ steps: "steps";
971
+ num_steps: "num_steps";
972
+ fixed: "fixed";
973
+ }>;
974
+ maxSteps: ZodNullable<ZodNumber>;
975
+ defaultSteps: ZodNullable<ZodNumber>;
976
+ referenceField: ZodNullable<ZodString>;
977
+ maxReferences: ZodNumber;
978
+ },
979
+ $strict
980
+ >
981
+ >;
982
+ ```
983
+
984
+ Media's provider catalog: Workers AI images plus gateway image and video models.
985
+
986
+ ---
987
+
988
+ ### mediaVideoModelIdSchema
989
+
990
+ ```ts
991
+ const mediaVideoModelIdSchema: ZodEnum<{
992
+ seedance: "bytedance/seedance-2.0";
993
+ seedanceFast: "bytedance/seedance-2.0-fast";
994
+ seedanceMini: "bytedance/seedance-2.0-mini";
995
+ veo: "google/veo-3.1";
996
+ veoFast: "google/veo-3.1-fast";
997
+ }>;
998
+ ```
999
+
1000
+ Verified Unified AI video identifiers; no inferred family aliases.
1001
+
1002
+ ---
1003
+
1004
+ ### mediaVideoResolutionSchema
1005
+
1006
+ ```ts
1007
+ const mediaVideoResolutionSchema: ZodEnum<{
1008
+ p480: "480p";
1009
+ p720: "720p";
1010
+ p1080: "1080p";
1011
+ p4k: "4k";
1012
+ }>;
1013
+ ```
1014
+
1015
+ Provider resolution selectors, refined against the selected catalog entry.
1016
+
1017
+ ---
1018
+
1019
+ ### mediaVideoAspectRatioSchema
1020
+
1021
+ ```ts
1022
+ const mediaVideoAspectRatioSchema: ZodEnum<{
1023
+ wide: "16:9";
1024
+ landscape: "4:3";
1025
+ square: "1:1";
1026
+ portrait: "3:4";
1027
+ tall: "9:16";
1028
+ ultrawide: "21:9";
1029
+ ultratall: "9:21";
1030
+ }>;
1031
+ ```
1032
+
1033
+ Documented video aspect selectors, refined per model.
1034
+
1035
+ ---
1036
+
1037
+ ### mediaVideoReferenceRoleSchema
1038
+
1039
+ ```ts
1040
+ const mediaVideoReferenceRoleSchema: ZodEnum<{
1041
+ first: "first-frame";
1042
+ last: "last-frame";
1043
+ reference: "reference";
1044
+ }>;
1045
+ ```
1046
+
1047
+ Explicit reference meaning; frame mode and reference mode are exclusive.
1048
+
1049
+ ---
1050
+
1051
+ ### mediaVideoFormatSchema
1052
+
1053
+ ```ts
1054
+ const mediaVideoFormatSchema: ZodReadonly<
1055
+ ZodObject<
1056
+ {
1057
+ resolution: ZodEnum<{
1058
+ p480: "480p";
1059
+ p720: "720p";
1060
+ p1080: "1080p";
1061
+ p4k: "4k";
1062
+ }>;
1063
+ aspectRatio: ZodEnum<{
1064
+ wide: "16:9";
1065
+ landscape: "4:3";
1066
+ square: "1:1";
1067
+ portrait: "3:4";
1068
+ tall: "9:16";
1069
+ ultrawide: "21:9";
1070
+ ultratall: "9:21";
1071
+ }>;
1072
+ width: ZodNumber;
1073
+ height: ZodNumber;
1074
+ },
1075
+ $strict
1076
+ >
1077
+ >;
1078
+ ```
1079
+
1080
+ One nominal size used to select provider resolution and aspect.
1081
+
1082
+ ---
1083
+
1084
+ ### mediaVideoSchema
1085
+
1086
+ ```ts
1087
+ const mediaVideoSchema: ZodReadonly<
1088
+ ZodObject<
1089
+ {
1090
+ minSeconds: ZodNumber;
1091
+ maxSeconds: ZodNumber;
1092
+ defaultSeconds: ZodNumber;
1093
+ durations: ZodReadonly<ZodArray<ZodNumber>>;
1094
+ provider: ZodEnum<{
1095
+ seedance: "seedance";
1096
+ veo: "veo";
1097
+ }>;
1098
+ formats: ZodReadonly<
1099
+ ZodArray<
1100
+ ZodReadonly<
1101
+ ZodObject<
1102
+ {
1103
+ resolution: ZodEnum<{
1104
+ p480: "480p";
1105
+ p720: "720p";
1106
+ p1080: "1080p";
1107
+ p4k: "4k";
1108
+ }>;
1109
+ aspectRatio: ZodEnum<{
1110
+ wide: "16:9";
1111
+ landscape: "4:3";
1112
+ square: "1:1";
1113
+ portrait: "3:4";
1114
+ tall: "9:16";
1115
+ ultrawide: "21:9";
1116
+ ultratall: "9:21";
1117
+ }>;
1118
+ width: ZodNumber;
1119
+ height: ZodNumber;
1120
+ },
1121
+ $strict
1122
+ >
1123
+ >
1124
+ >
1125
+ >;
1126
+ defaultResolution: ZodEnum<{
1127
+ p480: "480p";
1128
+ p720: "720p";
1129
+ p1080: "1080p";
1130
+ p4k: "4k";
1131
+ }>;
1132
+ defaultAspectRatio: ZodEnum<{
1133
+ wide: "16:9";
1134
+ landscape: "4:3";
1135
+ square: "1:1";
1136
+ portrait: "3:4";
1137
+ tall: "9:16";
1138
+ ultrawide: "21:9";
1139
+ ultratall: "9:21";
1140
+ }>;
1141
+ defaultGenerateAudio: ZodNullable<ZodBoolean>;
1142
+ maxPromptLength: ZodNumber;
1143
+ referenceRoles: ZodReadonly<
1144
+ ZodArray<
1145
+ ZodEnum<{
1146
+ first: "first-frame";
1147
+ last: "last-frame";
1148
+ reference: "reference";
1149
+ }>
1150
+ >
1151
+ >;
1152
+ maxReferenceImages: ZodNumber;
1153
+ referenceResolutions: ZodReadonly<
1154
+ ZodArray<
1155
+ ZodEnum<{
1156
+ p480: "480p";
1157
+ p720: "720p";
1158
+ p1080: "1080p";
1159
+ p4k: "4k";
1160
+ }>
1161
+ >
1162
+ >;
1163
+ prices: ZodReadonly<
1164
+ ZodArray<
1165
+ ZodReadonly<
1166
+ ZodObject<
1167
+ {
1168
+ resolution: ZodEnum<{
1169
+ p480: "480p";
1170
+ p720: "720p";
1171
+ p1080: "1080p";
1172
+ p4k: "4k";
1173
+ }>;
1174
+ silentMilliunitsPerSecond: ZodNumber;
1175
+ audioMilliunitsPerSecond: ZodNumber;
1176
+ },
1177
+ $strict
1178
+ >
1179
+ >
1180
+ >
1181
+ >;
1182
+ },
1183
+ $strict
1184
+ >
1185
+ >;
1186
+ ```
1187
+
1188
+ Verified video parameters and provider costs, checked 2026-10-11.
1189
+
1190
+ ---
1191
+
1192
+ ### mediaModelSchema
1193
+
1194
+ ```ts
1195
+ const mediaModelSchema: ZodReadonly<ZodObject<{
1196
+ id: ZodString;
1197
+ label: ZodString;
1198
+ kind: ZodEnum<{
1199
+ image: "image";
1200
+ video: "video";
1201
+ }>;
1202
+ tier: ZodEnum<{
1203
+ draft: "draft";
1204
+ balanced: "balanced";
1205
+ premium: "premium";
1206
+ max: "max";
1207
+ }>;
1208
+ outputFormats: ZodReadonly<ZodArray<ZodEnum<{
1209
+ png: "png";
1210
+ jpeg: "jpeg";
1211
+ webp: "webp";
1212
+ }>>>;
1213
+ input: ZodReadonly<ZodObject<{
1214
+ transport: ZodEnum<{
1215
+ json: "json";
1216
+ multipart: "multipart";
1217
+ }>;
1218
+ dimensions: ZodEnum<{
1219
+ none: "none";
1220
+ own: "own";
1221
+ }>;
1222
+ maxDimension: ZodNullable<ZodNumber>;
1223
+ defaultWidth: ZodNumber;
1224
+ defaultHeight: ZodNumber;
1225
+ steps: ZodEnum<{
1226
+ steps: "steps";
1227
+ num_steps: "num_steps";
1228
+ fixed: "fixed";
1229
+ }>;
1230
+ maxSteps: ZodNullable<ZodNumber>;
1231
+ defaultSteps: ZodNullable<ZodNumber>;
1232
+ referenceField: ZodNullable<ZodString>;
1233
+ maxReferences: ZodNumber;
1234
+ }, $strict>>;
1235
+ sizes: ZodNullable<ZodReadonly<ZodArray<ZodString>>>;
1236
+ video: ZodNullable<ZodReadonly<ZodObject<{
1237
+ minSeconds: ZodNumber;
1238
+ maxSeconds: ZodNumber;
1239
+ defaultSeconds: ZodNumber;
1240
+ durations: ZodReadonly<ZodArray<ZodNumber>>;
1241
+ provider: ZodEnum<{
1242
+ seedance: "seedance";
1243
+ veo: "veo";
1244
+ }>;
1245
+ formats: ZodReadonly<ZodArray<ZodReadonly<ZodObject<..., ...>>>>;
1246
+ defaultResolution: ZodEnum<{
1247
+ p480: "480p";
1248
+ p720: "720p";
1249
+ p1080: "1080p";
1250
+ p4k: "4k";
1251
+ }>;
1252
+ defaultAspectRatio: ZodEnum<{
1253
+ wide: "16:9";
1254
+ landscape: "4:3";
1255
+ square: "1:1";
1256
+ portrait: "3:4";
1257
+ tall: "9:16";
1258
+ ultrawide: "21:9";
1259
+ ultratall: "9:21";
1260
+ }>;
1261
+ defaultGenerateAudio: ZodNullable<ZodBoolean>;
1262
+ maxPromptLength: ZodNumber;
1263
+ referenceRoles: ZodReadonly<ZodArray<ZodEnum<{
1264
+ first: ...;
1265
+ last: ...;
1266
+ reference: ...;
1267
+ }>>>;
1268
+ maxReferenceImages: ZodNumber;
1269
+ referenceResolutions: ZodReadonly<ZodArray<ZodEnum<{
1270
+ p480: ...;
1271
+ p720: ...;
1272
+ p1080: ...;
1273
+ p4k: ...;
1274
+ }>>>;
1275
+ prices: ZodReadonly<ZodArray<ZodReadonly<ZodObject<..., ...>>>>;
1276
+ }, $strict>>>;
1277
+ }, $strict>>;
1278
+ ```
1279
+
1280
+ Public wire grammar for a catalog entry returned by the Media owner.
1281
+
1282
+ ---
1283
+
1284
+ ### mediaModels
1285
+
1286
+ ```ts
1287
+ const mediaModels: readonly MediaModel[] = models;
1288
+ ```
1289
+
1290
+ The immutable image and video model catalog.
1291
+
1292
+ ---
1293
+
1294
+ ### USD\_PER\_1K\_NEURONS
1295
+
1296
+ ```ts
1297
+ const USD_PER_1K_NEURONS: 0.011 = 0.011;
1298
+ ```
1299
+
1300
+ Published Workers AI image rate: $0.011 per 1,000 neurons.
1301
+
1302
+ ## Functions
1303
+
1304
+ ### estimateImageNeurons()
1305
+
1306
+ ```ts
1307
+ function estimateImageNeurons(modelId, params): number;
1308
+ ```
1309
+
1310
+ Estimate Workers AI neurons from a validated image request.
1311
+
1312
+ #### Parameters
1313
+
1314
+ | Parameter | Type |
1315
+ | --------- | ----------------------------- |
1316
+ | `modelId` | `string` |
1317
+ | `params` | [`ImageParams`](#imageparams) |
1318
+
1319
+ #### Returns
1320
+
1321
+ `number`
1322
+
1323
+ ---
1324
+
1325
+ ### estimateImageMilliunits()
1326
+
1327
+ ```ts
1328
+ function estimateImageMilliunits(modelId, params): number;
1329
+ ```
1330
+
1331
+ Quote the same estimate in milliunits (1 cent = 1,000 milliunits).
1332
+
1333
+ #### Parameters
1334
+
1335
+ | Parameter | Type |
1336
+ | --------- | ----------------------------- |
1337
+ | `modelId` | `string` |
1338
+ | `params` | [`ImageParams`](#imageparams) |
1339
+
1340
+ #### Returns
1341
+
1342
+ `number`
1343
+
1344
+ ---
1345
+
1346
+ ### validateMediaGenerationSettings()
1347
+
1348
+ ```ts
1349
+ function validateMediaGenerationSettings(raw): MediaGenerationSettings;
1350
+ ```
1351
+
1352
+ Validate caller settings and apply retained model defaults.
1353
+
1354
+ #### Parameters
1355
+
1356
+ | Parameter | Type | Description |
1357
+ | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
1358
+ | `raw` | \{ `model`: `string`; `prompt`: `string`; `width`: `number`; `height`: `number`; `steps?`: `number`; `durationSeconds?`: `number`; `resolution?`: `"480p"` \| `"720p"` \| `"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. |
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"` \| `"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. |
1369
+
1370
+ #### Returns
1371
+
1372
+ [`MediaGenerationSettings`](#mediagenerationsettings)
1373
+
1374
+ ---
1375
+
1376
+ ### validateMediaGenerationSelection()
1377
+
1378
+ ```ts
1379
+ function validateMediaGenerationSelection(
1380
+ raw,
1381
+ ): Readonly<Omit<MediaGenerationSettings, "references"> & object>;
1382
+ ```
1383
+
1384
+ Validate path-only selections without inventing a Computer identity.
1385
+
1386
+ #### Parameters
1387
+
1388
+ | Parameter | Type | Description |
1389
+ | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
1390
+ | `raw` | \{ `model`: `string`; `prompt`: `string`; `width`: `number`; `height`: `number`; `steps?`: `number`; `durationSeconds?`: `number`; `resolution?`: `"480p"` \| `"720p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `generateAudio?`: `boolean`; `references?`: `object`[]; \} | - |
1391
+ | `raw.model` | `string` | Provider catalog model identifier. |
1392
+ | `raw.prompt` | `string` | Generation prompt. |
1393
+ | `raw.width` | `number` | Requested image width or nominal video selector, not decoded MP4 dimensions. |
1394
+ | `raw.height` | `number` | Requested image height or nominal video selector, not decoded MP4 dimensions. |
1395
+ | `raw.steps?` | `number` | Model-specific inference step count. |
1396
+ | `raw.durationSeconds?` | `number` | Requested video length in whole seconds. |
1397
+ | `raw.resolution?` | `"480p"` \| `"720p"` \| `"1080p"` \| `"4k"` | Video resolution; must match the nominal width/height selector. |
1398
+ | `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. |
1399
+ | `raw.generateAudio?` | `boolean` | Video audio selection. |
1400
+ | `raw.references?` | `object`[] | Host-authorized reference images. |
1401
+
1402
+ #### Returns
1403
+
1404
+ `Readonly`\<`Omit`\<[`MediaGenerationSettings`](#mediagenerationsettings),
1405
+ `"references"`\> & `object`\>
1406
+
1407
+ ---
1408
+
1409
+ ### validateMediaVideoSelection()
1410
+
1411
+ ```ts
1412
+ function validateMediaVideoSelection(raw): MediaVideoSelection;
1413
+ ```
1414
+
1415
+ Validate supported model/size/duration/reference combinations before authority
1416
+ or billing admission.
1417
+
1418
+ #### Parameters
1419
+
1420
+ | Parameter | Type | Description |
1421
+ | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
1422
+ | `raw` | \{ `model`: \| `"bytedance/seedance-2.0"` \| `"bytedance/seedance-2.0-fast"` \| `"bytedance/seedance-2.0-mini"` \| `"google/veo-3.1"` \| `"google/veo-3.1-fast"`; `prompt`: `string`; `resolution?`: `"480p"` \| `"720p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `durationSeconds?`: `number`; `generateAudio?`: `boolean`; `references?`: `object`[]; \} | - |
1423
+ | `raw.model` | \| `"bytedance/seedance-2.0"` \| `"bytedance/seedance-2.0-fast"` \| `"bytedance/seedance-2.0-mini"` \| `"google/veo-3.1"` \| `"google/veo-3.1-fast"` | Verified catalog model identifier. |
1424
+ | `raw.prompt` | `string` | Trimmed prompt; Seedance allows 2,000 characters, Veo uses the retained host cap of 2,048. |
1425
+ | `raw.resolution?` | `"480p"` \| `"720p"` \| `"1080p"` \| `"4k"` | Model-specific resolution, default 720p. |
1426
+ | `raw.aspectRatio?` | `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"` | Model-specific aspect, default 16:9. |
1427
+ | `raw.durationSeconds?` | `number` | Whole seconds; Seedance 4–12, Veo exactly 4/6/8. |
1428
+ | `raw.generateAudio?` | `boolean` | Veo defaults true; Seedance omits the provider option when unset. |
1429
+ | `raw.references?` | `object`[] | Up to four references, with provider-specific roles and mode limits. |
1430
+
1431
+ #### Returns
1432
+
1433
+ [`MediaVideoSelection`](#mediavideoselection)
1434
+
1435
+ ---
1436
+
1437
+ ### resolveMediaReferences()
1438
+
1439
+ ```ts
1440
+ function resolveMediaReferences(
1441
+ settings,
1442
+ reader,
1443
+ ): Promise<
1444
+ readonly Readonly<{
1445
+ bytes: Uint8Array;
1446
+ format: ImageFormat;
1447
+ width: number;
1448
+ height: number;
1449
+ filename?: string;
1450
+ }>[]
1451
+ >;
1452
+ ```
1453
+
1454
+ Resolve only provider-accepted references through the caller's reader.
1455
+
1456
+ #### Parameters
1457
+
1458
+ | Parameter | Type |
1459
+ | ---------- | ----------------------------------------------------- |
1460
+ | `settings` | [`MediaGenerationSettings`](#mediagenerationsettings) |
1461
+ | `reader` | [`MediaReferenceReader`](#mediareferencereader) |
1462
+
1463
+ #### Returns
1464
+
1465
+ `Promise`\<readonly `Readonly`\<\{ `bytes`: `Uint8Array`; `format`:
1466
+ [`ImageFormat`](#imageformat); `width`: `number`; `height`: `number`;
1467
+ `filename?`: `string`; \}\>[]\>
1468
+
1469
+ ---
1470
+
1471
+ ### buildProviderInput()
1472
+
1473
+ ```ts
1474
+ function buildProviderInput(settings, references?): MediaProviderPayload;
1475
+ ```
1476
+
1477
+ Build the exact JSON or multipart payload required by a retained model.
1478
+
1479
+ #### Parameters
1480
+
1481
+ | Parameter | Type | Default value |
1482
+ | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------- |
1483
+ | `settings` | [`MediaGenerationSettings`](#mediagenerationsettings) | `undefined` |
1484
+ | `references` | readonly `Readonly`\<\{ `bytes`: `Uint8Array`; `format`: [`ImageFormat`](#imageformat); `width`: `number`; `height`: `number`; `filename?`: `string`; \}\>[] | `[]` |
1485
+
1486
+ #### Returns
1487
+
1488
+ [`MediaProviderPayload`](#mediaproviderpayload)
1489
+
1490
+ ---
1491
+
1492
+ ### parseMediaProviderOutput()
1493
+
1494
+ ```ts
1495
+ function parseMediaProviderOutput(value): MediaProviderOutput;
1496
+ ```
1497
+
1498
+ Parse the provider wire envelope before normalization.
1499
+
1500
+ #### Parameters
1501
+
1502
+ | Parameter | Type |
1503
+ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
1504
+ | `value` | \| `Response` \| `Uint8Array`\<`ArrayBuffer`\> \| `ReadableStream`\<`Uint8Array`\<`ArrayBufferLike`\>\> \| \{ `image`: `string`; \} \| \{ `image`: `object`[]; \} \| \{ `images`: `object`[]; \} |
1505
+
1506
+ #### Returns
1507
+
1508
+ [`MediaProviderOutput`](#mediaprovideroutput)
1509
+
1510
+ ---
1511
+
1512
+ ### readResponseBytes()
1513
+
1514
+ ```ts
1515
+ function readResponseBytes(
1516
+ response,
1517
+ maximumBytes,
1518
+ ): Promise<Uint8Array<ArrayBufferLike>>;
1519
+ ```
1520
+
1521
+ Read a successful provider response within an explicit byte bound, closing its
1522
+ reader.
1523
+
1524
+ #### Parameters
1525
+
1526
+ | Parameter | Type |
1527
+ | -------------- | ---------- |
1528
+ | `response` | `Response` |
1529
+ | `maximumBytes` | `number` |
1530
+
1531
+ #### Returns
1532
+
1533
+ `Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
1534
+
1535
+ ---
1536
+
1537
+ ### normalizeMediaProviderOutput()
1538
+
1539
+ ```ts
1540
+ function normalizeMediaProviderOutput(
1541
+ value,
1542
+ options?,
1543
+ ): Promise<
1544
+ Readonly<{
1545
+ bytes: Uint8Array;
1546
+ format: ImageFormat;
1547
+ }>
1548
+ >;
1549
+ ```
1550
+
1551
+ Normalize all retained provider envelopes into bounded image bytes.
1552
+
1553
+ #### Parameters
1554
+
1555
+ | Parameter | Type |
1556
+ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
1557
+ | `value` | \| `Response` \| `Uint8Array`\<`ArrayBuffer`\> \| `ReadableStream`\<`Uint8Array`\<`ArrayBufferLike`\>\> \| \{ `image`: `string`; \} \| \{ `image`: `object`[]; \} \| \{ `images`: `object`[]; \} |
1558
+ | `options` | [`MediaProviderOutputOptions`](#mediaprovideroutputoptions) |
1559
+
1560
+ #### Returns
1561
+
1562
+ `Promise`\<`Readonly`\<\{ `bytes`: `Uint8Array`; `format`:
1563
+ [`ImageFormat`](#imageformat); \}\>\>
1564
+
1565
+ ---
1566
+
1567
+ ### estimateVideoMilliunits()
1568
+
1569
+ ```ts
1570
+ function estimateVideoMilliunits(settings): number;
1571
+ ```
1572
+
1573
+ Provider video cost from the sole catalog, in milliunits (1 cent = 1,000).
1574
+ Video-input references are unsupported.
1575
+
1576
+ #### Parameters
1577
+
1578
+ | Parameter | Type |
1579
+ | ---------- | ----------------------------------------------------- |
1580
+ | `settings` | [`MediaVideoQuoteSettings`](#mediavideoquotesettings) |
1581
+
1582
+ #### Returns
1583
+
1584
+ `number`
1585
+
1586
+ ---
1587
+
1588
+ ### listMediaModels()
1589
+
1590
+ ```ts
1591
+ function listMediaModels(): readonly Readonly<{
1592
+ id: string;
1593
+ label: string;
1594
+ kind: "image" | "video";
1595
+ tier: "draft" | "balanced" | "premium" | "max";
1596
+ outputFormats: readonly ("png" | "jpeg" | "webp")[];
1597
+ input: Readonly<{
1598
+ transport: "json" | "multipart";
1599
+ dimensions: "none" | "own";
1600
+ maxDimension: number | null;
1601
+ defaultWidth: number;
1602
+ defaultHeight: number;
1603
+ steps: "steps" | "num_steps" | "fixed";
1604
+ maxSteps: number | null;
1605
+ defaultSteps: number | null;
1606
+ referenceField: string | null;
1607
+ maxReferences: number;
1608
+ }>;
1609
+ sizes: readonly string[] | null;
1610
+ video: Readonly<{
1611
+ minSeconds: number;
1612
+ maxSeconds: number;
1613
+ defaultSeconds: number;
1614
+ durations: readonly number[];
1615
+ provider: "seedance" | "veo";
1616
+ formats: readonly Readonly<{
1617
+ resolution: "480p" | "720p" | "1080p" | "4k";
1618
+ aspectRatio: "16:9" | "4:3" | "1:1" | "3:4" | "9:16" | "21:9" | "9:21";
1619
+ width: number;
1620
+ height: number;
1621
+ }>[];
1622
+ defaultResolution: "480p" | "720p" | "1080p" | "4k";
1623
+ defaultAspectRatio:
1624
+ "16:9" | "4:3" | "1:1" | "3:4" | "9:16" | "21:9" | "9:21";
1625
+ defaultGenerateAudio: boolean | null;
1626
+ maxPromptLength: number;
1627
+ referenceRoles: readonly ("first-frame" | "last-frame" | "reference")[];
1628
+ maxReferenceImages: number;
1629
+ referenceResolutions: readonly ("480p" | "720p" | "1080p" | "4k")[];
1630
+ prices: readonly Readonly<{
1631
+ resolution: "480p" | "720p" | "1080p" | "4k";
1632
+ silentMilliunitsPerSecond: number;
1633
+ audioMilliunitsPerSecond: number;
1634
+ }>[];
1635
+ }> | null;
1636
+ }>[];
1637
+ ```
1638
+
1639
+ List all image and video models in catalog order.
1640
+
1641
+ #### Returns
1642
+
1643
+ readonly `Readonly`\<\{ `id`: `string`; `label`: `string`; `kind`: `"image"` \|
1644
+ `"video"`; `tier`: `"draft"` \| `"balanced"` \| `"premium"` \| `"max"`;
1645
+ `outputFormats`: readonly (`"png"` \| `"jpeg"` \| `"webp"`)[]; `input`:
1646
+ `Readonly`\<\{ `transport`: `"json"` \| `"multipart"`; `dimensions`: `"none"` \|
1647
+ `"own"`; `maxDimension`: `number` \| `null`; `defaultWidth`: `number`;
1648
+ `defaultHeight`: `number`; `steps`: `"steps"` \| `"num_steps"` \| `"fixed"`;
1649
+ `maxSteps`: `number` \| `null`; `defaultSteps`: `number` \| `null`;
1650
+ `referenceField`: `string` \| `null`; `maxReferences`: `number`; \}\>; `sizes`:
1651
+ readonly `string`[] \| `null`; `video`: \| `Readonly`\<\{ `minSeconds`:
1652
+ `number`; `maxSeconds`: `number`; `defaultSeconds`: `number`; `durations`:
1653
+ readonly `number`[]; `provider`: `"seedance"` \| `"veo"`; `formats`: readonly
1654
+ `Readonly`\<\{ `resolution`: `"480p"` \| `"720p"` \| `"1080p"` \| `"4k"`;
1655
+ `aspectRatio`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"`
1656
+ \| `"9:21"`; `width`: `number`; `height`: `number`; \}\>[]; `defaultResolution`:
1657
+ `"480p"` \| `"720p"` \| `"1080p"` \| `"4k"`; `defaultAspectRatio`: `"16:9"` \|
1658
+ `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`;
1659
+ `defaultGenerateAudio`: `boolean` \| `null`; `maxPromptLength`: `number`;
1660
+ `referenceRoles`: readonly (`"first-frame"` \| `"last-frame"` \|
1661
+ `"reference"`)[]; `maxReferenceImages`: `number`; `referenceResolutions`:
1662
+ readonly (`"480p"` \| `"720p"` \| `"1080p"` \| `"4k"`)[]; `prices`: readonly
1663
+ `Readonly`\<\{ `resolution`: `"480p"` \| `"720p"` \| `"1080p"` \| `"4k"`;
1664
+ `silentMilliunitsPerSecond`: `number`; `audioMilliunitsPerSecond`: `number`;
1665
+ \}\>[]; \}\> \| `null`; \}\>[]
1666
+
1667
+ ---
1668
+
1669
+ ### getMediaModel()
1670
+
1671
+ ```ts
1672
+ function getMediaModel(id):
1673
+ | Readonly<{
1674
+ id: string;
1675
+ label: string;
1676
+ kind: "image" | "video";
1677
+ tier: "draft" | "balanced" | "premium" | "max";
1678
+ outputFormats: readonly ("png" | "jpeg" | "webp")[];
1679
+ input: Readonly<{
1680
+ transport: "json" | "multipart";
1681
+ dimensions: "none" | "own";
1682
+ maxDimension: number | null;
1683
+ defaultWidth: number;
1684
+ defaultHeight: number;
1685
+ steps: "steps" | "num_steps" | "fixed";
1686
+ maxSteps: number | null;
1687
+ defaultSteps: number | null;
1688
+ referenceField: string | null;
1689
+ maxReferences: number;
1690
+ }>;
1691
+ sizes: readonly string[] | null;
1692
+ video: Readonly<{
1693
+ minSeconds: number;
1694
+ maxSeconds: number;
1695
+ defaultSeconds: number;
1696
+ durations: readonly number[];
1697
+ provider: "seedance" | "veo";
1698
+ formats: readonly Readonly<{
1699
+ resolution: "480p" | "720p" | "1080p" | "4k";
1700
+ aspectRatio:
1701
+ "16:9" | "4:3" | "1:1" | "3:4" | "9:16" | "21:9" | "9:21";
1702
+ width: number;
1703
+ height: number;
1704
+ }>[];
1705
+ defaultResolution: "480p" | "720p" | "1080p" | "4k";
1706
+ defaultAspectRatio:
1707
+ "16:9" | "4:3" | "1:1" | "3:4" | "9:16" | "21:9" | "9:21";
1708
+ defaultGenerateAudio: boolean | null;
1709
+ maxPromptLength: number;
1710
+ referenceRoles: readonly ("first-frame" | "last-frame" | "reference")[];
1711
+ maxReferenceImages: number;
1712
+ referenceResolutions: readonly ("480p" | "720p" | "1080p" | "4k")[];
1713
+ prices: readonly Readonly<{
1714
+ resolution: "480p" | "720p" | "1080p" | "4k";
1715
+ silentMilliunitsPerSecond: number;
1716
+ audioMilliunitsPerSecond: number;
1717
+ }>[];
1718
+ }> | null;
1719
+ }>
1720
+ | undefined;
1721
+ ```
1722
+
1723
+ Find a model by provider identifier, returning undefined when it is absent.
1724
+
1725
+ #### Parameters
1726
+
1727
+ | Parameter | Type |
1728
+ | --------- | -------- |
1729
+ | `id` | `string` |
1730
+
1731
+ #### Returns
1732
+
1733
+ \| `Readonly`\<\{ `id`: `string`; `label`: `string`; `kind`: `"image"` \|
1734
+ `"video"`; `tier`: `"draft"` \| `"balanced"` \| `"premium"` \| `"max"`;
1735
+ `outputFormats`: readonly (`"png"` \| `"jpeg"` \| `"webp"`)[]; `input`:
1736
+ `Readonly`\<\{ `transport`: `"json"` \| `"multipart"`; `dimensions`: `"none"` \|
1737
+ `"own"`; `maxDimension`: `number` \| `null`; `defaultWidth`: `number`;
1738
+ `defaultHeight`: `number`; `steps`: `"steps"` \| `"num_steps"` \| `"fixed"`;
1739
+ `maxSteps`: `number` \| `null`; `defaultSteps`: `number` \| `null`;
1740
+ `referenceField`: `string` \| `null`; `maxReferences`: `number`; \}\>; `sizes`:
1741
+ readonly `string`[] \| `null`; `video`: \| `Readonly`\<\{ `minSeconds`:
1742
+ `number`; `maxSeconds`: `number`; `defaultSeconds`: `number`; `durations`:
1743
+ readonly `number`[]; `provider`: `"seedance"` \| `"veo"`; `formats`: readonly
1744
+ `Readonly`\<\{ `resolution`: `"480p"` \| `"720p"` \| `"1080p"` \| `"4k"`;
1745
+ `aspectRatio`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"`
1746
+ \| `"9:21"`; `width`: `number`; `height`: `number`; \}\>[]; `defaultResolution`:
1747
+ `"480p"` \| `"720p"` \| `"1080p"` \| `"4k"`; `defaultAspectRatio`: `"16:9"` \|
1748
+ `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`;
1749
+ `defaultGenerateAudio`: `boolean` \| `null`; `maxPromptLength`: `number`;
1750
+ `referenceRoles`: readonly (`"first-frame"` \| `"last-frame"` \|
1751
+ `"reference"`)[]; `maxReferenceImages`: `number`; `referenceResolutions`:
1752
+ readonly (`"480p"` \| `"720p"` \| `"1080p"` \| `"4k"`)[]; `prices`: readonly
1753
+ `Readonly`\<\{ `resolution`: `"480p"` \| `"720p"` \| `"1080p"` \| `"4k"`;
1754
+ `silentMilliunitsPerSecond`: `number`; `audioMilliunitsPerSecond`: `number`;
1755
+ \}\>[]; \}\> \| `null`; \}\> \| `undefined`
1756
+
1757
+ ---
1758
+
1759
+ ### neuronsToMilliunits()
1760
+
1761
+ ```ts
1762
+ function neuronsToMilliunits(neurons): number;
1763
+ ```
1764
+
1765
+ Convert a neuron estimate to milliunits, rounding up to avoid underquoting.
1766
+
1767
+ #### Parameters
1768
+
1769
+ | Parameter | Type |
1770
+ | --------- | -------- |
1771
+ | `neurons` | `number` |
1772
+
1773
+ #### Returns
1774
+
1775
+ `number`