@ai-sdk/topaz 0.0.0 → 2.0.1

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
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [604b4d3]
8
+ - @ai-sdk/provider-utils@4.0.58
9
+
10
+ ## 2.0.0
11
+
12
+ ### Major Changes
13
+
14
+ - 5da3c7e: feat (provider/topaz): add Topaz Labs provider
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,244 @@
1
+ import { ProviderV3, ImageModelV3, Experimental_VideoModelV3 } from '@ai-sdk/provider';
2
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
+ import { FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
4
+ import { z } from 'zod/v4';
5
+
6
+ /**
7
+ * Topaz image model ids.
8
+ *
9
+ * The AI SDK exposes a readable id that is mapped onto the name the Topaz API
10
+ * expects in the `model` form field (see `topazImageApiModelIds`). Passing a
11
+ * raw Topaz name such as `Wonder 3.5` also works - unknown ids are forwarded
12
+ * to the API unchanged.
13
+ */
14
+ type TopazImageModelId = 'wonder-3.5' | (string & {});
15
+
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
+
26
+ interface TopazProviderSettings {
27
+ /**
28
+ * Topaz Labs API key. Default value is taken from the `TOPAZ_API_KEY`
29
+ * environment variable.
30
+ *
31
+ * @see https://developer.topazlabs.com/getting-started/api-key-setup
32
+ */
33
+ apiKey?: string;
34
+ /**
35
+ * Base URL for the API calls.
36
+ */
37
+ baseURL?: string;
38
+ /**
39
+ * Custom headers to include in the requests.
40
+ */
41
+ headers?: Record<string, string>;
42
+ /**
43
+ * Custom fetch implementation. You can use it as a middleware to intercept
44
+ * requests, or to provide a custom fetch implementation for e.g. testing.
45
+ */
46
+ fetch?: FetchFunction;
47
+ }
48
+ interface TopazProvider extends ProviderV3 {
49
+ /**
50
+ * Creates a model for image enhancement.
51
+ */
52
+ image(modelId: TopazImageModelId): ImageModelV3;
53
+ /**
54
+ * Creates a model for image enhancement.
55
+ */
56
+ imageModel(modelId: TopazImageModelId): ImageModelV3;
57
+ /**
58
+ * Creates a model for video enhancement.
59
+ */
60
+ video(modelId: TopazVideoModelId): Experimental_VideoModelV3;
61
+ /**
62
+ * Creates a model for video enhancement.
63
+ */
64
+ videoModel(modelId: TopazVideoModelId): Experimental_VideoModelV3;
65
+ }
66
+ /**
67
+ * Create a Topaz Labs provider instance.
68
+ */
69
+ declare function createTopaz(options?: TopazProviderSettings): TopazProvider;
70
+ /**
71
+ * Default Topaz Labs provider instance.
72
+ */
73
+ declare const topaz: TopazProvider;
74
+
75
+ /**
76
+ * Provider options for Topaz generative image models (Wonder 3.5).
77
+ *
78
+ * The documented request schema fields are sent in snake_case
79
+ * (`output_width`, `output_format`, ...); model-specific settings are sent in
80
+ * camelCase, matching the Topaz model reference.
81
+ *
82
+ * @see https://developer.topazlabs.com/image-models/wonder/wonder-3.5-new
83
+ */
84
+ declare const topazImageModelOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
85
+ enhancementStrength?: "high" | "low" | "medium" | undefined;
86
+ grain?: boolean | undefined;
87
+ grainDensity?: number | undefined;
88
+ grainModel?: "silver" | "gaussian" | "grey" | undefined;
89
+ grainSize?: number | undefined;
90
+ grainStrength?: number | undefined;
91
+ inputWidth?: number | undefined;
92
+ inputHeight?: number | undefined;
93
+ outputWidth?: number | undefined;
94
+ outputHeight?: number | undefined;
95
+ outputFormat?: "jpeg" | "jpg" | "png" | "tiff" | "tif" | undefined;
96
+ cropToFill?: boolean | undefined;
97
+ webhookUrl?: string | undefined;
98
+ pollIntervalMillis?: number | undefined;
99
+ pollTimeoutMillis?: number | undefined;
100
+ }>;
101
+ type TopazImageModelOptions = InferSchema<typeof topazImageModelOptionsSchema>;
102
+
103
+ /**
104
+ * Metadata about the input video.
105
+ *
106
+ * Starlight models require `width`, `height`, `duration` and `frameRate`
107
+ * (Topaz prices them from these values), and for other models they let Topaz
108
+ * estimate the cost before it has the video. The AI SDK does not inspect
109
+ * media files, so the values come from the caller. Setting any of them
110
+ * requires all four.
111
+ */
112
+ declare const topazVideoSourceSchema: z.ZodObject<{
113
+ width: z.ZodOptional<z.ZodNumber>;
114
+ height: z.ZodOptional<z.ZodNumber>;
115
+ duration: z.ZodOptional<z.ZodNumber>;
116
+ frameRate: z.ZodOptional<z.ZodNumber>;
117
+ frameCount: z.ZodOptional<z.ZodNumber>;
118
+ container: z.ZodOptional<z.ZodEnum<{
119
+ "3gp": "3gp";
120
+ avi: "avi";
121
+ dv: "dv";
122
+ flv: "flv";
123
+ m1v: "m1v";
124
+ m2t: "m2t";
125
+ m2ts: "m2ts";
126
+ m2v: "m2v";
127
+ m4v: "m4v";
128
+ mkv: "mkv";
129
+ mov: "mov";
130
+ mp4: "mp4";
131
+ mpeg: "mpeg";
132
+ mpg: "mpg";
133
+ mts: "mts";
134
+ mxf: "mxf";
135
+ ser: "ser";
136
+ ts: "ts";
137
+ vob: "vob";
138
+ webm: "webm";
139
+ wmv: "wmv";
140
+ }>>;
141
+ }, z.core.$strip>;
142
+ type TopazVideoSource = z.infer<typeof topazVideoSourceSchema>;
143
+ /**
144
+ * Output settings for the enhanced video.
145
+ */
146
+ declare const topazVideoOutputSchema: z.ZodObject<{
147
+ width: z.ZodOptional<z.ZodNumber>;
148
+ height: z.ZodOptional<z.ZodNumber>;
149
+ frameRate: z.ZodOptional<z.ZodNumber>;
150
+ audioCodec: z.ZodOptional<z.ZodEnum<{
151
+ AAC: "AAC";
152
+ AC3: "AC3";
153
+ PCM: "PCM";
154
+ }>>;
155
+ audioBitrate: z.ZodOptional<z.ZodString>;
156
+ audioTransfer: z.ZodOptional<z.ZodEnum<{
157
+ Copy: "Copy";
158
+ Convert: "Convert";
159
+ None: "None";
160
+ }>>;
161
+ videoEncoder: z.ZodOptional<z.ZodEnum<{
162
+ AV1: "AV1";
163
+ H264: "H264";
164
+ H265: "H265";
165
+ ProRes: "ProRes";
166
+ VP9: "VP9";
167
+ }>>;
168
+ videoProfile: z.ZodOptional<z.ZodString>;
169
+ videoBitrate: z.ZodOptional<z.ZodString>;
170
+ dynamicCompressionLevel: z.ZodOptional<z.ZodEnum<{
171
+ Low: "Low";
172
+ Mid: "Mid";
173
+ High: "High";
174
+ }>>;
175
+ cropToFit: z.ZodOptional<z.ZodBoolean>;
176
+ container: z.ZodOptional<z.ZodEnum<{
177
+ avi: "avi";
178
+ mkv: "mkv";
179
+ mov: "mov";
180
+ mp4: "mp4";
181
+ webm: "webm";
182
+ }>>;
183
+ }, z.core.$strip>;
184
+ type TopazVideoOutput = z.infer<typeof topazVideoOutputSchema>;
185
+ /**
186
+ * Provider options for Topaz video models.
187
+ *
188
+ * @see https://developer.topazlabs.com/video-models/proteus/proteus-1
189
+ * @see https://developer.topazlabs.com/video-models/starlight/starlight-precise-2.6
190
+ */
191
+ declare const topazVideoModelOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
192
+ pollIntervalMillis?: number | undefined;
193
+ pollTimeoutMillis?: number | undefined;
194
+ source?: {
195
+ width?: number | undefined;
196
+ height?: number | undefined;
197
+ duration?: number | undefined;
198
+ frameRate?: number | undefined;
199
+ frameCount?: number | undefined;
200
+ container?: "3gp" | "avi" | "dv" | "flv" | "m1v" | "m2t" | "m2ts" | "m2v" | "m4v" | "mkv" | "mov" | "mp4" | "mpeg" | "mpg" | "mts" | "mxf" | "ser" | "ts" | "vob" | "webm" | "wmv" | undefined;
201
+ } | undefined;
202
+ output?: {
203
+ width?: number | undefined;
204
+ height?: number | undefined;
205
+ frameRate?: number | undefined;
206
+ audioCodec?: "AAC" | "AC3" | "PCM" | undefined;
207
+ audioBitrate?: string | undefined;
208
+ audioTransfer?: "Copy" | "Convert" | "None" | undefined;
209
+ videoEncoder?: "AV1" | "H264" | "H265" | "ProRes" | "VP9" | undefined;
210
+ videoProfile?: string | undefined;
211
+ videoBitrate?: string | undefined;
212
+ dynamicCompressionLevel?: "Low" | "Mid" | "High" | undefined;
213
+ cropToFit?: boolean | undefined;
214
+ container?: "avi" | "mkv" | "mov" | "mp4" | "webm" | undefined;
215
+ } | undefined;
216
+ additionalFilters?: Record<string, unknown>[] | undefined;
217
+ filter?: Record<string, unknown> | undefined;
218
+ videoType?: "Progressive" | "Interlaced" | "ProgressiveInterlaced" | undefined;
219
+ auto?: "Auto" | "Manual" | "Relative" | undefined;
220
+ fieldOrder?: "Auto" | "TopFirst" | "BottomFirst" | undefined;
221
+ focusFixLevel?: "None" | "Normal" | "Strong" | undefined;
222
+ compression?: number | undefined;
223
+ details?: number | undefined;
224
+ prenoise?: number | undefined;
225
+ noise?: number | undefined;
226
+ halo?: number | undefined;
227
+ preblur?: number | undefined;
228
+ blur?: number | undefined;
229
+ grain?: number | undefined;
230
+ grainSigma?: number | undefined;
231
+ grainSize?: number | undefined;
232
+ grainType?: "gaussian" | "grey" | "silver_rich" | undefined;
233
+ recoverOriginalDetailValue?: number | undefined;
234
+ sharpness?: number | undefined;
235
+ videoBitDepth?: number | undefined;
236
+ videoCodec?: "ffv1" | "prores" | "vp9" | undefined;
237
+ videoProfile?: "420" | "422" | "444" | undefined;
238
+ watermark?: boolean | undefined;
239
+ }>;
240
+ type TopazVideoModelOptions = InferSchema<typeof topazVideoModelOptionsSchema>;
241
+
242
+ declare const VERSION: string;
243
+
244
+ export { type TopazImageModelId, type TopazImageModelOptions, type TopazProvider, type TopazProviderSettings, type TopazVideoModelId, type TopazVideoModelOptions, type TopazVideoOutput, type TopazVideoSource, VERSION, createTopaz, topaz };