Installation

Install @mynthio/sdk, set MYNTH_API_KEY, and import from the right entry point.

pnpm add @mynthio/sdk

The package is ESM only. Import the default client:

import Mynth from "@mynthio/sdk";

const mynth = new Mynth();

API key#

Create a mak_ key with npx @mynthio/cli api-key create my-app or in the dashboard, and put it where the server process reads environment variables:

MYNTH_API_KEY=mak_...

new Mynth() does not check the key. The first read of mynth.image or mynth.video throws a plain Error when there is no MYNTH_API_KEY and no apiKey option. mynth.models.list() needs no key. Authentication covers scopes and spending limits.

Entry points#

The package has four entry points. Import only these.

ImportExports
@mynthio/sdkMynth, the result classes, the error classes, and the MynthSDKTypes types
@mynthio/sdk/nextmynthWebhookHandler for a Next.js route handler
@mynthio/sdk/tanstack-startmynthWebhookHandler for a TanStack Start route
@mynthio/sdk/convexmynthWebhookAction for a Convex HTTP action

There is no @mynthio/sdk/webhooks entry point. convex is an optional peer dependency, needed only for @mynthio/sdk/convex. The webhook helpers read MYNTH_WEBHOOK_SECRET unless you pass a secret. Webhooks shows each one mounted.

Optional environment#

VariableUsed for
MYNTH_API_KEYThe API key, unless you pass apiKey
MYNTH_DESTINATIONDefault destination for image generation and background removal
MYNTH_WEBHOOK_SECRETThe wbs_ secret the webhook helpers verify against

Next steps#