Getting started
Create an API key and generate a first image with the TypeScript SDK, the REST API, or the CLI.
You need an API key and one request. Pick how you want to work below.
Mynth is prepaid. A new account starts at $0, so the first paid request answers
402 insufficient_balance until you top up ($5 minimum).
Signup credits are paused, but you can ask for
testing credits.
Integrate Mynth media generation into this project. First read the docs: run npx @mynthio/cli docs list and npx @mynthio/cli docs get getting-started. Docs need no account. Before you
change anything, ask me how to handle credentials: (1) you run npx @mynthio/cli auth login and
npx @mynthio/cli api-key create my-app, I approve the login in my browser, and you add the key
to the right env file; or (2) I add MYNTH_API_KEY myself. Then scan the codebase, tell me where
media generation would fit, and wait for my go-ahead. Use @mynthio/sdk in TypeScript or JavaScript
projects. Always pass an explicit model id, never auto. Keep the API key on the server. Mynth is
prepaid: if a call answers 402 insufficient_balance, stop, read balance.available from GET /me,
tell me that number, and ask me to top up instead of retrying. On direct API calls, send the
header X-Mynth-Client: agent-prompt.
Log in once with the CLI. It opens your browser to approve the login. Then create a key for your app:
npx @mynthio/cli auth login
npx @mynthio/cli api-key create my-appapi-key create prints a mak_... key once. Put it where your app reads
environment variables:
MYNTH_API_KEY=mak_...You can also create a key in the dashboard.
pnpm add @mynthio/sdkimport 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 the task, waits for it, and returns the finished result.
The URL is served for 7 days. Tasks
covers keeping the file longer.
model accepts and where to find ids.