@mynthio/sdk 0.0.42 → 0.0.44

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 CHANGED
@@ -177,7 +177,6 @@ const task = await mynth.image.generate({
177
177
  count: 2,
178
178
  output: {
179
179
  format: "webp",
180
- quality: 80,
181
180
  },
182
181
  webhook: {
183
182
  dashboard: false,
@@ -214,7 +213,7 @@ const task = await mynth.image.generate({
214
213
 
215
214
  `access.pat.enabled` controls whether the create-task response includes a short-lived Public Access Token for browser-side polling. It defaults to `true`.
216
215
 
217
- `output` is optional. When you provide it, include both `format` and `quality`; when omitted, Mynth defaults to WebP at quality 80.
216
+ `output` is optional. Set `output.format` to `png`, `jpg`, or `webp`. When it is omitted, the result keeps the format the provider delivered.
218
217
 
219
218
  ## Upload Images
220
219
 
@@ -554,6 +553,7 @@ Current model IDs include:
554
553
  - `alibaba/qwen-image-3.0-pro`
555
554
  - `bytedance/seedream-5.0-lite`
556
555
  - `bytedance/seedream-pro`
556
+ - `bytedance/seedream-v5-flash`
557
557
  - `black-forest-labs/flux.1-dev`
558
558
  - `black-forest-labs/flux-1-schnell`
559
559
  - `black-forest-labs/flux.2-dev`
@@ -561,6 +561,7 @@ Current model IDs include:
561
561
  - `black-forest-labs/flux.2-flex`
562
562
  - `black-forest-labs/flux.2-max`
563
563
  - `black-forest-labs/flux.2-klein-4b`
564
+ - `goofy-ai/prefect-pony-xl-lora`
564
565
  - `google/gemini-3.1-flash-lite-image`
565
566
  - `google/gemini-3.1-flash-image`
566
567
  - `google/gemini-3-pro-image-preview`
@@ -577,6 +578,7 @@ Current model IDs include:
577
578
  - `openai/gpt-image-2`
578
579
  - `purplesmartai/pony-diffusion-v6-xl`
579
580
  - `recraft/recraft-v4`
581
+ - `recraft/recraft-v4.1-flash`
580
582
  - `recraft/recraft-v4-pro`
581
583
  - `sourceful/riverflow-2.0-pro`
582
584
  - `tongyi-mai/z-image`
@@ -705,13 +707,14 @@ console.log(model);
705
707
  // }
706
708
  ```
707
709
 
708
- | Model | Resolutions | Duration (s) | Inputs |
709
- | ------------------------------ | --------------- | ---------------- | ----------------------- |
710
- | `bytedance/seedance-2.0-mini` | 480p, 720p | 4–15 (default 5) | first frame, last frame |
711
- | `google/gemini-omni-flash-1.1` | 720p, 1080p, 4k | 3–10 (default 8) | first frame, last frame |
712
- | `prunaai/p-video` | 720p, 1080p | 1–10 (default 5) | first frame |
710
+ | Model | Resolutions | Duration (s) | Inputs |
711
+ | ------------------------------ | ----------------- | ---------------- | ----------------------- |
712
+ | `bytedance/seedance-2.0-mini` | 480p, 720p | 4–15 (default 5) | first frame, last frame |
713
+ | `google/gemini-omni-flash-1.1` | 720p, 1080p, 4k | 3–10 (default 8) | first frame, last frame |
714
+ | `prunaai/p-video` | 720p, 1080p | 1–10 (default 5) | first frame |
715
+ | `xai/grok-imagine-video-1.5` | 480p, 720p, 1080p | 1–15 (default 8) | first frame |
713
716
 
714
- All three support generated audio.
717
+ Each of these supports generated audio.
715
718
 
716
719
  `mynth.models.list()` covers these video models alongside the image catalog.
717
720
 
@@ -871,7 +874,8 @@ try {
871
874
  console.log(task.urls);
872
875
  } catch (error) {
873
876
  if (error instanceof MynthAPIError) {
874
- console.error(error.status, error.code, error.message);
877
+ // `message` says what to fix. On a VALIDATION_ERROR, `issues` lists each invalid field.
878
+ console.error(error.status, error.code, error.message, error.issues);
875
879
  } else if (error instanceof TaskAsyncTimeoutError) {
876
880
  console.error("Task polling timed out");
877
881
  } else if (error instanceof TaskAsyncUnauthorizedError) {
package/dist/index.d.ts CHANGED
@@ -8,8 +8,18 @@ export declare class MynthAPIError extends Error {
8
8
  readonly status: number;
9
9
  /** Error code from the API response, if available */
10
10
  readonly code?: string | undefined;
11
- constructor(message: string, status: number, code?: string);
11
+ /**
12
+ * One entry per invalid field when `code` is `VALIDATION_ERROR` and the
13
+ * request failed its schema. `message` already states all of them.
14
+ */
15
+ readonly issues?: ReadonlyArray<MynthAPIErrorIssue> | undefined;
16
+ constructor(message: string, status: number, code?: string, issues?: ReadonlyArray<MynthAPIErrorIssue>);
12
17
  }
18
+ type MynthAPIErrorIssue = {
19
+ /** Where the problem is, e.g. `["size", "scale"]`. Empty for the body as a whole. */
20
+ path: ReadonlyArray<string | number>;
21
+ message: string;
22
+ };
13
23
  type MynthClientRequestOptions = {
14
24
  headers?: Record<string, string>;
15
25
  accessToken?: string | undefined;
@@ -81,7 +91,7 @@ export declare class ImageGenerationResult<MetadataT = Record<string, unknown> |
81
91
  /** Current status of the task */
82
92
  get status(): MynthSDKTypes.TaskStatus;
83
93
  /**
84
- * The generation result containing images, cost, and model info.
94
+ * The generation result: images, the format each one was delivered in, and the model.
85
95
  * Returns `null` if the task hasn't completed yet.
86
96
  */
87
97
  get result(): TypedImageResult<RatingT> | null;
@@ -787,4 +797,4 @@ declare class Mynth {
787
797
  get video(): MynthVideo;
788
798
  }
789
799
  //#endregion
790
- 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 MynthRequestOptions, type MynthSDKTypes, MynthVideo, type TaskAsyncAccess, type TaskAsyncWaitOptions, type VideoInputRole, type VideoResolutionTier };
800
+ export { AVAILABLE_MODELS, AVAILABLE_VIDEO_MODELS, type AvailableModel, type AvailableVideoModel, type ModelCapability, Mynth, Mynth as default, type MynthAPIErrorIssue, MynthImage, type MynthModel, type MynthModelPricing, MynthModels, type MynthOptions, type MynthRequestOptions, type MynthSDKTypes, MynthVideo, type TaskAsyncAccess, type TaskAsyncWaitOptions, type VideoInputRole, type VideoResolutionTier };
package/dist/index.js CHANGED
@@ -57,6 +57,11 @@ const AVAILABLE_MODELS = [
57
57
  label: "Seedream Pro",
58
58
  capabilities: ["inputs"]
59
59
  },
60
+ {
61
+ id: "bytedance/seedream-v5-flash",
62
+ label: "Seedream 5.0 Flash",
63
+ capabilities: ["inputs"]
64
+ },
60
65
  {
61
66
  id: "black-forest-labs/flux.1-dev",
62
67
  label: "FLUX.1 Dev",
@@ -117,6 +122,11 @@ const AVAILABLE_MODELS = [
117
122
  label: "Anima",
118
123
  capabilities: ["inputs"]
119
124
  },
125
+ {
126
+ id: "goofy-ai/prefect-pony-xl-lora",
127
+ label: "Prefect Pony XL LoRA",
128
+ capabilities: []
129
+ },
120
130
  {
121
131
  id: "john6666/bismuth-illustrious-mix",
122
132
  label: "Bismuth Illustrious Mix",
@@ -192,6 +202,11 @@ const AVAILABLE_MODELS = [
192
202
  label: "Recraft V4",
193
203
  capabilities: []
194
204
  },
205
+ {
206
+ id: "recraft/recraft-v4.1-flash",
207
+ label: "Recraft V4.1 Flash",
208
+ capabilities: []
209
+ },
195
210
  {
196
211
  id: "recraft/recraft-v4-pro",
197
212
  label: "Recraft V4 Pro",
@@ -345,6 +360,24 @@ const AVAILABLE_VIDEO_MODELS = [
345
360
  audio: true,
346
361
  inputs: ["first_frame"],
347
362
  maxInputs: 1
363
+ },
364
+ {
365
+ id: "xai/grok-imagine-video-1.5",
366
+ label: "Grok Imagine Video 1.5",
367
+ resolutions: [
368
+ "480p",
369
+ "720p",
370
+ "1080p"
371
+ ],
372
+ defaultResolution: "480p",
373
+ duration: {
374
+ default: 8,
375
+ min: 1,
376
+ max: 15
377
+ },
378
+ audio: true,
379
+ inputs: ["first_frame"],
380
+ maxInputs: 1
348
381
  }
349
382
  ];
350
383
  //#endregion
@@ -357,16 +390,30 @@ var MynthAPIError = class extends Error {
357
390
  status;
358
391
  /** Error code from the API response, if available */
359
392
  code;
360
- constructor(message, status, code) {
393
+ /**
394
+ * One entry per invalid field when `code` is `VALIDATION_ERROR` and the
395
+ * request failed its schema. `message` already states all of them.
396
+ */
397
+ issues;
398
+ constructor(message, status, code, issues) {
361
399
  super(message);
362
400
  this.name = "MynthAPIError";
363
401
  this.status = status;
364
402
  this.code = code;
403
+ this.issues = issues;
365
404
  }
366
405
  };
367
406
  function createApiError(data, status) {
368
- const errorResponse = data;
369
- return new MynthAPIError(errorResponse.error || errorResponse.message || `Request failed with status ${status}`, status, errorResponse.code);
407
+ const errorResponse = typeof data === "object" && data !== null ? data : {};
408
+ return new MynthAPIError(typeof errorResponse.message === "string" && errorResponse.message || typeof errorResponse.error === "string" && errorResponse.error || `Request failed with status ${status}`, status, typeof errorResponse.code === "string" ? errorResponse.code : void 0, Array.isArray(errorResponse.issues) ? errorResponse.issues : void 0);
409
+ }
410
+ /** An error body that is not JSON (a proxy's HTML page, say) still yields an API error. */
411
+ async function readErrorBody(response) {
412
+ try {
413
+ return await response.json();
414
+ } catch {
415
+ return;
416
+ }
370
417
  }
371
418
  /**
372
419
  * Internal HTTP client for making API requests.
@@ -398,9 +445,8 @@ var MynthClient = class {
398
445
  body: isFormData ? data : JSON.stringify(data),
399
446
  ...signal ? { signal } : {}
400
447
  });
401
- const json = await response.json();
402
- if (!response.ok) throw createApiError(json, response.status);
403
- return json;
448
+ if (!response.ok) throw createApiError(await readErrorBody(response), response.status);
449
+ return await response.json();
404
450
  }
405
451
  async get(path, { headers, accessToken, auth, signal } = {}) {
406
452
  const response = await fetch(this.getUrl(path), {
@@ -475,7 +521,7 @@ var ImageGenerationResult = class {
475
521
  return this.data.status;
476
522
  }
477
523
  /**
478
- * The generation result containing images, cost, and model info.
524
+ * The generation result: images, the format each one was delivered in, and the model.
479
525
  * Returns `null` if the task hasn't completed yet.
480
526
  */
481
527
  get result() {
package/dist/types.d.ts CHANGED
@@ -130,16 +130,18 @@ declare namespace MynthSDKTypes {
130
130
  type VideoGenerationTaskData = Extract<TaskData, {
131
131
  type: "video.generate";
132
132
  }>;
133
- type ModelInputRule = {
133
+ type ImageModelInputKind = "source" | "reference";
134
+ type VideoModelInputKind = "first_frame" | "last_frame" | "reference" | "source";
135
+ type ModelInputRule<Kind extends string = ImageModelInputKind | VideoModelInputKind> = {
134
136
  type: "image";
135
137
  /** Role the input plays. Absent means the rule accepts any image. */
136
- kind?: string;
138
+ kind?: Kind;
137
139
  min?: number;
138
140
  max: number;
139
141
  };
140
- type ModelMode = {
142
+ type ModelMode<Kind extends string = ImageModelInputKind | VideoModelInputKind> = {
141
143
  inputs?: {
142
- rules: ModelInputRule[];
144
+ rules: ModelInputRule<Kind>[];
143
145
  maxTotal?: number;
144
146
  };
145
147
  };
@@ -163,19 +165,19 @@ declare namespace MynthSDKTypes {
163
165
  id: string;
164
166
  displayName: string | null;
165
167
  type: "image";
166
- modes: Partial<Record<"txt->img" | "img->img", ModelMode>>;
168
+ modes: Partial<Record<"txt->img" | "img->img", ModelMode<ImageModelInputKind>>>;
167
169
  pricing: ImageModelPricing | null;
168
170
  };
169
171
  type VideoModel = {
170
172
  id: string;
171
173
  displayName: string | null;
172
174
  type: "video";
173
- modes: Partial<Record<"txt->vid" | "img->vid", ModelMode>>;
175
+ modes: Partial<Record<"txt->vid" | "img->vid", ModelMode<VideoModelInputKind>>>;
174
176
  pricing: VideoModelPricing | null;
175
177
  };
176
178
  type Model = ImageModel | VideoModel;
177
179
  type ModelsListResponse = ApiResponse<Model[]>;
178
- type ImageGenerationModelId = "alibaba/qwen-image-2.0" | "alibaba/qwen-image-2.0-pro" | "alibaba/qwen-image-3.0" | "alibaba/qwen-image-3.0-pro" | "bytedance/seedream-5.0-lite" | "bytedance/seedream-pro" | "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" | "bria/fibo-edit-1.5" | "bria/fibo-generate-1.5" | "circlestone-labs/anima" | "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" | "meta/muse-image" | "microsoft/mai-image-2.6" | "microsoft/mai-image-2.6-flash" | "minimax/h3" | "openai/gpt-image-2" | "openai/gpt-image-2.5-flare" | "openai/gpt-image-2.5-sunburst" | "tongyi-mai/z-image" | "tongyi-mai/z-image-turbo" | "john6666/bismuth-illustrious-mix" | "maxfeifei8/one-obsession" | "purplesmartai/pony-diffusion-v6-xl" | "recraft/recraft-v4" | "recraft/recraft-v4-pro" | "reve/reve" | "reve/reve-remix" | "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-2.0" | "xai/grok-imagine-image-quality";
180
+ type ImageGenerationModelId = "alibaba/qwen-image-2.0" | "alibaba/qwen-image-2.0-pro" | "alibaba/qwen-image-3.0" | "alibaba/qwen-image-3.0-pro" | "bytedance/seedream-5.0-lite" | "bytedance/seedream-pro" | "bytedance/seedream-v5-flash" | "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" | "bria/fibo-edit-1.5" | "bria/fibo-generate-1.5" | "circlestone-labs/anima" | "goofy-ai/prefect-pony-xl-lora" | "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" | "meta/muse-image" | "microsoft/mai-image-2.6" | "microsoft/mai-image-2.6-flash" | "minimax/h3" | "openai/gpt-image-2" | "openai/gpt-image-2.5-flare" | "openai/gpt-image-2.5-sunburst" | "tongyi-mai/z-image" | "tongyi-mai/z-image-turbo" | "john6666/bismuth-illustrious-mix" | "maxfeifei8/one-obsession" | "purplesmartai/pony-diffusion-v6-xl" | "recraft/recraft-v4" | "recraft/recraft-v4.1-flash" | "recraft/recraft-v4-pro" | "reve/reve" | "reve/reve-remix" | "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-2.0" | "xai/grok-imagine-image-quality";
179
181
  type ImageGenerationModel = ImageGenerationModelId | "auto";
180
182
  type GenerateImageOptionsIn = {
181
183
  prompt: string;
@@ -186,9 +188,8 @@ declare namespace MynthSDKTypes {
186
188
  type ImageGenerationRequestPrompt = GenerateImageOptionsIn["prompt"];
187
189
  type ImageGenerationRequestOutputFormat = "png" | "jpg" | "webp";
188
190
  type ImageGenerationRequestOutput = {
189
- format: ImageGenerationRequestOutputFormat;
190
- /** Output quality 1-100. Defaults to 80 when output is omitted. */
191
- quality: number;
191
+ /** Converts the result to this format. When omitted, the provider's format is kept. */
192
+ format?: ImageGenerationRequestOutputFormat;
192
193
  };
193
194
  type ImageGenerationRequestCustomWebhook = {
194
195
  url: string;
@@ -293,7 +294,7 @@ declare namespace MynthSDKTypes {
293
294
  url: string | null;
294
295
  mynth_url: string;
295
296
  size: string;
296
- cost: string;
297
+ format: ImageGenerationRequestOutputFormat;
297
298
  destination?: ImageResultDestination;
298
299
  rating?: ImageResultRating;
299
300
  };
@@ -434,7 +435,7 @@ declare namespace MynthSDKTypes {
434
435
  type ImageRemoveBackgroundTaskResult = {
435
436
  image: ImageRemoveBackgroundResultImage;
436
437
  };
437
- type VideoGenerationModelId = "bytedance/seedance-2.0-mini" | "google/gemini-omni-flash-1.1" | "prunaai/p-video";
438
+ type VideoGenerationModelId = "bytedance/seedance-2.0-mini" | "google/gemini-omni-flash-1.1" | "prunaai/p-video" | "xai/grok-imagine-video-1.5";
438
439
  type VideoGenerationModel = VideoGenerationModelId;
439
440
  type VideoGenerationRequestResolution = "480p" | "720p" | "1080p" | "4k";
440
441
  type VideoGenerationRequestWebhook = ImageGenerationRequestWebhook;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mynthio/sdk",
3
- "version": "0.0.42",
3
+ "version": "0.0.44",
4
4
  "description": "Official Mynth SDK for image generation and analysis",
5
5
  "keywords": [
6
6
  "ai",