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

# /v1/images/edits

> 根据一张或多张输入图片和提示词创建编辑图像。支持 multipart/form-data 上传本地文件，也支持 application/json 传入图片 URL、纯 Base64 或 Data URI。



## OpenAPI

````yaml POST /v1/images/edits
openapi: 3.1.0
info:
  title: TokenOps AI API
  description: TokenOps AI API 提供了强大的AI服务能力，包括聊天对话、Gemini模型集成等功能。
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.tokenops.ai
    description: TokenOps AI API 生产环境
security: []
paths:
  /v1/images/edits:
    post:
      tags:
        - Images
      summary: 创建图像编辑
      description: >-
        根据一张或多张输入图片和提示词创建编辑图像。支持 multipart/form-data 上传本地文件，也支持 application/json
        传入图片 URL、纯 Base64 或 Data URI。
      operationId: createImageEdit
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/CreateImageEditRequest'
            examples:
              basic_edit:
                summary: 基础图像编辑
                description: 编辑图像的某个部分
                value:
                  image: '@image.png'
                  prompt: 在图片中添加一朵红色的玫瑰花
                  'n': 1
                  size: 1024x1024
          application/json:
            schema:
              $ref: '#/components/schemas/CreateImageEditJSONRequest'
            examples:
              url_edit:
                summary: 使用图片 URL 编辑
                value:
                  model: gpt-image-2.5-sunburst
                  prompt: 保留主体构图，将画面转换为干净的水彩海报
                  image:
                    - https://example.com/original.png
                  size: 1024x1024
                  quality: medium
                  input_fidelity: high
                  output_format: jpeg
                  output_compression: 80
                  response_format: url
              base64_edit:
                summary: 使用 Base64 图片编辑
                value:
                  model: gpt-image-2.5-flare
                  prompt: 给主体加上一顶红色帽子
                  image:
                    - data:image/png;base64,<BASE64_DATA>
                  quality: low
      responses:
        '200':
          description: 图像编辑成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImagesResponse'
              examples:
                success_response:
                  summary: 图像编辑成功
                  value:
                    created: 1589478378
                    data:
                      - url: >-
                          https://oaidalleapiprodscus.blob.core.windows.net/private/org-xyz/user-abc/img-edited.png
                    usage:
                      input_tokens: 18
                      input_tokens_details:
                        image_tokens: 5
                        text_tokens: 13
                      output_tokens: 205
                      output_tokens_details:
                        image_tokens: 205
                        text_tokens: 0
                      total_tokens: 223
                    generate_image: 1
        '400':
          description: 请求参数错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - OpenAIAuth: []
components:
  schemas:
    CreateImageEditRequest:
      type: object
      required:
        - image
        - model
        - prompt
      properties:
        image:
          anyOf:
            - type: string
              format: binary
            - type: array
              items:
                type: string
                format: binary
          description: >-
            要编辑的图像。必须是支持的图像文件或图像数组。对于 gpt-image-1，每个图像应为 png、webp 或 jpg 文件，小于
            50MB。最多可提供 16 个图像。对于 dall-e-2，只能提供一个图像，且应为正方形 png 文件，小于 4MB
        prompt:
          type: string
          description: 描述所需图像的文本提示。dall-e-2 最大长度为 1000 个字符，gpt-image-1 最大长度为 32000 个字符
          maxLength: 32000
          example: 在图片中添加一朵红色的玫瑰花
        background:
          anyOf:
            - type: string
              enum:
                - transparent
                - opaque
                - auto
            - type: 'null'
          description: >-
            设置生成图像背景的透明度。此参数仅支持 gpt-image-1。必须是 transparent、opaque 或
            auto（默认值）之一。当使用 auto 时，模型将自动确定图像的最佳背景。如果是
            transparent，输出格式需要支持透明度，因此应设置为 png（默认值）或 webp
          default: auto
        input_fidelity:
          type: string
          enum:
            - high
            - low
          description: >-
            控制模型匹配输入图片风格和特征的努力程度。GPT Image 2.5 当前仅 gpt-image-2.5-sunburst 支持
            high；Flare 请省略此字段。其他模型以模型说明为准
        mask:
          type: string
          format: binary
          description: >-
            一个额外的图像，其完全透明的区域（例如 alpha 为零的地方）指示应该编辑图像的位置。如果提供了多个图像，mask
            将应用于第一个图像。必须是有效的 PNG 文件，小于 4MB，并且与图像具有相同的尺寸
        model:
          anyOf:
            - type: string
              enum:
                - gpt-image-2.5-flare
                - gpt-image-2.5-sunburst
                - gpt-image-2-2026-04-21
                - gpt-image-2
                - gpt-image-1.5
                - gpt-image-1-mini
                - gpt-image-1
                - dall-e-2
            - type: 'null'
          description: 用于图片编辑的模型。新接入推荐 gpt-image-2.5-sunburst；低延迟场景可选 gpt-image-2.5-flare
          example: gpt-image-2.5-sunburst
        'n':
          anyOf:
            - type: integer
              minimum: 1
              maximum: 10
            - type: 'null'
          description: 要生成的图像数量。必须在 1 到 10 之间
          default: 1
        output_compression:
          anyOf:
            - type: integer
              minimum: 0
              maximum: 100
            - type: 'null'
          description: 生成图像的压缩级别（0-100%）。此参数仅支持使用 webp 或 jpeg 输出格式的 gpt-image-1，默认为 100
          default: 100
        output_format:
          anyOf:
            - type: string
              enum:
                - png
                - jpeg
                - webp
            - type: 'null'
          description: 输出图片格式。GPT Image 2.5 当前平台接入支持 png 或 jpeg，暂不支持 webp
          default: png
        partial_images:
          type: integer
          minimum: 0
          maximum: 3
          description: >-
            要生成的部分图像数量。此参数用于返回部分图像的流式响应。值必须在 0 到 3 之间。当设置为 0
            时，响应将是在一个流式事件中发送的单个图像。注意，如果完整图像生成得更快，最终图像可能会在生成完整数量的部分图像之前发送
          default: 0
        quality:
          anyOf:
            - type: string
              enum:
                - auto
                - max
                - xhigh
                - high
                - medium
                - low
                - standard
            - type: 'null'
          description: >-
            图像质量。GPT Image 2.5 支持 auto、low、medium、high、xhigh 和 max；dall-e-2 仅支持
            standard
          default: auto
        response_format:
          anyOf:
            - type: string
              enum:
                - url
                - b64_json
            - type: 'null'
          description: 平台响应格式。b64_json 直接返回图片 Base64；url 会由平台转存图片并返回签名 URL
          default: b64_json
        size:
          anyOf:
            - type: string
              enum:
                - 1024x1024
                - 1536x1024
                - 1024x1536
                - auto
                - 256x256
                - 512x512
            - type: 'null'
          description: >-
            生成图像的尺寸。gpt-image-1 必须是 1024x1024、1536x1024（横向）、1024x1536（纵向）或
            auto（默认值）之一。dall-e-2 必须是 256x256、512x512 或 1024x1024 之一
          default: 1024x1024
        stream:
          anyOf:
            - type: boolean
            - type: 'null'
          description: 以流式模式编辑图像。默认为 false。有关更多信息，请参阅图像生成指南
          default: false
        user:
          type: string
          description: 代表您的最终用户的唯一标识符，可以帮助 OpenAI 监控和检测滥用
    CreateImageEditJSONRequest:
      type: object
      required:
        - model
        - prompt
        - image
      properties:
        model:
          type: string
          enum:
            - gpt-image-2.5-flare
            - gpt-image-2.5-sunburst
            - gpt-image-2-2026-04-21
            - gpt-image-2
            - gpt-image-1.5
            - gpt-image-1-mini
            - gpt-image-1
          description: 用于图片编辑的模型
          example: gpt-image-2.5-sunburst
        prompt:
          type: string
          maxLength: 32000
          description: 描述需要对输入图片进行的修改
          example: 保留主体构图，将画面转换为干净的水彩海报
        image:
          type: array
          items:
            type: string
          minItems: 1
          maxItems: 16
          description: >-
            最多 16 张图片，即使只有一张也需使用数组。每项支持 HTTP(S) URL、纯 Base64 或
            data:image/...;base64,... Data URI
        mask:
          type: string
          description: >-
            可选遮罩图片，支持 HTTP(S) URL、纯 Base64 或 Data URI。PNG
            透明区域表示需要编辑的位置，尺寸须与第一张输入图一致
        'n':
          type: integer
          enum:
            - 1
          default: 1
          description: GPT Image 2.5 同步接口当前每次返回一张图片
        size:
          type: string
          enum:
            - 1024x1024
            - 1536x1024
            - 1024x1536
            - auto
          default: auto
          description: 输出图片尺寸
        quality:
          type: string
          enum:
            - auto
            - low
            - medium
            - high
            - xhigh
            - max
          default: auto
          description: 图片质量；档位越高，通常耗时、输出 token 和费用越高
        output_format:
          type: string
          enum:
            - png
            - jpeg
          default: png
          description: 当前平台接入暂不支持 webp
        output_compression:
          type: integer
          minimum: 0
          maximum: 100
          description: 当前仅在 output_format=jpeg 时使用
        background:
          type: string
          enum:
            - auto
            - opaque
            - transparent
          default: auto
          description: 透明背景请配合 output_format=png
        moderation:
          type: string
          enum:
            - auto
            - low
          default: auto
          description: 内容审核强度
        input_fidelity:
          type: string
          enum:
            - high
          description: 仅 gpt-image-2.5-sunburst 支持；Flare 请省略
        response_format:
          type: string
          enum:
            - b64_json
            - url
          default: b64_json
          description: url 为平台转存后返回的签名 URL
        user:
          type: string
          description: 业务侧最终用户标识，便于审计
    ImagesResponse:
      type: object
      required:
        - created
        - data
      properties:
        background:
          type: string
          enum:
            - transparent
            - opaque
            - auto
          description: OpenAI 兼容保留字段，上游可能回传实际背景设置。当前 Azure / QNAIGC GPT Image 2.5 适配器不返回
        created:
          type: integer
          format: int64
          description: 图像创建时的 Unix 时间戳（以秒为单位）
          example: 1677649963
        data:
          type: array
          description: 生成的图像列表
          items:
            $ref: '#/components/schemas/Image'
        output_format:
          type: string
          enum:
            - png
            - webp
            - jpeg
          description: OpenAI 兼容保留字段，上游可能回传实际图片格式。当前 Azure / QNAIGC GPT Image 2.5 适配器不返回
        quality:
          type: string
          enum:
            - low
            - medium
            - high
            - xhigh
            - max
            - auto
          description: OpenAI 兼容保留字段，上游可能回传实际质量档位。当前 Azure / QNAIGC GPT Image 2.5 适配器不返回
        size:
          type: string
          description: >-
            OpenAI 兼容保留字段，上游可能回传实际图片尺寸，例如 1024x1024。当前 Azure / QNAIGC GPT Image
            2.5 适配器不返回
        usage:
          $ref: '#/components/schemas/ImageUsage'
          description: GPT Image 模型的 token 使用信息。仅在上游提供 usage 时出现
        generate_image:
          type: integer
          minimum: 0
          description: 平台扩展字段，本次成功生成的图片张数。它不是 token，不应加到 total_tokens
        generate_image_r1:
          type: integer
          minimum: 0
          description: 平台扩展字段，R1 分辨率计费档位的图片张数；仅部分按张或档位计费的模型返回
        generate_image_r2:
          type: integer
          minimum: 0
          description: 平台扩展字段，R2 分辨率计费档位的图片张数；仅部分按张或档位计费的模型返回
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/Status'
          description: 错误信息
    Image:
      type: object
      properties:
        b64_json:
          type: string
          description: response_format=b64_json 或未传时返回的图片 Base64。与 url 按返回格式二选一
        revised_prompt:
          type: string
          description: 仅适用于 dall-e-3，用于生成图像的修订提示
          example: 一只可爱的小海獭仰躺在平静的蓝色水面上
        url:
          type: string
          format: uri
          description: response_format=url 时由平台转存并返回的签名 URL。与 b64_json 按返回格式二选一，URL 会过期
          example: https://model-static.skyengine.com.cn/<uid>/images/generated_xxx.png
    ImageUsage:
      type: object
      description: GPT Image 模型的 token 使用信息。字段缺失不等于数值为 0，以渠道实际上报为准
      properties:
        input_tokens:
          type: integer
          description: 输入提示中的 token 数量（图像和文本）
        input_tokens_details:
          $ref: '#/components/schemas/ImageInputTokensDetails'
          description: 图像生成的输入 token 详细信息
        output_tokens:
          type: integer
          description: 模型生成的输出 token 数量
        output_tokens_details:
          $ref: '#/components/schemas/ImageOutputTokensDetails'
          description: 图像生成的输出 token 详细信息
        total_tokens:
          type: integer
          description: 图像生成使用的 token 总数（图像和文本）
    Status:
      type: object
      properties:
        code:
          type: integer
          description: 错误代码
        message:
          type: string
          description: 错误消息
        details:
          type: array
          description: 错误详情
          items:
            type: object
            additionalProperties: true
    ImageInputTokensDetails:
      type: object
      description: 图像生成的输入 token 详细信息
      properties:
        image_tokens:
          type: integer
          description: 输入提示中的图像 token 数量
        text_tokens:
          type: integer
          description: 输入提示中的文本 token 数量
    ImageOutputTokensDetails:
      type: object
      description: 图像生成的输出 token 详细信息
      properties:
        image_tokens:
          type: integer
          description: 图片输出 token，按图片输出单价计费
        text_tokens:
          type: integer
          description: 输出文本 token；GPT Image 2.5 纯图片响应通常为 0 或省略，且不产生计费文本输出
  securitySchemes:
    OpenAIAuth:
      type: http
      scheme: bearer
      description: >-
        OpenAI API密钥认证。在 `Authorization` HTTP Header 中包含您的 API-Key，格式为 `Bearer
        {API_KEY}`

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.