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

# Create image edit

> 用 multipart/form-data 上传参考图并生成编辑结果。

`/v1/images/edits` 接受 `multipart/form-data`，把参考图作为文件上传。如果你的参考图已经是 URL 或 Data URL，更推荐用 [Create image generation](/api-reference/images/gpt-image-2/generation) 搭配 `image_urls` 走异步链路，更稳定。

## 请求地址

```http theme={null}
POST https://dimilinks.com/v1/images/edits
Content-Type: multipart/form-data
Authorization: Bearer <DIMILINKS_API_KEY>
```

至少上传一张 `image` 文件。

## 单图示例

```bash theme={null}
curl "https://dimilinks.com/v1/images/edits" \
  -H "Authorization: Bearer $DIMILINKS_API_KEY" \
  -F "model=gpt-image-2" \
  -F "prompt=把图片改成复古胶片风格，保留主体" \
  -F "size=16:9" \
  -F "resolution=2k" \
  -F "image=@/path/to/reference.png"
```

## 多图示例

最多上传 9 张参考图。

```bash theme={null}
curl "https://dimilinks.com/v1/images/edits" \
  -H "Authorization: Bearer $DIMILINKS_API_KEY" \
  -F "model=gpt-image-2" \
  -F "prompt=融合两张参考图的风格，生成电商主图" \
  -F "size=1:1" \
  -F "resolution=4k" \
  -F "image[]=@/path/to/ref-1.png" \
  -F "image[]=@/path/to/ref-2.png"
```

## 文件字段

| 字段                  | 说明               |
| ------------------- | ---------------- |
| `image`             | 单文件，推荐。          |
| `image[]`           | 多文件，最多 9 个。      |
| `images`            | 多文件兼容字段。         |
| `images[]`          | 多文件兼容字段。         |
| `image_1`、`image_2` | 编号字段兼容。          |
| `mask`              | 可选。当前会作为参考图一并处理。 |

## 响应

成功后返回与生成接口一致的结构：

```json theme={null}
{
  "created": 1777080000,
  "task_id": "img_xxx",
  "data": [
    {
      "url": "/p/img/img_xxx/0?exp=1777166400000&sig=...",
      "file_id": "file_xxx"
    }
  ]
}
```


## OpenAPI

````yaml POST /images/edits
openapi: 3.1.0
info:
  title: DimiLinks API
  description: >-
    DimiLinks unified API for chat (OpenAI-compatible and Anthropic native),
    image generation/editing, and video generation.
  version: 1.1.0
servers:
  - url: https://dimilinks.com/v1
    description: OpenAI 兼容入口：chat completions / images / videos / models / tasks
security:
  - bearerAuth: []
tags:
  - name: Models
  - name: Chat
  - name: Images
  - name: Videos
  - name: Tasks
paths:
  /images/edits:
    post:
      tags:
        - Images
      summary: Create image edit
      operationId: createImageEdit
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/ImageEditRequest'
      responses:
        '200':
          description: Image edit result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    ImageEditRequest:
      type: object
      properties:
        model:
          type: string
          default: gpt-image-2
        prompt:
          type: string
        size:
          type: string
        resolution:
          type: string
        image:
          type: string
          format: binary
        image[]:
          type: array
          items:
            type: string
            format: binary
          maxItems: 9
        mask:
          type: string
          format: binary
      required:
        - prompt
    ImageResponse:
      type: object
      properties:
        created:
          type: integer
          example: 1777080000
        task_id:
          type: string
          example: img_xxx
        data:
          type: array
          items:
            $ref: '#/components/schemas/ImageData'
    ImageData:
      type: object
      properties:
        url:
          type: string
          example: /p/img/img_xxx/0?exp=1777166400000&sig=...
        file_id:
          type: string
          example: file_xxx
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ErrorObject'
    ErrorObject:
      type: object
      properties:
        message:
          type: string
        type:
          type: string
          example: invalid_request_error
        code:
          oneOf:
            - type: string
            - type: integer
  responses:
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````