Client
The Mynth constructor options, where the key, base URL, and default destination come from, and the image, video, and models clients.
new Mynth() with no arguments reads MYNTH_API_KEY and sends requests to
https://api.mynth.io. Pass options only when a default is wrong:
import Mynth from "@mynthio/sdk";
const mynth = new Mynth({
apiKey: process.env.MYNTH_API_KEY,
baseUrl: "https://api.mynth.io",
destination: "product-photos",
});| Option | Default | What it does |
|---|---|---|
apiKey | MYNTH_API_KEY | The bearer key. Missing, it throws on first use of image or video |
baseUrl | https://api.mynth.io | A proxy or test host. A trailing slash is removed |
destination | MYNTH_DESTINATION | Default destination name for image generation and background removal |
An option wins over its environment variable, and a destination on a
request wins over both. Video has no destinations, so mynth.video ignores
the option.
The three clients#
| Property | Holds |
|---|---|
mynth.image | Image generation, rating, alt text, review, background removal, upload |
mynth.video | Video generation, estimates, upload |
mynth.models | list(): the public catalog, GET /models, no key needed |
image and video are created the first time you read them, and that is when
a missing key throws:
Mynth API key is required. Either pass it as an option or set the MYNTH_API_KEY environment variable.The throw is a plain Error, not a MynthAPIError.
models.list() returns image and video entries together. Filter on type.
The model field describes each entry.
MynthImage and MynthVideo are also exported for code that needs only one
side. MynthVideo takes apiKey and baseUrl. Types live on
MynthSDKTypes:
import type { MynthSDKTypes } from "@mynthio/sdk";Next steps#
- Generating media:
image.generate()andvideo.generate(). - Tasks and polling: keep the wait out of a request handler.