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

# gpt-image-2-图片编辑

> 使用 GPT Image 2 模型基于文本提示词编辑已有图片，请求体格式为 multipart/form-data。

每次请求最多支持 16 张输入图片（`image[]`）。支持格式：PNG、JPEG。图片必须通过 multipart/form-data 文件上传方式传入。



## OpenAPI

````yaml zh/api-reference/model-api/openai/openapi/gpt-image-2-edit/openapi.yaml POST /v1/images/edits
openapi: 3.1.0
info:
  title: GPT Image 2 — 图片编辑
  description: 通过 Anyfast API 使用 GPT Image 2 编辑已有图片
  version: 1.0.0
servers:
  - url: https://www.anyfast.ai
security:
  - bearerAuth: []
paths:
  /v1/images/edits:
    post:
      summary: 编辑图片
      description: >-
        使用 GPT Image 2 模型基于文本提示词编辑已有图片，请求体格式为 multipart/form-data。


        每次请求最多支持 16 张输入图片（`image[]`）。支持格式：PNG、JPEG。图片必须通过 multipart/form-data
        文件上传方式传入。
      operationId: editGptImage2
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - model
                - prompt
              properties:
                image:
                  type: string
                  format: binary
                  description: 单张源图片文件（PNG 或 JPEG）。多图时请改用 `image[]`。
                image[]:
                  type: array
                  items:
                    type: string
                    format: binary
                  description: 多张源图片文件（PNG 或 JPEG），每次请求最多 16 张。多图时用此参数替代 `image`。
                mask:
                  type: string
                  format: binary
                  description: >-
                    蒙版图片文件（含 Alpha 通道），用于指定源图片中要编辑的区域。必须与源图片格式和尺寸一致（<
                    50MB）。**需在控制台选择 Direct 分组。**
                model:
                  type: string
                  enum:
                    - gpt-image-2
                  description: 模型 ID。
                  example: gpt-image-2
                prompt:
                  type: string
                  description: 编辑指令文本。
                  example: 将图片背景替换为海上日落
                output_format:
                  type: string
                  enum:
                    - png
                    - jpeg
                  default: png
                  description: 输出图片格式，默认 `png`。
                output_compression:
                  type: integer
                  minimum: 0
                  maximum: 100
                  description: jpeg 格式的压缩级别（0–100）。
                'n':
                  type: integer
                  minimum: 1
                  maximum: 10
                  default: 1
                  description: 返回图片数量，支持 `1–10`，默认 `1`。**需在控制台选择 Direct 分组。**
                  example: 1
                size:
                  type: string
                  default: 1024x1024
                  description: 输出图片尺寸，格式 `{宽}x{高}`，约束与图片生成接口一致（灵活分辨率）。
                  example: 1024x1024
      responses:
        '200':
          description: 图片编辑成功。
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    description: 编辑后的图片数组。
                    items:
                      type: object
                      properties:
                        b64_json:
                          type: string
                          description: Base64 编码的图片数据。
                        revised_prompt:
                          type: string
                          description: 模型实际使用的修改后提示词。
        '400':
          description: 请求错误。参数无效。
        '401':
          description: 未授权。API 密钥无效或缺失。
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````