# Images

Generate and edit images.

`POST /v1/images/generations` returns image URLs on `cdn.ewest.ai`, kept for 7 days. Ask for `"response_format": "b64_json"` to also get the bytes.

Some models take extra options listed on their model page: `aspect_ratio`, `resolution` and `quality`. Models with image editing accept input images as `image_urls` (public https URLs), or as files on `POST /v1/images/edits` like OpenAI's images.edit.

Input images must be PNG, JPEG or WebP, up to 20 MB each when you upload them. Image addresses must be public `https://` URLs; a base64 data URI is not accepted here. See [Files](https://ewest.ai/docs/files) for the limits, what the errors mean and how generated images are stored.

cURL:

```bash
curl https://api.ewest.ai/v1/images/generations \
  -H "Authorization: Bearer $EWEST_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "ewest/flux-schnell", "prompt": "a cozy cabin in the snow"}'

# → {"data": [{"url": "https://cdn.ewest.ai/img/…"}]}
```

Python:

```python
import os
from openai import OpenAI

client = OpenAI(base_url="https://api.ewest.ai/v1", api_key=os.environ["EWEST_KEY"])
image = client.images.generate(model="ewest/flux-schnell", prompt="a cozy cabin in the snow")
print(image.data[0].url)
```

JavaScript:

```javascript
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.ewest.ai/v1", apiKey: process.env.EWEST_KEY });
const image = await client.images.generate({ model: "ewest/flux-schnell", prompt: "a cozy cabin in the snow" });
console.log(image.data[0].url);
```

Source: https://ewest.ai/docs/images
