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.

Agent prompt

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.

Get an API key#

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-app

api-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.

Install the SDK#

pnpm add @mynthio/sdk

Generate an image#

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 the task, waits for it, and returns the finished result. The URL is served for 7 days. Tasks covers keeping the file longer.

Next steps#

  • Tasks: statuses, partial failure, and file lifetimes.
  • The model field: what model accepts and where to find ids.
  • Webhooks: get called when a task settles.