Skip to main content
Use POST /image/generate (or mynth.image.generate()) to create an image generation task. The only required field is prompt. Defaults: model: "auto", count: 1, output: { format: "webp", quality: 80 }. Omitted size is treated as auto. This page is the core generation how-to. For other jobs, use the sibling guides: Full field definitions live in Image Generation Request.

Pricing

Generation is billed per successful image at the selected model’s price. Prices vary by model and scale (base vs 4K). Some models also charge per input image. Browse models at mynth.io/models or use the estimate endpoint below. When you create a task, Mynth reserves an estimatedCost up front. Failed images are refunded, so the final task cost may be lower than the reserve. model: "auto" reserves a flat upper-bound of $0.20 per image until a concrete model is selected. Pin a model for exact pricing. Magic prompt and generation-time content rating do not add an extra fee today.

Generate with the SDK

import Mynth from "@mynthio/sdk";

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

const task = await mynth.image.generate({
  prompt: "Architectural photograph of a brutalist library at golden hour",
  model: "google/gemini-3.1-flash-image",
  size: "landscape",
  count: 1,
});

console.log(task.urls); // successful delivery URLs
console.log(task.getImages()[0]?.mynth_url); // always on the Mynth CDN
generate() creates the task and waits until it completes. For fire-and-forget or browser polling, use generateAsync() — see Async and Polling.

Read the result

A completed task has per-image outcomes. Use task.urls or task.getImages() for successes only. Success:
{
  "status": "success",
  "id": "img_...",
  "url": "https://...",
  "mynth_url": "https://...",
  "cost": "0.03",
  "size": "1536x1024"
}
url is the delivery URL. It is null when the image was delivered only to a configured destination and that destination upload failed — mynth_url still points at the Mynth CDN. Failure (per image):
{
  "status": "failed",
  "error": {
    "code": "RESTRICTED_CONTENT",
    "message": "The request was blocked by content moderation."
  }
}
Known per-image codes: INVALID_INPUT, INVALID_PROMPT, RESTRICTED_CONTENT, UNKNOWN_ERROR.
for (const image of task.getImages({ includeFailed: true })) {
  if (image.status === "success") {
    console.log(image.id, image.url ?? image.mynth_url, image.cost);
  } else {
    console.error(image.error.code, image.error.message);
  }
}
If the whole task fails before producing a result, the task status is failed and errors is an array of { code } — see Tasks.

Set common options

FieldPurpose
promptRequired positive prompt (max 8192 characters).
modelModel ID, or "auto" (default). Pin a model in production.
sizePreset, aspect ratio, or auto. Omitted → auto.
countImages per task (default 1, max 20).
negative_promptText to discourage.
magic_promptSet true to rewrite the prompt before generation.
inputsInput images (URL strings or structured objects; max 20).
output{ format, quality } — default webp / 80. Formats: png, jpg, webp.
ratingOptional content classification on each success.
webhookDashboard off-switch and up to 5 custom endpoints.
destinationNamed storage destination for delivery.
metadataYour JSON context (max 2 KB), returned on the task and webhooks.
access{ pat: { enabled } } — Public Access Token in the create response (default on).
Details: Control Prompts, Control Size, Upload Input Images, Use Content Rating, Use Webhooks, Use Metadata.

Choose a model

Set model explicitly in production. model: "auto" is an early preview that picks a model from the prompt; cost is reserved as an upper bound until selection. Browse the catalog at mynth.io/models. Model pages document capabilities (inputs, negative prompt, 4K, native auto size).

Estimate cost before generating

POST /image/generate/estimate accepts the same body as generate. It validates the request and returns a cost estimate without creating a task or charging.
curl https://api.mynth.io/image/generate/estimate \
  -X POST \
  -H "Authorization: Bearer $MYNTH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Architectural photograph of a brutalist library at golden hour",
    "model": "google/gemini-3.1-flash-image",
    "size": "landscape",
    "count": 1
  }'
{
  "data": {
    "estimatedCost": "0.03",
    "currency": "usd",
    "estimateKind": "exact"
  }
}
estimateKind is "exact" when model is pinned, or "upper_bound" for model: "auto".

Generate with REST

curl https://api.mynth.io/image/generate \
  -X POST \
  -H "Authorization: Bearer $MYNTH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Architectural photograph of a brutalist library at golden hour",
    "model": "google/gemini-3.1-flash-image",
    "size": "landscape",
    "count": 1
  }'
Create response (201):
{
  "data": {
    "taskId": "tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP",
    "estimatedCost": "0.03",
    "access": {
      "publicAccessToken": "pat_eyJhbGciOi..."
    }
  }
}
Disable the Public Access Token with "access": { "pat": { "enabled": false } } when you only poll from the server with your API key. Creating a task does not return final images. Wait in the SDK, poll task endpoints, or use webhooks — see Async and Polling.

How generation fits

  1. You submit POST /image/generate (SDK or REST). Mynth validates, reserves cost, and enqueues an image.generate task.
  2. The worker resolves model, size, prompt (and optional magic prompt), then generates each image.
  3. Each success is uploaded to the Mynth CDN (and optional destination). Optional rating runs after CDN upload.
  4. The task completes with per-image success/failure. Failed images refund their reserved cost.
  5. You read results via SDK wait, polling, or webhooks (task.image.generate.completed / task.image.generate.failed).
For many independent prompts or models, fan out parallel requests — see Batch Generation.