@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/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # @ai-sdk/topaz
2
+
3
+ ## 3.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 09aa6c2: feat (provider/topaz): add Topaz Labs provider
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [8c65988]
12
+ - Updated dependencies [527a163]
13
+ - @ai-sdk/provider@4.0.21
14
+ - @ai-sdk/provider-utils@5.0.53
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Vercel, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md CHANGED
@@ -1,4 +1,68 @@
1
- # @ai-sdk/topaz
1
+ # AI SDK - Topaz Labs Provider
2
2
 
3
- Seed package provisioned by the internal npm provisioning control plane.
4
- Releases are published from [`vercel/ai`](https://github.com/vercel/ai) via `release.yml` using npm Trusted Publishing.
3
+ The **Topaz Labs provider** for the [AI SDK](https://ai-sdk.dev/docs) contains image and video model support for the [Topaz Labs API](https://developer.topazlabs.com).
4
+
5
+ Topaz models **enhance media you supply**. They upscale, denoise, sharpen and restore an existing image or video, and do not generate media from a text prompt.
6
+
7
+ > **Deploying to Vercel?** With Vercel's AI Gateway you can access Topaz Labs (and hundreds of models from other providers) — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
8
+
9
+ ## Setup
10
+
11
+ The Topaz Labs provider is available in the `@ai-sdk/topaz` module. You can install it with:
12
+
13
+ ```bash
14
+ npm i @ai-sdk/topaz
15
+ ```
16
+
17
+ ## Skill for Coding Agents
18
+
19
+ If you use coding agents such as Claude Code or Cursor, we highly recommend adding the AI SDK skill to your repository:
20
+
21
+ ```shell
22
+ npx skills add vercel/ai
23
+ ```
24
+
25
+ ## Provider Instance
26
+
27
+ You can import the default provider instance `topaz` from `@ai-sdk/topaz`:
28
+
29
+ ```ts
30
+ import { topaz } from '@ai-sdk/topaz';
31
+ ```
32
+
33
+ The default instance reads the API key from the `TOPAZ_API_KEY` environment variable. Use `createTopaz({ apiKey })` to pass it explicitly. See [API Key Setup](https://developer.topazlabs.com/getting-started/api-key-setup) to create a key.
34
+
35
+ ## Image Enhancement Example
36
+
37
+ ```ts
38
+ import { topaz } from '@ai-sdk/topaz';
39
+ import { generateImage } from 'ai';
40
+
41
+ const { image } = await generateImage({
42
+ model: topaz.image('wonder-3.5'),
43
+ prompt: {
44
+ images: ['https://example.com/photo.jpg'],
45
+ },
46
+ size: '4096x4096',
47
+ });
48
+ ```
49
+
50
+ ## Video Enhancement Example
51
+
52
+ `generateVideo` requires a prompt, so pass an empty one. `resolution` sets the output resolution. Starlight models also need the input video's properties in the `source` provider option:
53
+
54
+ ```ts
55
+ import { topaz } from '@ai-sdk/topaz';
56
+ import { experimental_generateVideo as generateVideo } from 'ai';
57
+
58
+ const { videos } = await generateVideo({
59
+ model: topaz.video('proteus'),
60
+ prompt: '',
61
+ inputReferences: ['https://example.com/clip.mp4'],
62
+ resolution: '3840x2160',
63
+ });
64
+ ```
65
+
66
+ ## Documentation
67
+
68
+ Please check out the **[Topaz Labs provider](https://ai-sdk.dev/providers/ai-sdk-providers/topaz)** for more information.
@@ -0,0 +1,247 @@
1
+ import { Experimental_VideoModelV4, ImageModelV4, ProviderV4 } from "@ai-sdk/provider";
2
+ import { FetchFunction, InferSchema } from "@ai-sdk/provider-utils";
3
+ import { z } from "zod/v4";
4
+ //#region src/topaz-image-settings.d.ts
5
+ /**
6
+ * Topaz image model ids.
7
+ *
8
+ * The AI SDK exposes a readable id that is mapped onto the name the Topaz API
9
+ * expects in the `model` form field (see `topazImageApiModelIds`). Passing a
10
+ * raw Topaz name such as `Wonder 3.5` also works - unknown ids are forwarded
11
+ * to the API unchanged.
12
+ */
13
+ type TopazImageModelId = 'wonder-3.5' | (string & {});
14
+ //#endregion
15
+ //#region src/topaz-video-settings.d.ts
16
+ /**
17
+ * Topaz video model ids.
18
+ *
19
+ * The AI SDK exposes readable ids that are mapped onto the short names the
20
+ * Topaz API expects in the `filters[].model` field (see
21
+ * `topazVideoApiModelIds`). Passing a raw Topaz name such as `slp-2.6` also
22
+ * works - unknown ids are forwarded to the API unchanged.
23
+ */
24
+ type TopazVideoModelId = 'proteus' | 'starlight-precise-2.6' | (string & {});
25
+ //#endregion
26
+ //#region src/topaz-provider.d.ts
27
+ interface TopazProviderSettings {
28
+ /**
29
+ * Topaz Labs API key. Default value is taken from the `TOPAZ_API_KEY`
30
+ * environment variable.
31
+ *
32
+ * @see https://developer.topazlabs.com/getting-started/api-key-setup
33
+ */
34
+ apiKey?: string;
35
+ /**
36
+ * Base URL for the API calls.
37
+ */
38
+ baseURL?: string;
39
+ /**
40
+ * Custom headers to include in the requests.
41
+ */
42
+ headers?: Record<string, string>;
43
+ /**
44
+ * Custom fetch implementation. You can use it as a middleware to intercept
45
+ * requests, or to provide a custom fetch implementation for e.g. testing.
46
+ */
47
+ fetch?: FetchFunction;
48
+ }
49
+ interface TopazProvider extends ProviderV4 {
50
+ /**
51
+ * Creates a model for image enhancement.
52
+ */
53
+ image(modelId: TopazImageModelId): ImageModelV4;
54
+ /**
55
+ * Creates a model for image enhancement.
56
+ */
57
+ imageModel(modelId: TopazImageModelId): ImageModelV4;
58
+ /**
59
+ * Creates a model for video enhancement.
60
+ */
61
+ video(modelId: TopazVideoModelId): Experimental_VideoModelV4;
62
+ /**
63
+ * Creates a model for video enhancement.
64
+ */
65
+ videoModel(modelId: TopazVideoModelId): Experimental_VideoModelV4;
66
+ }
67
+ /**
68
+ * Create a Topaz Labs provider instance.
69
+ */
70
+ export declare function createTopaz(options?: TopazProviderSettings): TopazProvider;
71
+ /**
72
+ * Default Topaz Labs provider instance.
73
+ */
74
+ export declare const topaz: TopazProvider;
75
+ //#endregion
76
+ //#region src/topaz-image-model-options.d.ts
77
+ /**
78
+ * Provider options for Topaz generative image models (Wonder 3.5).
79
+ *
80
+ * The documented request schema fields are sent in snake_case
81
+ * (`output_width`, `output_format`, ...); model-specific settings are sent in
82
+ * camelCase, matching the Topaz model reference.
83
+ *
84
+ * @see https://developer.topazlabs.com/image-models/wonder/wonder-3.5-new
85
+ */
86
+ declare const topazImageModelOptionsSchema: import("@ai-sdk/provider-utils").LazySchema<{
87
+ enhancementStrength?: "low" | "medium" | "high" | undefined;
88
+ grain?: boolean | undefined;
89
+ grainDensity?: number | undefined;
90
+ grainModel?: "silver" | "gaussian" | "grey" | undefined;
91
+ grainSize?: number | undefined;
92
+ grainStrength?: number | undefined;
93
+ inputWidth?: number | undefined;
94
+ inputHeight?: number | undefined;
95
+ outputWidth?: number | undefined;
96
+ outputHeight?: number | undefined;
97
+ outputFormat?: "jpeg" | "jpg" | "png" | "tiff" | "tif" | undefined;
98
+ cropToFill?: boolean | undefined;
99
+ webhookUrl?: string | undefined;
100
+ pollIntervalMillis?: number | undefined;
101
+ pollTimeoutMillis?: number | undefined;
102
+ }>;
103
+ type TopazImageModelOptions = InferSchema<typeof topazImageModelOptionsSchema>;
104
+ //#endregion
105
+ //#region src/topaz-video-model-options.d.ts
106
+ /**
107
+ * Metadata about the input video.
108
+ *
109
+ * Starlight models require `width`, `height`, `duration` and `frameRate`
110
+ * (Topaz prices them from these values), and for other models they let Topaz
111
+ * estimate the cost before it has the video. The AI SDK does not inspect
112
+ * media files, so the values come from the caller. Setting any of them
113
+ * requires all four.
114
+ */
115
+ declare const topazVideoSourceSchema: z.ZodObject<{
116
+ width: z.ZodOptional<z.ZodNumber>;
117
+ height: z.ZodOptional<z.ZodNumber>;
118
+ duration: z.ZodOptional<z.ZodNumber>;
119
+ frameRate: z.ZodOptional<z.ZodNumber>;
120
+ frameCount: z.ZodOptional<z.ZodNumber>;
121
+ container: z.ZodOptional<z.ZodEnum<{
122
+ "3gp": "3gp";
123
+ avi: "avi";
124
+ dv: "dv";
125
+ flv: "flv";
126
+ m1v: "m1v";
127
+ m2t: "m2t";
128
+ m2ts: "m2ts";
129
+ m2v: "m2v";
130
+ m4v: "m4v";
131
+ mkv: "mkv";
132
+ mov: "mov";
133
+ mp4: "mp4";
134
+ mpeg: "mpeg";
135
+ mpg: "mpg";
136
+ mts: "mts";
137
+ mxf: "mxf";
138
+ ser: "ser";
139
+ ts: "ts";
140
+ vob: "vob";
141
+ webm: "webm";
142
+ wmv: "wmv";
143
+ }>>;
144
+ }, z.core.$strip>;
145
+ type TopazVideoSource = z.infer<typeof topazVideoSourceSchema>;
146
+ /**
147
+ * Output settings for the enhanced video.
148
+ */
149
+ declare const topazVideoOutputSchema: z.ZodObject<{
150
+ width: z.ZodOptional<z.ZodNumber>;
151
+ height: z.ZodOptional<z.ZodNumber>;
152
+ frameRate: z.ZodOptional<z.ZodNumber>;
153
+ audioCodec: z.ZodOptional<z.ZodEnum<{
154
+ AAC: "AAC";
155
+ AC3: "AC3";
156
+ PCM: "PCM";
157
+ }>>;
158
+ audioBitrate: z.ZodOptional<z.ZodString>;
159
+ audioTransfer: z.ZodOptional<z.ZodEnum<{
160
+ Copy: "Copy";
161
+ Convert: "Convert";
162
+ None: "None";
163
+ }>>;
164
+ videoEncoder: z.ZodOptional<z.ZodEnum<{
165
+ AV1: "AV1";
166
+ H264: "H264";
167
+ H265: "H265";
168
+ ProRes: "ProRes";
169
+ VP9: "VP9";
170
+ }>>;
171
+ videoProfile: z.ZodOptional<z.ZodString>;
172
+ videoBitrate: z.ZodOptional<z.ZodString>;
173
+ dynamicCompressionLevel: z.ZodOptional<z.ZodEnum<{
174
+ Low: "Low";
175
+ Mid: "Mid";
176
+ High: "High";
177
+ }>>;
178
+ cropToFit: z.ZodOptional<z.ZodBoolean>;
179
+ container: z.ZodOptional<z.ZodEnum<{
180
+ avi: "avi";
181
+ mkv: "mkv";
182
+ mov: "mov";
183
+ mp4: "mp4";
184
+ webm: "webm";
185
+ }>>;
186
+ }, z.core.$strip>;
187
+ type TopazVideoOutput = z.infer<typeof topazVideoOutputSchema>;
188
+ /**
189
+ * Provider options for Topaz video models.
190
+ *
191
+ * @see https://developer.topazlabs.com/video-models/proteus/proteus-1
192
+ * @see https://developer.topazlabs.com/video-models/starlight/starlight-precise-2.6
193
+ */
194
+ declare const topazVideoModelOptionsSchema: import("@ai-sdk/provider-utils").LazySchema<{
195
+ source?: {
196
+ width?: number | undefined;
197
+ height?: number | undefined;
198
+ duration?: number | undefined;
199
+ frameRate?: number | undefined;
200
+ frameCount?: number | undefined;
201
+ container?: "3gp" | "avi" | "dv" | "flv" | "m1v" | "m2t" | "m2ts" | "m2v" | "m4v" | "mkv" | "mov" | "mp4" | "mpeg" | "mpg" | "mts" | "mxf" | "ser" | "ts" | "vob" | "webm" | "wmv" | undefined;
202
+ } | undefined;
203
+ output?: {
204
+ width?: number | undefined;
205
+ height?: number | undefined;
206
+ frameRate?: number | undefined;
207
+ audioCodec?: "AAC" | "AC3" | "PCM" | undefined;
208
+ audioBitrate?: string | undefined;
209
+ audioTransfer?: "Copy" | "Convert" | "None" | undefined;
210
+ videoEncoder?: "AV1" | "H264" | "H265" | "ProRes" | "VP9" | undefined;
211
+ videoProfile?: string | undefined;
212
+ videoBitrate?: string | undefined;
213
+ dynamicCompressionLevel?: "Low" | "Mid" | "High" | undefined;
214
+ cropToFit?: boolean | undefined;
215
+ container?: "avi" | "mkv" | "mov" | "mp4" | "webm" | undefined;
216
+ } | undefined;
217
+ additionalFilters?: Record<string, unknown>[] | undefined;
218
+ filter?: Record<string, unknown> | undefined;
219
+ videoType?: "Progressive" | "Interlaced" | "ProgressiveInterlaced" | undefined;
220
+ auto?: "Auto" | "Manual" | "Relative" | undefined;
221
+ fieldOrder?: "Auto" | "TopFirst" | "BottomFirst" | undefined;
222
+ focusFixLevel?: "None" | "Normal" | "Strong" | undefined;
223
+ compression?: number | undefined;
224
+ details?: number | undefined;
225
+ prenoise?: number | undefined;
226
+ noise?: number | undefined;
227
+ halo?: number | undefined;
228
+ preblur?: number | undefined;
229
+ blur?: number | undefined;
230
+ grain?: number | undefined;
231
+ grainSigma?: number | undefined;
232
+ grainSize?: number | undefined;
233
+ grainType?: "gaussian" | "grey" | "silver_rich" | undefined;
234
+ recoverOriginalDetailValue?: number | undefined;
235
+ sharpness?: number | undefined;
236
+ videoBitDepth?: number | undefined;
237
+ videoCodec?: "ffv1" | "prores" | "vp9" | undefined;
238
+ videoProfile?: "420" | "422" | "444" | undefined;
239
+ watermark?: boolean | undefined;
240
+ }>;
241
+ type TopazVideoModelOptions = InferSchema<typeof topazVideoModelOptionsSchema>;
242
+ //#endregion
243
+ //#region src/version.d.ts
244
+ export declare const VERSION: string;
245
+ //#endregion
246
+ export type { TopazImageModelId, TopazImageModelOptions, TopazProvider, TopazProviderSettings, TopazVideoModelId, TopazVideoModelOptions, TopazVideoOutput, TopazVideoSource };
247
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":["VideoModelV4"],"sources":["../src/topaz-image-settings.ts","../src/topaz-video-settings.ts","../src/topaz-provider.ts","../src/topaz-image-model-options.ts","../src/topaz-video-model-options.ts","../src/version.ts"],"mappings":";;;;;;;;;;;;KAQY;;;;;;;;;;;KCAA;;;UCUK;;;;;;;EAOf;;;;EAKA;;;;EAKA,UAAU;;;;;EAMV,QAAQ;;UAGO,sBAAsB;;;;EAIrC,MAAM,SAAS,oBAAoB;;;;EAKnC,WAAW,SAAS,oBAAoB;;;;EAKxC,MAAM,SAAS,oBAAoBA;;;;EAKnC,WAAW,SAAS,oBAAoBA;;;;;wBAQ1B,YACd,UAAS,wBACR;;;;qBA8DU,OAAK;;;;;;;;;;;;cCvHL,+DAA4B;;;;;;;;;;;;;;;;;KAwF7B,yBAAyB,mBAC5B;;;;;;;;;;;;cCnDI,wBAAsB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCjC,EAAA,KAAA;KAEU,mBAAmB,EAAE,aAAa;;;;cAKjC,wBAAsB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEjC,EAAA,KAAA;KAEU,mBAAmB,EAAE,aAAa;;;;;;;cAQjC,+DAA4B;;;;;;;;;;;;;;;;;;;;;;;sBAA5B;WAAA;;;;;;;;;;;;;;;;;;;;;;;KA+FD,yBAAyB,mBAC5B;;;qBC5QI"}