Image generation
Docs · API

Image generation

Generate images in one request: fields, what each model accepts, per-image and per-token pricing, and errors.

Image generation is synchronous: one request returns the images. It is OpenAI compatible, so the OpenAI SDK's images.generate works with the same key and host.

bash
curl https://api.lune.io/v1/images/generations \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "<image model id>", "prompt": "A lighthouse at dusk, watercolor", "size": "1024x1024"}'

Pick an image model on Models. Its page has a ready-to-run example under How to call, with the model id filled in.

Request fields#

FieldRequiredDescription
modelYesAn image model id from Models, in the form vendor/model.
promptYesWhat to generate.
nNoNumber of images, 1 or more. Defaults to 1.
sizeNo<width>x<height>, for example 1024x1024.
qualityNoPassed to models that support it.
response_formatNourl or b64_json.

Unknown fields are rejected with 422 invalid_request_error, and so are a missing prompt and an n below 1.

What each model accepts#

The names below are model families; use the full vendor/model id from Models in requests. Limits are checked before the request reaches the model. A request outside them gets 400 unsupported_image_option and is not billed.

ModelsImages per requestSizesReturns
Qwen Image 2.0 (qwen-image-2.0, -pro)Up to 6Total pixels from 512×512 to 2048×2048. Default 2048x2048A link, or b64_json on request
Qwen Image (qwen-image, -plus, -max)11664x928, 1472x1140, 1328x1328, 1140x1472, 928x1664. Default 1328x1328A link, or b64_json on request
Hunyuan Image 3.0 (hy-image-v3)1Each side 512–2048, area up to 1024×1024Always b64_json
Hunyuan Image 3.5 (hy-image-v3.5-preview)1Each side 256–8192, area up to 4096×4096Always b64_json

Models that make one image per request return 400 for n above 1. We don't split it into several calls for you. Links from Qwen models expire after 24 hours, so download the image promptly.

Pricing#

Each model page shows how it is priced.

  • Per image: images delivered × the price for the requested size. Some models price each size separately. The size you send picks the price; without size, the model's default size is used. A size that has no price on the model page is not sold and returns 400.
  • Per token: the tokens the model reports × the price per 1M image tokens. If a model returns images without reporting usage, we bill a conservative minimum per image rather than zero.
OutcomeCharge
Images returnedAs above
The model failed, returned no image, or timed outNothing (upstream_error; see Errors)
Blocked by content moderationNothing
The request is outside the model's limitsNothing (400)
Not enough balance, API key limit or budgetNothing (402)

Errors#

StatusCodeMeaning
400unsupported_image_optionThe count, size or quality isn't supported by this model, or the size has no price. The message lists what is allowed.
400content_policy_violationThe prompt was blocked by content moderation. You are not charged.
402insufficient_quotaYour balance or the API key's spending limit is too low for the request.
402period_quota_exceededA daily, weekly or monthly budget is used up. The error also carries period, limit, used, resets_at and target_type; see Spend-limit errors.
422invalid_request_errorThe body failed validation: a missing prompt, an n below 1, or a field this endpoint doesn't accept.
429rate_limit_exceededOver the request limit; see below.
500, 502, 504upstream_errorThe model failed (the status it returned, such as 500), returned no image or couldn't be reached (502), or timed out (504). You are not charged. Retry later.
503no_provider_model_availableNo route could serve the request, for example right after repeated failures on every key. Wait a little and retry.

Rate limit#

Image requests are limited to 60 per minute per API key owner, and video submits share that limit. The count is the same one that applies to chat and the other endpoints (600 per minute): every request from every key the person owns counts toward it, whatever the endpoint. Once the total passes 60 in a minute, image and video requests get 429 rate_limit_exceeded while chat and the other endpoints keep working up to 600.