Image Generation
Use Image Generation to create images from a text prompt in an application workflow. Typical uses include draft illustrations for editorial review, product mockups, marketing variations for A/B testing, and placeholder art that a designer refines later.
Authenticate requests with an AIVAX API key. See Authentication for authorization guidance.
Choose a model #
Select an image-generation model available to the authenticated account. Model availability and capabilities can change, so obtain current options from the platform instead of depending on a fixed list in this guide.
When several models are available, compare them by capability:
- Reference images: only some models accept
referenceImages. - Variations: decide how many images you need per prompt;
countaccepts 1 to 4. - Wait time: image requests on some models take a while. For those, send the request to
https://direct.inference.aivax.netand raise your client timeout, as described in long-running inference.
Generate an image #
Use prompts that state the outcome you need rather than relying on vague visual labels. Include the important details, such as the subject, environment, framing, and any text that must be present. One request can carry a single prompt or an array of prompts. Each prompt generates count images, and their URLs come back grouped by input prompt.
Control the output with these optional fields:
size: the image dimensions, either as a"1024x1024"string or as{ "width": 1024, "height": 1024 }. Each side must be between 64 and 4096 pixels. The default is 1080×1920. The model may adjust the size to a dimension it supports.format:png,jpegorwebp. When omitted, the image keeps the format produced by the model.quality: an integer from 1 to 100 that sets thejpegorwebpencoding quality. It has no effect onpng. When the image is converted andqualityis omitted, 90 is used.
Each prompt group returns images, the URLs of the delivered images, and outputs, one entry per requested image in request order. Each entry has the image url, the cost charged for it and, when it failed, an error message with a null URL. The group cost is the sum charged for that prompt. A request can succeed with some failed images, so check outputs.
Supply up to 16 reference images when the selected model supports them and the output must follow an existing subject, style, or composition. Each entry is a public HTTP(S) URL or a data:image/png, data:image/jpeg, data:image/webp, or data:image/gif base64 data URI of up to 8 MB. References guide the result; they do not guarantee identity preservation, so inspect the output before publishing.
Treat generated assets as drafts and review them for accuracy, brand suitability, and unintended content before release. When the first result is close but not right, iterate by tightening one element at a time — subject detail, composition, style constraint — rather than rewriting the whole prompt at once.
The embedded reference is the source of truth for the request shape, supported options, and response fields.
To let an MCP-compatible agent or IDE generate images without calling this endpoint directly, use the Media generation MCP. For a Claude Code setup, see generate images in Claude Code with an MCP server.
Async generation #
Add "async": true to queue the generation instead of keeping the request open. The API answers with HTTP 202 and an ID, and you fetch the stored result later or receive a webhook when it is done. See Async generations.
{
"input": "A kitten playing with a ball",
"model": "@alibaba/wan-image-2.7-pro",
"async": true
}Pricing, limits, and errors #
Image generation is charged per delivered image, with an additional charge per reference image on some models. Failed or undelivered outputs are not charged. Prompt processing is included, and no account or plan multiplier applies. Current tariffs for each model are listed in the Models catalog.
The built-in image generation and editing tool has a daily limit that depends on the plan; see Built-in tools and web search limits.
If a request fails, revise the reported validation issue before retrying.
