• Docs
  • API reference
  • SDKs & tools
  • Models
  • Changelog
Sign inGet an API key
DocsAPI referenceSDKs & toolsModelsChangelog

TypeScript SDK

OverviewInstallationClientGenerating mediaTasks and pollingErrors

CLI

OverviewLogging inCommands

Integrations

ConvexTanStack Start

Agents

llms.txtSkillsAgent prompt
  1. SDKs & tools
  2. /
  3. TypeScript SDK

Client

The Mynth constructor options, where the key, base URL, and default destination come from, and the image, video, and models clients.

PreviousInstallationNextGenerating media

On this page

The three clientsNext steps

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",
});
OptionDefaultWhat it does
apiKeyMYNTH_API_KEYThe bearer key. Missing, it throws on first use of image or video
baseUrlhttps://api.mynth.ioA proxy or test host. A trailing slash is removed
destinationMYNTH_DESTINATIONDefault destination name for image generation, background removal, and upscaling

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

PropertyHolds
mynth.imageImage generation, rating, alt text, review, background removal, upscaling, upload
mynth.videoVideo generation, estimates, upload
mynth.modelslist(): 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() and video.generate().
  • Tasks and polling: keep the wait out of a request handler.