@fungi.computer/darkroom 0.6.0 → 0.8.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 (53) hide show
  1. package/README.md +178 -0
  2. package/dist/app-media-contracts.d.ts +107 -12
  3. package/dist/audio-providers/elevenlabs.d.ts +40 -0
  4. package/dist/audio-providers/elevenlabs.js +69 -0
  5. package/dist/audio-reference-types.d.ts +28 -0
  6. package/dist/audio-reference-types.js +16 -0
  7. package/dist/audio-references.d.ts +14 -0
  8. package/dist/audio-references.js +69 -0
  9. package/dist/browser-failure.d.ts +2 -0
  10. package/dist/browser-failure.js +2 -0
  11. package/dist/cloudflare/provider.d.ts +6 -4
  12. package/dist/cloudflare/provider.js +39 -21
  13. package/dist/cloudflare/reference-images.d.ts +6 -0
  14. package/dist/cloudflare/reference-images.js +25 -7
  15. package/dist/cost-estimate.js +2 -2
  16. package/dist/daily-media-meter.d.ts +55 -0
  17. package/dist/daily-media-meter.js +81 -0
  18. package/dist/execution-error.d.ts +1 -1
  19. package/dist/gateway-models.d.ts +19 -9
  20. package/dist/gateway-models.js +57 -19
  21. package/dist/gateway-wire.d.ts +1 -0
  22. package/dist/gateway-wire.js +2 -0
  23. package/dist/index.d.ts +116 -24
  24. package/dist/index.js +147 -26
  25. package/dist/media-binding.d.ts +60 -7
  26. package/dist/media-binding.js +43 -21
  27. package/dist/media-generation.js +20 -7
  28. package/dist/media-operation-contract.d.ts +9 -3
  29. package/dist/media-operation-contract.js +6 -4
  30. package/dist/media-operation-do.d.ts +13 -2
  31. package/dist/media-operation-do.js +26 -1
  32. package/dist/media-operation-owner.d.ts +10 -2
  33. package/dist/media-operation-owner.js +56 -11
  34. package/dist/media-operation.js +5 -3
  35. package/dist/media-quote.d.ts +14 -0
  36. package/dist/media-quote.js +17 -0
  37. package/dist/model-catalog.d.ts +602 -6
  38. package/dist/model-catalog.js +309 -9
  39. package/dist/reference-image-size.d.ts +4 -3
  40. package/dist/reference-image-size.js +9 -9
  41. package/dist/server.d.ts +31 -8
  42. package/dist/server.js +51 -8
  43. package/dist/video-providers/reference-encoding.d.ts +7 -2
  44. package/dist/video-providers/reference-encoding.js +14 -3
  45. package/dist/video-providers/types.d.ts +2 -2
  46. package/dist/video-providers/unified.d.ts +1 -0
  47. package/dist/video-providers/unified.js +4 -2
  48. package/docs/api/app-media-contracts.md +50 -10
  49. package/docs/api/browser.md +4 -2
  50. package/docs/api/cloudflare.md +56 -3
  51. package/docs/api/index.md +1042 -121
  52. package/docs/api/server.md +306 -50
  53. package/package.json +3 -2
@@ -10,6 +10,74 @@
10
10
 
11
11
  ## Classes
12
12
 
13
+ ### DailyMediaMeter
14
+
15
+ A UTC-day total of admitted media cost, kept in one Durable Object's SQLite.
16
+ Every statement runs inside one synchronous transaction, so two concurrent
17
+ admits near the limit are serialized by the object and cannot both pass. Holds
18
+ are keyed by the durable operation id, so a retried admit never counts twice. A
19
+ hold that is never settled stays counted until its day ends.
20
+
21
+ #### Constructors
22
+
23
+ ##### Constructor
24
+
25
+ ```ts
26
+ new DailyMediaMeter(storage, now?): DailyMediaMeter;
27
+ ```
28
+
29
+ ###### Parameters
30
+
31
+ | Parameter | Type | Default value |
32
+ | --------- | --------------------------------------------------- | ------------- |
33
+ | `storage` | [`DailyMediaMeterStorage`](#dailymediameterstorage) | `undefined` |
34
+ | `now` | () => `number` | `Date.now` |
35
+
36
+ ###### Returns
37
+
38
+ [`DailyMediaMeter`](#dailymediameter)
39
+
40
+ #### Methods
41
+
42
+ ##### admit()
43
+
44
+ ```ts
45
+ admit(input): boolean;
46
+ ```
47
+
48
+ Hold `costMilliunits` for this operation unless the day's total would exceed the
49
+ limit.
50
+
51
+ ###### Parameters
52
+
53
+ | Parameter | Type |
54
+ | --------- | ----------------------------------------------------------------------------------------------------- |
55
+ | `input` | `Readonly`\<\{ `operationId`: `string`; `costMilliunits`: `number`; `limitMilliunits`: `number`; \}\> |
56
+
57
+ ###### Returns
58
+
59
+ `boolean`
60
+
61
+ ##### settle()
62
+
63
+ ```ts
64
+ settle(input): void;
65
+ ```
66
+
67
+ Keep the hold when media was delivered; release it when nothing was.
68
+
69
+ ###### Parameters
70
+
71
+ | Parameter | Type |
72
+ | --------- | -------------------------------------------------------------------- |
73
+ | `input` | `Readonly`\<\{ `operationId`: `string`; `delivered`: `boolean`; \}\> |
74
+
75
+ ###### Returns
76
+
77
+ `void`
78
+
79
+ ---
80
+
13
81
  ### MediaExecutionError
14
82
 
15
83
  A bounded stage marker for failures that cross the Media HTTP boundary.
@@ -419,7 +487,11 @@ Pin the admitted price and begin the generation lease.
419
487
  ##### dispatchInBackground()
420
488
 
421
489
  ```ts
422
- dispatchInBackground(leaseId, references): Promise<Readonly<{
490
+ dispatchInBackground(
491
+ leaseId,
492
+ references,
493
+ audioReferences
494
+ ): Promise<Readonly<{
423
495
  operationId: string;
424
496
  requestId: string;
425
497
  namespace: string;
@@ -463,10 +535,11 @@ output, and releases the lease so a later retry saves and charges it.
463
535
 
464
536
  ###### Parameters
465
537
 
466
- | Parameter | Type |
467
- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
468
- | `leaseId` | `string` |
469
- | `references` | readonly `Readonly`\<\{ `bytes`: `Uint8Array`; `format`: [`ImageFormat`](index.md#imageformat); `width`: `number`; `height`: `number`; `filename?`: `string`; \}\>[] |
538
+ | Parameter | Type |
539
+ | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
540
+ | `leaseId` | `string` |
541
+ | `references` | readonly `Readonly`\<\{ `bytes`: `Uint8Array`; `format`: [`ImageFormat`](index.md#imageformat); `width`: `number`; `height`: `number`; `filename?`: `string`; \}\>[] |
542
+ | `audioReferences` | readonly `Readonly`\<\{ `bytes`: `Uint8Array`; `mimeType`: [`AudioReferenceMimeType`](index.md#audioreferencemimetype); `durationSeconds`: `number`; `filename?`: `string`; \}\>[] |
470
543
 
471
544
  ###### Returns
472
545
 
@@ -802,6 +875,39 @@ Release preparation or refused admission so the same request can retry.
802
875
 
803
876
  ## Type Aliases
804
877
 
878
+ ### DailyMediaMeterStorage
879
+
880
+ ```ts
881
+ type DailyMediaMeterStorage = Readonly<{
882
+ sql: Readonly<{
883
+ exec: (
884
+ query,
885
+ ...bindings
886
+ ) => Readonly<{
887
+ toArray: () => readonly unknown[];
888
+ }>;
889
+ }>;
890
+ transactionSync: <T>(body) => T;
891
+ }>;
892
+ ```
893
+
894
+ The Durable Object storage slice the meter owns tables in.
895
+
896
+ ---
897
+
898
+ ### DailyMediaMeterPort
899
+
900
+ ```ts
901
+ type DailyMediaMeterPort = Readonly<{
902
+ dailyAdmit: (input) => Promise<boolean> | boolean;
903
+ dailySettle: (input) => Promise<void> | void;
904
+ }>;
905
+ ```
906
+
907
+ RPC surface of the Durable Object that owns one Oyster's daily media total.
908
+
909
+ ---
910
+
805
911
  ### MediaFailureStage
806
912
 
807
913
  ```ts
@@ -835,7 +941,8 @@ Private cause plus an independently decoded, safe provider diagnostic.
835
941
  ### MediaBillingRefusalCode
836
942
 
837
943
  ```ts
838
- type MediaBillingRefusalCode = "insufficient_credits" | "denied";
944
+ type MediaBillingRefusalCode =
945
+ "insufficient_credits" | "denied" | "daily_limit_reached";
839
946
  ```
840
947
 
841
948
  Why the host's billing owner refused to admit a new generation.
@@ -846,12 +953,15 @@ Why the host's billing owner refused to admit a new generation.
846
953
 
847
954
  ```ts
848
955
  type MediaUnits = Readonly<{
849
- unit: "image" | "video_second";
956
+ unit: "image" | "video_second" | "audio_second" | "audio_character_block";
850
957
  units: number;
851
958
  }>;
852
959
  ```
853
960
 
854
- What one generation bills: whole images, or seconds of video.
961
+ What one generation bills: whole images, seconds of video or music, or blocks of
962
+ [AUDIO\_CHARACTER\_BLOCK](index.md#audio_character_block) speech characters (so
963
+ a per-character provider rate is marked up once per block, not rounded up per
964
+ character).
855
965
 
856
966
  ---
857
967
 
@@ -1086,6 +1196,7 @@ Retained output projection, or a terminal spent format refusal.
1086
1196
  ```ts
1087
1197
  type MediaOperationHooks = Readonly<{
1088
1198
  namespace?: () => string | null;
1199
+ catalogue?: () => MediaCatalogue;
1089
1200
  }>;
1090
1201
  ```
1091
1202
 
@@ -1463,6 +1574,16 @@ Delete the owner-selected object key.
1463
1574
 
1464
1575
  ---
1465
1576
 
1577
+ ### MediaQuote
1578
+
1579
+ ```ts
1580
+ type MediaQuote = Readonly<MediaUnits & object>;
1581
+ ```
1582
+
1583
+ The provider cost of one exact generation request, before any billing policy.
1584
+
1585
+ ---
1586
+
1466
1587
  ### MediaScope
1467
1588
 
1468
1589
  ```ts
@@ -1503,8 +1624,17 @@ type MediaServiceHost = Readonly<{
1503
1624
  authorize: (path) => Promise<void>;
1504
1625
  write: (path, bytes) => Promise<void>;
1505
1626
  readReference?: (reference, model) => Promise<MediaReferenceBytes>;
1627
+ readAudioReference?: (reference) => Promise<Uint8Array>;
1506
1628
  }>;
1507
1629
  onFailure?: (error) => Response | undefined;
1630
+ }> &
1631
+ | Readonly<{
1632
+ catalogue?: undefined;
1633
+ estimate?: undefined;
1634
+ }>
1635
+ | Readonly<{
1636
+ catalogue: MediaCatalogue;
1637
+ estimate: (settings, references) => number;
1508
1638
  }> &
1509
1639
  | Readonly<{
1510
1640
  metering: "unmetered";
@@ -1544,10 +1674,10 @@ type MediaGenerationOutcome =
1544
1674
  path: string;
1545
1675
  bytes: number;
1546
1676
  costMilliunits: number;
1547
- format: "png" | "jpeg" | "gif" | "webp" | "mp4";
1548
- height: number;
1677
+ format: "png" | "jpeg" | "gif" | "webp" | "mp4" | "mp3";
1678
+ height?: number;
1549
1679
  model: string;
1550
- width: number;
1680
+ width?: number;
1551
1681
  }>
1552
1682
  | Readonly<{
1553
1683
  kind: "pending";
@@ -1579,8 +1709,6 @@ const mediaImageBindingInputSchema: ZodObject<{
1579
1709
  settings: ZodObject<{
1580
1710
  model: ZodString;
1581
1711
  prompt: ZodString;
1582
- width: ZodNumber;
1583
- height: ZodNumber;
1584
1712
  resolution: ZodOptional<ZodEnum<{
1585
1713
  p480: "480p";
1586
1714
  p720: "720p";
@@ -1607,6 +1735,8 @@ const mediaImageBindingInputSchema: ZodObject<{
1607
1735
  reference: ...;
1608
1736
  }>>;
1609
1737
  }, $strict>>>;
1738
+ width: ZodNumber;
1739
+ height: ZodNumber;
1610
1740
  steps: ZodOptional<ZodNumber>;
1611
1741
  }, $strict>;
1612
1742
  outputFormat: ZodOptional<ZodEnum<{
@@ -1661,6 +1791,9 @@ const mediaVideoBindingInputSchema: ZodObject<{
1661
1791
  path: ZodString;
1662
1792
  role: ZodEnum<...>;
1663
1793
  }, $strict>>>>;
1794
+ audioReferences: ZodOptional<ZodArray<ZodLazy<ZodObject<{
1795
+ path: ZodString;
1796
+ }, $strict>>>>;
1664
1797
  }, $strict>>;
1665
1798
  }, $strict>;
1666
1799
  ```
@@ -1679,8 +1812,6 @@ const mediaBindingGenerationSchema: ZodDiscriminatedUnion<[ZodObject<{
1679
1812
  settings: ZodObject<{
1680
1813
  model: ZodString;
1681
1814
  prompt: ZodString;
1682
- width: ZodNumber;
1683
- height: ZodNumber;
1684
1815
  resolution: ZodOptional<ZodEnum<{
1685
1816
  p480: "480p";
1686
1817
  p720: "720p";
@@ -1703,6 +1834,8 @@ const mediaBindingGenerationSchema: ZodDiscriminatedUnion<[ZodObject<{
1703
1834
  path: ZodString;
1704
1835
  role: ZodOptional<...>;
1705
1836
  }, $strict>>>;
1837
+ width: ZodNumber;
1838
+ height: ZodNumber;
1706
1839
  steps: ZodOptional<ZodNumber>;
1707
1840
  }, $strict>;
1708
1841
  outputFormat: ZodOptional<ZodEnum<{
@@ -1744,6 +1877,21 @@ const mediaBindingGenerationSchema: ZodDiscriminatedUnion<[ZodObject<{
1744
1877
  durationSeconds: ZodOptional<ZodNumber>;
1745
1878
  generateAudio: ZodOptional<ZodBoolean>;
1746
1879
  references: ZodOptional<ZodArray<ZodLazy<ZodObject<..., ...>>>>;
1880
+ audioReferences: ZodOptional<ZodArray<ZodLazy<ZodObject<..., ...>>>>;
1881
+ }, $strict>>;
1882
+ }, $strict>, ZodObject<{
1883
+ kind: ZodLiteral<"audio">;
1884
+ requestId: ZodLazy<ZodString>;
1885
+ libraryPath: ZodString & ZodType<string, string, $ZodTypeInternals<string, string>>;
1886
+ settings: ZodLazy<ZodObject<{
1887
+ model: ZodEnum<{
1888
+ multilingual: "elevenlabs/eleven-multilingual-v2";
1889
+ v3: "elevenlabs/eleven-v3";
1890
+ music: "elevenlabs/music-v2";
1891
+ }>;
1892
+ prompt: ZodString;
1893
+ voiceId: ZodOptional<ZodString>;
1894
+ durationSeconds: ZodOptional<ZodNumber>;
1747
1895
  }, $strict>>;
1748
1896
  }, $strict>], "kind">;
1749
1897
  ```
@@ -1768,12 +1916,12 @@ const mediaBindingCallSchema: ZodDiscriminatedUnion<[ZodObject<{
1768
1916
  settings: ZodObject<{
1769
1917
  model: ZodString;
1770
1918
  prompt: ZodString;
1771
- width: ZodNumber;
1772
- height: ZodNumber;
1773
1919
  resolution: ZodOptional<...>;
1774
1920
  aspectRatio: ZodOptional<...>;
1775
1921
  generateAudio: ZodOptional<...>;
1776
1922
  references: ZodOptional<...>;
1923
+ width: ZodNumber;
1924
+ height: ZodNumber;
1777
1925
  steps: ZodOptional<...>;
1778
1926
  }, $strict>;
1779
1927
  outputFormat: ZodOptional<ZodEnum<{
@@ -1793,6 +1941,17 @@ const mediaBindingCallSchema: ZodDiscriminatedUnion<[ZodObject<{
1793
1941
  durationSeconds: ...;
1794
1942
  generateAudio: ...;
1795
1943
  references: ...;
1944
+ audioReferences: ...;
1945
+ }, $strict>>;
1946
+ }, $strict>, ZodObject<{
1947
+ kind: ZodLiteral<"audio">;
1948
+ requestId: ZodLazy<ZodString>;
1949
+ libraryPath: ZodString & ZodType<string, string, $ZodTypeInternals<..., ...>>;
1950
+ settings: ZodLazy<ZodObject<{
1951
+ model: ...;
1952
+ prompt: ...;
1953
+ voiceId: ...;
1954
+ durationSeconds: ...;
1796
1955
  }, $strict>>;
1797
1956
  }, $strict>], "kind">;
1798
1957
  }, $strict>], "operation">;
@@ -1834,10 +1993,11 @@ const mediaResultSchema: ZodObject<
1834
1993
  gif: "gif";
1835
1994
  webp: "webp";
1836
1995
  mp4: "mp4";
1996
+ mp3: "mp3";
1837
1997
  }>;
1838
- height: ZodNumber;
1998
+ height: ZodOptional<ZodNumber>;
1839
1999
  model: ZodString;
1840
- width: ZodNumber;
2000
+ width: ZodOptional<ZodNumber>;
1841
2001
  },
1842
2002
  $strict
1843
2003
  >;
@@ -1953,10 +2113,11 @@ const mediaRequestSchema: ZodObject<{
1953
2113
  settings: ZodObject<{
1954
2114
  model: ZodString;
1955
2115
  prompt: ZodString;
1956
- width: ZodNumber;
1957
- height: ZodNumber;
2116
+ width: ZodOptional<ZodNumber>;
2117
+ height: ZodOptional<ZodNumber>;
1958
2118
  steps: ZodOptional<ZodNumber>;
1959
2119
  durationSeconds: ZodOptional<ZodNumber>;
2120
+ voiceId: ZodOptional<ZodString>;
1960
2121
  resolution: ZodOptional<ZodEnum<{
1961
2122
  p480: "480p";
1962
2123
  p720: "720p";
@@ -1983,6 +2144,10 @@ const mediaRequestSchema: ZodObject<{
1983
2144
  reference: ...;
1984
2145
  }>>;
1985
2146
  }, $strict>>>;
2147
+ audioReferences: ZodOptional<ZodArray<ZodObject<{
2148
+ computerId: ZodString;
2149
+ path: ZodString;
2150
+ }, $strict>>>;
1986
2151
  }, $strict>;
1987
2152
  outputFormat: ZodOptional<ZodEnum<{
1988
2153
  png: "png";
@@ -2012,28 +2177,50 @@ Quote the catalog defaults through the exact estimator used before dispatch.
2012
2177
 
2013
2178
  #### Returns
2014
2179
 
2015
- | Name | Type | Description |
2016
- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
2017
- | `kind` | `"estimate"` | An indicative quote, not an admitted generation receipt. |
2018
- | `basis` | `"provider-cost"` | Provider cost before the host's billing policy. |
2019
- | `settings` | `Readonly`\<\{ `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?`: readonly `Readonly`\<\{ `computerId`: `string`; `path`: `string`; `role?`: `"first-frame"` \| `"last-frame"` \| `"reference"`; \}\>[]; \}\> | Catalog defaults, a one-character prompt and no references. |
2020
- | `costMilliunits` | `number` | Estimated provider milliunits of a cent for these exact settings. |
2180
+ | Name | Type | Description |
2181
+ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------- |
2182
+ | `kind` | `"estimate"` | An indicative quote, not an admitted generation receipt. |
2183
+ | `basis` | `"provider-cost"` | Provider cost before the host's billing policy. |
2184
+ | `settings` | `Readonly`\<\{ `model`: `string`; `prompt`: `string`; `width?`: `number`; `height?`: `number`; `steps?`: `number`; `durationSeconds?`: `number`; `voiceId?`: `string`; `resolution?`: `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `generateAudio?`: `boolean`; `references?`: readonly `Readonly`\<\{ `computerId`: `string`; `path`: `string`; `role?`: `"first-frame"` \| `"last-frame"` \| `"reference"`; \}\>[]; `audioReferences?`: readonly `Readonly`\<\{ `computerId`: `string`; `path`: `string`; `role?`: `"first-frame"` \| `"last-frame"` \| `"reference"`; \}\>[]; \}\> | Catalog defaults, a one-character prompt and no references. |
2185
+ | `costMilliunits` | `number` | Estimated provider milliunits of a cent for these exact settings. |
2186
+
2187
+ ---
2188
+
2189
+ ### createDailyMediaMetering()
2190
+
2191
+ ```ts
2192
+ function createDailyMediaMetering(meter, limitMilliunits): MediaMetering;
2193
+ ```
2194
+
2195
+ `MediaMetering` that enforces one exact daily limit through the owning object.
2196
+
2197
+ #### Parameters
2198
+
2199
+ | Parameter | Type |
2200
+ | ----------------- | --------------------------------------------- |
2201
+ | `meter` | [`DailyMediaMeterPort`](#dailymediameterport) |
2202
+ | `limitMilliunits` | `number` |
2203
+
2204
+ #### Returns
2205
+
2206
+ [`MediaMetering`](#mediametering)
2021
2207
 
2022
2208
  ---
2023
2209
 
2024
2210
  ### mediaUnits()
2025
2211
 
2026
2212
  ```ts
2027
- function mediaUnits(settings): MediaUnits;
2213
+ function mediaUnits(settings, catalogue?): MediaUnits;
2028
2214
  ```
2029
2215
 
2030
2216
  Billing units for validated settings; video bills its requested length.
2031
2217
 
2032
2218
  #### Parameters
2033
2219
 
2034
- | Parameter | Type |
2035
- | ---------- | ------------------------------------------------------------- |
2036
- | `settings` | [`MediaGenerationSettings`](index.md#mediagenerationsettings) |
2220
+ | Parameter | Type | Default value |
2221
+ | ----------- | ------------------------------------------------------------- | ------------- |
2222
+ | `settings` | [`MediaGenerationSettings`](index.md#mediagenerationsettings) | `undefined` |
2223
+ | `catalogue` | [`MediaCatalogue`](index.md#mediacatalogue) | `mediaModels` |
2037
2224
 
2038
2225
  #### Returns
2039
2226
 
@@ -2062,13 +2249,13 @@ function parseMediaBindingCall(raw):
2062
2249
  settings: {
2063
2250
  model: string;
2064
2251
  prompt: string;
2065
- width: number;
2066
- height: number;
2067
2252
  resolution?: "480p" | "720p" | "768p" | "1080p" | "4k";
2068
2253
  aspectRatio?:
2069
2254
  "16:9" | "4:3" | "1:1" | "3:4" | "9:16" | "21:9" | "9:21";
2070
2255
  generateAudio?: boolean;
2071
2256
  references?: object[];
2257
+ width: number;
2258
+ height: number;
2072
2259
  steps?: number;
2073
2260
  };
2074
2261
  outputFormat?: "png" | "jpeg" | "webp";
@@ -2093,6 +2280,21 @@ function parseMediaBindingCall(raw):
2093
2280
  durationSeconds?: number;
2094
2281
  generateAudio?: boolean;
2095
2282
  references?: object[];
2283
+ audioReferences?: object[];
2284
+ };
2285
+ }
2286
+ | {
2287
+ kind: "audio";
2288
+ requestId: string;
2289
+ libraryPath: string;
2290
+ settings: {
2291
+ model:
2292
+ | "elevenlabs/eleven-multilingual-v2"
2293
+ | "elevenlabs/eleven-v3"
2294
+ | "elevenlabs/music-v2";
2295
+ prompt: string;
2296
+ voiceId?: string;
2297
+ durationSeconds?: number;
2096
2298
  };
2097
2299
  };
2098
2300
  };
@@ -2116,20 +2318,25 @@ Parsing and model refusal stay shared; authorization remains host-owned.
2116
2318
  \| `Readonly`\<\{ `kind`: `"parsed"`; `call`: \| \{ `operation`: `"models"`;
2117
2319
  `input`: `Record`\<`string`, `never`\>; \} \| \{ `operation`: `"generate"`;
2118
2320
  `input`: \| \{ `kind`: `"image"`; `requestId`: `string`; `libraryPath`:
2119
- `string`; `settings`: \{ `model`: `string`; `prompt`: `string`; `width`:
2120
- `number`; `height`: `number`; `resolution?`: `"480p"` \| `"720p"` \| `"768p"` \|
2121
- `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"`
2122
- \| `"9:16"` \| `"21:9"` \| `"9:21"`; `generateAudio?`: `boolean`; `references?`:
2123
- `object`[]; `steps?`: `number`; \}; `outputFormat?`: `"png"` \| `"jpeg"` \|
2124
- `"webp"`; \} \| \{ `kind`: `"video"`; `requestId`: `string`; `libraryPath`:
2321
+ `string`; `settings`: \{ `model`: `string`; `prompt`: `string`; `resolution?`:
2322
+ `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`:
2323
+ `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`;
2324
+ `generateAudio?`: `boolean`; `references?`: `object`[]; `width`: `number`;
2325
+ `height`: `number`; `steps?`: `number`; \}; `outputFormat?`: `"png"` \| `"jpeg"`
2326
+ \| `"webp"`; \} \| \{ `kind`: `"video"`; `requestId`: `string`; `libraryPath`:
2125
2327
  `string`; `settings`: \{ `model`: \| `"bytedance/seedance-2.5"` \|
2126
2328
  `"bytedance/seedance-2.0"` \| `"bytedance/seedance-2.0-fast"` \|
2127
2329
  `"bytedance/seedance-2.0-mini"` \| `"google/veo-3.1"` \| `"google/veo-3.1-fast"`
2128
2330
  \| `"minimax/h3-max"`; `prompt`: `string`; `resolution?`: `"480p"` \| `"720p"`
2129
2331
  \| `"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \|
2130
2332
  `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `durationSeconds?`:
2131
- `number`; `generateAudio?`: `boolean`; `references?`: `object`[]; \}; \}; \};
2132
- \}\> \| `Readonly`\<\{ `kind`: `"refused"`; `result`: `JSONType`; \}\>
2333
+ `number`; `generateAudio?`: `boolean`; `references?`: `object`[];
2334
+ `audioReferences?`: `object`[]; \}; \} \| \{ `kind`: `"audio"`; `requestId`:
2335
+ `string`; `libraryPath`: `string`; `settings`: \{ `model`: \|
2336
+ `"elevenlabs/eleven-multilingual-v2"` \| `"elevenlabs/eleven-v3"` \|
2337
+ `"elevenlabs/music-v2"`; `prompt`: `string`; `voiceId?`: `string`;
2338
+ `durationSeconds?`: `number`; \}; \}; \}; \}\> \| `Readonly`\<\{ `kind`:
2339
+ `"refused"`; `result`: `JSONType`; \}\>
2133
2340
 
2134
2341
  ---
2135
2342
 
@@ -2143,10 +2350,10 @@ Choose the same fixed filename on both hosts without a recursive App lookup.
2143
2350
 
2144
2351
  #### Parameters
2145
2352
 
2146
- | Parameter | Type |
2147
- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
2148
- | `input` | \| \{ `kind`: `"image"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: `string`; `prompt`: `string`; `width`: `number`; `height`: `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`[]; `steps?`: `number`; \}; `outputFormat?`: `"png"` \| `"jpeg"` \| `"webp"`; \} \| \{ `kind`: `"video"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: \| `"bytedance/seedance-2.5"` \| `"bytedance/seedance-2.0"` \| `"bytedance/seedance-2.0-fast"` \| `"bytedance/seedance-2.0-mini"` \| `"google/veo-3.1"` \| `"google/veo-3.1-fast"` \| `"minimax/h3-max"`; `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`[]; \}; \} |
2149
- | `computerId` | `string` |
2353
+ | Parameter | Type |
2354
+ | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2355
+ | `input` | \| \{ `kind`: `"image"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: `string`; `prompt`: `string`; `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`[]; `width`: `number`; `height`: `number`; `steps?`: `number`; \}; `outputFormat?`: `"png"` \| `"jpeg"` \| `"webp"`; \} \| \{ `kind`: `"video"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: \| `"bytedance/seedance-2.5"` \| `"bytedance/seedance-2.0"` \| `"bytedance/seedance-2.0-fast"` \| `"bytedance/seedance-2.0-mini"` \| `"google/veo-3.1"` \| `"google/veo-3.1-fast"` \| `"minimax/h3-max"`; `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`[]; `audioReferences?`: `object`[]; \}; \} \| \{ `kind`: `"audio"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: \| `"elevenlabs/eleven-multilingual-v2"` \| `"elevenlabs/eleven-v3"` \| `"elevenlabs/music-v2"`; `prompt`: `string`; `voiceId?`: `string`; `durationSeconds?`: `number`; \}; \} |
2356
+ | `computerId` | `string` |
2150
2357
 
2151
2358
  #### Returns
2152
2359
 
@@ -2164,11 +2371,11 @@ Decode bounded service replies once for both MEDIA host bindings.
2164
2371
 
2165
2372
  #### Parameters
2166
2373
 
2167
- | Parameter | Type |
2168
- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
2169
- | `input` | \| \{ `operation`: `"models"`; `input`: `Record`\<`string`, `never`\>; \} \| \{ `operation`: `"generate"`; `input`: \| \{ `kind`: `"image"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: `string`; `prompt`: `string`; `width`: `number`; `height`: `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`[]; `steps?`: `number`; \}; `outputFormat?`: `"png"` \| `"jpeg"` \| `"webp"`; \} \| \{ `kind`: `"video"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: \| `"bytedance/seedance-2.5"` \| `"bytedance/seedance-2.0"` \| `"bytedance/seedance-2.0-fast"` \| `"bytedance/seedance-2.0-mini"` \| `"google/veo-3.1"` \| `"google/veo-3.1-fast"` \| `"minimax/h3-max"`; `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`[]; \}; \}; \} |
2170
- | `computerId` | `string` |
2171
- | `response` | `Response` |
2374
+ | Parameter | Type |
2375
+ | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2376
+ | `input` | \| \{ `operation`: `"models"`; `input`: `Record`\<`string`, `never`\>; \} \| \{ `operation`: `"generate"`; `input`: \| \{ `kind`: `"image"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: `string`; `prompt`: `string`; `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`[]; `width`: `number`; `height`: `number`; `steps?`: `number`; \}; `outputFormat?`: `"png"` \| `"jpeg"` \| `"webp"`; \} \| \{ `kind`: `"video"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: \| `"bytedance/seedance-2.5"` \| `"bytedance/seedance-2.0"` \| `"bytedance/seedance-2.0-fast"` \| `"bytedance/seedance-2.0-mini"` \| `"google/veo-3.1"` \| `"google/veo-3.1-fast"` \| `"minimax/h3-max"`; `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`[]; `audioReferences?`: `object`[]; \}; \} \| \{ `kind`: `"audio"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: \| `"elevenlabs/eleven-multilingual-v2"` \| `"elevenlabs/eleven-v3"` \| `"elevenlabs/music-v2"`; `prompt`: `string`; `voiceId?`: `string`; `durationSeconds?`: `number`; \}; \}; \} |
2377
+ | `computerId` | `string` |
2378
+ | `response` | `Response` |
2172
2379
 
2173
2380
  #### Returns
2174
2381
 
@@ -2176,6 +2383,55 @@ Decode bounded service replies once for both MEDIA host bindings.
2176
2383
 
2177
2384
  ---
2178
2385
 
2386
+ ### quoteMediaGeneration()
2387
+
2388
+ ```ts
2389
+ function quoteMediaGeneration(
2390
+ raw,
2391
+ references,
2392
+ ): Promise<
2393
+ Readonly<
2394
+ Readonly<{
2395
+ unit: "image" | "video_second" | "audio_second" | "audio_character_block";
2396
+ units: number;
2397
+ }> &
2398
+ object
2399
+ >
2400
+ >;
2401
+ ```
2402
+
2403
+ Quote one exact request: the same settings validation, reference reads,
2404
+ estimator and billing units a generation uses at admission, run without
2405
+ dispatching anything. A host applies its billing policy to this per unit, the
2406
+ way its metering does, so the number matches the charge.
2407
+
2408
+ #### Parameters
2409
+
2410
+ | Parameter | Type | Description |
2411
+ | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
2412
+ | `raw` | \{ `model`: `string`; `prompt`: `string`; `width?`: `number`; `height?`: `number`; `steps?`: `number`; `durationSeconds?`: `number`; `voiceId?`: `string`; `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`[]; `audioReferences?`: `object`[]; \} | - |
2413
+ | `raw.model` | `string` | Provider catalog model identifier. |
2414
+ | `raw.prompt` | `string` | Generation prompt; each model's `maxPromptLength` is enforced on top of this ceiling. |
2415
+ | `raw.width?` | `number` | Requested image width or nominal video selector; absent for audio. |
2416
+ | `raw.height?` | `number` | Requested image height or nominal video selector; absent for audio. |
2417
+ | `raw.steps?` | `number` | Model-specific inference step count. |
2418
+ | `raw.durationSeconds?` | `number` | Requested video or music length in whole seconds. |
2419
+ | `raw.voiceId?` | `string` | Speech models only: a premade voice from the catalog; the default when omitted. |
2420
+ | `raw.resolution?` | `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"` | Video resolution; must match the nominal width/height selector. |
2421
+ | `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. |
2422
+ | `raw.generateAudio?` | `boolean` | Video audio selection. |
2423
+ | `raw.references?` | `object`[] | Host-authorized reference images. |
2424
+ | `raw.audioReferences?` | `object`[] | Host-authorized reference audio clips; only a model declaring `audioReferences` takes them. |
2425
+ | `references` | [`MediaReferenceReader`](index.md#mediareferencereader) | - |
2426
+
2427
+ #### Returns
2428
+
2429
+ `Promise`\<`Readonly`\<`Readonly`\<\{ `unit`: `"image"` \| `"video_second"` \|
2430
+ `"audio_second"` \| `"audio_character_block"`; `units`: `number`; \}\> &
2431
+ `object`\>\>
2432
+
2433
+ ---
2434
+
2179
2435
  ### generateMedia()
2180
2436
 
2181
2437
  ```ts