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#
| Surface | Methods |
|---|---|
mynth.image | generate, rate, alt, review, removeBackground, each with an Async twin, and upload |
mynth.video | generate, generateAsync, estimate, upload |
mynth.models | list, which needs no API key |
@mynthio/sdk/next, /tanstack-start, /convex | Webhook 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 thepat_token from the create response. See tasks and polling. - Pass a model id. Omitting
modelmakes the API useauto, which is experimental. See the model field. urlsandgetImages()skip failed images. Compare with thecountyou sent when a partial result matters.
In this section#
| Page | Covers |
|---|---|
| Installation | The package, the key, and the entry points |
| Client | apiKey, baseUrl, and the default destination |
| Generating media | Image, video, and tool calls, and what the result classes hold |
| Tasks and polling | generateAsync(), poll intervals, and the browser token |
| Errors | MynthAPIError and the errors a wait throws |
Next steps#
- Installation: add the package and set the key.
- Generate images: every field
image.generate()sends. - Webhooks: the helpers, mounted per framework.