# Image Generation (/docs/images)


Generate Images [#generate-images]

```
POST /v1/images/generations
```

Request [#request]

```json
{
  "model": "model-id",
  "prompt": "A serene mountain landscape at sunset, digital art",
  "n": 1,
  "size": "1024x1024",
  "quality": "hd"
}
```

Parameters [#parameters]

| Parameter         | Type    | Required | Description                    |
| ----------------- | ------- | -------- | ------------------------------ |
| `model`           | string  | Yes      | Image model ID                 |
| `prompt`          | string  | Yes      | Text description of the image  |
| `n`               | integer | No       | Number of images (1–10)        |
| `size`            | string  | No       | Image size (e.g., `1024x1024`) |
| `quality`         | string  | No       | `standard` or `hd`             |
| `style`           | string  | No       | `natural` or `vivid`           |
| `response_format` | string  | No       | `url` or `b64_json`            |

Response [#response]

```json
{
  "created": 1709251200,
  "data": [
    {
      "url": "https://api.yuhuanstudio.com/v1/temp-images/abc123.png",
      "revised_prompt": "A serene mountain landscape..."
    }
  ]
}
```

Edit Images [#edit-images]

```
POST /v1/images/edits
```

Edit or inpaint existing images:

```python
response = client.images.edit(
    model="model-id",
    image=open("original.png", "rb"),
    mask=open("mask.png", "rb"),
    prompt="Replace the sky with a starry night",
    n=1,
    size="1024x1024"
)
```

Examples [#examples]

<Tabs items="[&#x22;Python&#x22;, &#x22;JavaScript&#x22;, &#x22;cURL&#x22;]">
  <Tab value="Python">
    ```python
    from openai import OpenAI

    client = OpenAI(
        api_key="YOUR_API_KEY",
        base_url="https://api.yuhuanstudio.com/v1"
    )

    response = client.images.generate(
        model="model-id",
        prompt="A futuristic city with flying cars, cyberpunk style",
        size="1024x1024",
        quality="hd",
        n=1,
    )

    print(response.data[0].url)
    ```
  </Tab>

  <Tab value="JavaScript">
    ```javascript
    const response = await client.images.generate({
      model: "model-id",
      prompt: "A futuristic city with flying cars, cyberpunk style",
      size: "1024x1024",
      quality: "hd",
      n: 1,
    });

    console.log(response.data[0].url);
    ```
  </Tab>

  <Tab value="cURL">
    ```bash
    curl https://api.yuhuanstudio.com/v1/images/generations \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -d '{
        "model": "model-id",
        "prompt": "A futuristic city with flying cars, cyberpunk style",
        "size": "1024x1024",
        "quality": "hd",
        "n": 1
      }'
    ```
  </Tab>
</Tabs>

Image Models [#image-models]

<Callout type="info">
  For a list of available image models and their capabilities, please use the [Models API](/docs/models-api) with `GET /v1/models?type=image_generation`.
</Callout>
