@mynthio/sdk 0.0.26 → 0.0.28
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 +40 -4
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/convex/index.d.ts +16 -0
- package/dist/convex/index.d.ts.map +1 -1
- package/dist/convex/index.js +1 -1
- package/dist/image-alt-result.d.ts +39 -0
- package/dist/image-alt-result.d.ts.map +1 -0
- package/dist/index.d.ts +37 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/types.d.ts +70 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @mynthio/sdk
|
|
2
2
|
|
|
3
|
-
Official SDK for the [Mynth](https://mynth.io) image
|
|
3
|
+
Official SDK for the [Mynth](https://mynth.io) image API.
|
|
4
4
|
|
|
5
|
-
The SDK gives you a typed `Mynth` client, sync and async generation flows, model metadata, and a Convex webhook helper.
|
|
5
|
+
The SDK gives you a typed `Mynth` client, sync and async generation, rating, and alt text flows, model metadata, and a Convex webhook helper.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -61,7 +61,7 @@ const mynth = new Mynth({
|
|
|
61
61
|
});
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
- `apiKey`: required for image generation and
|
|
64
|
+
- `apiKey`: required for image generation, rating, and alt text unless `MYNTH_API_KEY` is set; not required for the public model catalog
|
|
65
65
|
- `baseUrl`: optional override for proxies or tests
|
|
66
66
|
|
|
67
67
|
## Generate vs Generate Async
|
|
@@ -341,6 +341,34 @@ const result = await taskAsync.wait();
|
|
|
341
341
|
console.log(result.getRatings());
|
|
342
342
|
```
|
|
343
343
|
|
|
344
|
+
## Alt Text
|
|
345
|
+
|
|
346
|
+
Generate short alt text for existing image URLs:
|
|
347
|
+
|
|
348
|
+
```ts
|
|
349
|
+
const result = await mynth.image.alt({
|
|
350
|
+
urls: ["https://example.com/image.webp"], // 1-10 URLs
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
console.log(result.task.id);
|
|
354
|
+
console.log(result.getAltTexts());
|
|
355
|
+
// [{ status: "success", url: "https://example.com/image.webp", alt: "..." }]
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
Use `altAsync()` when you want to create the alt text task now and wait later:
|
|
359
|
+
|
|
360
|
+
```ts
|
|
361
|
+
const taskAsync = await mynth.image.altAsync({
|
|
362
|
+
urls: ["https://example.com/image.webp"],
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
console.log(taskAsync.id);
|
|
366
|
+
|
|
367
|
+
const result = await taskAsync.wait();
|
|
368
|
+
console.log(result.getAltTexts());
|
|
369
|
+
console.log(result.getErrors());
|
|
370
|
+
```
|
|
371
|
+
|
|
344
372
|
## Working With Results
|
|
345
373
|
|
|
346
374
|
Completed tasks expose a few helpful accessors:
|
|
@@ -410,6 +438,7 @@ Current model IDs include:
|
|
|
410
438
|
- `google/gemini-3.1-flash-lite-image`
|
|
411
439
|
- `google/gemini-3.1-flash-image`
|
|
412
440
|
- `google/gemini-3-pro-image-preview`
|
|
441
|
+
- `ideogram/remove-background`
|
|
413
442
|
- `imagineart/imagineart-1.5-pro`
|
|
414
443
|
- `imagineart/imagineart-2.0`
|
|
415
444
|
- `john6666/bismuth-illustrious-mix`
|
|
@@ -467,6 +496,13 @@ export const mynthWebhook = mynthWebhookAction({
|
|
|
467
496
|
imageRateTaskFailed: async (payload) => {
|
|
468
497
|
console.error("Mynth rating task failed:", payload.task.id);
|
|
469
498
|
},
|
|
499
|
+
imageAltTaskCompleted: async (payload) => {
|
|
500
|
+
console.log("Completed alt text task:", payload.task.id);
|
|
501
|
+
console.log(payload.result.results);
|
|
502
|
+
},
|
|
503
|
+
imageAltTaskFailed: async (payload) => {
|
|
504
|
+
console.error("Mynth alt text task failed:", payload.task.id);
|
|
505
|
+
},
|
|
470
506
|
});
|
|
471
507
|
```
|
|
472
508
|
|
|
@@ -474,7 +510,7 @@ Set `MYNTH_WEBHOOK_SECRET` in your environment, or pass `webhookSecret` explicit
|
|
|
474
510
|
|
|
475
511
|
## Error Handling
|
|
476
512
|
|
|
477
|
-
`generate()`, `generateAsync()`, `rate()`, `rateAsync()`, and `models.list()` may throw `MynthAPIError` if the request fails. Polling can also throw task-specific errors:
|
|
513
|
+
`generate()`, `generateAsync()`, `rate()`, `rateAsync()`, `alt()`, `altAsync()`, and `models.list()` may throw `MynthAPIError` if the request fails. Polling can also throw task-specific errors:
|
|
478
514
|
|
|
479
515
|
```ts
|
|
480
516
|
import {
|
package/dist/constants.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare const API_KEY_ENV_VAR = "MYNTH_API_KEY";
|
|
|
6
6
|
export declare const DESTINATION_ENV_VAR = "MYNTH_DESTINATION";
|
|
7
7
|
export declare const GENERATE_IMAGE_PATH = "/image/generate";
|
|
8
8
|
export declare const RATE_IMAGE_PATH = "/image/rate";
|
|
9
|
+
export declare const ALT_IMAGE_PATH = "/image/alt";
|
|
9
10
|
export declare const MODELS_PATH = "/models";
|
|
10
11
|
export declare const TASK_PATH = "/tasks";
|
|
11
12
|
export declare const TASK_DETAILS_PATH: (id: string) => string;
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,eAAO,MAAM,OAAO,yBAAyB,CAAC;AAE9C,gDAAgD;AAChD,eAAO,MAAM,eAAe,kBAAkB,CAAC;AAE/C,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAEvD,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AACrD,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAC7C,eAAO,MAAM,WAAW,YAAY,CAAC;AACrC,eAAO,MAAM,SAAS,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AI,GAAG,uBAAuB,CAAC;AAE5F;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,mDAAmD;IACnD,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,YAAY,EAAE,SAAS,eAAe,EAAE,CAAC;CAC1C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,cAAc,EAoMrD,CAAC"}
|
package/dist/convex/index.d.ts
CHANGED
|
@@ -24,6 +24,16 @@ export type EventHandlers<T extends GenericActionCtx<any> = GenericActionCtx<any
|
|
|
24
24
|
context: T;
|
|
25
25
|
request: Request;
|
|
26
26
|
}) => Promise<void>;
|
|
27
|
+
/** Called when an image alt text task completes successfully */
|
|
28
|
+
imageAltTaskCompleted?: (payload: MynthSDKTypes.WebhookTaskImageAltCompletedPayload, context: {
|
|
29
|
+
context: T;
|
|
30
|
+
request: Request;
|
|
31
|
+
}) => Promise<void>;
|
|
32
|
+
/** Called when an image alt text task fails */
|
|
33
|
+
imageAltTaskFailed?: (payload: MynthSDKTypes.WebhookTaskImageAltFailedPayload, context: {
|
|
34
|
+
context: T;
|
|
35
|
+
request: Request;
|
|
36
|
+
}) => Promise<void>;
|
|
27
37
|
};
|
|
28
38
|
/**
|
|
29
39
|
* Options for configuring the webhook action.
|
|
@@ -60,6 +70,12 @@ export type MynthWebhookActionOptions = {
|
|
|
60
70
|
* results: payload.result.results,
|
|
61
71
|
* });
|
|
62
72
|
* },
|
|
73
|
+
* imageAltTaskCompleted: async (payload, { context }) => {
|
|
74
|
+
* await context.runMutation(internal.images.saveAltTexts, {
|
|
75
|
+
* taskId: payload.task.id,
|
|
76
|
+
* results: payload.result.results,
|
|
77
|
+
* });
|
|
78
|
+
* },
|
|
63
79
|
* });
|
|
64
80
|
* ```
|
|
65
81
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources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E,KACtC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,+CAA+C;IAC/C,kBAAkB,CAAC,EAAE,CACnB,OAAO,EAAE,aAAa,CAAC,gCAAgC,EACvD,OAAO,EAAE;QAAE,OAAO,EAAE,CAAC,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,KACtC,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,2FAA2F;IAC3F,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,kBAAkB,GAC7B,eAAe,aAAa,EAC5B,UAAU,yBAAyB,MAajC,KAAK,gBAAgB,CAAC,GAAG,CAAC,EAC1B,SAAS,OAAO,KACf,OAAO,CAAC,QAAQ,CAiEpB,CAAC"}
|
package/dist/convex/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var $=()=>{if(typeof process<"u"&&process.env)return process.env.MYNTH_WEBHOOK_SECRET;return};function I(z){let
|
|
2
|
+
var $=()=>{if(typeof process<"u"&&process.env)return process.env.MYNTH_WEBHOOK_SECRET;return};function I(z){let M=z.split(","),J,j;for(let L of M){let[Q,X]=L.split("=");if(Q==="t")J=X;else if(Q==="v1")j=X}if(!J||!j)return null;return{timestamp:J,signature:j}}async function C(z,M,J){let j=I(M);if(!j)return!1;let{timestamp:L,signature:Q}=j,X=`${L}.${z}`,Y=new TextEncoder,Z=await crypto.subtle.importKey("raw",Y.encode(J),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),P=await crypto.subtle.sign("HMAC",Z,Y.encode(X)),F=U(new Uint8Array(P));return V(F,Q)}function U(z){let M="";for(let J of z)M+=J.toString(16).padStart(2,"0");return M}function V(z,M){if(z.length!==M.length)return!1;let J=0;for(let j=0;j<z.length;j++)J|=z.charCodeAt(j)^M.charCodeAt(j);return J===0}var B="X-Mynth-Event",D="X-Mynth-Signature",N=(z,M)=>{let J=M?.webhookSecret??$();if(!J)throw Error("MYNTH_WEBHOOK_SECRET is required. Either pass it as an option or set the environment variable.");return async(j,L)=>{let Q=L.headers.get(D);if(!Q)return new Response("Unauthorized",{status:401});if(!L.headers.get(B))return new Response("Unauthorized",{status:401});let Y=await L.text();if(!await C(Y,Q,J))return new Response("Unauthorized",{status:401});let P=JSON.parse(Y);switch(P.event){case"task.image.generate.completed":await z.imageTaskCompleted?.(P,{context:j,request:L});break;case"task.image.generate.failed":await z.imageTaskFailed?.(P,{context:j,request:L});break;case"task.image.rate.completed":await z.imageRateTaskCompleted?.(P,{context:j,request:L});break;case"task.image.rate.failed":await z.imageRateTaskFailed?.(P,{context:j,request:L});break;case"task.image.alt.completed":await z.imageAltTaskCompleted?.(P,{context:j,request:L});break;case"task.image.alt.failed":await z.imageAltTaskFailed?.(P,{context:j,request:L});break;default:return new Response("Unauthorized",{status:401})}return new Response(void 0,{status:200})}};export{N as mynthWebhookAction};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { MynthSDKTypes } from "./types";
|
|
2
|
+
/** A successfully generated image alt text item */
|
|
3
|
+
type ImageAltResultItemSuccess = {
|
|
4
|
+
status: "success";
|
|
5
|
+
url: string;
|
|
6
|
+
alt: string;
|
|
7
|
+
};
|
|
8
|
+
type ImageAltResultItemError = {
|
|
9
|
+
status: "failed";
|
|
10
|
+
url: string;
|
|
11
|
+
error: {
|
|
12
|
+
code: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
/** Individual alt text result - success or error */
|
|
16
|
+
export type ImageAltResultItem = ImageAltResultItemSuccess | ImageAltResultItemError;
|
|
17
|
+
/**
|
|
18
|
+
* Represents the result of a completed image alt text task.
|
|
19
|
+
*/
|
|
20
|
+
export declare class ImageAltResult {
|
|
21
|
+
/** The task ID created for this alt text request */
|
|
22
|
+
readonly taskId: string;
|
|
23
|
+
/** Task metadata returned by the API */
|
|
24
|
+
readonly task: MynthSDKTypes.ImageAltResponse["task"];
|
|
25
|
+
/** Raw results array from the API */
|
|
26
|
+
readonly results: ImageAltResultItem[];
|
|
27
|
+
constructor(data: MynthSDKTypes.ImageAltResponse);
|
|
28
|
+
static fromTaskData(data: MynthSDKTypes.ImageAltTaskData): ImageAltResult;
|
|
29
|
+
/**
|
|
30
|
+
* Get only the successfully generated alt text items.
|
|
31
|
+
*/
|
|
32
|
+
getAltTexts(): ImageAltResultItemSuccess[];
|
|
33
|
+
/**
|
|
34
|
+
* Get only the images that failed to get alt text.
|
|
35
|
+
*/
|
|
36
|
+
getErrors(): ImageAltResultItemError[];
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=image-alt-result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-alt-result.d.ts","sourceRoot":"","sources":["../src/image-alt-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,mDAAmD;AACnD,KAAK,yBAAyB,GAAG;IAC/B,MAAM,EAAE,SAAS,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,MAAM,EAAE,QAAQ,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH,CAAC;AAEF,oDAAoD;AACpD,MAAM,MAAM,kBAAkB,GAAG,yBAAyB,GAAG,uBAAuB,CAAC;AAErF;;GAEG;AACH,qBAAa,cAAc;IACzB,oDAAoD;IACpD,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,wCAAwC;IACxC,SAAgB,IAAI,EAAE,aAAa,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAE7D,qCAAqC;IACrC,SAAgB,OAAO,EAAE,kBAAkB,EAAE,CAAC;gBAElC,IAAI,EAAE,aAAa,CAAC,gBAAgB;IAMhD,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,aAAa,CAAC,gBAAgB,GAAG,cAAc;IAmBzE;;OAEG;IACH,WAAW,IAAI,yBAAyB,EAAE;IAI1C;;OAEG;IACH,SAAS,IAAI,uBAAuB,EAAE;CAGvC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MynthAPIError } from "./client";
|
|
2
2
|
import type { AvailableModel, ModelCapability } from "./constants";
|
|
3
3
|
import { AVAILABLE_MODELS } from "./constants";
|
|
4
|
+
import { ImageAltResult } from "./image-alt-result";
|
|
4
5
|
import { ImageGenerationResult } from "./image-generation-result";
|
|
5
6
|
import { ImageRateResult } from "./image-rate-result";
|
|
6
7
|
import type { TaskAsyncAccess } from "./task-async";
|
|
@@ -57,7 +58,7 @@ type ExtractRateLevelValues<T extends MynthSDKTypes.ImageRateRequest> = T extend
|
|
|
57
58
|
}[];
|
|
58
59
|
} ? V extends string ? V : string : MynthSDKTypes.ImageResultRatingDefaultLevel;
|
|
59
60
|
/**
|
|
60
|
-
* Client for interacting with the Mynth image generation and
|
|
61
|
+
* Client for interacting with the Mynth image generation, rating, and alt text APIs.
|
|
61
62
|
*
|
|
62
63
|
* @example
|
|
63
64
|
* ```typescript
|
|
@@ -171,6 +172,39 @@ declare class MynthImage {
|
|
|
171
172
|
*/
|
|
172
173
|
rateAsync<const T extends MynthSDKTypes.ImageRateRequest>(request: T): Promise<TaskAsync<ImageRateResult<ExtractRateLevelValues<T>>>>;
|
|
173
174
|
private createRateTask;
|
|
175
|
+
/**
|
|
176
|
+
* Generate alt text for one or more images.
|
|
177
|
+
*
|
|
178
|
+
* Uses AI image analysis to produce short alt text for each image URL.
|
|
179
|
+
*
|
|
180
|
+
* @param request - URLs to generate alt text for
|
|
181
|
+
* @returns An ImageAltResult with per-image alt text
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```typescript
|
|
185
|
+
* const result = await image.alt({ urls: ["https://..."] });
|
|
186
|
+
* console.log(result.getAltTexts()); // [{ status: "success", url: "...", alt: "..." }]
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
alt(request: MynthSDKTypes.ImageAltRequest): Promise<ImageAltResult>;
|
|
190
|
+
/**
|
|
191
|
+
* Start image alt text generation without waiting for completion.
|
|
192
|
+
*
|
|
193
|
+
* @param request - URLs to generate alt text for
|
|
194
|
+
* @returns A TaskAsync that can be polled for completion via `.wait()`
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* const taskAsync = await image.altAsync({
|
|
199
|
+
* urls: ["https://..."],
|
|
200
|
+
* });
|
|
201
|
+
*
|
|
202
|
+
* const result = await taskAsync.wait();
|
|
203
|
+
* console.log(result.getAltTexts());
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
altAsync(request: MynthSDKTypes.ImageAltRequest): Promise<TaskAsync<ImageAltResult>>;
|
|
207
|
+
private createAltTask;
|
|
174
208
|
}
|
|
175
209
|
/**
|
|
176
210
|
* Client for interacting with the public Mynth model catalog.
|
|
@@ -225,10 +259,10 @@ declare class Mynth {
|
|
|
225
259
|
* @param options.baseUrl - Custom API base URL
|
|
226
260
|
*/
|
|
227
261
|
constructor(options?: MynthOptions);
|
|
228
|
-
/** Image generation and
|
|
262
|
+
/** Image generation, rating, and alt text client */
|
|
229
263
|
get image(): MynthImage;
|
|
230
264
|
}
|
|
231
|
-
export { AVAILABLE_MODELS, ImageGenerationResult, ImageRateResult, Mynth, MynthImage, MynthModels, TaskAsync, MynthAPIError, TaskAsyncFetchError, TaskAsyncTaskFailedError, TaskAsyncTaskFetchError, TaskAsyncTimeoutError, TaskAsyncUnauthorizedError, };
|
|
265
|
+
export { AVAILABLE_MODELS, ImageAltResult, ImageGenerationResult, ImageRateResult, Mynth, MynthImage, MynthModels, TaskAsync, MynthAPIError, TaskAsyncFetchError, TaskAsyncTaskFailedError, TaskAsyncTaskFetchError, TaskAsyncTimeoutError, TaskAsyncUnauthorizedError, };
|
|
232
266
|
export type { AvailableModel, ModelCapability, MynthModel, MynthModelPricing, MynthOptions, MynthSDKTypes, TaskAsyncAccess, };
|
|
233
267
|
export default Mynth;
|
|
234
268
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAe,MAAM,UAAU,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAe,MAAM,UAAU,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAGL,gBAAgB,EAKjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;GAEG;AACH,KAAK,YAAY,GAAG;IAClB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,OAAO,CAAC,E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AAED,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,eAAe,EACf,KAAK,EACL,UAAU,EACV,WAAW,EACX,SAAS,EAET,aAAa,EACb,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,GAC3B,CAAC;AACF,YAAY,EACV,cAAc,EACd,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,eAAe,GAChB,CAAC;AACF,eAAe,KAAK,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var v="https://api.mynth.io",w="MYNTH_API_KEY",K="MYNTH_DESTINATION",G="/image/generate",O="/image/rate",U="/models";var q=(J)=>`/tasks/${J}`;var F=(J)=>`/tasks/${J}/status`,k=[{id:"auto",label:"Auto",capabilities:[]},{id:"alibaba/qwen-image-2.0",label:"Qwen Image 2.0",capabilities:["inputs","native_enhance_prompt"]},{id:"alibaba/qwen-image-2.0-pro",label:"Qwen Image 2.0 Pro",capabilities:["inputs","native_enhance_prompt"]},{id:"bytedance/seedream-5.0-lite",label:"Seedream 5.0 Lite",capabilities:["inputs"]},{id:"black-forest-labs/flux.1-dev",label:"FLUX.1 Dev",capabilities:[]},{id:"black-forest-labs/flux-1-schnell",label:"FLUX.1 Schnell",capabilities:[]},{id:"tongyi-mai/z-image",label:"Z Image",capabilities:["inputs"]},{id:"tongyi-mai/z-image-turbo",label:"Z Image Turbo",capabilities:[]},{id:"black-forest-labs/flux.2-dev",label:"FLUX.2 Dev",capabilities:["inputs"]},{id:"black-forest-labs/flux.2-pro",label:"FLUX.2 Pro",capabilities:["inputs"]},{id:"black-forest-labs/flux.2-flex",label:"FLUX.2 Flex",capabilities:["inputs"]},{id:"black-forest-labs/flux.2-max",label:"FLUX.2 Max",capabilities:["inputs"]},{id:"black-forest-labs/flux.2-klein-4b",label:"FLUX.2 Klein 4B",capabilities:["inputs"]},{id:"black-forest-labs/flux-virtual-try-on",label:"FLUX Virtual Try-On",capabilities:["inputs"]},{id:"john6666/bismuth-illustrious-mix",label:"Bismuth Illustrious Mix",capabilities:["negative_prompt"]},{id:"klingai/kling-image-3.0",label:"Kling IMAGE 3.0",capabilities:["inputs"]},{id:"klingai/kling-image-o3",label:"Kling IMAGE O3",capabilities:["inputs","4k"]},{id:"krea/krea-2-turbo",label:"Krea 2 Turbo",capabilities:["inputs"]},{id:"krea/krea-2-medium",label:"Krea 2 Medium",capabilities:["inputs"]},{id:"krea/krea-2-large",label:"Krea 2 Large",capabilities:["inputs"]},{id:"luma/uni-1",label:"Luma UNI-1",capabilities:["inputs"]},{id:"luma/uni-1-max",label:"Luma UNI-1 Max",capabilities:["inputs"]},{id:"purplesmartai/pony-diffusion-v6-xl",label:"Pony Diffusion V6 XL",capabilities:["negative_prompt"]},{id:"recraft/recraft-v4",label:"Recraft V4",capabilities:[]},{id:"recraft/recraft-v4-pro",label:"Recraft V4 Pro",capabilities:[]},{id:"sourceful/riverflow-2.0-pro",label:"Riverflow 2.0 Pro",capabilities:["inputs","4k","native_enhance_prompt"]},{id:"google/gemini-3.1-flash-lite-image",label:"Nano Banana 2 Lite",capabilities:["inputs","native_enhance_prompt"]},{id:"google/gemini-3.1-flash-image",label:"Nano Banana 2",capabilities:["inputs","4k","native_enhance_prompt"]},{id:"google/gemini-3-pro-image-preview",label:"Nano Banana Pro",capabilities:["inputs","4k","native_enhance_prompt"]},{id:"imagineart/imagineart-1.5-pro",label:"ImagineArt 1.5 Pro",capabilities:["4k"]},{id:"imagineart/imagineart-2.0",label:"ImagineArt 2.0",capabilities:["inputs"]},{id:"openai/gpt-image-2",label:"GPT Image 2",capabilities:["inputs"]},{id:"prunaai/p-image-try-on",label:"P-Image Try-On",capabilities:["inputs"]},{id:"wan/wan2.6-image",label:"Wan 2.6 Image",capabilities:[]},{id:"wan/wan2.7-image",label:"Wan 2.7 Image",capabilities:["inputs"]},{id:"wan/wan2.7-image-pro",label:"Wan 2.7 Image Pro",capabilities:["inputs","4k"]},{id:"xai/grok-imagine-image",label:"Grok Imagine Image",capabilities:["inputs"]},{id:"xai/grok-imagine-image-quality",label:"Grok Imagine Image Quality",capabilities:["inputs"]}];class f extends Error{status;code;constructor(J,Q,Z){super(J);this.name="MynthAPIError",this.status=Q,this.code=Z}}function N(J,Q){let Z=J,$=Z.error||Z.message||`Request failed with status ${Q}`;return new f($,Q,Z.code)}class X{apiKey;baseUrl;constructor(J){this.apiKey=J.apiKey,this.baseUrl=J.baseUrl?J.baseUrl.endsWith("/")?J.baseUrl.slice(0,-1):J.baseUrl:v}getAuthHeaders(J){if(J?.auth===!1)return{};let Q=J?.accessToken??this.apiKey;return Q?{Authorization:`Bearer ${Q}`}:{}}getUrl(J){return`${this.baseUrl}${J}`}async post(J,Q){let Z=await fetch(this.getUrl(J),{method:"POST",headers:{"Content-Type":"application/json",...this.getAuthHeaders()},body:JSON.stringify(Q)}),$=await Z.json();if(!Z.ok)throw N($,Z.status);return $}async get(J,{headers:Q,accessToken:Z,auth:$}={}){let x=await fetch(this.getUrl(J),{headers:{...this.getAuthHeaders({accessToken:Z,auth:$}),...Q}});return{data:await x.json(),status:x.status,ok:x.ok}}async getOrThrow(J,Q={}){let Z=await this.get(J,Q);if(!Z.ok)throw N(Z.data,Z.status);return Z.data}}class H{data;constructor(J){this.data=J}get id(){return this.data.id}get status(){return this.data.status}get result(){return this.data.result}get isCompleted(){return this.data.status==="completed"}get isFailed(){return this.data.status==="failed"}get urls(){return this.data.result?.images.filter((J)=>J.status==="success").map((J)=>J.url).filter((J)=>J!==null)??[]}getImages(J={}){if(J.includeFailed)return this.data.result?.images??[];return this.data.result?.images.filter((Q)=>Q.status==="success")??[]}getMetadata(){return this.data.request?.metadata}}class j{taskId;task;results;constructor(J){this.task=J.task,this.taskId=J.task.id,this.results=J.results}static fromTaskData(J){if(J.status!=="completed"||J.result===null)throw Error(`Image rate task ${J.id} is not completed`);if(J.cost===null)throw Error(`Image rate task ${J.id} is missing cost`);return new j({task:{id:J.id,status:"completed",cost:J.cost},results:J.result.results})}getRatings(){return this.results.filter((J)=>J.status==="success")}getErrors(){return this.results.filter((J)=>J.status==="failed")}}var z=300000,E=12000,h=2500,y=5000,c=7;class C extends Error{constructor(J){super(`Task ${J} polling timed out after ${z}ms`);this.name="TaskAsyncTimeoutError"}}class W extends Error{constructor(J){super(`Unauthorized access to task ${J}`);this.name="TaskAsyncUnauthorizedError"}}class D extends Error{constructor(J,Q){super(`Failed to fetch status for task ${J} after multiple retries`);this.name="TaskAsyncFetchError",this.cause=Q}}class b extends Error{constructor(J,Q){let Z=Q?` (status ${Q})`:"";super(`Failed to fetch task ${J}${Z}`);this.name="TaskAsyncTaskFetchError"}}class V extends Error{constructor(J){super(`Task ${J} failed`);this.name="TaskAsyncTaskFailedError"}}class Y{id;client;_access;resultFactory;_completionPromise=null;constructor(J,Q){this.id=J,this.client=Q.client,this._access={publicAccessToken:Q.pat},this.resultFactory=Q.resultFactory}get access(){return this._access}toString(){return this.id}async wait(){if(!this._completionPromise)this._completionPromise=this.pollUntilCompleted();return this._completionPromise}async pollUntilCompleted(){let J=Date.now(),Q=0,Z=!1,$;while(!0){let x=Date.now()-J;if(x>=z)throw new C(this.id);let B=await this.fetchStatus(Z);if(B.ok){if(Q=0,B.status==="completed"){let I=await this.fetchTask();return this.resultFactory(I)}if(B.status==="failed")throw new V(this.id)}else{if(B.unauthorized){if(this._access.publicAccessToken&&!Z){Z=!0;continue}throw new W(this.id)}if(B.retryable){if(Q++,$=B.error,Q>=c)throw new D(this.id,$)}}let R=x<E?h:y,g=Math.random()*500,_=R+g,M=z-x,m=Math.min(_,M);await this.sleep(m)}}async fetchStatus(J){let Q=J||!this._access.publicAccessToken?void 0:this._access.publicAccessToken;try{let Z=await this.client.get(F(this.id),{accessToken:Q});if(Z.ok)return{ok:!0,status:Z.data.data.status};if(Z.status===401||Z.status===403)return{ok:!1,unauthorized:!0,retryable:!1};if(Z.status===404)return{ok:!1,unauthorized:!0,retryable:!1};if(Z.status>=500)return{ok:!1,unauthorized:!1,retryable:!0};return{ok:!1,unauthorized:!1,retryable:!1}}catch(Z){return{ok:!1,unauthorized:!1,retryable:!0,error:Z instanceof Error?Z:Error(String(Z))}}}async fetchTask(){let J=await this.client.get(q(this.id));if(J.ok)return J.data.data;if(J.status===401||J.status===403)throw new W(this.id);if(J.status===404)throw new W(this.id);throw new b(this.id,J.status)}sleep(J){return new Promise((Q)=>setTimeout(Q,J))}}function l(){if(typeof process<"u"&&process.env)return process.env[w];return}function A(){if(typeof process<"u"&&process.env)return process.env[K];return}class S{client;defaultDestination;constructor(J={}){let Q=J.apiKey??l();if(!Q)throw Error(`Mynth API key is required. Either pass it as an option or set the ${w} environment variable.`);this.defaultDestination=J.destination??A(),this.client=new X({apiKey:Q,baseUrl:J.baseUrl})}async generate(J){return(await this.createGenerationTask(J)).wait()}async generateAsync(J){return this.createGenerationTask(J)}async createGenerationTask(J){let Z=(await this.client.post(G,{...J,destination:J.destination??this.defaultDestination})).data;return new Y(Z.taskId,{client:this.client,pat:Z.access?.publicAccessToken,resultFactory:(x)=>new H(x)})}async rate(J){return(await this.createRateTask(J)).wait()}async rateAsync(J){return this.createRateTask(J)}async createRateTask(J){let Z=(await this.client.post(O,{...J,sync:!1})).data;return new Y(Z.task.id,{client:this.client,resultFactory:(x)=>j.fromTaskData(x)})}}class P{client;constructor(J={}){this.client=new X({baseUrl:J.baseUrl})}async list(){return(await this.client.getOrThrow(U,{auth:!1})).data}}class L{models;options;imageClient;constructor(J={}){this.options=J,this.models=new P({baseUrl:J.baseUrl})}get image(){return this.imageClient??=new S(this.options),this.imageClient}}var ZJ=L;export{ZJ as default,W as TaskAsyncUnauthorizedError,C as TaskAsyncTimeoutError,b as TaskAsyncTaskFetchError,V as TaskAsyncTaskFailedError,D as TaskAsyncFetchError,Y as TaskAsync,P as MynthModels,S as MynthImage,f as MynthAPIError,L as Mynth,j as ImageRateResult,H as ImageGenerationResult,k as AVAILABLE_MODELS};
|
|
2
|
+
var K="https://api.mynth.io",f="MYNTH_API_KEY",G="MYNTH_DESTINATION",O="/image/generate",U="/image/rate",F="/image/alt",N="/models";var S=(J)=>`/tasks/${J}`;var P=(J)=>`/tasks/${J}/status`,h=[{id:"auto",label:"Auto",capabilities:[]},{id:"alibaba/qwen-image-2.0",label:"Qwen Image 2.0",capabilities:["inputs","native_enhance_prompt"]},{id:"alibaba/qwen-image-2.0-pro",label:"Qwen Image 2.0 Pro",capabilities:["inputs","native_enhance_prompt"]},{id:"bytedance/seedream-5.0-lite",label:"Seedream 5.0 Lite",capabilities:["inputs"]},{id:"black-forest-labs/flux.1-dev",label:"FLUX.1 Dev",capabilities:[]},{id:"black-forest-labs/flux-1-schnell",label:"FLUX.1 Schnell",capabilities:[]},{id:"tongyi-mai/z-image",label:"Z Image",capabilities:["inputs"]},{id:"tongyi-mai/z-image-turbo",label:"Z Image Turbo",capabilities:[]},{id:"black-forest-labs/flux.2-dev",label:"FLUX.2 Dev",capabilities:["inputs"]},{id:"black-forest-labs/flux.2-pro",label:"FLUX.2 Pro",capabilities:["inputs"]},{id:"black-forest-labs/flux.2-flex",label:"FLUX.2 Flex",capabilities:["inputs"]},{id:"black-forest-labs/flux.2-max",label:"FLUX.2 Max",capabilities:["inputs"]},{id:"black-forest-labs/flux.2-klein-4b",label:"FLUX.2 Klein 4B",capabilities:["inputs"]},{id:"black-forest-labs/flux-virtual-try-on",label:"FLUX Virtual Try-On",capabilities:["inputs"]},{id:"ideogram/remove-background",label:"Ideogram Remove Background",capabilities:["inputs"]},{id:"john6666/bismuth-illustrious-mix",label:"Bismuth Illustrious Mix",capabilities:["negative_prompt"]},{id:"klingai/kling-image-3.0",label:"Kling IMAGE 3.0",capabilities:["inputs"]},{id:"klingai/kling-image-o3",label:"Kling IMAGE O3",capabilities:["inputs","4k"]},{id:"krea/krea-2-turbo",label:"Krea 2 Turbo",capabilities:["inputs"]},{id:"krea/krea-2-medium",label:"Krea 2 Medium",capabilities:["inputs"]},{id:"krea/krea-2-large",label:"Krea 2 Large",capabilities:["inputs"]},{id:"luma/uni-1",label:"Luma UNI-1",capabilities:["inputs"]},{id:"luma/uni-1-max",label:"Luma UNI-1 Max",capabilities:["inputs"]},{id:"purplesmartai/pony-diffusion-v6-xl",label:"Pony Diffusion V6 XL",capabilities:["negative_prompt"]},{id:"recraft/recraft-v4",label:"Recraft V4",capabilities:[]},{id:"recraft/recraft-v4-pro",label:"Recraft V4 Pro",capabilities:[]},{id:"sourceful/riverflow-2.0-pro",label:"Riverflow 2.0 Pro",capabilities:["inputs","4k","native_enhance_prompt"]},{id:"google/gemini-3.1-flash-lite-image",label:"Nano Banana 2 Lite",capabilities:["inputs","native_enhance_prompt"]},{id:"google/gemini-3.1-flash-image",label:"Nano Banana 2",capabilities:["inputs","4k","native_enhance_prompt"]},{id:"google/gemini-3-pro-image-preview",label:"Nano Banana Pro",capabilities:["inputs","4k","native_enhance_prompt"]},{id:"imagineart/imagineart-1.5-pro",label:"ImagineArt 1.5 Pro",capabilities:["4k"]},{id:"imagineart/imagineart-2.0",label:"ImagineArt 2.0",capabilities:["inputs"]},{id:"openai/gpt-image-2",label:"GPT Image 2",capabilities:["inputs"]},{id:"prunaai/p-image-try-on",label:"P-Image Try-On",capabilities:["inputs"]},{id:"wan/wan2.6-image",label:"Wan 2.6 Image",capabilities:[]},{id:"wan/wan2.7-image",label:"Wan 2.7 Image",capabilities:["inputs"]},{id:"wan/wan2.7-image-pro",label:"Wan 2.7 Image Pro",capabilities:["inputs","4k"]},{id:"xai/grok-imagine-image",label:"Grok Imagine Image",capabilities:["inputs"]},{id:"xai/grok-imagine-image-quality",label:"Grok Imagine Image Quality",capabilities:["inputs"]}];class z extends Error{status;code;constructor(J,Q,Z){super(J);this.name="MynthAPIError",this.status=Q,this.code=Z}}function q(J,Q){let Z=J,B=Z.error||Z.message||`Request failed with status ${Q}`;return new z(B,Q,Z.code)}class x{apiKey;baseUrl;constructor(J){this.apiKey=J.apiKey,this.baseUrl=J.baseUrl?J.baseUrl.endsWith("/")?J.baseUrl.slice(0,-1):J.baseUrl:K}getAuthHeaders(J){if(J?.auth===!1)return{};let Q=J?.accessToken??this.apiKey;return Q?{Authorization:`Bearer ${Q}`}:{}}getUrl(J){return`${this.baseUrl}${J}`}async post(J,Q){let Z=await fetch(this.getUrl(J),{method:"POST",headers:{"Content-Type":"application/json",...this.getAuthHeaders()},body:JSON.stringify(Q)}),B=await Z.json();if(!Z.ok)throw q(B,Z.status);return B}async get(J,{headers:Q,accessToken:Z,auth:B}={}){let $=await fetch(this.getUrl(J),{headers:{...this.getAuthHeaders({accessToken:Z,auth:B}),...Q}});return{data:await $.json(),status:$.status,ok:$.ok}}async getOrThrow(J,Q={}){let Z=await this.get(J,Q);if(!Z.ok)throw q(Z.data,Z.status);return Z.data}}class Y{taskId;task;results;constructor(J){this.task=J.task,this.taskId=J.task.id,this.results=J.results}static fromTaskData(J){if(J.status!=="completed"||J.result===null)throw Error(`Image alt task ${J.id} is not completed`);if(J.cost===null)throw Error(`Image alt task ${J.id} is missing cost`);return new Y({task:{id:J.id,status:"completed",cost:J.cost},results:J.result.results})}getAltTexts(){return this.results.filter((J)=>J.status==="success")}getErrors(){return this.results.filter((J)=>J.status==="failed")}}class H{data;constructor(J){this.data=J}get id(){return this.data.id}get status(){return this.data.status}get result(){return this.data.result}get isCompleted(){return this.data.status==="completed"}get isFailed(){return this.data.status==="failed"}get urls(){return this.data.result?.images.filter((J)=>J.status==="success").map((J)=>J.url).filter((J)=>J!==null)??[]}getImages(J={}){if(J.includeFailed)return this.data.result?.images??[];return this.data.result?.images.filter((Q)=>Q.status==="success")??[]}getMetadata(){return this.data.request?.metadata}}class w{taskId;task;results;constructor(J){this.task=J.task,this.taskId=J.task.id,this.results=J.results}static fromTaskData(J){if(J.status!=="completed"||J.result===null)throw Error(`Image rate task ${J.id} is not completed`);if(J.cost===null)throw Error(`Image rate task ${J.id} is missing cost`);return new w({task:{id:J.id,status:"completed",cost:J.cost},results:J.result.results})}getRatings(){return this.results.filter((J)=>J.status==="success")}getErrors(){return this.results.filter((J)=>J.status==="failed")}}var C=300000,y=12000,c=2500,T=5000,A=7;class D extends Error{constructor(J){super(`Task ${J} polling timed out after ${C}ms`);this.name="TaskAsyncTimeoutError"}}class X extends Error{constructor(J){super(`Unauthorized access to task ${J}`);this.name="TaskAsyncUnauthorizedError"}}class b extends Error{constructor(J,Q){super(`Failed to fetch status for task ${J} after multiple retries`);this.name="TaskAsyncFetchError",this.cause=Q}}class V extends Error{constructor(J,Q){let Z=Q?` (status ${Q})`:"";super(`Failed to fetch task ${J}${Z}`);this.name="TaskAsyncTaskFetchError"}}class v extends Error{constructor(J){super(`Task ${J} failed`);this.name="TaskAsyncTaskFailedError"}}class j{id;client;_access;resultFactory;_completionPromise=null;constructor(J,Q){this.id=J,this.client=Q.client,this._access={publicAccessToken:Q.pat},this.resultFactory=Q.resultFactory}get access(){return this._access}toString(){return this.id}async wait(){if(!this._completionPromise)this._completionPromise=this.pollUntilCompleted();return this._completionPromise}async pollUntilCompleted(){let J=Date.now(),Q=0,Z=!1,B;while(!0){let $=Date.now()-J;if($>=C)throw new D(this.id);let W=await this.fetchStatus(Z);if(W.ok){if(Q=0,W.status==="completed"){let I=await this.fetchTask();return this.resultFactory(I)}if(W.status==="failed")throw new v(this.id)}else{if(W.unauthorized){if(this._access.publicAccessToken&&!Z){Z=!0;continue}throw new X(this.id)}if(W.retryable){if(Q++,B=W.error,Q>=A)throw new b(this.id,B)}}let _=$<y?c:T,g=Math.random()*500,m=_+g,k=C-$,E=Math.min(m,k);await this.sleep(E)}}async fetchStatus(J){let Q=J||!this._access.publicAccessToken?void 0:this._access.publicAccessToken;try{let Z=await this.client.get(P(this.id),{accessToken:Q});if(Z.ok)return{ok:!0,status:Z.data.data.status};if(Z.status===401||Z.status===403)return{ok:!1,unauthorized:!0,retryable:!1};if(Z.status===404)return{ok:!1,unauthorized:!0,retryable:!1};if(Z.status>=500)return{ok:!1,unauthorized:!1,retryable:!0};return{ok:!1,unauthorized:!1,retryable:!1}}catch(Z){return{ok:!1,unauthorized:!1,retryable:!0,error:Z instanceof Error?Z:Error(String(Z))}}}async fetchTask(){let J=await this.client.get(S(this.id));if(J.ok)return J.data.data;if(J.status===401||J.status===403)throw new X(this.id);if(J.status===404)throw new X(this.id);throw new V(this.id,J.status)}sleep(J){return new Promise((Q)=>setTimeout(Q,J))}}function l(){if(typeof process<"u"&&process.env)return process.env[f];return}function u(){if(typeof process<"u"&&process.env)return process.env[G];return}class L{client;defaultDestination;constructor(J={}){let Q=J.apiKey??l();if(!Q)throw Error(`Mynth API key is required. Either pass it as an option or set the ${f} environment variable.`);this.defaultDestination=J.destination??u(),this.client=new x({apiKey:Q,baseUrl:J.baseUrl})}async generate(J){return(await this.createGenerationTask(J)).wait()}async generateAsync(J){return this.createGenerationTask(J)}async createGenerationTask(J){let Z=(await this.client.post(O,{...J,destination:J.destination??this.defaultDestination})).data;return new j(Z.taskId,{client:this.client,pat:Z.access?.publicAccessToken,resultFactory:($)=>new H($)})}async rate(J){return(await this.createRateTask(J)).wait()}async rateAsync(J){return this.createRateTask(J)}async createRateTask(J){let Z=(await this.client.post(U,{...J,sync:!1})).data;return new j(Z.task.id,{client:this.client,resultFactory:($)=>w.fromTaskData($)})}async alt(J){return(await this.createAltTask(J)).wait()}async altAsync(J){return this.createAltTask(J)}async createAltTask(J){let Z=(await this.client.post(F,{...J,sync:!1})).data;return new j(Z.task.id,{client:this.client,resultFactory:($)=>Y.fromTaskData($)})}}class R{client;constructor(J={}){this.client=new x({baseUrl:J.baseUrl})}async list(){return(await this.client.getOrThrow(N,{auth:!1})).data}}class M{models;options;imageClient;constructor(J={}){this.options=J,this.models=new R({baseUrl:J.baseUrl})}get image(){return this.imageClient??=new L(this.options),this.imageClient}}var XJ=M;export{XJ as default,X as TaskAsyncUnauthorizedError,D as TaskAsyncTimeoutError,V as TaskAsyncTaskFetchError,v as TaskAsyncTaskFailedError,b as TaskAsyncFetchError,j as TaskAsync,R as MynthModels,L as MynthImage,z as MynthAPIError,M as Mynth,w as ImageRateResult,H as ImageGenerationResult,Y as ImageAltResult,h as AVAILABLE_MODELS};
|
package/dist/types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare namespace MynthSDKTypes {
|
|
|
7
7
|
data: DataT;
|
|
8
8
|
};
|
|
9
9
|
type TaskStatus = "pending" | "completed" | "failed";
|
|
10
|
-
type TaskType = "image.generate" | "image.rate";
|
|
10
|
+
type TaskType = "image.generate" | "image.rate" | "image.alt";
|
|
11
11
|
type TaskBase = {
|
|
12
12
|
id: string;
|
|
13
13
|
status: TaskStatus;
|
|
@@ -29,6 +29,10 @@ export declare namespace MynthSDKTypes {
|
|
|
29
29
|
type: "image.rate";
|
|
30
30
|
request: ImageRateRequest;
|
|
31
31
|
result: ImageRateTaskResult | null;
|
|
32
|
+
}) | (TaskBase & {
|
|
33
|
+
type: "image.alt";
|
|
34
|
+
request: ImageAltRequest;
|
|
35
|
+
result: ImageAltTaskResult | null;
|
|
32
36
|
});
|
|
33
37
|
type ImageGenerationTaskData = Extract<TaskData, {
|
|
34
38
|
type: "image.generate";
|
|
@@ -36,6 +40,9 @@ export declare namespace MynthSDKTypes {
|
|
|
36
40
|
type ImageRateTaskData = Extract<TaskData, {
|
|
37
41
|
type: "image.rate";
|
|
38
42
|
}>;
|
|
43
|
+
type ImageAltTaskData = Extract<TaskData, {
|
|
44
|
+
type: "image.alt";
|
|
45
|
+
}>;
|
|
39
46
|
type ModelPricing = {
|
|
40
47
|
perImage: {
|
|
41
48
|
base: string;
|
|
@@ -49,7 +56,7 @@ export declare namespace MynthSDKTypes {
|
|
|
49
56
|
pricing: ModelPricing | null;
|
|
50
57
|
};
|
|
51
58
|
type ModelsListResponse = ApiResponse<Model[]>;
|
|
52
|
-
type ImageGenerationModelId = "alibaba/qwen-image-2.0" | "alibaba/qwen-image-2.0-pro" | "bytedance/seedream-5.0-lite" | "black-forest-labs/flux.1-dev" | "black-forest-labs/flux-1-schnell" | "black-forest-labs/flux.2-dev" | "black-forest-labs/flux.2-pro" | "black-forest-labs/flux.2-flex" | "black-forest-labs/flux.2-max" | "black-forest-labs/flux.2-klein-4b" | "black-forest-labs/flux-virtual-try-on" | "google/gemini-3.1-flash-lite-image" | "google/gemini-3.1-flash-image" | "google/gemini-3-pro-image-preview" | "imagineart/imagineart-1.5-pro" | "imagineart/imagineart-2.0" | "klingai/kling-image-3.0" | "klingai/kling-image-o3" | "krea/krea-2-turbo" | "krea/krea-2-medium" | "krea/krea-2-large" | "luma/uni-1" | "luma/uni-1-max" | "openai/gpt-image-2" | "prunaai/p-image-try-on" | "tongyi-mai/z-image" | "tongyi-mai/z-image-turbo" | "john6666/bismuth-illustrious-mix" | "purplesmartai/pony-diffusion-v6-xl" | "recraft/recraft-v4" | "recraft/recraft-v4-pro" | "sourceful/riverflow-2.0-pro" | "wan/wan2.6-image" | "wan/wan2.7-image" | "wan/wan2.7-image-pro" | "xai/grok-imagine-image" | "xai/grok-imagine-image-quality";
|
|
59
|
+
type ImageGenerationModelId = "alibaba/qwen-image-2.0" | "alibaba/qwen-image-2.0-pro" | "bytedance/seedream-5.0-lite" | "black-forest-labs/flux.1-dev" | "black-forest-labs/flux-1-schnell" | "black-forest-labs/flux.2-dev" | "black-forest-labs/flux.2-pro" | "black-forest-labs/flux.2-flex" | "black-forest-labs/flux.2-max" | "black-forest-labs/flux.2-klein-4b" | "black-forest-labs/flux-virtual-try-on" | "google/gemini-3.1-flash-lite-image" | "google/gemini-3.1-flash-image" | "google/gemini-3-pro-image-preview" | "ideogram/remove-background" | "imagineart/imagineart-1.5-pro" | "imagineart/imagineart-2.0" | "klingai/kling-image-3.0" | "klingai/kling-image-o3" | "krea/krea-2-turbo" | "krea/krea-2-medium" | "krea/krea-2-large" | "luma/uni-1" | "luma/uni-1-max" | "openai/gpt-image-2" | "prunaai/p-image-try-on" | "tongyi-mai/z-image" | "tongyi-mai/z-image-turbo" | "john6666/bismuth-illustrious-mix" | "purplesmartai/pony-diffusion-v6-xl" | "recraft/recraft-v4" | "recraft/recraft-v4-pro" | "sourceful/riverflow-2.0-pro" | "wan/wan2.6-image" | "wan/wan2.7-image" | "wan/wan2.7-image-pro" | "xai/grok-imagine-image" | "xai/grok-imagine-image-quality";
|
|
53
60
|
type ImageGenerationModel = ImageGenerationModelId | "auto";
|
|
54
61
|
type GenerateImageOptionsIn = {
|
|
55
62
|
prompt: string;
|
|
@@ -244,6 +251,45 @@ export declare namespace MynthSDKTypes {
|
|
|
244
251
|
type ImageRateTaskResult<LevelT extends string = string> = {
|
|
245
252
|
results: ImageRateResponseItem<LevelT>[];
|
|
246
253
|
};
|
|
254
|
+
/** Request body for the image alt endpoint */
|
|
255
|
+
type ImageAltRequest = {
|
|
256
|
+
/** Image URLs to generate alt text for (1-10) */
|
|
257
|
+
urls: string[];
|
|
258
|
+
};
|
|
259
|
+
/** A successfully generated image alt text item */
|
|
260
|
+
type ImageAltResponseItemSuccess = {
|
|
261
|
+
status: "success";
|
|
262
|
+
url: string;
|
|
263
|
+
alt: string;
|
|
264
|
+
};
|
|
265
|
+
type ImageAltResponseItemError = {
|
|
266
|
+
status: "failed";
|
|
267
|
+
url: string;
|
|
268
|
+
error: {
|
|
269
|
+
code: string;
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
/** Individual alt text result item */
|
|
273
|
+
type ImageAltResponseItem = ImageAltResponseItemSuccess | ImageAltResponseItemError;
|
|
274
|
+
/** API response from the image alt endpoint */
|
|
275
|
+
type ImageAltResponse = {
|
|
276
|
+
task: {
|
|
277
|
+
id: string;
|
|
278
|
+
status: "completed";
|
|
279
|
+
cost: string;
|
|
280
|
+
};
|
|
281
|
+
results: ImageAltResponseItem[];
|
|
282
|
+
};
|
|
283
|
+
/** Pending response from the image alt endpoint when async mode is used */
|
|
284
|
+
type ImageAltPendingResponse = {
|
|
285
|
+
task: {
|
|
286
|
+
id: string;
|
|
287
|
+
status: "pending";
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
type ImageAltTaskResult = {
|
|
291
|
+
results: ImageAltResponseItem[];
|
|
292
|
+
};
|
|
247
293
|
/**
|
|
248
294
|
* Webhook payload for image generation task completion.
|
|
249
295
|
*/
|
|
@@ -286,9 +332,30 @@ export declare namespace MynthSDKTypes {
|
|
|
286
332
|
event: "task.image.rate.failed";
|
|
287
333
|
request: ImageRateRequest;
|
|
288
334
|
};
|
|
335
|
+
/**
|
|
336
|
+
* Webhook payload for image alt text task completion.
|
|
337
|
+
*/
|
|
338
|
+
type WebhookTaskImageAltCompletedPayload = {
|
|
339
|
+
task: {
|
|
340
|
+
id: string;
|
|
341
|
+
};
|
|
342
|
+
event: "task.image.alt.completed";
|
|
343
|
+
result: ImageAltTaskResult;
|
|
344
|
+
request: ImageAltRequest;
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Webhook payload for image alt text task failure.
|
|
348
|
+
*/
|
|
349
|
+
type WebhookTaskImageAltFailedPayload = {
|
|
350
|
+
task: {
|
|
351
|
+
id: string;
|
|
352
|
+
};
|
|
353
|
+
event: "task.image.alt.failed";
|
|
354
|
+
request: ImageAltRequest;
|
|
355
|
+
};
|
|
289
356
|
/**
|
|
290
357
|
* Webhook payload union.
|
|
291
358
|
*/
|
|
292
|
-
type WebhookPayload = WebhookTaskImageCompletedPayload | WebhookTaskImageFailedPayload | WebhookTaskImageRateCompletedPayload | WebhookTaskImageRateFailedPayload;
|
|
359
|
+
type WebhookPayload = WebhookTaskImageCompletedPayload | WebhookTaskImageFailedPayload | WebhookTaskImageRateCompletedPayload | WebhookTaskImageRateFailedPayload | WebhookTaskImageAltCompletedPayload | WebhookTaskImageAltFailedPayload;
|
|
293
360
|
}
|
|
294
361
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GA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