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.
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#
| Field | Required | Description |
|---|---|---|
model | Yes | An image model id from Models, in the form vendor/model. |
prompt | Yes | What to generate. |
n | No | Number of images, 1 or more. Defaults to 1. |
size | No | <width>x<height>, for example 1024x1024. |
quality | No | Passed to models that support it. |
response_format | No | url 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.
| Models | Images per request | Sizes | Returns |
|---|---|---|---|
Qwen Image 2.0 (qwen-image-2.0, -pro) | Up to 6 | Total pixels from 512×512 to 2048×2048. Default 2048x2048 | A link, or b64_json on request |
Qwen Image (qwen-image, -plus, -max) | 1 | 1664x928, 1472x1140, 1328x1328, 1140x1472, 928x1664. Default 1328x1328 | A link, or b64_json on request |
Hunyuan Image 3.0 (hy-image-v3) | 1 | Each side 512–2048, area up to 1024×1024 | Always b64_json |
Hunyuan Image 3.5 (hy-image-v3.5-preview) | 1 | Each side 256–8192, area up to 4096×4096 | Always 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 returns400. - 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.
| Outcome | Charge |
|---|---|
| Images returned | As above |
| The model failed, returned no image, or timed out | Nothing (upstream_error; see Errors) |
| Blocked by content moderation | Nothing |
| The request is outside the model's limits | Nothing (400) |
| Not enough balance, API key limit or budget | Nothing (402) |
Errors#
| Status | Code | Meaning |
|---|---|---|
| 400 | unsupported_image_option | The count, size or quality isn't supported by this model, or the size has no price. The message lists what is allowed. |
| 400 | content_policy_violation | The prompt was blocked by content moderation. You are not charged. |
| 402 | insufficient_quota | Your balance or the API key's spending limit is too low for the request. |
| 402 | period_quota_exceeded | A daily, weekly or monthly budget is used up. The error also carries period, limit, used, resets_at and target_type; see Spend-limit errors. |
| 422 | invalid_request_error | The body failed validation: a missing prompt, an n below 1, or a field this endpoint doesn't accept. |
| 429 | rate_limit_exceeded | Over the request limit; see below. |
| 500, 502, 504 | upstream_error | The 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. |
| 503 | no_provider_model_available | No 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.