Overview

@mynthio/sdk is the TypeScript client for Mynth. It creates tasks, waits for them, uploads local files, and ships webhook helpers for Next.js, TanStack Start, and Convex.

@mynthio/sdk is the TypeScript client for Mynth. Construct one client, pass a model id and a prompt, and read the file URLs from the result.

import Mynth from "@mynthio/sdk";

const mynth = new Mynth(); // reads MYNTH_API_KEY

const task = await mynth.image.generate({
  model: "black-forest-labs/flux.2-pro",
  prompt: "A lighthouse at dusk, film grain",
});

console.log(task.urls[0]);

generate() creates a task and polls it until it settles. Use generateAsync() when the caller cannot wait, and finish on a webhook.

What the SDK covers#

SurfaceMethods
mynth.imagegenerate, rate, alt, review, removeBackground, each with an Async twin, and upload
mynth.videogenerate, generateAsync, estimate, upload
mynth.modelslist, which needs no API key
@mynthio/sdk/next, /tanstack-start, /convexWebhook helpers that verify the signature

The SDK does not wrap account management: keys, webhooks, destinations, and balance. Use the REST API or the CLI for those.

Rules#

  • Keep the mak_ key on the server. A browser polls one task with the pat_ token from the create response. See tasks and polling.
  • Pass a model id. Omitting model makes the API use auto, which is experimental. See the model field.
  • urls and getImages() skip failed images. Compare with the count you sent when a partial result matters.

In this section#

PageCovers
InstallationThe package, the key, and the entry points
ClientapiKey, baseUrl, and the default destination
Generating mediaImage, video, and tool calls, and what the result classes hold
Tasks and pollinggenerateAsync(), poll intervals, and the browser token
ErrorsMynthAPIError and the errors a wait throws

Next steps#