# Images

> POST /v1/images/generations — image generation from a prompt and references.

`POST /v1/images/generations` generates images in the OpenAI Images format. It
works only with image models from the [catalog](https://ai-seller.vibe-codes.ru/en/docs/models).

## Request

```bash [curl]
curl https://ai-seller.vibe-codes.ru/v1/images/generations \
  -H "Authorization: Bearer $AISELLER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2.5",
    "prompt": "A fox in a neon city, watercolor",
    "n": 1,
    "size": "1024x1024"
  }'
```

```python [Python]
import base64
from openai import OpenAI

client = OpenAI(base_url="https://ai-seller.vibe-codes.ru/v1", api_key="$AISELLER_API_KEY")
resp = client.images.generate(
    model="gpt-image-2.5",
    prompt="A fox in a neon city, watercolor",
    n=1,
    size="1024x1024",
)
with open("fox.png", "wb") as f:
    f.write(base64.b64decode(resp.data[0].b64_json))
```

## Response

```json
{
  "created": 1790000000,
  "data": [{"b64_json": "iVBORw0KGgo..."}]
}
```

## Specifics

- **The response never streams**, and generation may take minutes — give your
  client a generous timeout.
- **Images come in `data[].b64_json`.** If the provider returns a link, the
  gateway downloads the file itself — the response has no links to the
  provider's storage.
- **`n` is 1 to 10.** You are billed per delivered image, but never for more
  than `n`.
- **References** go in the `image` / `images` fields — as a link or a base64
  `data:` URL. The request body limit is 70 MiB.
- Other parameters (`size`, `aspect_ratio`, `resolution`, `quality`,
  `background`, `output_format`, `output_compression`) are passed to the model
  as is; which values it supports is up to its provider.

## Generation errors

| HTTP | code | What to do |
| --- | --- | --- |
| 400 | `content_policy_violation` | The content policy rejected the prompt — change it. |
| 400 | `invalid_image` | The model rejected the reference — try a different image. |
| 422 | `generation_failed` | The model returned no image — retry or rephrase the prompt. |

Other codes are in [Errors](https://ai-seller.vibe-codes.ru/en/docs/errors).
