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

# Image generation

> POST /v1/images/generations — text-to-image

Generate images from a natural-language description.

## Request

```bash theme={null}
curl https://openp.ai/v1/images/generations \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A black-and-white pencil sketch of a Shiba Inu wearing glasses",
    "size": "1024x1024",
    "n": 1,
    "quality": "high"
  }'
```

### Parameters

| Field             | Type    | Required | Description                                                                   |
| ----------------- | ------- | :------: | ----------------------------------------------------------------------------- |
| `model`           | string  |     ✅    | `gpt-image-2` / `gpt-image-1` / `dall-e-3` / `dall-e-2`                       |
| `prompt`          | string  |     ✅    | Text prompt, up to 4000 characters                                            |
| `n`               | integer |          | Number of images (dall-e-3 supports only 1)                                   |
| `size`            | string  |          | `1024x1024` / `1792x1024` / `1024x1792` (DALL·E 3); gpt-image-1 supports more |
| `quality`         | string  |          | `standard` / `hd` (dall-e-3); `low` / `medium` / `high` (gpt-image-1)         |
| `style`           | string  |          | `vivid` / `natural` (dall-e-3)                                                |
| `response_format` | string  |          | `url` (default) or `b64_json`                                                 |
| `background`      | string  |          | `transparent` / `opaque` (gpt-image-1)                                        |
| `output_format`   | string  |          | `png` / `jpeg` / `webp` (gpt-image-1)                                         |

## Response

```json theme={null}
{
  "created": 1715750400,
  "data": [
    {
      "url": "https://...",
      "revised_prompt": "A pencil sketch in black and white of a Shiba Inu..."
    }
  ]
}
```

The `url` is usually valid for only 1 hour — download it or copy it to your own storage.

With `response_format: "b64_json"`, base64 is returned:

```json theme={null}
{
  "data": [{"b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."}]
}
```

## DALL·E 3 notes

* Only `n=1`; call multiple times to generate several images.
* The `prompt` is automatically rewritten by the model; the returned `revised_prompt` is the prompt actually used.
* No `mask` editing support (use [images/edits](/en/api-reference/openai/images-edits)).

## gpt-image-1 notes

* Supports `n > 1` to generate multiple images at once.
* Supports three `quality` tiers with notable price differences.
* Supports a transparent background (`background: "transparent"`).

## Billing

A fixed charge per **model × size × quality × count**, unlike token billing.
The specific multipliers shown in [Console → Models](https://openp.ai/dashboard/models) are authoritative.
