@mynthio/sdk 0.0.45 → 0.0.46
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/README.md +54 -2
- package/dist/handler.d.ts +2 -0
- package/dist/handler.js +2 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +84 -1
- package/dist/types.d.ts +69 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -473,6 +473,51 @@ const taskAsync = await mynth.image.removeBackgroundAsync({
|
|
|
473
473
|
return { id: taskAsync.id, access: taskAsync.access };
|
|
474
474
|
```
|
|
475
475
|
|
|
476
|
+
## Upscale
|
|
477
|
+
|
|
478
|
+
Enlarge an existing image 2x or 4x. Mynth picks the model, so there is no `model` field. `size` and `effort` are both required:
|
|
479
|
+
|
|
480
|
+
```ts
|
|
481
|
+
const result = await mynth.image.upscale({
|
|
482
|
+
url: "https://example.com/product.jpg",
|
|
483
|
+
size: "2x",
|
|
484
|
+
effort: "low",
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
console.log(result.image.url); // upscaled image
|
|
488
|
+
console.log(result.image.size); // e.g. "2048x1536"
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
`effort` sets the price: `low` is fast and sharp, `high` rebuilds fine detail such as small text and faces. `size` is `"2x"` or `"4x"`, or `{ type: "scale", factor: 2 | 4 }`. The upscaled image can be at most 4096x4096 pixels; a larger request fails with `OUTPUT_TOO_LARGE` and is not charged.
|
|
492
|
+
|
|
493
|
+
The result keeps the format the provider returned. Set `output.format` to always get `png`, `jpg`, or `webp`.
|
|
494
|
+
`upscale()` also takes a local `file`, plus `destination`, `webhook`, and `metadata` like `generate()`:
|
|
495
|
+
|
|
496
|
+
```ts
|
|
497
|
+
const result = await mynth.image.upscale({
|
|
498
|
+
file,
|
|
499
|
+
size: "4x",
|
|
500
|
+
effort: "high",
|
|
501
|
+
output: { format: "webp" },
|
|
502
|
+
destination: "bunny-prod",
|
|
503
|
+
metadata: { productId: "sku_1" },
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
console.log(result.metadata.productId);
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
Use `upscaleAsync()` to create the task without waiting. It returns a public access token, like `generateAsync()`:
|
|
510
|
+
|
|
511
|
+
```ts
|
|
512
|
+
const taskAsync = await mynth.image.upscaleAsync({
|
|
513
|
+
url: "https://example.com/product.jpg",
|
|
514
|
+
size: "2x",
|
|
515
|
+
effort: "low",
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
return { id: taskAsync.id, access: taskAsync.access };
|
|
519
|
+
```
|
|
520
|
+
|
|
476
521
|
## Working With Image Results
|
|
477
522
|
|
|
478
523
|
Completed generation tasks expose a few helpful accessors:
|
|
@@ -839,6 +884,13 @@ export const mynthWebhook = mynthWebhookAction({
|
|
|
839
884
|
imageRemoveBackgroundTaskFailed: async (payload) => {
|
|
840
885
|
console.error("Mynth remove background task failed:", payload.task.id);
|
|
841
886
|
},
|
|
887
|
+
imageUpscaleTaskCompleted: async (payload) => {
|
|
888
|
+
console.log("Completed upscale task:", payload.task.id);
|
|
889
|
+
console.log(payload.result.image.url);
|
|
890
|
+
},
|
|
891
|
+
imageUpscaleTaskFailed: async (payload) => {
|
|
892
|
+
console.error("Mynth upscale task failed:", payload.task.id);
|
|
893
|
+
},
|
|
842
894
|
videoTaskCompleted: async (payload) => {
|
|
843
895
|
console.log("Completed video task:", payload.task.id);
|
|
844
896
|
console.log(payload.result.videos);
|
|
@@ -853,7 +905,7 @@ Set `MYNTH_WEBHOOK_SECRET` in your environment, or pass `webhookSecret` explicit
|
|
|
853
905
|
|
|
854
906
|
## Error Handling
|
|
855
907
|
|
|
856
|
-
`upload()`, `generate()`, `generateAsync()`, `rate()`, `rateAsync()`, `alt()`, `altAsync()`, `review()`, `reviewAsync()`, `removeBackground()`, `removeBackgroundAsync()`, `models.list()`, and the `video` equivalents (`video.generate()`, `video.generateAsync()`, `video.upload()`, `video.estimate()`) may throw `MynthAPIError` if the request fails. Polling can also throw task-specific errors:
|
|
908
|
+
`upload()`, `generate()`, `generateAsync()`, `rate()`, `rateAsync()`, `alt()`, `altAsync()`, `review()`, `reviewAsync()`, `removeBackground()`, `removeBackgroundAsync()`, `upscale()`, `upscaleAsync()`, `models.list()`, and the `video` equivalents (`video.generate()`, `video.generateAsync()`, `video.upload()`, `video.estimate()`) may throw `MynthAPIError` if the request fails. Polling can also throw task-specific errors:
|
|
857
909
|
|
|
858
910
|
While polling, transient failures (404, 5xx, dropped connections) are retried: a created task is owed an answer, so a cold cache or a brief outage does not lose you the result. A 429 slows polling down, doubling the interval up to 30 seconds, and only the timeout ends it. Polling gives up after 20 consecutive failures (~100s) with `TaskAsyncFetchError` or `TaskAsyncTaskFetchError`, immediately on a 401 or 403 with `TaskAsyncUnauthorizedError`, and immediately on any other 4xx with `TaskAsyncFetchError` or `TaskAsyncTaskFetchError`. Image waits time out after 30 minutes, video waits after an hour.
|
|
859
911
|
|
|
@@ -892,7 +944,7 @@ try {
|
|
|
892
944
|
|
|
893
945
|
## Documentation
|
|
894
946
|
|
|
895
|
-
For product documentation and API guides, visit [
|
|
947
|
+
For product documentation and API guides, visit [mynth.io/docs](https://mynth.io/docs).
|
|
896
948
|
|
|
897
949
|
## Contributing
|
|
898
950
|
|
package/dist/handler.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ declare const EVENT_HANDLER_NAMES: {
|
|
|
12
12
|
readonly "task.image.review.failed": "imageReviewTaskFailed";
|
|
13
13
|
readonly "task.image.remove_background.completed": "imageRemoveBackgroundTaskCompleted";
|
|
14
14
|
readonly "task.image.remove_background.failed": "imageRemoveBackgroundTaskFailed";
|
|
15
|
+
readonly "task.image.upscale.completed": "imageUpscaleTaskCompleted";
|
|
16
|
+
readonly "task.image.upscale.failed": "imageUpscaleTaskFailed";
|
|
15
17
|
readonly "task.video.generate.completed": "videoTaskCompleted";
|
|
16
18
|
readonly "task.video.generate.failed": "videoTaskFailed";
|
|
17
19
|
};
|
package/dist/handler.js
CHANGED
|
@@ -73,6 +73,8 @@ const EVENT_HANDLER_NAMES = {
|
|
|
73
73
|
"task.image.review.failed": "imageReviewTaskFailed",
|
|
74
74
|
"task.image.remove_background.completed": "imageRemoveBackgroundTaskCompleted",
|
|
75
75
|
"task.image.remove_background.failed": "imageRemoveBackgroundTaskFailed",
|
|
76
|
+
"task.image.upscale.completed": "imageUpscaleTaskCompleted",
|
|
77
|
+
"task.image.upscale.failed": "imageUpscaleTaskFailed",
|
|
76
78
|
"task.video.generate.completed": "videoTaskCompleted",
|
|
77
79
|
"task.video.generate.failed": "videoTaskFailed"
|
|
78
80
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -197,6 +197,30 @@ export declare class ImageReviewResult {
|
|
|
197
197
|
static fromTaskData(data: MynthSDKTypes.ImageReviewTaskData): ImageReviewResult;
|
|
198
198
|
}
|
|
199
199
|
//#endregion
|
|
200
|
+
//#region src/image-upscale-result.d.ts
|
|
201
|
+
/**
|
|
202
|
+
* Represents the result of a completed image upscale task.
|
|
203
|
+
*
|
|
204
|
+
* @template MetadataT - Type of the metadata attached to the request
|
|
205
|
+
*/
|
|
206
|
+
export declare class ImageUpscaleResult<MetadataT = Record<string, unknown> | undefined> {
|
|
207
|
+
/** The task ID created for this request */
|
|
208
|
+
readonly taskId: string;
|
|
209
|
+
/** Cost charged for the completed task */
|
|
210
|
+
readonly cost: string;
|
|
211
|
+
/** The upscaled image */
|
|
212
|
+
readonly image: MynthSDKTypes.ImageUpscaleResultImage;
|
|
213
|
+
/** Metadata attached to the request */
|
|
214
|
+
readonly metadata: MetadataT;
|
|
215
|
+
constructor(data: {
|
|
216
|
+
taskId: string;
|
|
217
|
+
cost: string;
|
|
218
|
+
image: MynthSDKTypes.ImageUpscaleResultImage;
|
|
219
|
+
metadata: MetadataT;
|
|
220
|
+
});
|
|
221
|
+
static fromTaskData<MetadataT = Record<string, unknown> | undefined>(data: MynthSDKTypes.ImageUpscaleTaskData): ImageUpscaleResult<MetadataT>;
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
200
224
|
//#region src/task-async.d.ts
|
|
201
225
|
/**
|
|
202
226
|
* Polling cadence overrides. Anything omitted keeps the image-task default.
|
|
@@ -387,6 +411,7 @@ type MynthModelPricing = MynthSDKTypes.ModelPricing;
|
|
|
387
411
|
type ExtractMetadata<T extends MynthSDKTypes.ImageGenerationClientRequest> = T["metadata"];
|
|
388
412
|
type ExtractVideoMetadata<T extends MynthSDKTypes.VideoGenerationClientRequest> = T["metadata"];
|
|
389
413
|
type ExtractRemoveBackgroundMetadata<T extends MynthSDKTypes.ImageRemoveBackgroundClientRequest> = T["metadata"];
|
|
414
|
+
type ExtractUpscaleMetadata<T extends MynthSDKTypes.ImageUpscaleClientRequest> = T["metadata"];
|
|
390
415
|
type ExtractRatingConfig<T extends MynthSDKTypes.ImageGenerationClientRequest> = T["rating"];
|
|
391
416
|
type ExtractRatingLevels<T extends MynthSDKTypes.ImageGenerationClientRequest> = ExtractRatingConfig<T> extends {
|
|
392
417
|
levels: readonly (infer L)[];
|
|
@@ -628,6 +653,38 @@ declare class MynthImage {
|
|
|
628
653
|
*/
|
|
629
654
|
removeBackgroundAsync<const T extends MynthSDKTypes.ImageRemoveBackgroundClientRequest>(request: T): Promise<TaskAsync<ImageRemoveBackgroundResult<ExtractRemoveBackgroundMetadata<T>>>>;
|
|
630
655
|
private createRemoveBackgroundTask;
|
|
656
|
+
/**
|
|
657
|
+
* Upscale a single image 2x or 4x.
|
|
658
|
+
*
|
|
659
|
+
* Mynth picks the model. `effort` sets the price, so it has no default. The
|
|
660
|
+
* upscaled image can be at most 4096x4096 pixels; a larger request fails
|
|
661
|
+
* with `OUTPUT_TOO_LARGE` and is not charged.
|
|
662
|
+
*
|
|
663
|
+
* @param request - Image URL or local file, size, and effort, plus optional output, destination, webhook, and metadata
|
|
664
|
+
* @returns An ImageUpscaleResult with the enlarged image
|
|
665
|
+
*
|
|
666
|
+
* @example
|
|
667
|
+
* ```typescript
|
|
668
|
+
* const result = await image.upscale({ url: "https://...", size: "2x", effort: "low" });
|
|
669
|
+
* console.log(result.image.url);
|
|
670
|
+
* ```
|
|
671
|
+
*/
|
|
672
|
+
upscale<const T extends MynthSDKTypes.ImageUpscaleClientRequest>(request: T): Promise<ImageUpscaleResult<ExtractUpscaleMetadata<T>>>;
|
|
673
|
+
/**
|
|
674
|
+
* Start an upscale without waiting for completion.
|
|
675
|
+
*
|
|
676
|
+
* @param request - Image URL or local file, size, and effort, plus optional output, destination, webhook, and metadata
|
|
677
|
+
* @returns A TaskAsync that can be polled for completion via `.wait()`
|
|
678
|
+
*
|
|
679
|
+
* @example
|
|
680
|
+
* ```typescript
|
|
681
|
+
* const taskAsync = await image.upscaleAsync({ url: "https://...", size: "2x", effort: "low" });
|
|
682
|
+
*
|
|
683
|
+
* return { id: taskAsync.id, access: taskAsync.access };
|
|
684
|
+
* ```
|
|
685
|
+
*/
|
|
686
|
+
upscaleAsync<const T extends MynthSDKTypes.ImageUpscaleClientRequest>(request: T): Promise<TaskAsync<ImageUpscaleResult<ExtractUpscaleMetadata<T>>>>;
|
|
687
|
+
private createUpscaleTask;
|
|
631
688
|
}
|
|
632
689
|
/**
|
|
633
690
|
* Client for interacting with the Mynth video generation API.
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ const RATE_IMAGE_PATH = "/image/rate";
|
|
|
11
11
|
const ALT_IMAGE_PATH = "/image/alt";
|
|
12
12
|
const REVIEW_IMAGE_PATH = "/image/review";
|
|
13
13
|
const REMOVE_BACKGROUND_IMAGE_PATH = "/image/remove-background";
|
|
14
|
+
const UPSCALE_IMAGE_PATH = "/image/upscale";
|
|
14
15
|
const GENERATE_VIDEO_PATH = "/video/generate";
|
|
15
16
|
const ESTIMATE_VIDEO_PATH = "/video/generate/estimate";
|
|
16
17
|
const MODELS_PATH = "/models";
|
|
@@ -654,6 +655,39 @@ var ImageReviewResult = class ImageReviewResult {
|
|
|
654
655
|
}
|
|
655
656
|
};
|
|
656
657
|
//#endregion
|
|
658
|
+
//#region src/image-upscale-result.ts
|
|
659
|
+
/**
|
|
660
|
+
* Represents the result of a completed image upscale task.
|
|
661
|
+
*
|
|
662
|
+
* @template MetadataT - Type of the metadata attached to the request
|
|
663
|
+
*/
|
|
664
|
+
var ImageUpscaleResult = class ImageUpscaleResult {
|
|
665
|
+
/** The task ID created for this request */
|
|
666
|
+
taskId;
|
|
667
|
+
/** Cost charged for the completed task */
|
|
668
|
+
cost;
|
|
669
|
+
/** The upscaled image */
|
|
670
|
+
image;
|
|
671
|
+
/** Metadata attached to the request */
|
|
672
|
+
metadata;
|
|
673
|
+
constructor(data) {
|
|
674
|
+
this.taskId = data.taskId;
|
|
675
|
+
this.cost = data.cost;
|
|
676
|
+
this.image = data.image;
|
|
677
|
+
this.metadata = data.metadata;
|
|
678
|
+
}
|
|
679
|
+
static fromTaskData(data) {
|
|
680
|
+
if (data.status !== "completed" || data.result === null) throw new Error(`Image upscale task ${data.id} is not completed`);
|
|
681
|
+
if (data.cost === null) throw new Error(`Image upscale task ${data.id} is missing cost`);
|
|
682
|
+
return new ImageUpscaleResult({
|
|
683
|
+
taskId: data.id,
|
|
684
|
+
cost: data.cost,
|
|
685
|
+
image: data.result.image,
|
|
686
|
+
metadata: data.request.metadata
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
//#endregion
|
|
657
691
|
//#region src/task-async.ts
|
|
658
692
|
const POLLING_TIMEOUT_MS = 18e5;
|
|
659
693
|
const FAST_POLLING_DURATION_MS = 12e3;
|
|
@@ -1369,6 +1403,55 @@ var MynthImage = class {
|
|
|
1369
1403
|
resultFactory: (taskData) => ImageRemoveBackgroundResult.fromTaskData(taskData)
|
|
1370
1404
|
});
|
|
1371
1405
|
}
|
|
1406
|
+
/**
|
|
1407
|
+
* Upscale a single image 2x or 4x.
|
|
1408
|
+
*
|
|
1409
|
+
* Mynth picks the model. `effort` sets the price, so it has no default. The
|
|
1410
|
+
* upscaled image can be at most 4096x4096 pixels; a larger request fails
|
|
1411
|
+
* with `OUTPUT_TOO_LARGE` and is not charged.
|
|
1412
|
+
*
|
|
1413
|
+
* @param request - Image URL or local file, size, and effort, plus optional output, destination, webhook, and metadata
|
|
1414
|
+
* @returns An ImageUpscaleResult with the enlarged image
|
|
1415
|
+
*
|
|
1416
|
+
* @example
|
|
1417
|
+
* ```typescript
|
|
1418
|
+
* const result = await image.upscale({ url: "https://...", size: "2x", effort: "low" });
|
|
1419
|
+
* console.log(result.image.url);
|
|
1420
|
+
* ```
|
|
1421
|
+
*/
|
|
1422
|
+
async upscale(request) {
|
|
1423
|
+
return (await this.createUpscaleTask(request)).wait();
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* Start an upscale without waiting for completion.
|
|
1427
|
+
*
|
|
1428
|
+
* @param request - Image URL or local file, size, and effort, plus optional output, destination, webhook, and metadata
|
|
1429
|
+
* @returns A TaskAsync that can be polled for completion via `.wait()`
|
|
1430
|
+
*
|
|
1431
|
+
* @example
|
|
1432
|
+
* ```typescript
|
|
1433
|
+
* const taskAsync = await image.upscaleAsync({ url: "https://...", size: "2x", effort: "low" });
|
|
1434
|
+
*
|
|
1435
|
+
* return { id: taskAsync.id, access: taskAsync.access };
|
|
1436
|
+
* ```
|
|
1437
|
+
*/
|
|
1438
|
+
async upscaleAsync(request) {
|
|
1439
|
+
return this.createUpscaleTask(request);
|
|
1440
|
+
}
|
|
1441
|
+
async createUpscaleTask(request) {
|
|
1442
|
+
const url = await this.resolveUrlOrFile(request);
|
|
1443
|
+
const { file: _, url: __, ...rest } = request;
|
|
1444
|
+
const data = (await this.client.post(UPSCALE_IMAGE_PATH, {
|
|
1445
|
+
...rest,
|
|
1446
|
+
url,
|
|
1447
|
+
destination: request.destination ?? this.defaultDestination
|
|
1448
|
+
})).data;
|
|
1449
|
+
return new TaskAsync(data.taskId, {
|
|
1450
|
+
client: this.client,
|
|
1451
|
+
pat: data.access?.publicAccessToken,
|
|
1452
|
+
resultFactory: (taskData) => ImageUpscaleResult.fromTaskData(taskData)
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1372
1455
|
};
|
|
1373
1456
|
/**
|
|
1374
1457
|
* Client for interacting with the Mynth video generation API.
|
|
@@ -1582,4 +1665,4 @@ var Mynth = class {
|
|
|
1582
1665
|
}
|
|
1583
1666
|
};
|
|
1584
1667
|
//#endregion
|
|
1585
|
-
export { AVAILABLE_MODELS, AVAILABLE_VIDEO_MODELS, ImageAltResult, ImageGenerationResult, ImageRateResult, ImageRemoveBackgroundResult, ImageReviewResult, Mynth, Mynth as default, MynthAPIError, MynthImage, MynthModels, MynthVideo, TaskAsync, TaskAsyncFetchError, TaskAsyncTaskFailedError, TaskAsyncTaskFetchError, TaskAsyncTimeoutError, TaskAsyncUnauthorizedError, VideoGenerationResult };
|
|
1668
|
+
export { AVAILABLE_MODELS, AVAILABLE_VIDEO_MODELS, ImageAltResult, ImageGenerationResult, ImageRateResult, ImageRemoveBackgroundResult, ImageReviewResult, ImageUpscaleResult, Mynth, Mynth as default, MynthAPIError, MynthImage, MynthModels, MynthVideo, TaskAsync, TaskAsyncFetchError, TaskAsyncTaskFailedError, TaskAsyncTaskFetchError, TaskAsyncTimeoutError, TaskAsyncUnauthorizedError, VideoGenerationResult };
|
package/dist/types.d.ts
CHANGED
|
@@ -72,7 +72,7 @@ declare namespace MynthSDKTypes {
|
|
|
72
72
|
data: DataT;
|
|
73
73
|
};
|
|
74
74
|
type TaskStatus = "pending" | "completed" | "failed";
|
|
75
|
-
type TaskType = "image.generate" | "image.rate" | "image.alt" | "image.review" | "image.remove_background" | "video.generate";
|
|
75
|
+
type TaskType = "image.generate" | "image.rate" | "image.alt" | "image.review" | "image.remove_background" | "image.upscale" | "video.generate";
|
|
76
76
|
type TaskBase = {
|
|
77
77
|
id: string;
|
|
78
78
|
status: TaskStatus;
|
|
@@ -107,6 +107,10 @@ declare namespace MynthSDKTypes {
|
|
|
107
107
|
type: "image.remove_background";
|
|
108
108
|
request: ImageRemoveBackgroundRequest;
|
|
109
109
|
result: ImageRemoveBackgroundTaskResult | null;
|
|
110
|
+
}) | (TaskBase & {
|
|
111
|
+
type: "image.upscale";
|
|
112
|
+
request: ImageUpscaleRequest;
|
|
113
|
+
result: ImageUpscaleTaskResult | null;
|
|
110
114
|
}) | (TaskBase & {
|
|
111
115
|
type: "video.generate";
|
|
112
116
|
request: VideoGenerationRequest;
|
|
@@ -127,6 +131,9 @@ declare namespace MynthSDKTypes {
|
|
|
127
131
|
type ImageRemoveBackgroundTaskData = Extract<TaskData, {
|
|
128
132
|
type: "image.remove_background";
|
|
129
133
|
}>;
|
|
134
|
+
type ImageUpscaleTaskData = Extract<TaskData, {
|
|
135
|
+
type: "image.upscale";
|
|
136
|
+
}>;
|
|
130
137
|
type VideoGenerationTaskData = Extract<TaskData, {
|
|
131
138
|
type: "video.generate";
|
|
132
139
|
}>;
|
|
@@ -435,6 +442,50 @@ declare namespace MynthSDKTypes {
|
|
|
435
442
|
type ImageRemoveBackgroundTaskResult = {
|
|
436
443
|
image: ImageRemoveBackgroundResultImage;
|
|
437
444
|
};
|
|
445
|
+
type ImageUpscaleEffort = "low" | "high";
|
|
446
|
+
type ImageUpscaleFactor = 2 | 4;
|
|
447
|
+
type ImageUpscaleSize = "2x" | "4x" | {
|
|
448
|
+
type: "scale";
|
|
449
|
+
factor: ImageUpscaleFactor;
|
|
450
|
+
};
|
|
451
|
+
type ImageUpscaleOutputFormat = "png" | "jpg" | "webp";
|
|
452
|
+
type ImageUpscaleRequestOutput = {
|
|
453
|
+
/** Converts the result to this format. When omitted, the provider's format is kept. */
|
|
454
|
+
format?: ImageUpscaleOutputFormat;
|
|
455
|
+
};
|
|
456
|
+
type ImageUpscaleRequest = {
|
|
457
|
+
/** Image URL to upscale. */
|
|
458
|
+
url: string;
|
|
459
|
+
size: ImageUpscaleSize;
|
|
460
|
+
/** Sets the price, so there is no default. */
|
|
461
|
+
effort: ImageUpscaleEffort;
|
|
462
|
+
output?: ImageUpscaleRequestOutput;
|
|
463
|
+
webhook?: ImageGenerationRequestWebhook;
|
|
464
|
+
access?: ImageGenerationRequestAccess;
|
|
465
|
+
metadata?: Record<string, unknown>;
|
|
466
|
+
destination?: string;
|
|
467
|
+
};
|
|
468
|
+
type ImageUpscaleClientRequest = ImageClientUrlOrFile & Omit<ImageUpscaleRequest, "url">;
|
|
469
|
+
type ImageUpscaleCreatedResponse = {
|
|
470
|
+
taskId: string;
|
|
471
|
+
estimatedCost: string;
|
|
472
|
+
access?: {
|
|
473
|
+
publicAccessToken: string;
|
|
474
|
+
};
|
|
475
|
+
};
|
|
476
|
+
type ImageUpscaleResultImage = {
|
|
477
|
+
id: string;
|
|
478
|
+
/** Destination URL, or the Mynth URL without a destination. `null` when delivery failed. */
|
|
479
|
+
url: string | null;
|
|
480
|
+
mynth_url: string;
|
|
481
|
+
/** `{width}x{height}`. Can be a few pixels off the source times the factor. */
|
|
482
|
+
size: string;
|
|
483
|
+
format: ImageUpscaleOutputFormat;
|
|
484
|
+
destination?: ImageResultDestination;
|
|
485
|
+
};
|
|
486
|
+
type ImageUpscaleTaskResult = {
|
|
487
|
+
image: ImageUpscaleResultImage;
|
|
488
|
+
};
|
|
438
489
|
type VideoGenerationModelId = "bytedance/seedance-2.0-mini" | "google/gemini-omni-flash-1.1" | "prunaai/p-video" | "xai/grok-imagine-video-1.5";
|
|
439
490
|
type VideoGenerationModel = VideoGenerationModelId;
|
|
440
491
|
type VideoGenerationRequestResolution = "480p" | "720p" | "1080p" | "4k";
|
|
@@ -593,6 +644,22 @@ declare namespace MynthSDKTypes {
|
|
|
593
644
|
request: ImageRemoveBackgroundRequest;
|
|
594
645
|
errors: TaskError[];
|
|
595
646
|
};
|
|
647
|
+
type WebhookTaskImageUpscaleCompletedPayload = {
|
|
648
|
+
task: {
|
|
649
|
+
id: string;
|
|
650
|
+
};
|
|
651
|
+
event: "task.image.upscale.completed";
|
|
652
|
+
result: ImageUpscaleTaskResult;
|
|
653
|
+
request: ImageUpscaleRequest;
|
|
654
|
+
};
|
|
655
|
+
type WebhookTaskImageUpscaleFailedPayload = {
|
|
656
|
+
task: {
|
|
657
|
+
id: string;
|
|
658
|
+
};
|
|
659
|
+
event: "task.image.upscale.failed";
|
|
660
|
+
request: ImageUpscaleRequest;
|
|
661
|
+
errors: TaskError[];
|
|
662
|
+
};
|
|
596
663
|
type WebhookTaskVideoCompletedPayload = {
|
|
597
664
|
task: {
|
|
598
665
|
id: string;
|
|
@@ -609,7 +676,7 @@ declare namespace MynthSDKTypes {
|
|
|
609
676
|
request: VideoGenerationRequest;
|
|
610
677
|
errors: TaskError[];
|
|
611
678
|
};
|
|
612
|
-
type WebhookPayload = WebhookTaskImageCompletedPayload | WebhookTaskImageFailedPayload | WebhookTaskImageRateCompletedPayload | WebhookTaskImageRateFailedPayload | WebhookTaskImageAltCompletedPayload | WebhookTaskImageAltFailedPayload | WebhookTaskImageReviewCompletedPayload | WebhookTaskImageReviewFailedPayload | WebhookTaskImageRemoveBackgroundCompletedPayload | WebhookTaskImageRemoveBackgroundFailedPayload | WebhookTaskVideoCompletedPayload | WebhookTaskVideoFailedPayload;
|
|
679
|
+
type WebhookPayload = WebhookTaskImageCompletedPayload | WebhookTaskImageFailedPayload | WebhookTaskImageRateCompletedPayload | WebhookTaskImageRateFailedPayload | WebhookTaskImageAltCompletedPayload | WebhookTaskImageAltFailedPayload | WebhookTaskImageReviewCompletedPayload | WebhookTaskImageReviewFailedPayload | WebhookTaskImageRemoveBackgroundCompletedPayload | WebhookTaskImageRemoveBackgroundFailedPayload | WebhookTaskImageUpscaleCompletedPayload | WebhookTaskImageUpscaleFailedPayload | WebhookTaskVideoCompletedPayload | WebhookTaskVideoFailedPayload;
|
|
613
680
|
}
|
|
614
681
|
//#endregion
|
|
615
682
|
export { AvailableVideoModel as a, VideoResolutionTier as c, AvailableModel as i, AVAILABLE_MODELS as n, ModelCapability as o, AVAILABLE_VIDEO_MODELS as r, VideoInputRole as s, MynthSDKTypes as t };
|