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

# /v1/images/edits

> 通过上传图像和描述所需更改的提示来创建编辑图像或扩展图像。要求图像必须是有效的PNG文件，小于4MB，并且是正方形。如果mask未提供，图像必须具有透明度，将被用作mask。



## 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://model-api.skyengine.com.cn
    description: TokenOps AI API 生产环境
security: []
paths:
  /v1/images/edits:
    post:
      tags:
        - Images
      summary: 创建图像编辑
      description: >-
        通过上传图像和描述所需更改的提示来创建编辑图像或扩展图像。要求图像必须是有效的PNG文件，小于4MB，并且是正方形。如果mask未提供，图像必须具有透明度，将被用作mask。
      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
      responses:
        '200':
          description: 图像编辑成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImagesResponse'
              examples:
                success_response:
                  summary: 图像编辑成功
                  value:
                    created: 1589478378
                    background: auto
                    output_format: png
                    quality: high
                    size: 1024x1024
                    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: 1
                      total_tokens: 19
        '400':
          description: 请求参数错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - OpenAIAuth: []
components:
  schemas:
    CreateImageEditRequest:
      type: object
      required:
        - image
        - 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-1。gpt-image-1-mini
            不支持。支持 high 和 low，默认为 low
          default: low
        mask:
          type: string
          format: binary
          description: >-
            一个额外的图像，其完全透明的区域（例如 alpha 为零的地方）指示应该编辑图像的位置。如果提供了多个图像，mask
            将应用于第一个图像。必须是有效的 PNG 文件，小于 4MB，并且与图像具有相同的尺寸
        model:
          anyOf:
            - type: string
              enum:
                - dall-e-2
                - gpt-image-1
            - type: 'null'
          description: >-
            用于图像生成的模型。仅支持 dall-e-2 和 gpt-image-1。默认为 dall-e-2，除非使用特定于
            gpt-image-1 的参数
          default: dall-e-2
        '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-1。必须是 png、jpeg 或 webp 之一。默认值为 png
          default: png
        partial_images:
          type: integer
          minimum: 0
          maximum: 3
          description: >-
            要生成的部分图像数量。此参数用于返回部分图像的流式响应。值必须在 0 到 3 之间。当设置为 0
            时，响应将是在一个流式事件中发送的单个图像。注意，如果完整图像生成得更快，最终图像可能会在生成完整数量的部分图像之前发送
          default: 0
        quality:
          anyOf:
            - type: string
              enum:
                - auto
                - high
                - medium
                - low
                - standard
            - type: 'null'
          description: >-
            将要生成的图像质量。gpt-image-1 仅支持 high、medium 和 low。dall-e-2 仅支持 standard
            质量。默认为 auto
          default: auto
        response_format:
          anyOf:
            - type: string
              enum:
                - url
                - b64_json
            - type: 'null'
          description: >-
            生成图像的返回格式。必须是 url 或 b64_json 之一。URL 仅在生成图像后的 60 分钟内有效。此参数仅支持
            dall-e-2，因为 gpt-image-1 始终返回 base64 编码的图像
          default: url
        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 监控和检测滥用
    ImagesResponse:
      type: object
      required:
        - created
        - data
      properties:
        background:
          type: string
          enum:
            - transparent
            - opaque
          description: 用于图像生成的背景参数。transparent 或 opaque
        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: 图像生成的输出格式。png、webp 或 jpeg
        quality:
          type: string
          enum:
            - low
            - medium
            - high
          description: 生成图像的质量。low、medium 或 high
        size:
          type: string
          enum:
            - 1024x1024
            - 1024x1536
            - 1536x1024
          description: 生成图像的尺寸。1024x1024、1024x1536 或 1536x1024
        usage:
          $ref: '#/components/schemas/ImageUsage'
          description: 仅适用于 gpt-image-1，图像生成的 token 使用信息
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/Status'
          description: 错误信息
    Image:
      type: object
      properties:
        b64_json:
          type: string
          description: >-
            生成图像的 base64 编码 JSON。gpt-image-1 的默认值，仅当 dall-e-2 和 dall-e-3 的
            response_format 设置为 b64_json 时才存在
        revised_prompt:
          type: string
          description: 仅适用于 dall-e-3，用于生成图像的修订提示
          example: 一只可爱的小海獭仰躺在平静的蓝色水面上
        url:
          type: string
          description: >-
            使用 dall-e-2 或 dall-e-3 时，如果 response_format 设置为 url（默认值），则为生成图像的
            URL。gpt-image-1 不支持
          example: >-
            https://oaidalleapiprodscus.blob.core.windows.net/private/org-abc123/user-abc123/img-abc123.png
    ImageUsage:
      type: object
      description: 仅适用于 gpt-image-1，图像生成的 token 使用信息
      properties:
        input_tokens:
          type: integer
          description: 输入提示中的 token 数量（图像和文本）
        input_tokens_details:
          $ref: '#/components/schemas/ImageInputTokensDetails'
          description: 图像生成的输入 token 详细信息
        output_tokens:
          type: integer
          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 数量
  securitySchemes:
    OpenAIAuth:
      type: http
      scheme: bearer
      description: >-
        OpenAI API密钥认证。在 `Authorization` HTTP Header 中包含您的 API-Key，格式为 `Bearer
        {API_KEY}`

````