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

# 编辑图片

> 使用图片和提示词创建编辑结果

请求使用 `multipart/form-data`。

| 字段                            | 类型           | 必填 | 说明                   |
| ----------------------------- | ------------ | -- | -------------------- |
| `image`                       | file/file\[] | 是  | 待编辑图片。格式、尺寸和数量受模型限制。 |
| `prompt`                      | string       | 是  | 期望的编辑结果。             |
| `model`                       | string       | 是  | 图片编辑模型 ID。           |
| `mask`                        | file         | 否  | 指示可编辑区域的遮罩。          |
| `n`, `size`, `quality`        | mixed        | 否  | 数量、尺寸与质量。            |
| `background`, `output_format` | string       | 否  | 背景与输出格式。             |
| `user`                        | string       | 否  | 终端用户标识。              |

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.bianxie.ai/v1/images/edits \
    -H "Authorization: Bearer API_KEY" \
    -F "model=your-model" \
    -F "prompt=添加一顶红色帽子" \
    -F "image=@input.png"
  ```

  ```python Python theme={null}
  client.images.edit(model="your-model", image=open("input.png", "rb"), prompt="添加一顶红色帽子")
  ```

  ```javascript Node.js theme={null}
  await client.images.edit({ model: "your-model", image: fs.createReadStream("input.png"), prompt: "Add a red hat" });
  ```
</CodeGroup>

响应结构与图片生成接口一致。不要手动设置 multipart boundary；让 HTTP 客户端生成。默认不支持流式输出。
