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

# 编辑图像

> 根据一张或多张源图与提示词生成编辑/扩展后的图像。以 `multipart/form-data` 提交：单张用 `image`，多张用重复的 `image[]`，可附带 `mask`。



## OpenAPI

````yaml https://cdn.amux.ai/data/gpt-image-2-official.openapi.zh.json post /v1/images/edits
openapi: 3.1.0
info:
  title: amux 图像 API — gpt-image-2-official
  version: 1.0.0
  description: >-
    在 amux（https://api.amux.ai）上使用 `gpt-image-2-official` 模型进行图像生成与编辑，兼容 OpenAI
    图像接口。图像统一以 base64 返回（`data[].b64_json`）。
servers:
  - url: https://api.amux.ai
    description: amux API
security:
  - bearerAuth: []
tags:
  - name: images
    description: 图像生成与编辑
paths:
  /v1/images/edits:
    post:
      tags:
        - images
      summary: 编辑图像
      description: >-
        根据一张或多张源图与提示词生成编辑/扩展后的图像。以 `multipart/form-data` 提交：单张用 `image`，多张用重复的
        `image[]`，可附带 `mask`。
      operationId: createImageEdit
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/CreateImageEditRequest'
            encoding:
              image:
                contentType: image/png, image/jpeg, image/webp
              image[]:
                contentType: image/png, image/jpeg, image/webp
              mask:
                contentType: image/png
      responses:
        '200':
          description: 编辑后的图像。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImagesResponse'
              example:
                created: 1713833628
                background: opaque
                data:
                  - b64_json: <base64-png>
                output_format: png
                quality: auto
                size: 1024x1024
                usage:
                  input_tokens: 12
                  input_tokens_details:
                    image_tokens: 1
                    text_tokens: 11
                  output_tokens: 4096
                  total_tokens: 4108
                  output_tokens_details:
                    image_tokens: 4096
                    text_tokens: 0
        '400':
          description: 请求无效。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: 缺少或无效的 API Key。
components:
  schemas:
    CreateImageEditRequest:
      type: object
      required:
        - image
        - prompt
      additionalProperties: false
      description: multipart/form-data 请求体。
      properties:
        image:
          type: string
          format: binary
          description: 待编辑的输入图像（png/jpeg/webp）。多张输入请改用重复的 `image[]` 字段。
        image[]:
          type: array
          items:
            type: string
            format: binary
          description: 多张输入图像（重复表单字段，最多 16 张）。
        prompt:
          type: string
          maxLength: 32000
          description: 描述所需编辑的指令。
        mask:
          type: string
          format: binary
          description: 可选 PNG 蒙版；完全透明（alpha=0）区域为待编辑区域。
        model:
          type: string
          default: gpt-image-2-official
          enum:
            - gpt-image-2-official
        input_fidelity:
          type: string
          enum:
            - high
            - low
          description: 对原始输入图像的保真程度。
        'n':
          type: integer
          minimum: 1
          maximum: 10
          default: 1
          description: 生成的编辑图数量。
        size:
          type: string
          default: auto
          examples:
            - auto
            - 1024x1024
            - 1536x1024
            - 1024x1536
          description: 输出尺寸（规则同生成接口）。
        quality:
          type: string
          enum:
            - low
            - medium
            - high
            - auto
          default: auto
        background:
          type: string
          enum:
            - opaque
            - auto
          default: auto
          description: 背景处理。暂不支持透明背景。
        output_format:
          type: string
          enum:
            - png
            - jpeg
          default: png
          description: 输出图像格式。
        output_compression:
          type: integer
          minimum: 0
          maximum: 100
          default: 100
          description: '`jpeg` 输出的压缩级别。'
        moderation:
          type: string
          enum:
            - low
            - auto
          default: auto
        user:
          type: string
          description: 用于滥用监测的终端用户标识。
    ImagesResponse:
      type: object
      required:
        - created
        - data
      properties:
        created:
          type: integer
          description: Unix 时间戳（秒）。
        background:
          type: string
          enum:
            - opaque
        data:
          type: array
          items:
            $ref: '#/components/schemas/ImageObject'
        output_format:
          type: string
          enum:
            - png
            - jpeg
        quality:
          type: string
          enum:
            - low
            - medium
            - high
        size:
          type: string
          description: 实际渲染尺寸，如 `1024x1024`。
        usage:
          $ref: '#/components/schemas/Usage'
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            param:
              type: string
              nullable: true
            code:
              type: string
              nullable: true
    ImageObject:
      type: object
      properties:
        b64_json:
          type: string
          description: Base64 编码的图像字节。
    Usage:
      type: object
      required:
        - input_tokens
        - output_tokens
        - total_tokens
      properties:
        input_tokens:
          type: integer
        input_tokens_details:
          type: object
          properties:
            image_tokens:
              type: integer
            text_tokens:
              type: integer
        output_tokens:
          type: integer
        total_tokens:
          type: integer
        output_tokens_details:
          type: object
          properties:
            image_tokens:
              type: integer
            text_tokens:
              type: integer
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'API Key 通过 `Authorization: Bearer <key>` 传入。'

````