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:
- Control Prompts — negative prompts and magic prompt
- Control Size — presets, aspect ratios, 4K, output format
- Upload Input Images — image-to-image inputs
- Use Content Rating — classify generated images
- Rate Image Content / Generate Image Alt Text — analyze existing images (not generation)
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 anestimatedCost 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
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. Usetask.urls or task.getImages() for successes only.
Success:
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):
INVALID_INPUT, INVALID_PROMPT, RESTRICTED_CONTENT, UNKNOWN_ERROR.
failed and errors is an array of { code } — see Tasks.
Set common options
| Field | Purpose |
|---|---|
prompt | Required positive prompt (max 8192 characters). |
model | Model ID, or "auto" (default). Pin a model in production. |
size | Preset, aspect ratio, or auto. Omitted → auto. |
count | Images per task (default 1, max 20). |
negative_prompt | Text to discourage. |
magic_prompt | Set true to rewrite the prompt before generation. |
inputs | Input images (URL strings or structured objects; max 20). |
output | { format, quality } — default webp / 80. Formats: png, jpg, webp. |
rating | Optional content classification on each success. |
webhook | Dashboard off-switch and up to 5 custom endpoints. |
destination | Named storage destination for delivery. |
metadata | Your JSON context (max 2 KB), returned on the task and webhooks. |
access | { pat: { enabled } } — Public Access Token in the create response (default on). |
Choose a model
Setmodel 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.
estimateKind is "exact" when model is pinned, or "upper_bound" for model: "auto".
Generate with REST
201):
"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
- You submit
POST /image/generate(SDK or REST). Mynth validates, reserves cost, and enqueues animage.generatetask. - The worker resolves model, size, prompt (and optional magic prompt), then generates each image.
- Each success is uploaded to the Mynth CDN (and optional destination). Optional rating runs after CDN upload.
- The task completes with per-image success/failure. Failed images refund their reserved cost.
- You read results via SDK wait, polling, or webhooks (
task.image.generate.completed/task.image.generate.failed).