Skip to main content
The SDK exposes a single client class: Mynth.

Basic setup

import Mynth from "@mynthio/sdk";

const client = new Mynth();
If you omit apiKey, the SDK reads MYNTH_API_KEY from the environment.

Explicit configuration

import Mynth from "@mynthio/sdk";

const client = new Mynth({
  apiKey: process.env.MYNTH_API_KEY,
  baseUrl: "https://api.mynth.io",
  destination: "my-store",
});

Options

OptionTypeDescription
apiKeystringYour Mynth API key. Optional only when MYNTH_API_KEY is already set.
baseUrlstringOverride the default API base URL. Useful for proxies, tests, or custom deployments.
destinationstringDefault destination slug to deliver generated images to. Optional only when MYNTH_DESTINATION is already set. Overridable per request via request.destination.

Authentication behavior

The client always sends Bearer authentication:
Authorization: Bearer mak_...
The SDK uses your API key for server-to-server requests. For browser-safe task polling, use the task’s publicAccessToken instead of your API key. The same client exposes image generation, rating, and alt text methods:
await client.image.generate({ prompt: "A product photo" });
await client.image.rate({ urls: ["https://example.com/image.webp"], mode: "nsfw_sfw" });
await client.image.alt({ urls: ["https://example.com/image.webp"] });

When to override baseUrl

Override baseUrl only when you have a clear reason:
  • an internal proxy
  • a staging API
  • tests that run against a mocked or isolated host
For standard production usage, keep the default https://api.mynth.io.