@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
@@ -1,22 +1,39 @@
1
- import { getMediaModel, MediaSettingsError } from "./model-catalog.js";
2
- import { validateMediaGenerationSettings, estimateVideoMilliunits, } from "./index.js";
1
+ import { getGatewayModel, getMediaModel, mediaModels, MediaSettingsError, } from "./model-catalog.js";
2
+ import { validateMediaGenerationSettings, mediaSettingsInput, estimateVideoMilliunits, } from "./index.js";
3
+ import { AUDIO_CHARACTER_BLOCK } from "./model-catalog.js";
4
+ import { buildElevenLabsInput, estimateElevenLabsMilliunits, } from "./audio-providers/elevenlabs.js";
3
5
  import { imageDataUri } from "./video-providers/reference-encoding.js";
4
6
  import { videoProviderAdapters, } from "./video-providers/index.js";
5
- export const isGatewayModel = (id) => id === "openai/gpt-image-2" || getMediaModel(id)?.kind === "video";
7
+ export const isGatewayModel = (id) => {
8
+ if (id === "openai/gpt-image-2" || id === "bytedance/seedream-5-pro")
9
+ return true;
10
+ const kind = getGatewayModel(id)?.kind;
11
+ return kind === "video" || kind === "audio";
12
+ };
13
+ /** Re-run the settings grammar over already-normalized settings. */
14
+ const revalidate = (settings, catalogue = mediaModels) => validateMediaGenerationSettings(mediaSettingsInput(settings), catalogue);
6
15
  /** Billing units for validated settings; video bills its requested length. */
7
- export function mediaUnits(settings) {
8
- const model = getMediaModel(settings.model);
16
+ export function mediaUnits(settings, catalogue = mediaModels) {
17
+ const model = getMediaModel(settings.model, catalogue);
9
18
  if (model === undefined)
10
19
  throw new MediaSettingsError("billing units require a known Media model");
11
20
  if (model.kind === "video") {
12
- const checked = validateMediaGenerationSettings({
13
- ...settings,
14
- references: settings.references?.map((reference) => ({ ...reference })),
15
- });
21
+ const checked = revalidate(settings, catalogue);
16
22
  if (checked.durationSeconds === undefined)
17
23
  throw new MediaSettingsError("video settings need a duration");
18
24
  return { unit: "video_second", units: checked.durationSeconds };
19
25
  }
26
+ if (model.kind === "audio") {
27
+ const checked = revalidate(settings, catalogue);
28
+ if (model.audio?.mode === "speech")
29
+ return {
30
+ unit: "audio_character_block",
31
+ units: Math.ceil(checked.prompt.length / AUDIO_CHARACTER_BLOCK),
32
+ };
33
+ if (checked.durationSeconds === undefined)
34
+ throw new MediaSettingsError("music settings need a length");
35
+ return { unit: "audio_second", units: checked.durationSeconds };
36
+ }
20
37
  return { unit: "image", units: 1 };
21
38
  }
22
39
  /**
@@ -35,9 +52,11 @@ const gptImageOutputTokens = new Map([
35
52
  ]);
36
53
  const gptImageTokensPerMegapixel = 1_056 / 1_048_576;
37
54
  function gptImageOutputTokenCount(settings) {
55
+ const { width, height } = settings;
56
+ if (width === undefined || height === undefined)
57
+ throw new MediaSettingsError("an image needs a width and a height");
38
58
  const known = gptImageOutputTokens.get(sizeOf(settings));
39
- return (known ??
40
- Math.ceil(settings.width * settings.height * gptImageTokensPerMegapixel));
59
+ return known ?? Math.ceil(width * height * gptImageTokensPerMegapixel);
41
60
  }
42
61
  /**
43
62
  * USD per million tokens: text input, image input and image output, as
@@ -83,8 +102,16 @@ export function estimateGatewayMilliunits(settings, references) {
83
102
  inputImage * gptImageRates.inputImage) /
84
103
  10);
85
104
  }
86
- if (getMediaModel(settings.model)?.kind === "video")
105
+ // Cloudflare prices Seedream 5 Pro at $0.045 per image, and $0.03 per input
106
+ // image (none are sent); it states no price by size.
107
+ // https://developers.cloudflare.com/ai/models/bytedance/seedream-5-pro/
108
+ if (settings.model === "bytedance/seedream-5-pro")
109
+ return 4_500;
110
+ const model = getGatewayModel(settings.model);
111
+ if (model?.kind === "video")
87
112
  return estimateVideoMilliunits(settings);
113
+ if (model?.kind === "audio")
114
+ return estimateElevenLabsMilliunits(revalidate(settings), model);
88
115
  throw new MediaSettingsError(`${settings.model} is not a gateway model`);
89
116
  }
90
117
  /**
@@ -98,7 +125,7 @@ function gptImageReference(reference) {
98
125
  return imageDataUri(reference);
99
126
  }
100
127
  /** The provider JSON body for one validated gateway generation. */
101
- export function gatewayInput(settings, references = [], outputFormat = "png") {
128
+ export function gatewayInput(settings, references = [], outputFormat = "png", audioReferences = []) {
102
129
  if (settings.model === "openai/gpt-image-2") {
103
130
  const body = {
104
131
  prompt: settings.prompt,
@@ -112,11 +139,20 @@ export function gatewayInput(settings, references = [], outputFormat = "png") {
112
139
  return body;
113
140
  return { ...body, images: references.map(gptImageReference) };
114
141
  }
115
- const checked = validateMediaGenerationSettings({
116
- ...settings,
117
- references: settings.references?.map((reference) => ({ ...reference })),
118
- });
119
- const model = getMediaModel(checked.model);
142
+ if (settings.model === "bytedance/seedream-5-pro") {
143
+ if (references.length > 0)
144
+ throw new MediaSettingsError("bytedance/seedream-5-pro takes no reference images here");
145
+ // `watermark` is a required field; false adds none.
146
+ return {
147
+ prompt: settings.prompt,
148
+ size: sizeOf(settings),
149
+ watermark: false,
150
+ };
151
+ }
152
+ const checked = revalidate(settings);
153
+ const model = getGatewayModel(checked.model);
154
+ if (model?.audio != null)
155
+ return buildElevenLabsInput(checked, model);
120
156
  if (model?.video == null ||
121
157
  checked.resolution === undefined ||
122
158
  checked.aspectRatio === undefined ||
@@ -124,11 +160,13 @@ export function gatewayInput(settings, references = [], outputFormat = "png") {
124
160
  throw new MediaSettingsError("not a video gateway model");
125
161
  if (references.length !== (checked.references?.length ?? 0))
126
162
  throw new MediaSettingsError("resolved video references must match every admitted reference");
163
+ if (audioReferences.length !== (checked.audioReferences?.length ?? 0))
164
+ throw new MediaSettingsError("resolved audio references must match every admitted audio reference");
127
165
  const videoSettings = {
128
166
  ...checked,
129
167
  resolution: checked.resolution,
130
168
  aspectRatio: checked.aspectRatio,
131
169
  durationSeconds: checked.durationSeconds,
132
170
  };
133
- return videoProviderAdapters[model.video.provider].buildInput(videoSettings, references, model);
171
+ return videoProviderAdapters[model.video.provider].buildInput(videoSettings, references, model, audioReferences);
134
172
  }
@@ -7,6 +7,7 @@ export declare const gatewayOutputSchema: z.ZodLazy<z.ZodObject<{
7
7
  state: z.ZodOptional<z.ZodLiteral<"Completed">>;
8
8
  result: z.ZodObject<{
9
9
  image: z.ZodOptional<z.ZodLazy<z.ZodURL>>;
10
+ images: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodURL>>>;
10
11
  video: z.ZodOptional<z.ZodLazy<z.ZodURL>>;
11
12
  }, z.core.$loose>;
12
13
  }, z.core.$loose>>;
@@ -9,6 +9,8 @@ export const gatewayOutputSchema = z.lazy(() => z.looseObject({
9
9
  state: z.literal("Completed").optional(),
10
10
  result: z.looseObject({
11
11
  image: resultUrl.optional(),
12
+ /** Seedream answers with a list of result URLs. */
13
+ images: z.array(resultUrl).min(1).optional(),
12
14
  video: resultUrl.optional(),
13
15
  }),
14
16
  }));
package/dist/index.d.ts CHANGED
@@ -1,8 +1,11 @@
1
1
  import * as z from "zod";
2
- import { type MediaVideoReferenceRole, type MediaVideoModelId, type MediaVideoResolution, type MediaVideoAspectRatio } from "./model-catalog.js";
2
+ import type { MediaAudioReferenceBytes } from "./audio-reference-types.js";
3
+ import { type MediaVideoReferenceRole, type MediaCatalogue, type MediaVideoResolution, type MediaVideoAspectRatio } from "./model-catalog.js";
3
4
  export { mediaFailureStageSchema } from "./execution-error.js";
4
- export { MAX_MEDIA_PROMPT_LENGTH, getMediaModel, MAX_REFERENCE_COUNT, listMediaModels, mediaModelInputSchema, mediaModelSchema, mediaRequestedImageFormatSchema, mediaModels, mediaModelTierSchema, MediaSettingsError, mediaVideoModelIdSchema, mediaVideoResolutionSchema, mediaVideoAspectRatioSchema, mediaVideoReferenceRoleSchema, mediaVideoFormatSchema, mediaVideoSchema, } from "./model-catalog.js";
5
- export type { MediaModel, MediaModelInput, MediaModelTier, MediaVideoModelId, MediaVideoResolution, MediaVideoAspectRatio, MediaVideoReferenceRole, MediaVideoModel, MediaVideoFormat, } from "./model-catalog.js";
5
+ export { MAX_AUDIO_REFERENCE_BODY_BYTES, MAX_AUDIO_REFERENCE_BYTES, } from "./audio-reference-types.js";
6
+ export type { AudioReferenceMimeType, MediaAudioReferenceBytes, } from "./audio-reference-types.js";
7
+ export { MAX_MEDIA_PROMPT_LENGTH, getMediaModel, getGatewayModel, MAX_REFERENCE_COUNT, listMediaModels, listPictureMediaModels, mediaCatalogueSchema, mediaCatalogueModelSchema, parseMediaCatalogue, mediaModelInputSchema, mediaModelSchema, mediaRequestedImageFormatSchema, mediaModels, mediaModelTierSchema, MediaSettingsError, mediaVideoModelIdSchema, mediaVideoResolutionSchema, mediaVideoAspectRatioSchema, mediaVideoReferenceRoleSchema, mediaVideoFormatSchema, mediaVideoSchema, mediaAudioModelIdSchema, mediaAudioSchema, mediaAudioVoiceSchema, AUDIO_CHARACTER_BLOCK, } from "./model-catalog.js";
8
+ export type { MediaCatalogue, MediaCatalogueModel, MediaModel, MediaPictureModel, MediaModelInput, MediaModelTier, MediaVideoModelId, MediaVideoResolution, MediaVideoAspectRatio, MediaVideoReferenceRole, MediaVideoModel, MediaVideoFormat, MediaAudioModelId, MediaAudioModel, MediaAudioVoice, } from "./model-catalog.js";
6
9
  /** A reference file selected by the host, with its destination identity and path. */
7
10
  export type MediaReference = Readonly<{
8
11
  /** Host-admitted destination or reference identity. */
@@ -16,8 +19,8 @@ export type MediaReference = Readonly<{
16
19
  export type ImageFormat = "png" | "jpeg" | "gif" | "webp";
17
20
  /** MIME type corresponding to a supported image encoding. */
18
21
  export type ImageMimeType = `image/${ImageFormat}`;
19
- /** A saved generation: an image, or an MP4 from a video model. */
20
- export type MediaOutputFormat = ImageFormat | "mp4";
22
+ /** A saved generation: an image, an MP4 from a video model, or an MP3 from an audio model. */
23
+ export type MediaOutputFormat = ImageFormat | "mp4" | "mp3";
21
24
  /** Decoded reference bytes and the dimensions sent to the provider. */
22
25
  export type MediaReferenceBytes = Readonly<{
23
26
  /** Decoded reference image bytes. */
@@ -37,14 +40,16 @@ export type MediaGenerationSettings = Readonly<{
37
40
  model: string;
38
41
  /** Trimmed generation prompt. */
39
42
  prompt: string;
40
- /** Requested image width or nominal video resolution/aspect selector. */
41
- width: number;
42
- /** Requested image height or nominal video resolution/aspect selector. */
43
- height: number;
43
+ /** Requested image width or nominal video resolution/aspect selector; absent for audio. */
44
+ width?: number;
45
+ /** Requested image height or nominal video resolution/aspect selector; absent for audio. */
46
+ height?: number;
44
47
  /** Model-specific inference steps. */
45
48
  steps?: number;
46
- /** Video models only: output length in whole seconds. */
49
+ /** Video and music models only: output length in whole seconds. */
47
50
  durationSeconds?: number;
51
+ /** Speech models only: the catalog voice that reads the prompt. */
52
+ voiceId?: string;
48
53
  /** Video resolution selector, normalized from the catalog. */
49
54
  resolution?: MediaVideoResolution;
50
55
  /** Requested video aspect; a first image may override it upstream. */
@@ -53,12 +58,14 @@ export type MediaGenerationSettings = Readonly<{
53
58
  generateAudio?: boolean;
54
59
  /** Host-authorized reference files. */
55
60
  references?: readonly MediaReference[];
61
+ /** Host-authorized reference audio clips; video models declaring `audioReferences` only. */
62
+ audioReferences?: readonly MediaReference[];
56
63
  }>;
57
64
  /**
58
65
  * One Media provider call: validated settings and reference bytes in, output
59
66
  * bytes out. Hosts may bind it to Workers AI or their own transport.
60
67
  */
61
- export type MediaProvider = (settings: MediaGenerationSettings, references: readonly MediaReferenceBytes[], signal?: AbortSignal, outputFormat?: "png" | "jpeg" | "webp") => Promise<Readonly<{
68
+ export type MediaProvider = (settings: MediaGenerationSettings, references: readonly MediaReferenceBytes[], signal?: AbortSignal, outputFormat?: "png" | "jpeg" | "webp", audioReferences?: readonly MediaAudioReferenceBytes[]) => Promise<Readonly<{
62
69
  /** Generated output bytes. */
63
70
  bytes: Uint8Array;
64
71
  /** Actual output encoding. */
@@ -91,14 +98,17 @@ export declare const MAX_REFERENCE_BYTES: number;
91
98
  export declare const MAX_REFERENCE_BODY_BYTES: number;
92
99
  /** Maximum retained still-image output bytes. */
93
100
  export declare const MAX_OUTPUT_BYTES: number;
101
+ /** Schema ceiling for audio reference lists; each model's own `audioReferences.max` is enforced after parsing. */
102
+ export declare const MAX_AUDIO_REFERENCE_COUNT = 10;
94
103
  /** Structural wire grammar for one Media generation request. */
95
104
  export declare const mediaGenerationSettingsSchema: z.ZodObject<{
96
105
  model: z.ZodString;
97
106
  prompt: z.ZodString;
98
- width: z.ZodNumber;
99
- height: z.ZodNumber;
107
+ width: z.ZodOptional<z.ZodNumber>;
108
+ height: z.ZodOptional<z.ZodNumber>;
100
109
  steps: z.ZodOptional<z.ZodNumber>;
101
110
  durationSeconds: z.ZodOptional<z.ZodNumber>;
111
+ voiceId: z.ZodOptional<z.ZodString>;
102
112
  resolution: z.ZodOptional<z.ZodEnum<{
103
113
  readonly p480: "480p";
104
114
  readonly p720: "720p";
@@ -125,6 +135,10 @@ export declare const mediaGenerationSettingsSchema: z.ZodObject<{
125
135
  readonly reference: "reference";
126
136
  }>>;
127
137
  }, z.core.$strict>>>;
138
+ audioReferences: z.ZodOptional<z.ZodArray<z.ZodObject<{
139
+ computerId: z.ZodString;
140
+ path: z.ZodString;
141
+ }, z.core.$strict>>>;
128
142
  }, z.core.$strict>;
129
143
  /** Caller settings before model defaults and refinements are applied. */
130
144
  export type MediaGenerationSettingsInput = z.input<typeof mediaGenerationSettingsSchema>;
@@ -132,10 +146,11 @@ export type MediaGenerationSettingsInput = z.input<typeof mediaGenerationSetting
132
146
  export declare const mediaGenerationSelectionSchema: z.ZodObject<{
133
147
  model: z.ZodString;
134
148
  prompt: z.ZodString;
135
- width: z.ZodNumber;
136
- height: z.ZodNumber;
149
+ width: z.ZodOptional<z.ZodNumber>;
150
+ height: z.ZodOptional<z.ZodNumber>;
137
151
  steps: z.ZodOptional<z.ZodNumber>;
138
152
  durationSeconds: z.ZodOptional<z.ZodNumber>;
153
+ voiceId: z.ZodOptional<z.ZodString>;
139
154
  resolution: z.ZodOptional<z.ZodEnum<{
140
155
  readonly p480: "480p";
141
156
  readonly p720: "720p";
@@ -162,13 +177,22 @@ export declare const mediaGenerationSelectionSchema: z.ZodObject<{
162
177
  readonly reference: "reference";
163
178
  }>>;
164
179
  }, z.core.$strict>>>;
180
+ audioReferences: z.ZodOptional<z.ZodArray<z.ZodObject<{
181
+ computerId: z.ZodOptional<z.ZodString>;
182
+ path: z.ZodString;
183
+ }, z.core.$strict>>>;
165
184
  }, z.core.$strict>;
166
185
  /** Generation settings with reference paths resolved by an admitting host. */
167
186
  export type MediaGenerationSelection = z.output<typeof mediaGenerationSelectionSchema>;
168
- /** Validate caller settings and apply retained model defaults. */
169
- export declare const validateMediaGenerationSettings: (raw: MediaGenerationSettingsInput) => MediaGenerationSettings;
187
+ /** Mutable caller input for already-normalized settings, so they can be validated again. */
188
+ export declare const mediaSettingsInput: (settings: MediaGenerationSettings) => MediaGenerationSettingsInput;
189
+ /**
190
+ * Validate caller settings against `catalogue`, the active provider's model
191
+ * list (the Fungi gateway's by default), and apply that model's defaults.
192
+ */
193
+ export declare const validateMediaGenerationSettings: (raw: MediaGenerationSettingsInput, catalogue?: MediaCatalogue) => MediaGenerationSettings;
170
194
  /** Validate selections without granting Computer authority. */
171
- export declare const validateMediaGenerationSelection: (raw: z.input<typeof mediaGenerationSelectionSchema>) => Readonly<Omit<MediaGenerationSettings, "references"> & {
195
+ export declare const validateMediaGenerationSelection: (raw: z.input<typeof mediaGenerationSelectionSchema>, catalogue?: MediaCatalogue) => Readonly<Omit<MediaGenerationSettings, "references" | "audioReferences"> & {
172
196
  /** Host-authorized reference images. */
173
197
  references?: readonly Readonly<{
174
198
  /** Fixed destination or reference file path. */
@@ -178,6 +202,13 @@ export declare const validateMediaGenerationSelection: (raw: z.input<typeof medi
178
202
  /** Video-only reference role. */
179
203
  role?: MediaVideoReferenceRole;
180
204
  }>[];
205
+ /** Host-authorized reference audio clips. */
206
+ audioReferences?: readonly Readonly<{
207
+ /** Fixed reference file path. */
208
+ path: string;
209
+ /** Optional reference Computer; authorization remains host-owned. */
210
+ computerId?: string;
211
+ }>[];
181
212
  }>;
182
213
  /** Path-only video reference; the host supplies authority and reads its bytes. */
183
214
  export declare const mediaVideoReferenceSchema: z.ZodLazy<z.ZodObject<{
@@ -190,6 +221,12 @@ export declare const mediaVideoReferenceSchema: z.ZodLazy<z.ZodObject<{
190
221
  }, z.core.$strict>>;
191
222
  /** One path-only video reference. */
192
223
  export type MediaVideoReference = z.output<typeof mediaVideoReferenceSchema>;
224
+ /** Path-only audio reference; the host supplies authority and reads its bytes. */
225
+ export declare const mediaAudioReferenceSelectionSchema: z.ZodLazy<z.ZodObject<{
226
+ path: z.ZodString;
227
+ }, z.core.$strict>>;
228
+ /** One path-only audio reference. */
229
+ export type MediaAudioReferenceSelection = z.output<typeof mediaAudioReferenceSelectionSchema>;
193
230
  /** Neutral video selection; model-specific combinations are checked by validateMediaVideoSelection. */
194
231
  export declare const mediaVideoSelectionSchema: z.ZodLazy<z.ZodObject<{
195
232
  model: z.ZodEnum<{
@@ -228,13 +265,53 @@ export declare const mediaVideoSelectionSchema: z.ZodLazy<z.ZodObject<{
228
265
  readonly reference: "reference";
229
266
  }>;
230
267
  }, z.core.$strict>>>>;
268
+ audioReferences: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
269
+ path: z.ZodString;
270
+ }, z.core.$strict>>>>;
231
271
  }, z.core.$strict>>;
272
+ /**
273
+ * The same selection for a host's own catalogue: the model is any id that
274
+ * catalogue lists, checked by `validateMediaVideoSelection`.
275
+ */
276
+ declare const catalogueVideoSelectionSchema: z.ZodObject<{
277
+ prompt: z.ZodString;
278
+ resolution: z.ZodOptional<z.ZodEnum<{
279
+ readonly p480: "480p";
280
+ readonly p720: "720p";
281
+ readonly p768: "768p";
282
+ readonly p1080: "1080p";
283
+ readonly p4k: "4k";
284
+ }>>;
285
+ aspectRatio: z.ZodOptional<z.ZodEnum<{
286
+ readonly wide: "16:9";
287
+ readonly landscape: "4:3";
288
+ readonly square: "1:1";
289
+ readonly portrait: "3:4";
290
+ readonly tall: "9:16";
291
+ readonly ultrawide: "21:9";
292
+ readonly ultratall: "9:21";
293
+ }>>;
294
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
295
+ generateAudio: z.ZodOptional<z.ZodBoolean>;
296
+ references: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
297
+ path: z.ZodString;
298
+ role: z.ZodEnum<{
299
+ readonly first: "first-frame";
300
+ readonly last: "last-frame";
301
+ readonly reference: "reference";
302
+ }>;
303
+ }, z.core.$strict>>>>;
304
+ audioReferences: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
305
+ path: z.ZodString;
306
+ }, z.core.$strict>>>>;
307
+ model: z.ZodString;
308
+ }, z.core.$strict>;
232
309
  /** Caller video selection before defaults and model-specific refinements. */
233
310
  export type MediaVideoSelectionInput = z.input<typeof mediaVideoSelectionSchema>;
234
311
  /** Normalized path-only video settings, ready for host-authorized reference hydration. */
235
312
  export type MediaVideoSelection = Readonly<{
236
- /** Verified catalog video identifier. */
237
- model: MediaVideoModelId;
313
+ /** Catalogue video identifier. */
314
+ model: string;
238
315
  /** Trimmed, bounded prompt. */
239
316
  prompt: string;
240
317
  /** Nominal width selecting resolution/aspect, not decoded MP4 dimensions. */
@@ -251,16 +328,31 @@ export type MediaVideoSelection = Readonly<{
251
328
  generateAudio?: boolean;
252
329
  /** Normalized paths and required frame/reference roles. */
253
330
  references?: readonly Readonly<MediaVideoReference>[];
331
+ /** Normalized reference audio paths. */
332
+ audioReferences?: readonly Readonly<MediaAudioReferenceSelection>[];
254
333
  }>;
255
334
  /** Validate supported model/size/duration/reference combinations before authority or billing admission. */
256
- export declare function validateMediaVideoSelection(raw: MediaVideoSelectionInput): MediaVideoSelection;
335
+ export declare function validateMediaVideoSelection(raw: z.input<typeof catalogueVideoSelectionSchema>, catalogue?: MediaCatalogue): MediaVideoSelection;
336
+ /** Neutral audio selection: speech takes a voice, music a length; model-specific limits are checked by validateMediaGenerationSettings. */
337
+ export declare const mediaAudioSelectionSchema: z.ZodLazy<z.ZodObject<{
338
+ model: z.ZodEnum<{
339
+ readonly multilingual: "elevenlabs/eleven-multilingual-v2";
340
+ readonly v3: "elevenlabs/eleven-v3";
341
+ readonly music: "elevenlabs/music-v2";
342
+ }>;
343
+ prompt: z.ZodString;
344
+ voiceId: z.ZodOptional<z.ZodString>;
345
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
346
+ }, z.core.$strict>>;
347
+ /** Caller audio selection before defaults and model-specific refinements. */
348
+ export type MediaAudioSelectionInput = z.input<typeof mediaAudioSelectionSchema>;
257
349
  /** Host-authorized reader for decoded reference images. */
258
350
  export type MediaReferenceReader = Readonly<{
259
351
  /** Authorize and fit one reference for the selected catalog model. */
260
352
  read: (reference: MediaReference, model: string) => Promise<MediaReferenceBytes>;
261
353
  }>;
262
354
  /** Resolve only provider-accepted references through the caller's reader. */
263
- export declare const resolveMediaReferences: (settings: MediaGenerationSettings, reader: MediaReferenceReader) => Promise<readonly MediaReferenceBytes[]>;
355
+ export declare const resolveMediaReferences: (settings: MediaGenerationSettings, reader: MediaReferenceReader, catalogue?: MediaCatalogue) => Promise<readonly MediaReferenceBytes[]>;
264
356
  /** Provider JSON image input for models without multipart references. */
265
357
  export type MediaJsonBody = Readonly<{
266
358
  /** Generation prompt. */
@@ -364,5 +456,5 @@ export { neuronsToMilliunits, USD_PER_1K_NEURONS } from "./neurons.js";
364
456
  export type { ImageParams, ImageReference } from "./cost-estimate.js";
365
457
  /** Authority-free video quote settings; hydrated host settings are structurally compatible. */
366
458
  export type MediaVideoQuoteSettings = ReturnType<typeof validateMediaGenerationSelection>;
367
- /** Provider video cost from the sole catalog, in milliunits (1 cent = 1,000). Video-input references are unsupported. */
368
- export declare function estimateVideoMilliunits(settings: MediaVideoQuoteSettings): number;
459
+ /** Provider video cost from `catalogue`, in milliunits (1 cent = 1,000). Video-input references are unsupported. */
460
+ export declare function estimateVideoMilliunits(settings: MediaVideoQuoteSettings, catalogue?: MediaCatalogue): number;