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

# 即梦图像编辑

> 使用 `POST /v1/images/edits` 基于参考图编辑生成新图像。

# 即梦图像编辑

OpenAI 兼容格式的图像编辑接口，使用 `multipart/form-data` 提交，支持基于参考图生成新图像。

* 路由入口是 `POST /v1/images/edits`。
* 当前使用 `multipart/form-data` 提交。
* 必须传入参考图片文件进行编辑。
* 支持即梦模型的图像编辑能力。

## 支持模型

* `jimeng-4.0`：即梦 4.0 模型
* `jimeng-4.5`：即梦 4.5 模型

## 方法与路径

```http theme={null}
POST /v1/images/edits
```

## 请求示例

<CodeGroup>
  ```bash theme={null}
  curl -X POST https://octopusx.ai/v1/images/edits \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -F "model=jimeng-4.0" \
    -F "prompt=参考图片生成写实类型的图像" \
    -F "image=@/path/to/image.png" \
    -F "n=1" \
    -F "ratio=16:9"
  ```

  ```python theme={null}
  import requests

  with open("image.png", "rb") as f:
      resp = requests.post(
          "https://octopusx.ai/v1/images/edits",
          headers={"Authorization": "Bearer YOUR_API_KEY"},
          data={
              "model": "jimeng-4.0",
              "prompt": "参考图片生成写实类型的图像",
              "n": 1,
              "ratio": "16:9",
          },
          files={"image": f},
          timeout=60,
      )
      print(resp.json())
  ```
</CodeGroup>

## 响应示例

<ResponseExample>
  ```json 200 theme={null}
  {
    "created": 1735689600,
    "data": [
      {
        "url": "https://example.com/edited-image.png",
        "revised_prompt": "参考图片生成写实类型的图像"
      }
    ]
  }
  ```
</ResponseExample>

## 认证

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

## Body

<ParamField body="model" type="string">
  模型名称。例如 `jimeng-4.0`、`jimeng-4.5`。
</ParamField>

<ParamField body="prompt" type="string" required>
  提示词。描述编辑内容的文本，支持中文和英文。
</ParamField>

<ParamField body="image" type="file" required>
  要编辑的图片。上传单个图片文件，用于编辑。必须是受支持的图片文件，支持 png、webp、jpg 格式，每张图片大小不超过 25MB。
</ParamField>

<ParamField body="n" type="integer">
  图像数量。生成图片的数量，默认为 1。
</ParamField>

<ParamField body="ratio" type="string">
  生成图像的尺寸比例。例如 `16:9`、`1:1`、`9:16` 等。
</ParamField>

<ParamField body="quality" type="string">
  生成图像的质量。`auto`（默认）将自动为给定模型选择最佳质量。`gpt-image-l` 支持 `high`、`medium`、`low`；`dall-e-3` 支持 `hd`、`standard`；`dall-e-2` 只支持 `standard`。
</ParamField>

<ParamField body="response_format" type="string">
  返回生成图像的格式。必须是 `url` 或 `b64_json` 之一。
</ParamField>

<ParamField body="resolution" type="string">
  分辨率。可选值：`1k`、`2k`、`4k`。
</ParamField>

## Response

<ResponseField name="created" type="integer">
  生成时间戳（Unix 时间戳）。
</ResponseField>

<ResponseField name="data" type="array">
  生成结果数组。
</ResponseField>

<ResponseField name="data[].url" type="string">
  生成图片的 URL 地址。
</ResponseField>

<ResponseField name="data[].revised_prompt" type="string">
  改写后的提示词（部分上游会返回）。
</ResponseField>

## 相关接口

* [即梦图像概览](./overview)
* [图像生成](./generation)
* [官方格式生图](./official-generation)
* [官方格式查询](./official-query)
