Skip to main content
Use count on POST /image/generate (or mynth.image.generate() / generateAsync()) when you want several images from the same prompt and model in one task. Default is 1. Maximum is 20. For different prompts or models, create separate tasks in parallel. There is no multi-prompt bulk endpoint. For a single image, see Generate Images. For waiting on results, see Async and polling.

Pricing

Mynth reserves the full cost up front: per-image price × count (plus magic prompt once, if enabled). You are charged only for images that succeed. Reserved balance for failed images is released. If your balance cannot cover the full reservation, task creation fails with 422 INSUFFICIENT_BALANCE.

Generate several images in one task

Set count to request multiple variants of one prompt:
import Mynth from "@mynthio/sdk";

const mynth = new Mynth();

const task = await mynth.image.generate({
  prompt: "Editorial product photo of a ceramic mug on marble",
  model: "google/gemini-3.1-flash-image",
  size: "landscape",
  count: 4,
});

console.log(task.urls); // successful image URLs only
console.log(task.getImages().length); // 0–4 successful images
FieldDefaultLimits
count1Integer from 1 to 20
count greater than 20 is rejected with HTTP 400 and code: "VALIDATION_ERROR".

Handle partial success

Each requested image is generated independently. The task can complete with a mix of successful and failed images. The task status is still completed when any images settle; inspect per-image status. Success item:
{
  "status": "success",
  "id": "img_...",
  "url": "https://...",
  "mynth_url": "https://...",
  "cost": "0.03",
  "size": "1536x1024"
}
Failed item:
{
  "status": "failed",
  "error": { "code": "UNKNOWN_ERROR" }
}
Per-image error 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);
  } else {
    console.error(image.error.code);
  }
}
task.urls and task.getImages() return only successful images. Use getImages({ includeFailed: true }) when you need failures.

Fan out across prompts or models

One request has a single prompt and model. For independent combinations, create one task per combination. Mynth does not enforce API concurrency limits.
const prompts = [
  "Packaging photo for a botanical tea brand",
  "Packaging photo for a specialty coffee brand",
  "Packaging photo for a skincare brand",
];

const tasks = await Promise.all(
  prompts.map((prompt) =>
    mynth.image.generateAsync({
      prompt,
      model: "google/gemini-3.1-flash-image",
      count: 2,
    }),
  ),
);

console.log(tasks.map((task) => task.id));
Across models:
const models = [
  "google/gemini-3.1-flash-image",
  "black-forest-labs/flux.2-dev",
  "black-forest-labs/flux.2-pro",
  "recraft/recraft-v4",
] as const;

const tasks = await Promise.all(
  models.map((model) =>
    mynth.image.generateAsync({
      prompt: "Hero illustration for a fintech landing page",
      model,
      size: "landscape",
    }),
  ),
);
Use generateAsync when you want task IDs immediately and will poll or use webhooks later. Use generate when you can wait for each task in place. See Async and polling. Size your own parallelism for budget, downstream capacity, and client UX. Each task reserves cost at creation.

REST example

curl https://api.mynth.io/image/generate \
  -X POST \
  -H "Authorization: Bearer $MYNTH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Editorial product photo of a ceramic mug on marble",
    "model": "google/gemini-3.1-flash-image",
    "size": "landscape",
    "count": 4
  }'
Creating a task does not return images immediately. Poll task endpoints or use webhooks — see Async and polling and Use Webhooks.

Choose count vs parallel tasks

GoalApproach
Several variants of one prompt and modelOne request with count (max 20)
Different prompts, same or different modelsOne task per combination (Promise.all, etc.)
Different models for the same promptOne task per model
Track each job with your own IDsmetadata per task — see Use Metadata

How batch generation works

  1. Mynth validates the request (count 1–20) and reserves cost for all requested images.
  2. The worker runs the count generations in parallel for that task.
  3. Each image is finalized independently (upload, optional rating, destination).
  4. The task completes with result.images — one entry per requested image, success or failed.
  5. You are charged only for successful images; unused reservation is released.
For field-level request details, see Image Generation Request. For limits, see Errors and Limits.