Create Image
Creates one or more images from a prompt, in OpenAI's shape (images.generate() in OpenAI's SDKs). The default model is z-image-turbo. GET /v1/images/models lists the image models currently served with what each accepts.
The answer is a link (url) unless response_format is b64_json; POST /v1/images answers base64 by default. Every error is OpenRouter's envelope.
quality (auto, low, medium, high, standard, hd) is accepted and ignored on a model without quality tiers, where steps trades time for detail. On minimax-h3 it selects a tier: low or auto Turbo (4 steps), medium or standard 20 steps at 1.5 times the megapixels billed, high or hd 40 steps at 3 times, ultra 50 steps at 5 times, and a raw steps bills the tier whose step range holds it; GET /v1/images/models/{author}/{slug}/endpoints lists them as quality_tiers. moderation and style are not supported and are a 400 naming the field. stream: true answers one image_ event and [DONE] (partial_images above 0 is a 400). output_format (png, jpeg, webp) and output_compression are passed to the engine. Model-specific settings are steps (or num_inference_steps), guidance_scale and negative_prompt, also under provider.options (see POST /v1/images).
images or input_references make the request an edit with a model that has reference editing, answered as POST /v1/images/edits answers it (minimax-h3's reference stills included).
For reproducible output, send an integer seed together with steps and guidance_scale, and keep every other field the same between requests.
Body
application/jsonOne request shape for POST /v1/images, /v1/images/generations and (as JSON) /v1/images/edits: OpenRouter's image request, OpenAI's image request and the parameter names each model declares in GET /v1/images/models are all accepted on all three routes.
Every field is read, accepted and ignored by design (user, session_id, trace, and provider's routing fields such as order and sort), quality (auto, low, medium, high, standard, hd; any other value is a 400; on minimax-h3 it selects a quality tier, and ultra is one more: low Turbo, medium 20 steps billed 1.5x, high or hd 40 steps billed 3x, ultra 50 steps billed 5x), or refused with a 400 naming it: moderation, style, input_fidelity, lora, loras, partial_images above 0, and any field the model does not declare. Limits below are z-image-turbo's; each model's own are in GET /v1/images/models.
-
prompt string required
A text description of the desired image(s). The maximum length is the model's (4000 characters for
z-image-turbo), counted as Unicode characters rather than bytes.at most 4000 characters -
model string
The model to use for image generation. Defaults to
z-image-turbo.GET /v1/images/modelslists the image models currently served. An unknown model returns 404.default z-image-turbo -
n integer
The number of images to generate. The images in one request are generated together, so changing
ncan change every image, including the first, for the sameseed.default 1range 1–10 -
response_format string
How the image comes back.
urlis a presigned link that expires after one hour;b64_jsonis the image inline as base64. The default isb64_jsononPOST /v1/images(OpenRouter's SDKs require it) andurlon/v1/images/generationsand/v1/images/edits.urlb64_json -
size string
WIDTHxHEIGHTin pixels, or a resolution label (1K,2K, ...). Forz-image-turboany sides that are multiples of 16, an area from 65,536 to 4,194,304 pixels and a longer side at most 4 times the shorter (so768x768works and1000x1000is a 400).autois the same as leaving it out. Anaspect_ratioorresolutionbeside an explicit size must agree with it.default 1024x1024 -
width integer deprecated
Legacy spelling of
size, kept because this API once documented it as ignored. Needsheightand meanssize"{width}x{height}"under the same rules; a 400 if it disagrees with asizesent beside it. Usesize. -
height integer deprecated
See
width. -
aspect_ratio string
One of the model's aspect ratios (
GET /v1/images/models). Withresolution, or alone at the model's default resolution, it picks the size. -
resolution string
One of the model's resolutions (
512,768,1K,1.5K,2Kforz-image-turbo;4Kis a 400). -
seed integer (int64)
Random seed. Must be an integer; fractional values are rejected rather than rounded. When omitted, each request uses a random seed.
Repeating a request with the same seed and the same value for every other field, including
nandsize, returns the same images from the same model version on the same hardware. A model or engine update can change the images a seed produces, and replicas on different GPUs can differ in the last bits. -
output_format stringdefault pngpngjpegwebp
-
output_compression integer
The encoder quality for
jpegandwebp, the compression level forpng. The engine's own default applies when omitted.range 0–100 -
background string
autoandopaquegive an opaque image.transparentonly works on a model whose spec supports it (it also needsoutput_formatpngorwebp); onz-image-turboit is a 400.default autoautoopaquetransparent -
input_references array of objects
OpenRouter's reference images, for a model with reference editing (
z-image-turbohas none, so it is a 400 naming this field). Each is{"type": "image_url", "image_url": {"url": "<https URL or base64 data URI>"}}. The gateway fetches an https URL itself. -
steps integer
The number of denoising steps (
z-image-turbo: 1 to 50, default 8). Generation time grows roughly linearly with steps. Also accepted asnum_inference_steps, and underprovider.options(seeprovider).For
z-image-turbothe last step of the schedule lands at zero noise and does not change the image, soNsteps applyN - 1denoising updates. The default of 8 applies 7; 9 matches the 8 updates in the upstream Z-Image-Turbo reference.range 1–50 -
num_inference_steps integer
Alias of
steps.range 1–50 -
guidance_scale number (float)
Classifier-free guidance strength, on the model's own scale, so a value from its model card works as written. Each model's range and default are in its entry in
GET /v1/images/models; when omitted, that default is used.On
z-image-turbo0 is off and the default (also the upstream recommendation for Turbo models); higher values are not a quality setting there. Onmoss-imageandqwen-image-2.11 is off (qwen-image-2.1defaults to 1 and also accepts this setting astrue_cfg_scale). Guidance above off enablesnegative_promptand roughly doubles the model work per step.range 0–20 -
negative_prompt string
Text describing what to steer the image away from. It only takes effect when
guidance_scaleis above 0; at thez-image-turbodefault of 0 it is ignored. Onqwen-image-2.1it takes effect whenguidance_scaleis above 1, and when omitted it is" "(the model's empty negative prompt), soguidance_scalealone turns guidance on. It changes the output, but does not guarantee that the described content is absent. -
provider object
OpenRouter's provider preferences. The routing fields (
order,only,ignore,sort,allow_fallbacks, ...) are accepted and ignored.optionscarries the model's own settings (steps,guidance_scale,negative_prompt) for clients that cannot add top-level fields. From OpenRouter's SDKs useoptions.stealth: they keep only the slugs on their closed list and drop any other,vultrincluded, without an error. The first form present wins, the top level before any option; a key the model does not declare is a 400 naming its path. -
upscale object
What to answer when the upscale of a size the gateway enlarges after the model (minimax-h3's
4K, with SeedVR2) cannot run.fallbacknone(the default) fails the request with 429, 503 or 502 and bills nothing;originalanswers the model's own render instead and says so (upscale.appliedfalse in the answer, and theX-Vultr-Upscaleheader). On any other size it changes nothing. In a multipart form send it as JSON text. -
stream boolean
trueanswerstext/event-stream: oneimage_event (see the response), thengeneration. completed [DONE]. Always base64. Not withnabove 1. -
partial_images integer
OpenAI's partial image count. Only 0 is accepted; a stream carries the finished image only.
range 0–0 -
user string
Accepted and ignored.
-
session_id string
Accepted and ignored.
-
trace object
Accepted and ignored.
Responses
OK
application/json · create-image-response-payload
A field the model does not accept or a malformed input. The message names the field.
application/json · error-payload
The API key is missing, unknown or not active. Send it as Authorization: Bearer <key>.
application/json · error-payload
The model does not exist
application/json · error-payload
A reference image over 20 MB, the images over 64 MB together, or a reference above 50 megapixels on a model that scales references down (minimax-h3)
application/json · error-payload
Too many requests for this model from your subscription in the last minute or at once, or, on a size the gateway upscales, your requests already hold your share of its upscaler (metadata.error_type upscale_, header X-Vultr-Upscale: refused; reason=account_limit; nothing was generated or billed). Wait for Retry-After, then retry.
application/json · error-payload
The model is temporarily unavailable, or, on a size the gateway upscales, its upscaler is busy or unavailable (metadata.error_type upscale_capacity or upscale_unavailable, header X-Vultr-Upscale: refused; reason=...): nothing was generated or billed. Retry after Retry-After, or send upscale: {"fallback": "original"} to take the model's render instead.
application/json · error-payload
The model answered without an image, or, on a size the gateway upscales, the upscaler failed twice after the model rendered (metadata.error_type upscale_, header X-Vultr-Upscale: failed; reason=upscaler_error). Nothing was billed. Send upscale: {"fallback": "original"} to take the model's render when the upscale fails.
application/json · error-payload
curl https://api.vultrinference.com/v1/images/generations \
-H "Authorization: Bearer $VULTR_INFERENCE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "z-image-turbo",
"prompt": "Studio photograph of a red ceramic teapot beside a blue cup on a wooden table.",
"n": 1,
"size": "1024x1024",
"response_format": "b64_json"
}'import os
import requests
response = requests.post(
"https://api.vultrinference.com/v1/images/generations",
headers={"Authorization": f"Bearer {os.environ['VULTR_INFERENCE_API_KEY']}"},
json={
"model": "z-image-turbo",
"prompt": "Studio photograph of a red ceramic teapot beside a blue cup on a wooden table.",
"n": 1,
"size": "1024x1024",
"response_format": "b64_json",
},
)
print(response.json())const response = await fetch("https://api.vultrinference.com/v1/images/generations", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.VULTR_INFERENCE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"model": "z-image-turbo",
"prompt": "Studio photograph of a red ceramic teapot beside a blue cup on a wooden table.",
"n": 1,
"size": "1024x1024",
"response_format": "b64_json"
}),
});
console.log(await response.json());{
"created": 0,
"data": [
{
"media_type": "image/png"
}
],
"size": "1024x1024",
"output_format": "png",
"background": "opaque",
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0,
"input_tokens": 0,
"output_tokens": 0,
"cost": 0.02097152,
"megapixels": 1.048576
}
}