@mynthio/sdk 0.0.39 → 0.0.41

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 (42) hide show
  1. package/README.md +49 -9
  2. package/dist/convex/index.d.ts +39 -90
  3. package/dist/convex/index.js +41 -2
  4. package/dist/handler.d.ts +28 -0
  5. package/dist/handler.js +121 -0
  6. package/dist/index.d.ts +675 -328
  7. package/dist/index.js +1469 -2
  8. package/dist/next/index.d.ts +14 -22
  9. package/dist/next/index.js +25 -2
  10. package/dist/tanstack-start/index.d.ts +18 -21
  11. package/dist/tanstack-start/index.js +11 -2
  12. package/dist/types.d.ts +610 -592
  13. package/package.json +16 -21
  14. package/dist/client.d.ts +0 -41
  15. package/dist/client.d.ts.map +0 -1
  16. package/dist/constants.d.ts +0 -94
  17. package/dist/constants.d.ts.map +0 -1
  18. package/dist/convex/index.d.ts.map +0 -1
  19. package/dist/convex/utils.d.ts +0 -2
  20. package/dist/convex/utils.d.ts.map +0 -1
  21. package/dist/image-alt-result.d.ts +0 -22
  22. package/dist/image-alt-result.d.ts.map +0 -1
  23. package/dist/image-generation-result.d.ts +0 -58
  24. package/dist/image-generation-result.d.ts.map +0 -1
  25. package/dist/image-rate-result.d.ts +0 -24
  26. package/dist/image-rate-result.d.ts.map +0 -1
  27. package/dist/image-review-result.d.ts +0 -31
  28. package/dist/image-review-result.d.ts.map +0 -1
  29. package/dist/index-apss16tr.js +0 -3
  30. package/dist/index-pjgsme75.js +0 -3
  31. package/dist/index.d.ts.map +0 -1
  32. package/dist/next/index.d.ts.map +0 -1
  33. package/dist/tanstack-start/index.d.ts.map +0 -1
  34. package/dist/task-async.d.ts +0 -95
  35. package/dist/task-async.d.ts.map +0 -1
  36. package/dist/types.d.ts.map +0 -1
  37. package/dist/uploads.d.ts +0 -31
  38. package/dist/uploads.d.ts.map +0 -1
  39. package/dist/video-generation-result.d.ts +0 -46
  40. package/dist/video-generation-result.d.ts.map +0 -1
  41. package/dist/webhooks/utils.d.ts +0 -5
  42. package/dist/webhooks/utils.d.ts.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,65 +1,383 @@
1
- import { MynthAPIError } from "./client";
2
- import type { AvailableModel, ModelCapability } from "./constants";
3
- import type { AvailableVideoModel, VideoInputRole, VideoResolutionTier } from "./constants";
4
- import { AVAILABLE_MODELS, AVAILABLE_VIDEO_MODELS } from "./constants";
5
- import { ImageAltResult } from "./image-alt-result";
6
- import { ImageGenerationResult } from "./image-generation-result";
7
- import { ImageRateResult } from "./image-rate-result";
8
- import { ImageReviewResult } from "./image-review-result";
9
- import type { TaskAsyncAccess } from "./task-async";
10
- import { TaskAsync, TaskAsyncFetchError, TaskAsyncTaskFailedError, TaskAsyncTaskFetchError, TaskAsyncTimeoutError, TaskAsyncUnauthorizedError } from "./task-async";
11
- import type { MynthSDKTypes } from "./types";
12
- import { VideoGenerationResult } from "./video-generation-result";
1
+ import { a as AvailableVideoModel, c as VideoResolutionTier, i as AvailableModel, n as AVAILABLE_MODELS, o as ModelCapability, r as AVAILABLE_VIDEO_MODELS, s as VideoInputRole, t as MynthSDKTypes } from "./types.js";
2
+ //#region src/client.d.ts
3
+ /**
4
+ * Error thrown when an API request fails.
5
+ */
6
+ export declare class MynthAPIError extends Error {
7
+ /** HTTP status code of the failed request */
8
+ readonly status: number;
9
+ /** Error code from the API response, if available */
10
+ readonly code?: string | undefined;
11
+ constructor(message: string, status: number, code?: string);
12
+ }
13
+ type MynthClientRequestOptions = {
14
+ headers?: Record<string, string>;
15
+ accessToken?: string | undefined;
16
+ auth?: boolean | undefined;
17
+ };
18
+ /**
19
+ * Internal HTTP client for making API requests.
20
+ * @internal
21
+ */
22
+ declare class MynthClient {
23
+ private readonly apiKey;
24
+ private readonly baseUrl;
25
+ constructor(options: {
26
+ apiKey?: string | undefined;
27
+ baseUrl?: string | undefined;
28
+ });
29
+ getAuthHeaders(override?: Omit<MynthClientRequestOptions, "headers">): Record<string, string>;
30
+ getUrl(path: string): string;
31
+ post<DataType>(path: string, data: unknown): Promise<DataType>;
32
+ get<DataType>(path: string, { headers, accessToken, auth }?: MynthClientRequestOptions): Promise<{
33
+ data: DataType;
34
+ status: number;
35
+ ok: boolean;
36
+ }>;
37
+ getOrThrow<DataType>(path: string, options?: MynthClientRequestOptions): Promise<DataType>;
38
+ }
39
+ //#endregion
40
+ //#region src/image-alt-result.d.ts
41
+ /**
42
+ * Represents the result of a completed image alt text task.
43
+ */
44
+ export declare class ImageAltResult {
45
+ /** The task ID created for this alt text request */
46
+ readonly taskId: string;
47
+ /** Cost charged for the completed task */
48
+ readonly cost: string;
49
+ /** Generated alt text */
50
+ readonly alt: string;
51
+ constructor(data: {
52
+ taskId: string;
53
+ cost: string;
54
+ alt: string;
55
+ });
56
+ static fromTaskData(data: MynthSDKTypes.ImageAltTaskData): ImageAltResult;
57
+ }
58
+ //#endregion
59
+ //#region src/image-generation-result.d.ts
60
+ type TypedImageResultImageSuccess<RatingT> = Omit<MynthSDKTypes.ImageResultImageSuccess, "rating"> & {
61
+ rating?: RatingT;
62
+ };
63
+ type TypedImageResultImageFailure = MynthSDKTypes.ImageResultImageFailure;
64
+ type TypedImageResultImage<RatingT> = TypedImageResultImageSuccess<RatingT> | TypedImageResultImageFailure;
65
+ type TypedImageResult<RatingT> = Omit<MynthSDKTypes.ImageResult, "images"> & {
66
+ images: TypedImageResultImage<RatingT>[];
67
+ };
68
+ /**
69
+ * Represents a completed image generation task.
70
+ *
71
+ * @template MetadataT - Type of the metadata attached to the request
72
+ * @template RatingT - Type of the rating response
73
+ */
74
+ export declare class ImageGenerationResult<MetadataT = Record<string, unknown> | undefined, RatingT = MynthSDKTypes.ImageResultRating | undefined> {
75
+ /** Raw task data from the API */
76
+ readonly data: MynthSDKTypes.ImageGenerationTaskData;
77
+ constructor(data: MynthSDKTypes.ImageGenerationTaskData);
78
+ /** Unique identifier for this task */
79
+ get id(): string;
80
+ /** Current status of the task */
81
+ get status(): MynthSDKTypes.TaskStatus;
82
+ /**
83
+ * The generation result containing images, cost, and model info.
84
+ * Returns `null` if the task hasn't completed yet.
85
+ */
86
+ get result(): TypedImageResult<RatingT> | null;
87
+ /** Whether the task completed successfully */
88
+ get isCompleted(): boolean;
89
+ /** Whether the task failed */
90
+ get isFailed(): boolean;
91
+ /**
92
+ * Get all successfully generated image URLs.
93
+ * Convenience method that extracts just the URLs from successful images.
94
+ * Images delivered only to a user destination may have a `null` url and are omitted here;
95
+ * use `getImages()` and read `mynth_url` to access the CDN URL directly.
96
+ */
97
+ get urls(): string[];
98
+ /**
99
+ * Get generated images from the task result.
100
+ *
101
+ * @param options.includeFailed - If true, includes failed image results
102
+ * @returns Array of image results
103
+ */
104
+ getImages(options: {
105
+ includeFailed: true;
106
+ }): TypedImageResultImage<RatingT>[];
107
+ getImages(options?: {
108
+ includeFailed?: false;
109
+ }): TypedImageResultImageSuccess<RatingT>[];
110
+ /**
111
+ * Get the metadata that was attached to the generation request.
112
+ */
113
+ getMetadata(): MetadataT;
114
+ }
115
+ //#endregion
116
+ //#region src/image-rate-result.d.ts
117
+ /**
118
+ * Represents the result of a completed image content rating task.
119
+ *
120
+ * @template LevelT - Union of possible rating level strings (e.g. `"sfw" | "nsfw"`)
121
+ */
122
+ export declare class ImageRateResult<LevelT extends string = "sfw" | "nsfw"> {
123
+ /** The task ID created for this rating request */
124
+ readonly taskId: string;
125
+ /** Cost charged for the completed task */
126
+ readonly cost: string;
127
+ /** Assigned rating level */
128
+ readonly level: LevelT;
129
+ constructor(data: {
130
+ taskId: string;
131
+ cost: string;
132
+ level: LevelT;
133
+ });
134
+ static fromTaskData<LevelT extends string = "sfw" | "nsfw">(data: MynthSDKTypes.ImageRateTaskData): ImageRateResult<LevelT>;
135
+ }
136
+ //#endregion
137
+ //#region src/image-remove-background-result.d.ts
138
+ /**
139
+ * Represents the result of a completed image background removal task.
140
+ *
141
+ * @template MetadataT - Type of the metadata attached to the request
142
+ */
143
+ export declare class ImageRemoveBackgroundResult<MetadataT = Record<string, unknown> | undefined> {
144
+ /** The task ID created for this request */
145
+ readonly taskId: string;
146
+ /** Cost charged for the completed task */
147
+ readonly cost: string;
148
+ /** The image with its background removed */
149
+ readonly image: MynthSDKTypes.ImageRemoveBackgroundResultImage;
150
+ /** Metadata attached to the request */
151
+ readonly metadata: MetadataT;
152
+ constructor(data: {
153
+ taskId: string;
154
+ cost: string;
155
+ image: MynthSDKTypes.ImageRemoveBackgroundResultImage;
156
+ metadata: MetadataT;
157
+ });
158
+ static fromTaskData<MetadataT = Record<string, unknown> | undefined>(data: MynthSDKTypes.ImageRemoveBackgroundTaskData): ImageRemoveBackgroundResult<MetadataT>;
159
+ }
160
+ //#endregion
161
+ //#region src/image-review-result.d.ts
162
+ /**
163
+ * Represents the result of a completed image quality review task.
164
+ */
165
+ export declare class ImageReviewResult {
166
+ /** The task ID created for this review request */
167
+ readonly taskId: string;
168
+ /** Cost charged for the completed task */
169
+ readonly cost: string;
170
+ /** Median reviewer score from 1 to 4. Higher is better. */
171
+ readonly score: number;
172
+ /** Review summary */
173
+ readonly summary: string;
174
+ /** Defects found by the reviewer panel */
175
+ readonly findings: MynthSDKTypes.ImageReviewFinding[];
176
+ /** Strengths identified by the reviewer panel */
177
+ readonly strengths: MynthSDKTypes.ImageReviewStrength[];
178
+ constructor(data: {
179
+ taskId: string;
180
+ cost: string;
181
+ score: number;
182
+ summary: string;
183
+ findings: MynthSDKTypes.ImageReviewFinding[];
184
+ strengths: MynthSDKTypes.ImageReviewStrength[];
185
+ });
186
+ static fromTaskData(data: MynthSDKTypes.ImageReviewTaskData): ImageReviewResult;
187
+ }
188
+ //#endregion
189
+ //#region src/task-async.d.ts
190
+ /**
191
+ * Polling cadence overrides. Anything omitted keeps the image-task default.
192
+ */
193
+ type TaskAsyncPolling = {
194
+ /** Total wait budget before `TaskAsyncTimeoutError`. */
195
+ timeoutMs?: number;
196
+ /** How long the opening fast-polling phase lasts. `0` disables it. */
197
+ fastDurationMs?: number;
198
+ /** Interval used during the fast phase. */
199
+ fastIntervalMs?: number;
200
+ /** Interval used after the fast phase. */
201
+ intervalMs?: number;
202
+ };
203
+ /**
204
+ * Error thrown when task polling exceeds the maximum timeout duration.
205
+ */
206
+ export declare class TaskAsyncTimeoutError extends Error {
207
+ constructor(taskId: string, timeoutMs?: number);
208
+ }
209
+ /**
210
+ * Error thrown when access to a task is denied (invalid API key or PAT).
211
+ */
212
+ export declare class TaskAsyncUnauthorizedError extends Error {
213
+ constructor(taskId: string);
214
+ }
215
+ /**
216
+ * Error thrown when fetching task status fails after multiple retries.
217
+ */
218
+ export declare class TaskAsyncFetchError extends Error {
219
+ constructor(taskId: string, cause?: Error);
220
+ }
221
+ /**
222
+ * Error thrown when fetching full task data fails.
223
+ */
224
+ export declare class TaskAsyncTaskFetchError extends Error {
225
+ constructor(taskId: string, status?: number, cause?: Error);
226
+ }
227
+ /**
228
+ * Error thrown when a task fails before completion.
229
+ */
230
+ export declare class TaskAsyncTaskFailedError extends Error {
231
+ constructor(taskId: string);
232
+ }
233
+ /**
234
+ * Public access information for a task, used for client-side polling.
235
+ */
236
+ type TaskAsyncAccess = {
237
+ /** Public access token for client-side status polling */
238
+ publicAccessToken?: string | undefined;
239
+ };
240
+ /**
241
+ * Represents an async task that can be polled for completion.
242
+ * Use `wait()` to poll until completion and get the typed result.
243
+ *
244
+ * @template ResultT - The result type returned once the task completes
245
+ */
246
+ export declare class TaskAsync<ResultT> {
247
+ /** The unique identifier for this task */
248
+ readonly id: string;
249
+ private readonly client;
250
+ private readonly _access;
251
+ private readonly resultFactory;
252
+ private readonly polling;
253
+ private _completionPromise;
254
+ constructor(id: string, options: {
255
+ client: MynthClient;
256
+ pat?: string | undefined;
257
+ resultFactory: (data: MynthSDKTypes.TaskData) => ResultT;
258
+ polling?: TaskAsyncPolling;
259
+ });
260
+ /**
261
+ * Public access information for client-side polling.
262
+ * Contains the public access token if one was generated.
263
+ */
264
+ get access(): TaskAsyncAccess;
265
+ toString(): string;
266
+ /**
267
+ * Polls the task until completion and returns the typed result.
268
+ * Multiple calls to this method return the same promise.
269
+ *
270
+ * @throws {TaskAsyncTimeoutError} If polling exceeds the timeout
271
+ * @throws {TaskAsyncUnauthorizedError} If access is denied
272
+ * @throws {TaskAsyncFetchError} If fetching status fails repeatedly
273
+ * @throws {TaskAsyncTaskFetchError} If fetching the completed task fails
274
+ * @throws {TaskAsyncTaskFailedError} If the task fails before completion
275
+ */
276
+ wait(): Promise<ResultT>;
277
+ private pollUntilCompleted;
278
+ private fetchStatus;
279
+ private fetchTask;
280
+ private sleep;
281
+ }
282
+ //#endregion
283
+ //#region src/video-generation-result.d.ts
284
+ /**
285
+ * Represents a completed video generation task.
286
+ *
287
+ * @template MetadataT - Type of the metadata attached to the request
288
+ */
289
+ export declare class VideoGenerationResult<MetadataT = Record<string, unknown> | undefined> {
290
+ /** Raw task data from the API */
291
+ readonly data: MynthSDKTypes.VideoGenerationTaskData;
292
+ constructor(data: MynthSDKTypes.VideoGenerationTaskData);
293
+ /** Unique identifier for this task */
294
+ get id(): string;
295
+ /** Current status of the task */
296
+ get status(): MynthSDKTypes.TaskStatus;
297
+ /**
298
+ * The generation result containing videos and model info.
299
+ * Returns `null` if the task hasn't completed yet.
300
+ */
301
+ get result(): MynthSDKTypes.VideoResult | null;
302
+ /** Whether the task completed successfully */
303
+ get isCompleted(): boolean;
304
+ /** Whether the task failed */
305
+ get isFailed(): boolean;
306
+ /**
307
+ * Get all successfully generated video URLs.
308
+ * Convenience method that extracts just the URLs from successful videos.
309
+ */
310
+ get urls(): string[];
311
+ /**
312
+ * Get generated videos from the task result.
313
+ *
314
+ * @param options.includeFailed - If true, includes failed video results
315
+ * @returns Array of video results
316
+ */
317
+ getVideos(options: {
318
+ includeFailed: true;
319
+ }): MynthSDKTypes.VideoResultVideo[];
320
+ getVideos(options?: {
321
+ includeFailed?: false;
322
+ }): MynthSDKTypes.VideoResultVideoSuccess[];
323
+ /**
324
+ * Get the metadata that was attached to the generation request.
325
+ */
326
+ getMetadata(): MetadataT;
327
+ }
328
+ //#endregion
329
+ //#region src/index.d.ts
13
330
  /**
14
331
  * Configuration options for the Mynth client.
15
332
  */
16
333
  type MynthOptions = {
17
- /**
18
- * Your Mynth API key. If not provided, reads from MYNTH_API_KEY environment variable.
19
- */
20
- apiKey?: string;
21
- /**
22
- * Custom base URL for the API. Useful for proxies or testing.
23
- */
24
- baseUrl?: string;
25
- /**
26
- * Default destination name (slug) to deliver generated images to.
27
- * If not provided, reads from MYNTH_DESTINATION environment variable.
28
- * Can be overridden on a per-request basis via `request.destination`.
29
- */
30
- destination?: string;
334
+ /**
335
+ * Your Mynth API key. If not provided, reads from MYNTH_API_KEY environment variable.
336
+ */
337
+ apiKey?: string | undefined;
338
+ /**
339
+ * Custom base URL for the API. Useful for proxies or testing.
340
+ */
341
+ baseUrl?: string | undefined;
342
+ /**
343
+ * Default destination name (slug) to deliver generated images to.
344
+ * If not provided, reads from MYNTH_DESTINATION environment variable.
345
+ * Can be overridden on a per-request basis via `request.destination`.
346
+ */
347
+ destination?: string | undefined;
31
348
  };
32
349
  type MynthModel = MynthSDKTypes.Model;
33
350
  type MynthModelPricing = MynthSDKTypes.ModelPricing;
34
351
  type ExtractMetadata<T extends MynthSDKTypes.ImageGenerationClientRequest> = T["metadata"];
35
352
  type ExtractVideoMetadata<T extends MynthSDKTypes.VideoGenerationClientRequest> = T["metadata"];
353
+ type ExtractRemoveBackgroundMetadata<T extends MynthSDKTypes.ImageRemoveBackgroundClientRequest> = T["metadata"];
36
354
  type ExtractRatingConfig<T extends MynthSDKTypes.ImageGenerationClientRequest> = T["rating"];
37
355
  type ExtractRatingLevels<T extends MynthSDKTypes.ImageGenerationClientRequest> = ExtractRatingConfig<T> extends {
38
- levels: readonly (infer L)[];
356
+ levels: readonly (infer L)[];
39
357
  } ? L : ExtractRatingConfig<T> extends {
40
- levels: (infer L)[];
358
+ levels: (infer L)[];
41
359
  } ? L : never;
42
360
  type ExtractRatingLevelValues<T extends MynthSDKTypes.ImageGenerationClientRequest> = ExtractRatingLevels<T> extends {
43
- value: infer V;
361
+ value: infer V;
44
362
  } ? (V extends string ? V : never) : never;
45
363
  type IsRatingCustom<T extends MynthSDKTypes.ImageGenerationClientRequest> = ExtractRatingConfig<T> extends {
46
- mode: "custom";
47
- levels: readonly any[] | any[];
364
+ mode: "custom";
365
+ levels: readonly any[] | any[];
48
366
  } ? true : false;
49
367
  type ExtractRatingResponse<T extends MynthSDKTypes.ImageGenerationClientRequest> = IsRatingCustom<T> extends true ? {
50
- status: "success";
51
- level: ExtractRatingLevelValues<T>;
368
+ status: "success";
369
+ level: ExtractRatingLevelValues<T>;
52
370
  } | MynthSDKTypes.ImageResultRatingFailure : ExtractRatingConfig<T> extends true | {
53
- mode: "nsfw_sfw";
371
+ mode: "nsfw_sfw";
54
372
  } ? {
55
- status: "success";
56
- level: MynthSDKTypes.ImageResultRatingDefaultLevel;
373
+ status: "success";
374
+ level: MynthSDKTypes.ImageResultRatingDefaultLevel;
57
375
  } | MynthSDKTypes.ImageResultRatingFailure : MynthSDKTypes.ImageResultRating | undefined;
58
376
  type ExtractRateLevelValues<T extends MynthSDKTypes.ImageRateClientRequest> = T extends {
59
- mode: "custom";
60
- levels: readonly {
61
- value: infer V;
62
- }[];
377
+ mode: "custom";
378
+ levels: readonly {
379
+ value: infer V;
380
+ }[];
63
381
  } ? V extends string ? V : string : MynthSDKTypes.ImageResultRatingDefaultLevel;
64
382
  /**
65
383
  * Client for interacting with the Mynth image generation and analysis APIs.
@@ -82,165 +400,196 @@ type ExtractRateLevelValues<T extends MynthSDKTypes.ImageRateClientRequest> = T
82
400
  * ```
83
401
  */
84
402
  declare class MynthImage {
85
- private readonly client;
86
- private readonly defaultDestination?;
87
- /**
88
- * Creates a new MynthImage client instance.
89
- *
90
- * @param options - Configuration options
91
- * @param options.apiKey - Your API key (defaults to MYNTH_API_KEY env var)
92
- * @param options.baseUrl - Custom API base URL
93
- * @param options.destination - Default destination name (defaults to MYNTH_DESTINATION env var)
94
- * @throws {Error} If no API key is provided and MYNTH_API_KEY is not set
95
- */
96
- constructor(options?: MynthOptions);
97
- /**
98
- * Generate images from a text prompt.
99
- *
100
- * @param request - Image generation request parameters
101
- * @returns A completed ImageGenerationResult with the generation results
102
- *
103
- * @example
104
- * ```typescript
105
- * const result = await image.generate({
106
- * prompt: "A serene lake at dawn",
107
- * model: "black-forest-labs/flux.1-dev",
108
- * });
109
- * console.log(result.urls);
110
- * ```
111
- */
112
- generate<const T extends MynthSDKTypes.ImageGenerationClientRequest>(request: T): Promise<ImageGenerationResult<ExtractMetadata<T>, ExtractRatingResponse<T>>>;
113
- /**
114
- * Upload one or more images to Mynth temporary input storage.
115
- *
116
- * Accepts File/Blob or an array of File/Blob inputs.
117
- *
118
- * @param input - Image input or inputs to upload
119
- * @returns Uploaded image URLs that can be passed to generation `inputs`
120
- *
121
- * @example
122
- * ```typescript
123
- * const { urls } = await image.upload(file);
124
- * await image.generate({ prompt: "Use this reference", inputs: urls });
125
- * ```
126
- */
127
- upload(input: MynthSDKTypes.ImageUploadInput | readonly MynthSDKTypes.ImageUploadInput[]): Promise<MynthSDKTypes.ImageUploadResponse>;
128
- /**
129
- * Start image generation without waiting for completion.
130
- *
131
- * @param request - Image generation request parameters
132
- * @returns A TaskAsync that can be polled for completion via `.wait()`
133
- *
134
- * @example
135
- * ```typescript
136
- * const taskAsync = await image.generateAsync({
137
- * prompt: "A futuristic cityscape",
138
- * });
139
- *
140
- * return { id: taskAsync.id, access: taskAsync.access };
141
- * ```
142
- */
143
- generateAsync<const T extends MynthSDKTypes.ImageGenerationClientRequest>(request: T): Promise<TaskAsync<ImageGenerationResult<ExtractMetadata<T>, ExtractRatingResponse<T>>>>;
144
- private createGenerationTask;
145
- /**
146
- * Rate the content of a single image.
147
- *
148
- * Uses AI classification to assign a rating level. Mode defaults to
149
- * `"nsfw_sfw"` (`"sfw"` / `"nsfw"`); pass custom `levels` to define your own scale.
150
- *
151
- * @param request - Image URL or local file, and optional rating mode
152
- * @returns An ImageRateResult with the assigned level
153
- *
154
- * @example
155
- * ```typescript
156
- * // Default sfw/nsfw (mode optional)
157
- * const result = await image.rate({ url: "https://..." });
158
- * console.log(result.level); // "sfw" | "nsfw"
159
- *
160
- * // Custom levels
161
- * const result = await image.rate({
162
- * url: "https://...",
163
- * mode: "custom",
164
- * levels: [
165
- * { value: "safe", description: "No explicit content" },
166
- * { value: "mature", description: "Adult themes, no nudity" },
167
- * { value: "explicit", description: "Contains nudity or graphic content" },
168
- * ] as const,
169
- * });
170
- * console.log(result.level); // "safe" | "mature" | "explicit"
171
- * ```
172
- */
173
- rate<const T extends MynthSDKTypes.ImageRateClientRequest>(request: T): Promise<ImageRateResult<ExtractRateLevelValues<T>>>;
174
- /**
175
- * Start image content rating without waiting for completion.
176
- *
177
- * @param request - Image URL or local file, and optional rating mode
178
- * @returns A TaskAsync that can be polled for completion via `.wait()`
179
- *
180
- * @example
181
- * ```typescript
182
- * const taskAsync = await image.rateAsync({ url: "https://..." });
183
- *
184
- * const result = await taskAsync.wait();
185
- * console.log(result.level);
186
- * ```
187
- */
188
- rateAsync<const T extends MynthSDKTypes.ImageRateClientRequest>(request: T): Promise<TaskAsync<ImageRateResult<ExtractRateLevelValues<T>>>>;
189
- private resolveUrlOrFile;
190
- private createRateTask;
191
- /**
192
- * Generate alt text for a single image.
193
- *
194
- * Uses AI image analysis to produce short alt text for the image.
195
- *
196
- * @param request - Image URL or local file
197
- * @returns An ImageAltResult with the generated alt text
198
- *
199
- * @example
200
- * ```typescript
201
- * const result = await image.alt({ url: "https://..." });
202
- * console.log(result.alt);
203
- * ```
204
- */
205
- alt(request: MynthSDKTypes.ImageAltClientRequest): Promise<ImageAltResult>;
206
- /**
207
- * Start image alt text generation without waiting for completion.
208
- *
209
- * @param request - Image URL or local file
210
- * @returns A TaskAsync that can be polled for completion via `.wait()`
211
- *
212
- * @example
213
- * ```typescript
214
- * const taskAsync = await image.altAsync({ url: "https://..." });
215
- *
216
- * const result = await taskAsync.wait();
217
- * console.log(result.alt);
218
- * ```
219
- */
220
- altAsync(request: MynthSDKTypes.ImageAltClientRequest): Promise<TaskAsync<ImageAltResult>>;
221
- private createAltTask;
222
- /**
223
- * Review a single image with a multi-model quality panel.
224
- *
225
- * @param request - Image URL or local file, and optional review effort
226
- * @returns An ImageReviewResult with the score, summary, findings, and strengths
227
- *
228
- * @example
229
- * ```typescript
230
- * const result = await image.review({ url: "https://..." });
231
- * console.log(result.score); // 1–4, higher is better
232
- * console.log(result.findings);
233
- * ```
234
- */
235
- review(request: MynthSDKTypes.ImageReviewClientRequest): Promise<ImageReviewResult>;
236
- /**
237
- * Start an image quality review without waiting for completion.
238
- *
239
- * @param request - Image URL or local file, and optional review effort
240
- * @returns A TaskAsync that can be polled for completion via `.wait()`
241
- */
242
- reviewAsync(request: MynthSDKTypes.ImageReviewClientRequest): Promise<TaskAsync<ImageReviewResult>>;
243
- private createReviewTask;
403
+ private readonly client;
404
+ private readonly defaultDestination;
405
+ /**
406
+ * Creates a new MynthImage client instance.
407
+ *
408
+ * @param options - Configuration options
409
+ * @param options.apiKey - Your API key (defaults to MYNTH_API_KEY env var)
410
+ * @param options.baseUrl - Custom API base URL
411
+ * @param options.destination - Default destination name (defaults to MYNTH_DESTINATION env var)
412
+ * @throws {Error} If no API key is provided and MYNTH_API_KEY is not set
413
+ */
414
+ constructor(options?: MynthOptions);
415
+ /**
416
+ * Generate images from a text prompt.
417
+ *
418
+ * @param request - Image generation request parameters
419
+ * @returns A completed ImageGenerationResult with the generation results
420
+ *
421
+ * @example
422
+ * ```typescript
423
+ * const result = await image.generate({
424
+ * prompt: "A serene lake at dawn",
425
+ * model: "black-forest-labs/flux.1-dev",
426
+ * });
427
+ * console.log(result.urls);
428
+ * ```
429
+ */
430
+ generate<const T extends MynthSDKTypes.ImageGenerationClientRequest>(request: T): Promise<ImageGenerationResult<ExtractMetadata<T>, ExtractRatingResponse<T>>>;
431
+ /**
432
+ * Upload one or more images to Mynth temporary input storage.
433
+ *
434
+ * Accepts File/Blob or an array of File/Blob inputs.
435
+ *
436
+ * @param input - Image input or inputs to upload
437
+ * @returns Uploaded image URLs that can be passed to generation `inputs`
438
+ *
439
+ * @example
440
+ * ```typescript
441
+ * const { urls } = await image.upload(file);
442
+ * await image.generate({ prompt: "Use this reference", inputs: urls });
443
+ * ```
444
+ */
445
+ upload(input: MynthSDKTypes.ImageUploadInput | readonly MynthSDKTypes.ImageUploadInput[]): Promise<MynthSDKTypes.ImageUploadResponse>;
446
+ /**
447
+ * Start image generation without waiting for completion.
448
+ *
449
+ * @param request - Image generation request parameters
450
+ * @returns A TaskAsync that can be polled for completion via `.wait()`
451
+ *
452
+ * @example
453
+ * ```typescript
454
+ * const taskAsync = await image.generateAsync({
455
+ * prompt: "A futuristic cityscape",
456
+ * });
457
+ *
458
+ * return { id: taskAsync.id, access: taskAsync.access };
459
+ * ```
460
+ */
461
+ generateAsync<const T extends MynthSDKTypes.ImageGenerationClientRequest>(request: T): Promise<TaskAsync<ImageGenerationResult<ExtractMetadata<T>, ExtractRatingResponse<T>>>>;
462
+ private createGenerationTask;
463
+ /**
464
+ * Rate the content of a single image.
465
+ *
466
+ * Uses AI classification to assign a rating level. Mode defaults to
467
+ * `"nsfw_sfw"` (`"sfw"` / `"nsfw"`); pass custom `levels` to define your own scale.
468
+ *
469
+ * @param request - Image URL or local file, and optional rating mode
470
+ * @returns An ImageRateResult with the assigned level
471
+ *
472
+ * @example
473
+ * ```typescript
474
+ * // Default sfw/nsfw (mode optional)
475
+ * const result = await image.rate({ url: "https://..." });
476
+ * console.log(result.level); // "sfw" | "nsfw"
477
+ *
478
+ * // Custom levels
479
+ * const result = await image.rate({
480
+ * url: "https://...",
481
+ * mode: "custom",
482
+ * levels: [
483
+ * { value: "safe", description: "No explicit content" },
484
+ * { value: "mature", description: "Adult themes, no nudity" },
485
+ * { value: "explicit", description: "Contains nudity or graphic content" },
486
+ * ] as const,
487
+ * });
488
+ * console.log(result.level); // "safe" | "mature" | "explicit"
489
+ * ```
490
+ */
491
+ rate<const T extends MynthSDKTypes.ImageRateClientRequest>(request: T): Promise<ImageRateResult<ExtractRateLevelValues<T>>>;
492
+ /**
493
+ * Start image content rating without waiting for completion.
494
+ *
495
+ * @param request - Image URL or local file, and optional rating mode
496
+ * @returns A TaskAsync that can be polled for completion via `.wait()`
497
+ *
498
+ * @example
499
+ * ```typescript
500
+ * const taskAsync = await image.rateAsync({ url: "https://..." });
501
+ *
502
+ * const result = await taskAsync.wait();
503
+ * console.log(result.level);
504
+ * ```
505
+ */
506
+ rateAsync<const T extends MynthSDKTypes.ImageRateClientRequest>(request: T): Promise<TaskAsync<ImageRateResult<ExtractRateLevelValues<T>>>>;
507
+ private resolveUrlOrFile;
508
+ private createRateTask;
509
+ /**
510
+ * Generate alt text for a single image.
511
+ *
512
+ * Uses AI image analysis to produce short alt text for the image.
513
+ *
514
+ * @param request - Image URL or local file
515
+ * @returns An ImageAltResult with the generated alt text
516
+ *
517
+ * @example
518
+ * ```typescript
519
+ * const result = await image.alt({ url: "https://..." });
520
+ * console.log(result.alt);
521
+ * ```
522
+ */
523
+ alt(request: MynthSDKTypes.ImageAltClientRequest): Promise<ImageAltResult>;
524
+ /**
525
+ * Start image alt text generation without waiting for completion.
526
+ *
527
+ * @param request - Image URL or local file
528
+ * @returns A TaskAsync that can be polled for completion via `.wait()`
529
+ *
530
+ * @example
531
+ * ```typescript
532
+ * const taskAsync = await image.altAsync({ url: "https://..." });
533
+ *
534
+ * const result = await taskAsync.wait();
535
+ * console.log(result.alt);
536
+ * ```
537
+ */
538
+ altAsync(request: MynthSDKTypes.ImageAltClientRequest): Promise<TaskAsync<ImageAltResult>>;
539
+ private createAltTask;
540
+ /**
541
+ * Review a single image with a multi-model quality panel.
542
+ *
543
+ * @param request - Image URL or local file, and optional review effort
544
+ * @returns An ImageReviewResult with the score, summary, findings, and strengths
545
+ *
546
+ * @example
547
+ * ```typescript
548
+ * const result = await image.review({ url: "https://..." });
549
+ * console.log(result.score); // 1–4, higher is better
550
+ * console.log(result.findings);
551
+ * ```
552
+ */
553
+ review(request: MynthSDKTypes.ImageReviewClientRequest): Promise<ImageReviewResult>;
554
+ /**
555
+ * Start an image quality review without waiting for completion.
556
+ *
557
+ * @param request - Image URL or local file, and optional review effort
558
+ * @returns A TaskAsync that can be polled for completion via `.wait()`
559
+ */
560
+ reviewAsync(request: MynthSDKTypes.ImageReviewClientRequest): Promise<TaskAsync<ImageReviewResult>>;
561
+ private createReviewTask;
562
+ /**
563
+ * Remove the background from a single image.
564
+ *
565
+ * Mynth picks the model. The result keeps the provider's format unless
566
+ * `output.format` asks for `png` or `webp`.
567
+ *
568
+ * @param request - Image URL or local file, plus optional output, destination, webhook, and metadata
569
+ * @returns An ImageRemoveBackgroundResult with the transparent image
570
+ *
571
+ * @example
572
+ * ```typescript
573
+ * const result = await image.removeBackground({ url: "https://..." });
574
+ * console.log(result.image.url);
575
+ * ```
576
+ */
577
+ removeBackground<const T extends MynthSDKTypes.ImageRemoveBackgroundClientRequest>(request: T): Promise<ImageRemoveBackgroundResult<ExtractRemoveBackgroundMetadata<T>>>;
578
+ /**
579
+ * Start background removal without waiting for completion.
580
+ *
581
+ * @param request - Image URL or local file, plus optional output, destination, webhook, and metadata
582
+ * @returns A TaskAsync that can be polled for completion via `.wait()`
583
+ *
584
+ * @example
585
+ * ```typescript
586
+ * const taskAsync = await image.removeBackgroundAsync({ url: "https://..." });
587
+ *
588
+ * return { id: taskAsync.id, access: taskAsync.access };
589
+ * ```
590
+ */
591
+ removeBackgroundAsync<const T extends MynthSDKTypes.ImageRemoveBackgroundClientRequest>(request: T): Promise<TaskAsync<ImageRemoveBackgroundResult<ExtractRemoveBackgroundMetadata<T>>>>;
592
+ private createRemoveBackgroundTask;
244
593
  }
245
594
  /**
246
595
  * Client for interacting with the Mynth video generation API.
@@ -264,119 +613,119 @@ declare class MynthImage {
264
613
  * ```
265
614
  */
266
615
  declare class MynthVideo {
267
- private readonly client;
268
- /**
269
- * Creates a new MynthVideo client instance.
270
- *
271
- * @param options - Configuration options
272
- * @param options.apiKey - Your API key (defaults to MYNTH_API_KEY env var)
273
- * @param options.baseUrl - Custom API base URL
274
- * @throws {Error} If no API key is provided and MYNTH_API_KEY is not set
275
- */
276
- constructor(options?: Omit<MynthOptions, "destination">);
277
- /**
278
- * Generate a video from a text prompt, optionally guided by input images.
279
- *
280
- * Waits for the task to complete. Video generation is slow: this poll can
281
- * legitimately run for many minutes. Use `generateAsync()` (or a webhook)
282
- * when you cannot hold a request open that long.
283
- *
284
- * @param request - Video generation request parameters
285
- * @returns A completed VideoGenerationResult
286
- *
287
- * @example
288
- * ```typescript
289
- * const result = await video.generate({
290
- * model: "bytedance/seedance-2.0-mini",
291
- * prompt: "A drone shot over a misty forest at dawn",
292
- * });
293
- * console.log(result.urls);
294
- * ```
295
- */
296
- generate<const T extends MynthSDKTypes.VideoGenerationClientRequest>(request: T): Promise<VideoGenerationResult<ExtractVideoMetadata<T>>>;
297
- /**
298
- * Start video generation without waiting for completion.
299
- *
300
- * The preferred entry point for server code: hand `taskAsync.id` and
301
- * `taskAsync.access.publicAccessToken` to the browser, or register a webhook,
302
- * instead of holding a connection open for the length of a render.
303
- *
304
- * @param request - Video generation request parameters
305
- * @returns A TaskAsync that can be polled for completion via `.wait()`
306
- *
307
- * @example
308
- * ```typescript
309
- * const taskAsync = await video.generateAsync({
310
- * model: "prunaai/p-video",
311
- * prompt: "A neon city street in the rain",
312
- * });
313
- *
314
- * return { id: taskAsync.id, access: taskAsync.access };
315
- * ```
316
- */
317
- generateAsync<const T extends MynthSDKTypes.VideoGenerationClientRequest>(request: T): Promise<TaskAsync<VideoGenerationResult<ExtractVideoMetadata<T>>>>;
318
- /**
319
- * Upload one or more images to Mynth temporary input storage.
320
- *
321
- * Video inputs are images, so this is the same storage `image.upload()` uses.
322
- * Passing files straight to `generate()` uploads them for you; call this
323
- * directly only when you want to reuse the URLs across several requests.
324
- *
325
- * @param input - Image input or inputs to upload
326
- * @returns Uploaded image URLs that can be passed to generation `inputs`
327
- */
328
- upload(input: MynthSDKTypes.ImageUploadInput | readonly MynthSDKTypes.ImageUploadInput[]): Promise<MynthSDKTypes.ImageUploadResponse>;
329
- /**
330
- * Price a video generation request without generating anything.
331
- *
332
- * The request is validated exactly as `generate()` would validate it, so an
333
- * unsupported duration, resolution or input combination throws here too —
334
- * making this a cheap pre-flight check as well as a cost lookup. Because
335
- * video pins a concrete model, the returned estimate is exact.
336
- *
337
- * @param request - The same request you would pass to `generate()`
338
- * @returns The estimated cost in USD
339
- *
340
- * @example
341
- * ```typescript
342
- * const { estimatedCost } = await video.estimate({
343
- * model: "google/gemini-omni-flash-1.1",
344
- * prompt: "A timelapse of clouds over a canyon",
345
- * duration: 10,
346
- * resolution: "4k",
347
- * });
348
- * ```
349
- */
350
- estimate(request: MynthSDKTypes.VideoGenerationClientRequest): Promise<MynthSDKTypes.VideoGenerationEstimate>;
351
- private toRequestBody;
352
- private createGenerationTask;
616
+ private readonly client;
617
+ /**
618
+ * Creates a new MynthVideo client instance.
619
+ *
620
+ * @param options - Configuration options
621
+ * @param options.apiKey - Your API key (defaults to MYNTH_API_KEY env var)
622
+ * @param options.baseUrl - Custom API base URL
623
+ * @throws {Error} If no API key is provided and MYNTH_API_KEY is not set
624
+ */
625
+ constructor(options?: Omit<MynthOptions, "destination">);
626
+ /**
627
+ * Generate a video from a text prompt, optionally guided by input images.
628
+ *
629
+ * Waits for the task to complete. Video generation is slow: this poll can
630
+ * legitimately run for many minutes. Use `generateAsync()` (or a webhook)
631
+ * when you cannot hold a request open that long.
632
+ *
633
+ * @param request - Video generation request parameters
634
+ * @returns A completed VideoGenerationResult
635
+ *
636
+ * @example
637
+ * ```typescript
638
+ * const result = await video.generate({
639
+ * model: "bytedance/seedance-2.0-mini",
640
+ * prompt: "A drone shot over a misty forest at dawn",
641
+ * });
642
+ * console.log(result.urls);
643
+ * ```
644
+ */
645
+ generate<const T extends MynthSDKTypes.VideoGenerationClientRequest>(request: T): Promise<VideoGenerationResult<ExtractVideoMetadata<T>>>;
646
+ /**
647
+ * Start video generation without waiting for completion.
648
+ *
649
+ * The preferred entry point for server code: hand `taskAsync.id` and
650
+ * `taskAsync.access.publicAccessToken` to the browser, or register a webhook,
651
+ * instead of holding a connection open for the length of a render.
652
+ *
653
+ * @param request - Video generation request parameters
654
+ * @returns A TaskAsync that can be polled for completion via `.wait()`
655
+ *
656
+ * @example
657
+ * ```typescript
658
+ * const taskAsync = await video.generateAsync({
659
+ * model: "prunaai/p-video",
660
+ * prompt: "A neon city street in the rain",
661
+ * });
662
+ *
663
+ * return { id: taskAsync.id, access: taskAsync.access };
664
+ * ```
665
+ */
666
+ generateAsync<const T extends MynthSDKTypes.VideoGenerationClientRequest>(request: T): Promise<TaskAsync<VideoGenerationResult<ExtractVideoMetadata<T>>>>;
667
+ /**
668
+ * Upload one or more images to Mynth temporary input storage.
669
+ *
670
+ * Video inputs are images, so this is the same storage `image.upload()` uses.
671
+ * Passing files straight to `generate()` uploads them for you; call this
672
+ * directly only when you want to reuse the URLs across several requests.
673
+ *
674
+ * @param input - Image input or inputs to upload
675
+ * @returns Uploaded image URLs that can be passed to generation `inputs`
676
+ */
677
+ upload(input: MynthSDKTypes.ImageUploadInput | readonly MynthSDKTypes.ImageUploadInput[]): Promise<MynthSDKTypes.ImageUploadResponse>;
678
+ /**
679
+ * Price a video generation request without generating anything.
680
+ *
681
+ * The request is validated exactly as `generate()` would validate it, so an
682
+ * unsupported duration, resolution or input combination throws here too —
683
+ * making this a cheap pre-flight check as well as a cost lookup. Because
684
+ * video pins a concrete model, the returned estimate is exact.
685
+ *
686
+ * @param request - The same request you would pass to `generate()`
687
+ * @returns The estimated cost in USD
688
+ *
689
+ * @example
690
+ * ```typescript
691
+ * const { estimatedCost } = await video.estimate({
692
+ * model: "google/gemini-omni-flash-1.1",
693
+ * prompt: "A timelapse of clouds over a canyon",
694
+ * duration: 10,
695
+ * resolution: "4k",
696
+ * });
697
+ * ```
698
+ */
699
+ estimate(request: MynthSDKTypes.VideoGenerationClientRequest): Promise<MynthSDKTypes.VideoGenerationEstimate>;
700
+ private toRequestBody;
701
+ private createGenerationTask;
353
702
  }
354
703
  /**
355
704
  * Client for interacting with the public Mynth model catalog.
356
705
  */
357
706
  declare class MynthModels {
358
- private readonly client;
359
- /**
360
- * Creates a new MynthModels client instance.
361
- *
362
- * @param options - Configuration options
363
- * @param options.baseUrl - Custom API base URL
364
- */
365
- constructor(options?: Pick<MynthOptions, "baseUrl">);
366
- /**
367
- * List available image generation models.
368
- *
369
- * This endpoint is public and does not require a Mynth API key.
370
- *
371
- * @returns Available image and video models with display names, served modes, and pricing
372
- *
373
- * @example
374
- * ```typescript
375
- * const models = await mynth.models.list();
376
- * console.log(models[0]?.id);
377
- * ```
378
- */
379
- list(): Promise<MynthSDKTypes.Model[]>;
707
+ private readonly client;
708
+ /**
709
+ * Creates a new MynthModels client instance.
710
+ *
711
+ * @param options - Configuration options
712
+ * @param options.baseUrl - Custom API base URL
713
+ */
714
+ constructor(options?: Pick<MynthOptions, "baseUrl">);
715
+ /**
716
+ * List available image generation models.
717
+ *
718
+ * This endpoint is public and does not require a Mynth API key.
719
+ *
720
+ * @returns Available image and video models with display names, served modes, and pricing
721
+ *
722
+ * @example
723
+ * ```typescript
724
+ * const models = await mynth.models.list();
725
+ * console.log(models[0]?.id);
726
+ * ```
727
+ */
728
+ list(): Promise<MynthSDKTypes.Model[]>;
380
729
  }
381
730
  /**
382
731
  * Bundled Mynth client providing access to all media type clients.
@@ -392,25 +741,23 @@ declare class MynthModels {
392
741
  * ```
393
742
  */
394
743
  declare class Mynth {
395
- /** Public model catalog client */
396
- readonly models: MynthModels;
397
- private readonly options;
398
- private imageClient?;
399
- private videoClient?;
400
- /**
401
- * Creates a new Mynth client instance.
402
- *
403
- * @param options - Configuration options
404
- * @param options.apiKey - Your API key (defaults to MYNTH_API_KEY env var)
405
- * @param options.baseUrl - Custom API base URL
406
- */
407
- constructor(options?: MynthOptions);
408
- /** Image generation and analysis client */
409
- get image(): MynthImage;
410
- /** Video generation client */
411
- get video(): MynthVideo;
744
+ /** Public model catalog client */
745
+ readonly models: MynthModels;
746
+ private readonly options;
747
+ private imageClient?;
748
+ private videoClient?;
749
+ /**
750
+ * Creates a new Mynth client instance.
751
+ *
752
+ * @param options - Configuration options
753
+ * @param options.apiKey - Your API key (defaults to MYNTH_API_KEY env var)
754
+ * @param options.baseUrl - Custom API base URL
755
+ */
756
+ constructor(options?: MynthOptions);
757
+ /** Image generation and analysis client */
758
+ get image(): MynthImage;
759
+ /** Video generation client */
760
+ get video(): MynthVideo;
412
761
  }
413
- export { AVAILABLE_MODELS, AVAILABLE_VIDEO_MODELS, ImageAltResult, ImageGenerationResult, ImageRateResult, ImageReviewResult, Mynth, MynthImage, MynthModels, MynthVideo, TaskAsync, VideoGenerationResult, MynthAPIError, TaskAsyncFetchError, TaskAsyncTaskFailedError, TaskAsyncTaskFetchError, TaskAsyncTimeoutError, TaskAsyncUnauthorizedError, };
414
- export type { AvailableModel, AvailableVideoModel, ModelCapability, MynthModel, MynthModelPricing, MynthOptions, MynthSDKTypes, TaskAsyncAccess, VideoInputRole, VideoResolutionTier, };
415
- export default Mynth;
416
- //# sourceMappingURL=index.d.ts.map
762
+ //#endregion
763
+ export { AVAILABLE_MODELS, AVAILABLE_VIDEO_MODELS, type AvailableModel, type AvailableVideoModel, type ModelCapability, Mynth, Mynth as default, MynthImage, type MynthModel, type MynthModelPricing, MynthModels, type MynthOptions, type MynthSDKTypes, MynthVideo, type TaskAsyncAccess, type VideoInputRole, type VideoResolutionTier };