@ai-sdk/topaz 0.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1154 @@
1
+ import { AISDKError, APICallError, InvalidArgumentError, InvalidResponseDataError, NoSuchModelError } from "@ai-sdk/provider";
2
+ import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertBase64ToUint8Array, createBinaryResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, delay, getFromApi, isSameOrigin, lazySchema, loadApiKey, mediaTypeToExtension, parseProviderOptions, postFormDataToApi, postJsonToApi, removeUndefinedEntries, resolve, serializeModelOptions, validateDownloadUrl, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
3
+ import { z } from "zod/v4";
4
+ //#region src/topaz-error.ts
5
+ /**
6
+ * The image API reports errors as `{ "message": ... }` and the video API as
7
+ * `{ "message": ..., "errorCode": ... }`. `detail` (a message or FastAPI's
8
+ * array of validation issues) and `error` are accepted as well because a few
9
+ * endpoints use them instead.
10
+ */
11
+ const topazErrorDataSchema = z.object({
12
+ detail: z.union([z.string(), z.array(z.object({ msg: z.string().nullish() }).loose())]).nullish(),
13
+ message: z.string().nullish(),
14
+ error: z.string().nullish(),
15
+ errorCode: z.string().nullish(),
16
+ errors: z.array(z.object({ msg: z.string().nullish() }).loose()).nullish()
17
+ });
18
+ function topazErrorToMessage(data) {
19
+ const message = baseErrorMessage(data);
20
+ const withCode = data.errorCode != null ? `${message} (${data.errorCode})` : message;
21
+ const issues = (data.errors ?? []).map((issue) => issue.msg).filter((msg) => msg != null);
22
+ return issues.length > 0 ? `${withCode}: ${issues.join("; ")}` : withCode;
23
+ }
24
+ function baseErrorMessage(data) {
25
+ const { detail } = data;
26
+ if (typeof detail === "string") return detail;
27
+ if (Array.isArray(detail)) {
28
+ const messages = detail.map((issue) => issue.msg).filter((msg) => msg != null);
29
+ if (messages.length > 0) return messages.join("; ");
30
+ }
31
+ return data.message ?? data.error ?? "Unknown Topaz API error";
32
+ }
33
+ const topazFailedResponseHandler = createJsonErrorResponseHandler({
34
+ errorSchema: topazErrorDataSchema,
35
+ errorToMessage: topazErrorToMessage
36
+ });
37
+ //#endregion
38
+ //#region src/topaz-image-model-options.ts
39
+ /**
40
+ * Provider options for Topaz generative image models (Wonder 3.5).
41
+ *
42
+ * The documented request schema fields are sent in snake_case
43
+ * (`output_width`, `output_format`, ...); model-specific settings are sent in
44
+ * camelCase, matching the Topaz model reference.
45
+ *
46
+ * @see https://developer.topazlabs.com/image-models/wonder/wonder-3.5-new
47
+ */
48
+ const topazImageModelOptionsSchema = lazySchema(() => zodSchema(z.object({
49
+ /**
50
+ * How aggressively the model enhances the image. Defaults to `high`.
51
+ */
52
+ enhancementStrength: z.enum([
53
+ "low",
54
+ "medium",
55
+ "high"
56
+ ]).optional(),
57
+ /**
58
+ * Whether to add grain to the output. Defaults to `false`.
59
+ */
60
+ grain: z.boolean().optional(),
61
+ /**
62
+ * Grain intensity, 0.0 to 1.0. Defaults to 0.5.
63
+ */
64
+ grainDensity: z.number().min(0).max(1).optional(),
65
+ /**
66
+ * Grain model. Defaults to `silver`.
67
+ */
68
+ grainModel: z.enum([
69
+ "silver",
70
+ "gaussian",
71
+ "grey"
72
+ ]).optional(),
73
+ /**
74
+ * Grain particle size, 1 to 5. Defaults to 1.
75
+ */
76
+ grainSize: z.number().min(1).max(5).optional(),
77
+ /**
78
+ * Grain effect strength, 0.0 to 1.0. Defaults to 0.5.
79
+ */
80
+ grainStrength: z.number().min(0).max(1).optional(),
81
+ /**
82
+ * Width of the input image in pixels. Topaz infers this from the upload when
83
+ * omitted.
84
+ */
85
+ inputWidth: z.number().int().positive().optional(),
86
+ /**
87
+ * Height of the input image in pixels. Topaz infers this from the upload
88
+ * when omitted.
89
+ */
90
+ inputHeight: z.number().int().positive().optional(),
91
+ /**
92
+ * Width of the output image in pixels, 1 to 32000. Takes precedence over the
93
+ * width derived from the `size` call option.
94
+ */
95
+ outputWidth: z.number().int().min(1).max(32e3).optional(),
96
+ /**
97
+ * Height of the output image in pixels, 1 to 32000. Takes precedence over
98
+ * the height derived from the `size` call option.
99
+ */
100
+ outputHeight: z.number().int().min(1).max(32e3).optional(),
101
+ /**
102
+ * Output image format. Defaults to the Topaz API default.
103
+ */
104
+ outputFormat: z.enum([
105
+ "jpeg",
106
+ "jpg",
107
+ "png",
108
+ "tiff",
109
+ "tif"
110
+ ]).optional(),
111
+ /**
112
+ * Whether to crop the output to fill the requested dimensions. Defaults to
113
+ * `false`.
114
+ */
115
+ cropToFill: z.boolean().optional(),
116
+ /**
117
+ * URL to receive job-status webhooks.
118
+ */
119
+ webhookUrl: z.string().optional(),
120
+ /**
121
+ * How often to poll the Topaz status endpoint, in milliseconds. Defaults to
122
+ * 2000.
123
+ */
124
+ pollIntervalMillis: z.number().int().positive().optional(),
125
+ /**
126
+ * How long to wait for the job to finish before failing, in milliseconds.
127
+ * Defaults to 600000 (10 minutes).
128
+ */
129
+ pollTimeoutMillis: z.number().int().positive().optional()
130
+ })));
131
+ //#endregion
132
+ //#region src/topaz-image-settings.ts
133
+ /**
134
+ * Maps AI SDK image model ids onto Topaz API model names.
135
+ *
136
+ * @see https://developer.topazlabs.com/image-models/wonder/wonder-3.5-new
137
+ */
138
+ const topazImageApiModelIds = { "wonder-3.5": "Wonder 3.5" };
139
+ function resolveTopazImageApiModelId(modelId) {
140
+ return topazImageApiModelIds[modelId] ?? modelId;
141
+ }
142
+ //#endregion
143
+ //#region src/topaz-image-model.ts
144
+ const DEFAULT_POLL_INTERVAL_MILLIS = 2e3;
145
+ const DEFAULT_POLL_TIMEOUT_MILLIS = 6e5;
146
+ /**
147
+ * Topaz enhances an image that the caller supplies, so `files` is required and
148
+ * exactly one image is processed per call.
149
+ */
150
+ var TopazImageModel = class TopazImageModel {
151
+ get provider() {
152
+ return this.config.provider;
153
+ }
154
+ static [WORKFLOW_SERIALIZE](model) {
155
+ return serializeModelOptions({
156
+ modelId: model.modelId,
157
+ config: model.config
158
+ });
159
+ }
160
+ static [WORKFLOW_DESERIALIZE](options) {
161
+ return new TopazImageModel(options.modelId, options.config);
162
+ }
163
+ constructor(modelId, config) {
164
+ this.modelId = modelId;
165
+ this.config = config;
166
+ this.specificationVersion = "v4";
167
+ this.maxImagesPerCall = 1;
168
+ this.supportsFileInputs = true;
169
+ this.supportsMaskInputs = false;
170
+ }
171
+ async doGenerate(options) {
172
+ const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
173
+ const warnings = [];
174
+ const topazOptions = await parseProviderOptions({
175
+ provider: "topaz",
176
+ providerOptions: options.providerOptions,
177
+ schema: topazImageModelOptionsSchema
178
+ });
179
+ const headers = combineHeaders(await resolve(this.config.headers), options.headers);
180
+ this.addUnsupportedWarnings(options, warnings);
181
+ const formData = await this.buildFormData(options, topazOptions, warnings);
182
+ const { value: submitResponse } = await postFormDataToApi({
183
+ url: `${this.config.baseURL}/image/v1/enhance-gen/async`,
184
+ headers,
185
+ formData,
186
+ successfulResponseHandler: createJsonResponseHandler(topazImageSubmitResponseSchema),
187
+ failedResponseHandler: topazFailedResponseHandler,
188
+ abortSignal: options.abortSignal,
189
+ fetch: this.config.fetch
190
+ });
191
+ const processId = submitResponse.process_id;
192
+ if (processId == null) throw new InvalidResponseDataError({
193
+ data: submitResponse,
194
+ message: "Topaz did not return a process_id for the enhance request."
195
+ });
196
+ let status;
197
+ try {
198
+ status = await this.waitForCompletion({
199
+ processId,
200
+ headers,
201
+ abortSignal: options.abortSignal,
202
+ pollIntervalMillis: topazOptions?.pollIntervalMillis ?? DEFAULT_POLL_INTERVAL_MILLIS,
203
+ pollTimeoutMillis: topazOptions?.pollTimeoutMillis ?? DEFAULT_POLL_TIMEOUT_MILLIS
204
+ });
205
+ } catch (error) {
206
+ if (options.abortSignal?.aborted) await this.cancelQuietly(processId, headers);
207
+ throw error;
208
+ }
209
+ const { image, responseHeaders } = await this.download({
210
+ processId,
211
+ headers,
212
+ abortSignal: options.abortSignal
213
+ });
214
+ return {
215
+ images: [image],
216
+ warnings,
217
+ response: {
218
+ timestamp: currentDate,
219
+ modelId: this.modelId,
220
+ headers: responseHeaders
221
+ },
222
+ providerMetadata: { topaz: { images: [{
223
+ processId,
224
+ ...status.credits != null ? { credits: status.credits } : {},
225
+ ...status.output_width != null ? { width: status.output_width } : {},
226
+ ...status.output_height != null ? { height: status.output_height } : {},
227
+ ...status.output_format != null ? { format: status.output_format } : {}
228
+ }] } }
229
+ };
230
+ }
231
+ addUnsupportedWarnings(options, warnings) {
232
+ if (options.prompt != null) warnings.push({
233
+ type: "unsupported",
234
+ feature: "prompt",
235
+ details: "Topaz image models enhance an existing image and do not take a text prompt. The prompt was ignored."
236
+ });
237
+ if (options.aspectRatio != null) warnings.push({
238
+ type: "unsupported",
239
+ feature: "aspectRatio",
240
+ details: "Topaz image models do not support aspectRatio. Use `size`, or the `outputWidth` / `outputHeight` provider options, to set output dimensions."
241
+ });
242
+ if (options.seed != null) warnings.push({
243
+ type: "unsupported",
244
+ feature: "seed",
245
+ details: "Topaz image models do not support seed."
246
+ });
247
+ if (options.mask != null) warnings.push({
248
+ type: "unsupported",
249
+ feature: "mask",
250
+ details: "Topaz image models do not support masks. The mask was ignored."
251
+ });
252
+ if (options.n > 1) warnings.push({
253
+ type: "unsupported",
254
+ feature: "n",
255
+ details: "Topaz image models enhance one image per call. Only 1 image will be returned."
256
+ });
257
+ }
258
+ async buildFormData(options, topazOptions, warnings) {
259
+ const file = options.files?.[0];
260
+ if (file == null) throw new InvalidArgumentError({
261
+ argument: "files",
262
+ message: "Topaz image models enhance an existing image. Pass the input image via `prompt.images`."
263
+ });
264
+ if (options.files != null && options.files.length > 1) warnings.push({
265
+ type: "unsupported",
266
+ feature: "files",
267
+ details: "Topaz image models enhance one image per call. Only the first file was used."
268
+ });
269
+ const formData = new FormData();
270
+ formData.append("model", resolveTopazImageApiModelId(this.modelId));
271
+ if (file.type === "url") formData.append("source_url", file.url);
272
+ else {
273
+ const bytes = typeof file.data === "string" ? convertBase64ToUint8Array(file.data) : file.data;
274
+ const extension = mediaTypeToExtension(file.mediaType) ?? "png";
275
+ formData.append("image", new File([bytes], `image.${extension}`, { type: file.mediaType }));
276
+ }
277
+ const { width, height } = parseSize(options.size);
278
+ appendIfDefined(formData, "output_width", topazOptions?.outputWidth ?? width);
279
+ appendIfDefined(formData, "output_height", topazOptions?.outputHeight ?? height);
280
+ appendIfDefined(formData, "output_format", topazOptions?.outputFormat);
281
+ appendIfDefined(formData, "crop_to_fill", topazOptions?.cropToFill);
282
+ appendIfDefined(formData, "webhook_url", topazOptions?.webhookUrl);
283
+ appendIfDefined(formData, "enhancementStrength", topazOptions?.enhancementStrength);
284
+ appendIfDefined(formData, "grain", topazOptions?.grain);
285
+ appendIfDefined(formData, "grainDensity", topazOptions?.grainDensity);
286
+ appendIfDefined(formData, "grainModel", topazOptions?.grainModel);
287
+ appendIfDefined(formData, "grainSize", topazOptions?.grainSize);
288
+ appendIfDefined(formData, "grainStrength", topazOptions?.grainStrength);
289
+ appendIfDefined(formData, "inputWidth", topazOptions?.inputWidth);
290
+ appendIfDefined(formData, "inputHeight", topazOptions?.inputHeight);
291
+ return formData;
292
+ }
293
+ async waitForCompletion({ processId, headers, abortSignal, pollIntervalMillis, pollTimeoutMillis }) {
294
+ const deadline = Date.now() + pollTimeoutMillis;
295
+ while (true) {
296
+ const { value: status } = await getFromApi({
297
+ url: `${this.config.baseURL}/image/v1/status/${processId}`,
298
+ validateUrl: false,
299
+ headers,
300
+ successfulResponseHandler: createJsonResponseHandler(topazImageStatusResponseSchema),
301
+ failedResponseHandler: topazFailedResponseHandler,
302
+ abortSignal,
303
+ fetch: this.config.fetch
304
+ });
305
+ if (status.status === "Completed") return status;
306
+ if (status.status === "Failed" || status.status === "Cancelled") throw new AISDKError({
307
+ name: "TOPAZ_IMAGE_ENHANCEMENT_FAILED",
308
+ message: `Topaz image enhancement ${status.status.toLowerCase()} for process ${processId}.`
309
+ });
310
+ if (Date.now() + pollIntervalMillis > deadline) {
311
+ await this.cancelQuietly(processId, headers ?? {});
312
+ throw new AISDKError({
313
+ name: "TOPAZ_IMAGE_ENHANCEMENT_TIMEOUT",
314
+ message: `Topaz image enhancement did not finish within ${pollTimeoutMillis}ms (process ${processId}, last status ${status.status ?? "unknown"}). Increase the \`pollTimeoutMillis\` provider option if the job needs longer.`
315
+ });
316
+ }
317
+ await delay(pollIntervalMillis, { abortSignal });
318
+ }
319
+ }
320
+ async cancelQuietly(processId, headers) {
321
+ const fetchImpl = this.config.fetch ?? globalThis.fetch;
322
+ try {
323
+ await fetchImpl(`${this.config.baseURL}/image/v1/cancel/${processId}`, {
324
+ method: "DELETE",
325
+ headers: removeUndefinedEntries(headers)
326
+ });
327
+ } catch {}
328
+ }
329
+ async download({ processId, headers, abortSignal }) {
330
+ const { value: downloadResponse } = await getFromApi({
331
+ url: `${this.config.baseURL}/image/v1/download/${processId}`,
332
+ validateUrl: false,
333
+ headers,
334
+ successfulResponseHandler: createJsonResponseHandler(topazImageDownloadResponseSchema),
335
+ failedResponseHandler: topazFailedResponseHandler,
336
+ abortSignal,
337
+ fetch: this.config.fetch
338
+ });
339
+ const downloadUrl = downloadResponse.download_url;
340
+ if (downloadUrl == null) throw new InvalidResponseDataError({
341
+ data: downloadResponse,
342
+ message: `Topaz did not return a download URL for process ${processId}.`
343
+ });
344
+ const { value: image, responseHeaders } = await getFromApi({
345
+ url: downloadUrl,
346
+ validateUrl: true,
347
+ credentialedOrigin: this.config.baseURL,
348
+ trustedOrigin: this.config.baseURL,
349
+ headers,
350
+ successfulResponseHandler: createBinaryResponseHandler(),
351
+ failedResponseHandler: topazFailedResponseHandler,
352
+ abortSignal,
353
+ fetch: this.config.fetch
354
+ });
355
+ return {
356
+ image,
357
+ responseHeaders
358
+ };
359
+ }
360
+ };
361
+ function parseSize(size) {
362
+ if (size == null) return {
363
+ width: void 0,
364
+ height: void 0
365
+ };
366
+ const [width, height] = size.split("x").map(Number);
367
+ return {
368
+ width,
369
+ height
370
+ };
371
+ }
372
+ function appendIfDefined(formData, key, value) {
373
+ if (value !== void 0) formData.append(key, String(value));
374
+ }
375
+ const topazImageSubmitResponseSchema = z.object({ process_id: z.string().nullish() });
376
+ const topazImageStatusResponseSchema = z.object({
377
+ status: z.string().nullish(),
378
+ credits: z.number().nullish(),
379
+ output_width: z.number().nullish(),
380
+ output_height: z.number().nullish(),
381
+ output_format: z.string().nullish()
382
+ });
383
+ const topazImageDownloadResponseSchema = z.object({ download_url: z.string().nullish() });
384
+ //#endregion
385
+ //#region src/topaz-video-model-options.ts
386
+ /**
387
+ * Containers Topaz accepts for the input video.
388
+ */
389
+ const topazSourceContainers = [
390
+ "3gp",
391
+ "avi",
392
+ "dv",
393
+ "flv",
394
+ "m1v",
395
+ "m2t",
396
+ "m2ts",
397
+ "m2v",
398
+ "m4v",
399
+ "mkv",
400
+ "mov",
401
+ "mp4",
402
+ "mpeg",
403
+ "mpg",
404
+ "mts",
405
+ "mxf",
406
+ "ser",
407
+ "ts",
408
+ "vob",
409
+ "webm",
410
+ "wmv"
411
+ ];
412
+ /**
413
+ * Containers Topaz can produce for the enhanced video.
414
+ */
415
+ const topazOutputContainers = [
416
+ "mp4",
417
+ "mov",
418
+ "mkv",
419
+ "avi",
420
+ "webm"
421
+ ];
422
+ /**
423
+ * Metadata about the input video.
424
+ *
425
+ * Starlight models require `width`, `height`, `duration` and `frameRate`
426
+ * (Topaz prices them from these values), and for other models they let Topaz
427
+ * estimate the cost before it has the video. The AI SDK does not inspect
428
+ * media files, so the values come from the caller. Setting any of them
429
+ * requires all four.
430
+ */
431
+ const topazVideoSourceSchema = z.object({
432
+ /**
433
+ * Width of the input video in pixels.
434
+ */
435
+ width: z.number().int().positive().optional(),
436
+ /**
437
+ * Height of the input video in pixels.
438
+ */
439
+ height: z.number().int().positive().optional(),
440
+ /**
441
+ * Duration of the input video in seconds.
442
+ */
443
+ duration: z.number().positive().optional(),
444
+ /**
445
+ * Frame rate of the input video.
446
+ */
447
+ frameRate: z.number().positive().optional(),
448
+ /**
449
+ * Total number of frames in the input video. Derived from
450
+ * `duration * frameRate` when omitted, which is only correct for
451
+ * constant-frame-rate input, so set it explicitly for variable-frame-rate
452
+ * sources.
453
+ */
454
+ frameCount: z.number().int().positive().optional(),
455
+ /**
456
+ * Container of the input video. Detected from the input file's media type
457
+ * or URL extension when omitted.
458
+ */
459
+ container: z.enum(topazSourceContainers).optional()
460
+ });
461
+ /**
462
+ * Output settings for the enhanced video.
463
+ */
464
+ const topazVideoOutputSchema = z.object({
465
+ /**
466
+ * Width of the output video in pixels. Takes precedence over the
467
+ * `resolution` call option.
468
+ */
469
+ width: z.number().int().positive().optional(),
470
+ /**
471
+ * Height of the output video in pixels. Takes precedence over the
472
+ * `resolution` call option.
473
+ */
474
+ height: z.number().int().positive().optional(),
475
+ /**
476
+ * Frame rate of the output video. Takes precedence over the `fps` call
477
+ * option. Topaz only changes the frame rate when a frame-interpolation
478
+ * filter is present.
479
+ */
480
+ frameRate: z.number().positive().optional(),
481
+ /**
482
+ * Audio codec of the output video. Defaults to `AAC`.
483
+ */
484
+ audioCodec: z.enum([
485
+ "AAC",
486
+ "AC3",
487
+ "PCM"
488
+ ]).optional(),
489
+ /**
490
+ * Audio bitrate, e.g. `192k`. Topaz uses the codec default when omitted.
491
+ */
492
+ audioBitrate: z.string().optional(),
493
+ /**
494
+ * How to handle the input audio track. Defaults to `Copy`.
495
+ */
496
+ audioTransfer: z.enum([
497
+ "Copy",
498
+ "Convert",
499
+ "None"
500
+ ]).optional(),
501
+ /**
502
+ * Video encoder. Topaz defaults to `H265`. `ProRes` forces a `mov`
503
+ * container, `AV1` and `VP9` force `mp4`.
504
+ */
505
+ videoEncoder: z.enum([
506
+ "AV1",
507
+ "H264",
508
+ "H265",
509
+ "ProRes",
510
+ "VP9"
511
+ ]).optional(),
512
+ /**
513
+ * Encoder profile, e.g. `Main10` for H265 or `422 HQ` for ProRes. Topaz uses
514
+ * the encoder's default profile when omitted.
515
+ */
516
+ videoProfile: z.string().optional(),
517
+ /**
518
+ * Constant bitrate, e.g. `20m`. Required for `VP9`. Mutually exclusive with
519
+ * `dynamicCompressionLevel`.
520
+ */
521
+ videoBitrate: z.string().optional(),
522
+ /**
523
+ * Automatic constant-quality compression level. Topaz defaults to `High`
524
+ * unless `videoBitrate` is set.
525
+ */
526
+ dynamicCompressionLevel: z.enum([
527
+ "Low",
528
+ "Mid",
529
+ "High"
530
+ ]).optional(),
531
+ /**
532
+ * Center-crop to fit the output dimensions.
533
+ */
534
+ cropToFit: z.boolean().optional(),
535
+ /**
536
+ * Container of the output video. Defaults to the input container when Topaz
537
+ * can produce it, otherwise `mp4`.
538
+ */
539
+ container: z.enum(topazOutputContainers).optional()
540
+ });
541
+ /**
542
+ * Provider options for Topaz video models.
543
+ *
544
+ * @see https://developer.topazlabs.com/video-models/proteus/proteus-1
545
+ * @see https://developer.topazlabs.com/video-models/starlight/starlight-precise-2.6
546
+ */
547
+ const topazVideoModelOptionsSchema = lazySchema(() => zodSchema(z.object({
548
+ source: topazVideoSourceSchema.optional(),
549
+ output: topazVideoOutputSchema.optional(),
550
+ /**
551
+ * Extra `filters[]` entries to send alongside the model's own filter, e.g. a
552
+ * frame-interpolation filter. Each entry must include a `model` key.
553
+ */
554
+ additionalFilters: z.array(z.record(z.string(), z.unknown())).optional(),
555
+ /**
556
+ * Escape hatch for filter settings this package does not model yet. Merged
557
+ * into the model's filter entry, taking precedence over the typed options
558
+ * below.
559
+ */
560
+ filter: z.record(z.string(), z.unknown()).optional(),
561
+ /** Proteus: how the input frames are encoded. */
562
+ videoType: z.enum([
563
+ "Progressive",
564
+ "Interlaced",
565
+ "ProgressiveInterlaced"
566
+ ]).optional(),
567
+ /** Proteus: parameter estimation mode. */
568
+ auto: z.enum([
569
+ "Auto",
570
+ "Manual",
571
+ "Relative"
572
+ ]).optional(),
573
+ /** Proteus: field order for interlaced input. */
574
+ fieldOrder: z.enum([
575
+ "TopFirst",
576
+ "BottomFirst",
577
+ "Auto"
578
+ ]).optional(),
579
+ /** Proteus: focus-fix strength. */
580
+ focusFixLevel: z.enum([
581
+ "None",
582
+ "Normal",
583
+ "Strong"
584
+ ]).optional(),
585
+ /** Proteus: compression artifact removal, -1 to 1. */
586
+ compression: z.number().min(-1).max(1).optional(),
587
+ /** Proteus: detail recovery, -1 to 1. */
588
+ details: z.number().min(-1).max(1).optional(),
589
+ /** Proteus: pre-processing noise reduction, 0 to 0.1. */
590
+ prenoise: z.number().min(0).max(.1).optional(),
591
+ /** Proteus: noise reduction, -1 to 1. */
592
+ noise: z.number().min(-1).max(1).optional(),
593
+ /** Proteus: halo suppression, -1 to 1. */
594
+ halo: z.number().min(-1).max(1).optional(),
595
+ /** Proteus: pre-processing blur, -1 to 1. */
596
+ preblur: z.number().min(-1).max(1).optional(),
597
+ /** Proteus: sharpening, -1 to 1. */
598
+ blur: z.number().min(-1).max(1).optional(),
599
+ /** Proteus: grain amount, 0 to 0.1. */
600
+ grain: z.number().min(0).max(.1).optional(),
601
+ /** Proteus: grain sigma, 0 to 1. */
602
+ grainSigma: z.number().min(0).max(1).optional(),
603
+ /** Proteus: grain size, 0 to 5. */
604
+ grainSize: z.number().min(0).max(5).optional(),
605
+ /** Proteus: grain model. */
606
+ grainType: z.enum([
607
+ "silver_rich",
608
+ "gaussian",
609
+ "grey"
610
+ ]).optional(),
611
+ /** Proteus: original detail recovery, 0 to 1. */
612
+ recoverOriginalDetailValue: z.number().min(0).max(1).optional(),
613
+ /** Starlight: sharpening applied to the output, 1.0 to 5.0. Defaults to 5.0. */
614
+ sharpness: z.number().min(1).max(5).optional(),
615
+ /** Starlight: output bit depth. */
616
+ videoBitDepth: z.number().int().positive().optional(),
617
+ /** Starlight: output video codec. */
618
+ videoCodec: z.enum([
619
+ "ffv1",
620
+ "prores",
621
+ "vp9"
622
+ ]).optional(),
623
+ /** Starlight: output chroma subsampling profile. */
624
+ videoProfile: z.enum([
625
+ "420",
626
+ "422",
627
+ "444"
628
+ ]).optional(),
629
+ /** Starlight: whether to watermark the output. Defaults to `false`. */
630
+ watermark: z.boolean().optional()
631
+ })));
632
+ /**
633
+ * Option keys that are structural rather than filter settings, so they are not
634
+ * forwarded into the `filters[]` entry.
635
+ */
636
+ const TOPAZ_NON_FILTER_OPTION_KEYS = [
637
+ "source",
638
+ "output",
639
+ "additionalFilters",
640
+ "filter"
641
+ ];
642
+ //#endregion
643
+ //#region src/topaz-video-settings.ts
644
+ /**
645
+ * Maps AI SDK video model ids onto Topaz API model names.
646
+ *
647
+ * @see https://developer.topazlabs.com/video-models/proteus/proteus-1
648
+ * @see https://developer.topazlabs.com/video-models/starlight/starlight-precise-2.6
649
+ */
650
+ const topazVideoApiModelIds = {
651
+ proteus: "prob-4",
652
+ "starlight-precise-2.6": "slp-2.6"
653
+ };
654
+ function resolveTopazVideoApiModelId(modelId) {
655
+ return topazVideoApiModelIds[modelId] ?? modelId;
656
+ }
657
+ //#endregion
658
+ //#region src/version.ts
659
+ const VERSION = "3.0.0";
660
+ //#endregion
661
+ //#region src/topaz-video-model.ts
662
+ const mediaTypeContainers = {
663
+ "video/mp4": "mp4",
664
+ "video/quicktime": "mov",
665
+ "video/mov": "mov",
666
+ "video/x-matroska": "mkv",
667
+ "video/matroska": "mkv",
668
+ "video/webm": "webm",
669
+ "video/x-msvideo": "avi",
670
+ "video/avi": "avi",
671
+ "video/mpeg": "mpeg",
672
+ "video/mp2t": "ts",
673
+ "video/x-ms-wmv": "wmv",
674
+ "video/x-flv": "flv",
675
+ "video/3gpp": "3gp",
676
+ "video/x-m4v": "m4v",
677
+ "application/mxf": "mxf"
678
+ };
679
+ const extensionContainers = {
680
+ ...Object.fromEntries(topazSourceContainers.map((c) => [c, c])),
681
+ qt: "mov"
682
+ };
683
+ const containerMediaTypes = {
684
+ mp4: "video/mp4",
685
+ m4v: "video/mp4",
686
+ mov: "video/quicktime",
687
+ mkv: "video/x-matroska",
688
+ webm: "video/webm",
689
+ avi: "video/x-msvideo",
690
+ mpeg: "video/mpeg",
691
+ mpg: "video/mpeg",
692
+ ts: "video/mp2t",
693
+ wmv: "video/x-ms-wmv",
694
+ flv: "video/x-flv",
695
+ "3gp": "video/3gpp",
696
+ mxf: "application/mxf"
697
+ };
698
+ /**
699
+ * Topaz video models enhance a video the caller supplies, passed through
700
+ * `inputReferences`. `doStart` creates an express request: Topaz fetches URL
701
+ * inputs itself, and file inputs are uploaded to the returned URL. Processing
702
+ * starts once Topaz has the video, and `doStatus` polls.
703
+ */
704
+ var TopazVideoModel = class TopazVideoModel {
705
+ get provider() {
706
+ return this.config.provider;
707
+ }
708
+ static [WORKFLOW_SERIALIZE](model) {
709
+ return serializeModelOptions({
710
+ modelId: model.modelId,
711
+ config: model.config
712
+ });
713
+ }
714
+ static [WORKFLOW_DESERIALIZE](options) {
715
+ return new TopazVideoModel(options.modelId, options.config);
716
+ }
717
+ constructor(modelId, config) {
718
+ this.modelId = modelId;
719
+ this.config = config;
720
+ this.specificationVersion = "v4";
721
+ this.maxVideosPerCall = 1;
722
+ }
723
+ async doStart(options) {
724
+ const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
725
+ const warnings = [];
726
+ const topazOptions = await parseProviderOptions({
727
+ provider: "topaz",
728
+ providerOptions: options.providerOptions,
729
+ schema: topazVideoModelOptionsSchema
730
+ });
731
+ const headers = combineHeaders(await resolve(this.config.headers), options.headers);
732
+ this.addUnsupportedWarnings(options, warnings);
733
+ const input = this.selectInputVideo(options, warnings);
734
+ const source = resolveSource(topazOptions, resolveContainer(input, topazOptions?.source?.container));
735
+ const output = buildOutput({
736
+ options,
737
+ topazOptions,
738
+ source
739
+ });
740
+ const filters = [buildFilter(this.modelId, topazOptions), ...topazOptions?.additionalFilters ?? []];
741
+ const contentType = containerMediaTypes[source.container] ?? "application/octet-stream";
742
+ const metadata = source.metadata;
743
+ const bytes = input.type === "file" ? fileBytes(input) : void 0;
744
+ let requestId;
745
+ try {
746
+ const { value: created, responseHeaders } = await postJsonToApi({
747
+ url: `${this.config.baseURL}/video/express`,
748
+ headers,
749
+ body: {
750
+ source: {
751
+ container: source.container,
752
+ ...metadata != null ? {
753
+ duration: metadata.duration,
754
+ frameCount: metadata.frameCount,
755
+ frameRate: metadata.frameRate,
756
+ resolution: {
757
+ width: metadata.width,
758
+ height: metadata.height
759
+ }
760
+ } : {},
761
+ ...input.type === "url" ? { external: {
762
+ provider: "s3",
763
+ presignedUrl: input.url
764
+ } } : { size: bytes?.byteLength }
765
+ },
766
+ output,
767
+ filters
768
+ },
769
+ successfulResponseHandler: createJsonResponseHandler(topazVideoExpressResponseSchema),
770
+ failedResponseHandler: topazFailedResponseHandler,
771
+ abortSignal: options.abortSignal,
772
+ fetch: this.config.fetch
773
+ });
774
+ requestId = requireRequestId(created.requestId);
775
+ if (bytes != null) await this.uploadVideo({
776
+ requestId,
777
+ bytes,
778
+ urls: created.uploadUrls,
779
+ contentType,
780
+ abortSignal: options.abortSignal
781
+ });
782
+ return {
783
+ operation: {
784
+ requestId,
785
+ outputContainer: output.container
786
+ },
787
+ warnings,
788
+ providerMetadata: { topaz: {
789
+ requestId,
790
+ ...created.estimates?.cost != null ? { estimatedCredits: created.estimates.cost } : {}
791
+ } },
792
+ response: {
793
+ timestamp: currentDate,
794
+ modelId: this.modelId,
795
+ headers: responseHeaders
796
+ }
797
+ };
798
+ } catch (error) {
799
+ if (requestId != null) await this.cancelQuietly(requestId, headers);
800
+ throw error;
801
+ }
802
+ }
803
+ async doStatus(options) {
804
+ const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
805
+ const { requestId, outputContainer } = options.operation;
806
+ const { value: status, responseHeaders } = await getFromApi({
807
+ url: `${this.config.baseURL}/video/${requestId}/status`,
808
+ validateUrl: false,
809
+ headers: combineHeaders(await resolve(this.config.headers), options.headers),
810
+ successfulResponseHandler: createJsonResponseHandler(topazVideoStatusResponseSchema),
811
+ failedResponseHandler: topazFailedResponseHandler,
812
+ abortSignal: options.abortSignal,
813
+ fetch: this.config.fetch
814
+ });
815
+ const response = {
816
+ timestamp: currentDate,
817
+ modelId: this.modelId,
818
+ headers: responseHeaders
819
+ };
820
+ if (status.status === "complete") {
821
+ const credits = lowerBoundCredits(status.estimates?.cost);
822
+ const url = status.download?.url;
823
+ if (url == null) throw new InvalidResponseDataError({
824
+ data: status,
825
+ message: `Topaz reported request ${requestId} complete but returned no download URL.`
826
+ });
827
+ return {
828
+ status: "completed",
829
+ videos: [{
830
+ type: "url",
831
+ url,
832
+ mediaType: (outputContainer != null ? containerMediaTypes[outputContainer] : void 0) ?? "video/mp4"
833
+ }],
834
+ warnings: [],
835
+ response,
836
+ providerMetadata: { topaz: {
837
+ requestId,
838
+ ...credits != null ? { credits } : {},
839
+ ...status.estimates?.cost != null ? { estimatedCredits: status.estimates.cost } : {},
840
+ ...status.outputSize != null ? { outputSize: status.outputSize } : {},
841
+ ...status.download?.expiresAt != null ? { expiresAt: status.download.expiresAt } : {}
842
+ } }
843
+ };
844
+ }
845
+ if (status.status === "failed" || status.status === "canceled") return {
846
+ status: "error",
847
+ error: `Topaz video request ${requestId} ${status.status}` + (status.errorCode != null ? ` (${status.errorCode})` : "") + (status.message != null ? `: ${status.message}` : "."),
848
+ providerMetadata: { topaz: {
849
+ requestId,
850
+ ...status.errorCode != null ? { errorCode: status.errorCode } : {}
851
+ } },
852
+ response
853
+ };
854
+ return {
855
+ status: "pending",
856
+ response
857
+ };
858
+ }
859
+ addUnsupportedWarnings(options, warnings) {
860
+ if (options.prompt != null && options.prompt.trim() !== "") warnings.push({
861
+ type: "unsupported",
862
+ feature: "prompt",
863
+ details: "Topaz video models enhance an existing video and do not take a text prompt. The prompt was ignored."
864
+ });
865
+ if (options.aspectRatio != null) warnings.push({
866
+ type: "unsupported",
867
+ feature: "aspectRatio",
868
+ details: "Topaz video models do not support aspectRatio. Use `resolution`, or the `output` provider option, to set the output dimensions."
869
+ });
870
+ if (options.seed != null) warnings.push({
871
+ type: "unsupported",
872
+ feature: "seed",
873
+ details: "Topaz video models do not support seed."
874
+ });
875
+ if (options.duration != null) warnings.push({
876
+ type: "unsupported",
877
+ feature: "duration",
878
+ details: "Topaz video models enhance the whole input video, so duration was ignored. Pass the input duration via the `source.duration` provider option instead."
879
+ });
880
+ if (options.generateAudio != null) warnings.push({
881
+ type: "unsupported",
882
+ feature: "generateAudio",
883
+ details: "Topaz video models do not generate audio. Use the `output.audioTransfer` provider option to control how the input audio track is carried over."
884
+ });
885
+ if (options.frameImages != null && options.frameImages.length > 0) warnings.push({
886
+ type: "unsupported",
887
+ feature: "frameImages",
888
+ details: "Topaz video models do not support first/last frame generation. The frame images were ignored."
889
+ });
890
+ if (options.n > 1) warnings.push({
891
+ type: "unsupported",
892
+ feature: "n",
893
+ details: "Topaz video models enhance one video per call. Only 1 video will be produced."
894
+ });
895
+ }
896
+ selectInputVideo(options, warnings) {
897
+ const references = options.inputReferences ?? [];
898
+ const videos = references.filter(isVideoReference);
899
+ if (videos.length === 0) {
900
+ if (options.image != null) throw new InvalidArgumentError({
901
+ argument: "image",
902
+ message: "Topaz video models enhance an existing video, not a still image. Pass the input video via `inputReferences`."
903
+ });
904
+ throw new InvalidArgumentError({
905
+ argument: "inputReferences",
906
+ message: "Topaz video models require an input video. Pass it via `inputReferences`, e.g. `inputReferences: [{ type: \"file\", mediaType: \"video/mp4\", data: bytes }]`. For URL references, include `mediaType` so the reference is recognized as a video."
907
+ });
908
+ }
909
+ if (references.length > 1) warnings.push({
910
+ type: "unsupported",
911
+ feature: "inputReferences",
912
+ details: "Topaz video models enhance a single video. Only the first video reference was used."
913
+ });
914
+ return videos[0];
915
+ }
916
+ async uploadVideo({ requestId, bytes, urls, contentType, abortSignal }) {
917
+ const url = urls?.[0];
918
+ if (url == null) throw new InvalidResponseDataError({
919
+ data: urls,
920
+ message: `Topaz returned no upload URL for request ${requestId}.`
921
+ });
922
+ if (!isSameOrigin(url, this.config.baseURL)) validateDownloadUrl(url);
923
+ const response = await (this.config.fetch ?? globalThis.fetch)(url, {
924
+ method: "PUT",
925
+ headers: withUserAgentSuffix({ "Content-Type": contentType }, `ai-sdk-topaz/${VERSION}`),
926
+ body: bytes,
927
+ signal: abortSignal
928
+ });
929
+ if (!response.ok) throw new APICallError({
930
+ message: `Uploading the input video failed with status ${response.status}.`,
931
+ url,
932
+ requestBodyValues: {},
933
+ statusCode: response.status,
934
+ responseHeaders: Object.fromEntries(response.headers.entries()),
935
+ responseBody: await response.text()
936
+ });
937
+ }
938
+ async cancelQuietly(requestId, headers) {
939
+ const fetchImpl = this.config.fetch ?? globalThis.fetch;
940
+ try {
941
+ await fetchImpl(`${this.config.baseURL}/video/${requestId}`, {
942
+ method: "DELETE",
943
+ headers: removeUndefinedEntries(headers)
944
+ });
945
+ } catch {}
946
+ }
947
+ };
948
+ function lowerBoundCredits(cost) {
949
+ return cost != null && cost.length > 0 ? Math.min(...cost) : void 0;
950
+ }
951
+ function fileBytes(input) {
952
+ return typeof input.data === "string" ? convertBase64ToUint8Array(input.data) : input.data;
953
+ }
954
+ function resolveContainer(input, declaredContainer) {
955
+ if (declaredContainer != null) return declaredContainer;
956
+ if (input.type === "file") {
957
+ const container = mediaTypeContainers[input.mediaType.toLowerCase()];
958
+ if (container == null) throw new InvalidArgumentError({
959
+ argument: "inputReferences",
960
+ message: `Could not map the media type "${input.mediaType}" onto a Topaz container. Set the \`source.container\` provider option explicitly.`
961
+ });
962
+ return container;
963
+ }
964
+ const container = (input.mediaType != null ? mediaTypeContainers[input.mediaType.toLowerCase()] : void 0) ?? containerFromUrl(input.url);
965
+ if (container == null) throw new InvalidArgumentError({
966
+ argument: "inputReferences",
967
+ message: `Could not determine the container of the input video at "${input.url}". Set the \`source.container\` provider option, or pass \`mediaType\` on the reference.`
968
+ });
969
+ return container;
970
+ }
971
+ function isVideoReference(reference) {
972
+ if (reference.type === "file") return reference.mediaType.toLowerCase().startsWith("video/");
973
+ if (reference.mediaType != null) return reference.mediaType.toLowerCase().startsWith("video/");
974
+ return containerFromUrl(reference.url) != null;
975
+ }
976
+ function containerFromUrl(url) {
977
+ const extension = url.split(/[?#]/)[0].split(".").pop()?.toLowerCase();
978
+ return extension != null ? extensionContainers[extension] : void 0;
979
+ }
980
+ /**
981
+ * Reads the optional source metadata, which is all or nothing. Starlight
982
+ * models require it, and it lets Topaz estimate the cost up front. Nothing is
983
+ * read out of the video bytes: no provider package inspects media files.
984
+ */
985
+ function resolveSource(topazOptions, container) {
986
+ const source = topazOptions?.source;
987
+ const { width, height, duration, frameRate } = source ?? {};
988
+ if (width == null && height == null && duration == null && frameRate == null && source?.frameCount == null) return {
989
+ container,
990
+ metadata: void 0
991
+ };
992
+ const frameCount = source?.frameCount ?? (duration != null && frameRate != null ? Math.round(duration * frameRate) : void 0);
993
+ const missing = [
994
+ width == null ? "source.width" : void 0,
995
+ height == null ? "source.height" : void 0,
996
+ duration == null ? "source.duration" : void 0,
997
+ frameRate == null ? "source.frameRate" : void 0
998
+ ].filter((field) => field != null);
999
+ if (width == null || height == null || duration == null || frameRate == null || frameCount == null) throw new InvalidArgumentError({
1000
+ argument: "providerOptions.topaz.source",
1001
+ message: `Source metadata must be complete. Missing: ${missing.join(", ")}.`
1002
+ });
1003
+ return {
1004
+ container,
1005
+ metadata: {
1006
+ duration,
1007
+ frameRate,
1008
+ frameCount,
1009
+ width,
1010
+ height
1011
+ }
1012
+ };
1013
+ }
1014
+ function parseResolution(resolution) {
1015
+ if (resolution == null) return {
1016
+ width: void 0,
1017
+ height: void 0
1018
+ };
1019
+ const [width, height] = resolution.split("x").map(Number);
1020
+ return {
1021
+ width,
1022
+ height
1023
+ };
1024
+ }
1025
+ function buildOutput({ options, topazOptions, source }) {
1026
+ const output = topazOptions?.output;
1027
+ const resolution = parseResolution(options.resolution);
1028
+ const width = output?.width ?? resolution.width ?? source.metadata?.width;
1029
+ const height = output?.height ?? resolution.height ?? source.metadata?.height;
1030
+ if (width == null || height == null) throw new InvalidArgumentError({
1031
+ argument: "resolution",
1032
+ message: "Topaz needs the output resolution. Set the `resolution` call option or the `output.width` / `output.height` provider options."
1033
+ });
1034
+ const frameRate = output?.frameRate ?? options.fps ?? source.metadata?.frameRate;
1035
+ const audioTransfer = output?.audioTransfer ?? "Copy";
1036
+ return {
1037
+ resolution: {
1038
+ width,
1039
+ height
1040
+ },
1041
+ ...frameRate != null ? { frameRate } : {},
1042
+ audioTransfer,
1043
+ ...audioTransfer !== "None" ? { audioCodec: output?.audioCodec ?? "AAC" } : output?.audioCodec != null ? { audioCodec: output.audioCodec } : {},
1044
+ ...output?.audioBitrate != null ? { audioBitrate: output.audioBitrate } : {},
1045
+ ...output?.videoEncoder != null ? { videoEncoder: output.videoEncoder } : {},
1046
+ ...output?.videoProfile != null ? { videoProfile: output.videoProfile } : {},
1047
+ ...output?.videoBitrate != null ? { videoBitrate: output.videoBitrate } : {},
1048
+ ...output?.dynamicCompressionLevel != null ? { dynamicCompressionLevel: output.dynamicCompressionLevel } : {},
1049
+ ...output?.cropToFit != null ? { cropToFit: output.cropToFit } : {},
1050
+ container: resolveOutputContainer(output, source.container)
1051
+ };
1052
+ }
1053
+ /**
1054
+ * Mirrors Topaz's container rules so `doStatus` can report the media type of
1055
+ * the file Topaz will actually produce.
1056
+ */
1057
+ function resolveOutputContainer(output, sourceContainer) {
1058
+ switch (output?.videoEncoder) {
1059
+ case "ProRes": return "mov";
1060
+ case "AV1":
1061
+ case "VP9": return "mp4";
1062
+ }
1063
+ if (output?.container != null) return output.container;
1064
+ return sourceContainer === "mov" || sourceContainer === "mkv" ? sourceContainer : "mp4";
1065
+ }
1066
+ function requireRequestId(requestId) {
1067
+ if (requestId == null) throw new InvalidResponseDataError({
1068
+ data: requestId,
1069
+ message: "Topaz did not return a requestId for the video request."
1070
+ });
1071
+ return requestId;
1072
+ }
1073
+ function buildFilter(modelId, topazOptions) {
1074
+ const filter = { model: resolveTopazVideoApiModelId(modelId) };
1075
+ if (topazOptions != null) {
1076
+ const nonFilterKeys = new Set(TOPAZ_NON_FILTER_OPTION_KEYS);
1077
+ for (const [key, value] of Object.entries(topazOptions)) if (!nonFilterKeys.has(key) && value !== void 0) filter[key] = value;
1078
+ Object.assign(filter, topazOptions.filter ?? {});
1079
+ }
1080
+ return filter;
1081
+ }
1082
+ const topazVideoEstimatesSchema = z.object({
1083
+ cost: z.array(z.number()).nullish(),
1084
+ time: z.array(z.number()).nullish()
1085
+ }).nullish();
1086
+ const topazVideoExpressResponseSchema = z.object({
1087
+ requestId: z.string().nullish(),
1088
+ uploadUrls: z.array(z.string()).nullish(),
1089
+ estimates: topazVideoEstimatesSchema
1090
+ });
1091
+ const topazVideoStatusResponseSchema = z.object({
1092
+ status: z.string().nullish(),
1093
+ message: z.string().nullish(),
1094
+ errorCode: z.string().nullish(),
1095
+ outputSize: z.union([z.string(), z.number()]).nullish(),
1096
+ estimates: topazVideoEstimatesSchema,
1097
+ download: z.object({
1098
+ url: z.string().nullish(),
1099
+ expiresAt: z.union([z.string(), z.number()]).nullish()
1100
+ }).nullish()
1101
+ });
1102
+ //#endregion
1103
+ //#region src/topaz-provider.ts
1104
+ const defaultBaseURL = "https://api.topazlabs.com";
1105
+ /**
1106
+ * Create a Topaz Labs provider instance.
1107
+ */
1108
+ function createTopaz(options = {}) {
1109
+ const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL) ?? defaultBaseURL;
1110
+ const getHeaders = () => withUserAgentSuffix({
1111
+ "X-API-Key": loadApiKey({
1112
+ apiKey: options.apiKey,
1113
+ environmentVariableName: "TOPAZ_API_KEY",
1114
+ description: "Topaz Labs"
1115
+ }),
1116
+ accept: "application/json",
1117
+ ...options.headers
1118
+ }, `ai-sdk-topaz/${VERSION}`);
1119
+ const createImageModel = (modelId) => new TopazImageModel(modelId, {
1120
+ provider: "topaz.image",
1121
+ baseURL,
1122
+ headers: getHeaders,
1123
+ fetch: options.fetch
1124
+ });
1125
+ const createVideoModel = (modelId) => new TopazVideoModel(modelId, {
1126
+ provider: "topaz.video",
1127
+ baseURL,
1128
+ headers: getHeaders,
1129
+ fetch: options.fetch
1130
+ });
1131
+ const noSuchModel = (modelId, modelType) => {
1132
+ throw new NoSuchModelError({
1133
+ modelId,
1134
+ modelType
1135
+ });
1136
+ };
1137
+ return {
1138
+ specificationVersion: "v4",
1139
+ image: createImageModel,
1140
+ imageModel: createImageModel,
1141
+ video: createVideoModel,
1142
+ videoModel: createVideoModel,
1143
+ languageModel: (modelId) => noSuchModel(modelId, "languageModel"),
1144
+ embeddingModel: (modelId) => noSuchModel(modelId, "embeddingModel")
1145
+ };
1146
+ }
1147
+ /**
1148
+ * Default Topaz Labs provider instance.
1149
+ */
1150
+ const topaz = createTopaz();
1151
+ //#endregion
1152
+ export { VERSION, createTopaz, topaz };
1153
+
1154
+ //# sourceMappingURL=index.js.map