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

# GPT Image 2

> GPT Image 2: image generation model. Request examples and parameters for MixRoute.

GPT Image 2 is available through the native image API described below.

Supports image generation and editing. Size constraints, transparent-background support, and input fidelity are model-specific.

<Tip>
  [Generation parameters](/api-reference/endpoint/gpt-image) | [Editing parameters](/api-reference/endpoint/gpt-image-edit)
</Tip>

`POST https://api.mixroute.ai/v1/images/generations`

## Examples

Use your MixRoute key in the `MIXROUTE_API_KEY` environment variable. Requests use `Authorization: Bearer ...`. Replace source-image placeholders with accessible images or local files before editing.

```bash theme={null}
curl --request POST "https://api.mixroute.ai/v1/images/generations" \
  --header "Authorization: Bearer $MIXROUTE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "gpt-image-2",
  "prompt": "A clean product photograph of a red ceramic mug on a white background.",
  "n": 1,
  "size": "1024x1024",
  "quality": "low",
  "output_format": "png"
}'
```

### Python

```python theme={null}
import json
import os
import requests

payload = json.loads(r'''
{
  "model": "gpt-image-2",
  "prompt": "A clean product photograph of a red ceramic mug on a white background.",
  "n": 1,
  "size": "1024x1024",
  "quality": "low",
  "output_format": "png"
}
''')
response = requests.post(
    "https://api.mixroute.ai/v1/images/generations",
    headers={"Authorization": "Bearer " + os.environ["MIXROUTE_API_KEY"]},
    json=payload,
    timeout=180,
)
response.raise_for_status()
result = response.json()
import base64
from pathlib import Path

for index, item in enumerate(result["data"]):
    Path(f"image_{index}.png").write_bytes(base64.b64decode(item["b64_json"]))
```


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