Generate your first image with Mynth and understand the result you get back.
This quickstart gets you from zero to a completed image task using the official JavaScript and TypeScript SDK.
1
Create an API key
Create a key in the Mynth dashboard.If you work with multiple environments, create separate keys and set a spending limit for each one.
2
Install the SDK
bun add @mynthio/sdk
3
Set your environment variable
bash export MYNTH_API_KEY=mak_your_key_here
4
Generate an image
import Mynth from "@mynthio/sdk";const mynth = new Mynth();const task = await mynth.generate({ prompt: "Editorial product photo of a ceramic mug on a linen tablecloth", model: "google/gemini-3.1-flash-image",});console.log(task.urls);
By default, generate() waits for completion. The returned task is already a completed task object, so task.urls contains the successful image URLs immediately.
5
Return immediately with async mode
const task = await mynth.generate( { prompt: "A floating garden at sunrise", model: "google/gemini-3.1-flash-image", }, { mode: "async" },);console.log(task.id);console.log(task.access.publicAccessToken);
Async mode returns a TaskAsync. Use it when your server should start work now and your app will poll or wait later.
Set model explicitly in production. model: "auto" is an early preview feature intended for
experimentation.