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

# 编辑图片

# 图像 (Images) - 编辑图像 (原生 OpenAI 格式)

在给定原始图像和提示的情况下创建编辑或扩展图像。

* **接口地址**: `POST /v1/images/edits`
* **请求格式 (Content-Type)**: `multipart/form-data`

## 认证与请求头 (Headers)

* `Authorization` (**必选**): 使用 Bearer Token 认证。格式: `Bearer <token>`

## 请求参数 (Request Body - FormData)

| 参数名               | 类型             | 必选    | 说明                                                                                       |
| :---------------- | :------------- | :---- | :--------------------------------------------------------------------------------------- |
| `image`           | File (binary)  | **是** | 要编辑的图像。必须是有效的 PNG 文件，大小小于 4MB，并且是方形的。如果未提供遮罩(`mask`)，图像必须具有透明度，该透明区域将被用作遮罩。              |
| `prompt`          | String         | **是** | 所需图像的文本描述。最小长度1，最大长度为 32000 个字符。                                                         |
| `mask`            | File (binary)  | 否     | 附加图像，其完全透明区域（例如，alpha 为零的区域）指示 `image` 应编辑的位置。必须是有效的 PNG 文件，大小小于 4MB，并且尺寸与原始 `image` 相同。 |
| `model`           | String         | 否     | 模型名称（如 `dall-e-2` 等）。                                                                    |
| `n`               | String/Integer | 否     | 要生成的图像数量。必须介于 1 和 10 之间。                                                                 |
| `size`            | String         | 否     | 生成图像的大小。必须是 `256x256`、`512x512` 或 `1024x1024` 之一。                                        |
| `response_format` | String         | 否     | 生成的图像返回的格式。必须是 `url` 或 `b64_json`。                                                       |
| `user`            | String         | 否     | 代表您的最终用户的唯一标识符，可以帮助监控和检测滥用行为。                                                            |

## 示例代码 (cURL)

```bash theme={null}
curl -X POST "[https://www.ominiapi.com/v1/images/edits/](https://www.ominiapi.com/v1/images/edits/)" \
  -H "Authorization: Bearer <您的_API_KEY>" \
  -F image="@/path/to/image.png" \
  -F prompt="A cute baby sea otter wearing a beret." \
  -F n="1" \
  -F size="1024x1024"
```

## 响应体结构 (Response - 200 OK)

成功请求将返回 JSON 格式结果，具体包含的内容取决于 response\_format 参数（返回图片 URL 列表或 Base64 字符串列表）。

```bash theme={null}
{
  "created": 1589478378,
  "data": [
    {
      "url": "https://..."
    }
  ]
}
```
