> ## Documentation Index
> Fetch the complete documentation index at: https://docs.refillapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Image generation

> POST /v1/images/generations with Qwen-Image 3.0, Z-Image Turbo and Wan 2.7 Image Pro.

```text theme={null}
POST https://refillapi.com/v1/images/generations
```

The image endpoint is **synchronous**: the response comes back when the images are ready, usually in 10–60 seconds. Set your client timeout to at least 2 minutes, and do not resubmit on a client timeout — each request is billed.

| Model ID | Best for | Size | Images per request | Reference images |
| - | - | - | - | - |
| `qwen-image-3.0` | Posters and text in images | `size` from 512×512 to 2048×2048 | 1–6 | Up to 3 |
| `z-image-turbo` | Fast, low-cost text to image | `size` from 512×512 to 2048×2048 | 1 | — |
| `wan2.7-image-pro` | Editing and multi-image reference, up to 4K | `1K`, `2K`, `4K` (text only) or `WIDTHxHEIGHT` | 1–4 | Up to 9 |

## Request fields

| Field | Type | Description |
| - | - | - |
| `model` | string | Required. One of the IDs above |
| `prompt` | string | Required. What to draw |
| `size` | string | Output size, e.g. `1328x1328`, `1664x928`, `1104x1472`. Aspect ratio up to 8:1 |
| `n` | integer | Number of images, default 1 — see the table |
| `images` | string\[] | Reference image URLs (public `http(s)`). With references, the request becomes image editing / image-to-image |
| `negative_prompt` | string | What you do not want in the image |
| `seed` | integer | Random seed |
| `prompt_extend` | boolean | `z-image-turbo` only: let the model rewrite the prompt. Doubles the price |

Streaming is not supported.

## Text to image

```bash curl theme={null}
curl https://refillapi.com/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-image-3.0",
    "prompt": "Autumn latte poster for a coffee shop, warm tones, space for a headline",
    "size": "1104x1472"
  }'
```

```python Python theme={null}
from openai import OpenAI

client = OpenAI(api_key="YOUR_API_KEY", base_url="https://refillapi.com/v1", timeout=300)
result = client.images.generate(
    model="z-image-turbo",
    prompt="Autumn latte poster for a coffee shop, warm tones, space for a headline",
    size="1104x1472",
)
print(result.data[0].url)
```

Non-OpenAI fields such as `images` or `negative_prompt` go in `extra_body` with the OpenAI SDK.

## Edit with reference images

```bash theme={null}
curl https://refillapi.com/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "wan2.7-image-pro",
    "prompt": "Put this product on a clean white studio background, keep the product unchanged",
    "images": ["https://example.com/product.jpg"],
    "size": "1328x1328"
  }'
```

## Response

```json theme={null}
{
  "created": 1790524433,
  "data": [
    { "url": "https://..." }
  ]
}
```

With `n` greater than 1, `data` has one item per image.

> [!WARNING]
>
> Image URLs are temporary. Download the images right away and store your own copy — plan on links expiring after **24 hours**.

## Billing

Per image actually generated; failed generations are not billed.

* `qwen-image-3.0`: same price for every size; each reference image adds a small fee.
* `z-image-turbo`: double price with `prompt_extend`.
* `wan2.7-image-pro`: same price for 1K, 2K and 4K.

Current prices: [Models & pricing](https://refillapi.com/pricing).

## Errors

| Error | Cause |
| - | - |
| `prompt is required` | No prompt |
| `image must be an HTTP URL or Base64 data URL` | A reference image is neither a URL nor a data URL |
| `too many input images for this model` | Too many reference images |
| `this model only supports text-to-image input` | Reference images sent to `z-image-turbo` |
| `stream is not supported` | Images cannot be streamed |
| `model_endpoint_unsupported` | An image model was called on `/v1/chat/completions` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.