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

# MAI Image 2.7 Flash 图像编辑

> MAI Image 2.7 Flash 图像编辑 API 快速编辑一张图片或把最多 5 张参考图合成一张 1K 或 2K 结果，支持自定义尺寸和透明背景。

> [!TIP]
>
> 1. 提交后会返回 `task_id`。如果提供了 `callback_url`，当任务状态变为 `finished` 或 `failed` 时，系统会向 `callback_url` 发送 POST 请求。
> 2. 无论是否提供 `callback_url`，都可以通过统一的[查询任务状态](https://docs.vidgo.ai/zh/api-manual/task-management/status.md)接口获取结果。

MAI Image 2.7 Flash 图像编辑根据文字指令修改图片，或把多张参考图组合成一张新图。MAI Image 2.7 Flash 是微软 MAI Image 2.7 更快、成本更低的版本，适合草图和批量生成。

只用提示词生成图片时，请使用 [MAI Image 2.7 Flash 文生图](https://docs.vidgo.ai/zh/api-manual/image-series/microsoft-mai-image-2-7-flash-text-to-image.md)。MAI Image 2.7 Flash 与 MAI Image 2.7 参数相同，参见 [MAI Image 2.7 文生图](https://docs.vidgo.ai/zh/api-manual/image-series/microsoft-mai-image-2-7-text-to-image.md)。

## 模型

* **microsoft/mai-image-2.7-flash/edit** — MAI Image 2.7 Flash 图像编辑，1–5 张参考图，每次一张图片。

## 功能

* 编辑一张图片，或组合最多 5 张参考图（JPEG、PNG 或 WebP）。
* 省略 `size` 时，输出沿用第一张参考图的宽高比，约 100 万像素。
* 宽高比预设（`1K` 或 `2K`），或最多 4,194,304 像素的自定义尺寸。
* 透明背景；PNG、JPEG 或 WebP 输出。

## 必填参数

* `prompt` (string)：编辑指令。1–32,000 个字符的文本。
* `image_urls` (string\[])：1–5 张参考图（JPEG、PNG 或 WebP），使用公开可访问的 HTTP(S) URL。一张图时编辑该图，多张图时组合。

## 可选参数

* `size` (string)：宽高比预设或自定义 `WIDTHxHEIGHT`。省略时输出沿用第一张参考图的宽高比，约 100 万像素。参见[尺寸](#尺寸)。
* `resolution` (string)：`1K` 或 `2K`。默认 `1K`。只对宽高比预设生效。
* `background` (string)：`opaque` 或 `transparent`。默认 `opaque`。`transparent` 要求 `output_format` 为 `png` 或 `webp`。
* `output_format` (string)：`png`、`jpeg` 或 `webp`。默认 `png`。

## 尺寸

* 预设：`1:1`、`4:3`、`3:4`、`3:2`、`2:3`、`16:9`、`9:16`，按所选 `resolution` 出图：`1K` 约 100 万像素（`1:1` 为 1024x1024），`2K` 约 400 万像素（`16:9` 为 2720x1536）。
* 自定义 `WIDTHxHEIGHT`（用 `x` 或 `X`，例如 `3072x1344`）：两边都必须是 16 的倍数，每边至少 768 像素，总像素最多 4,194,304。图片按给定尺寸原样输出，其他自定义值返回 400。`resolution` 用于比例预设。

## 示例

* **编辑一张图片**：更换背景，尺寸沿用参考图。
* **组合图片**：两张参考图合成，`4:3`、`2K`。
* **透明抠图**：`background: transparent`，PNG。

## 注意事项

* 每次请求返回一张图片。`input` 接收上文列出的字段，其他字段返回 400。`model` 和 `callback_url` 放在请求根级，与 `input` 并列。
* `background: transparent` 搭配 `output_format: jpeg` 会返回 400。
* `image_urls` 接收 1–5 个有效的 HTTP(S) URL，其他值返回 400。超过约 100 万像素的参考图会在生成前缩小。
* 按 token 计费：提示词文本 token、参考图 token（按像素数计，每张最多约 100 万像素）和输出图片 token（输出宽 × 高 / 1024）。价格随输出尺寸变化，`2K` 和更大的自定义尺寸费用更高。提交时按本次请求的上限预扣，任务完成后按实际输出尺寸结算，最多为预扣金额，多余部分退还。任务失败会全额退还。当前费率见[定价页](https://vidgo.ai/apis/api-pricing)。


## OpenAPI

````yaml zh/api-manual/image-series/microsoft-mai-image-2-7-flash-edit.json POST /api/generate/submit
openapi: 3.0.0
info:
  title: Vidgo API - MAI Image 2.7 Flash 图像编辑
  description: >-
    MAI Image 2.7 Flash 图像编辑 API 快速编辑一张图片或把最多 5 张参考图合成一张 1K 或 2K
    结果，支持自定义尺寸和透明背景。
  version: 1.0.0
servers:
  - url: https://api.vidgo.ai
    description: 生产环境服务器
security:
  - BearerAuth: []
paths:
  /api/generate/submit:
    post:
      tags:
        - MAI Image 2.7 Flash Edit
      summary: 提交 MAI Image 2.7 Flash 图像编辑 任务
      operationId: submitMAIImage27FlashEditTask
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubmitRequest'
            examples:
              single-edit:
                summary: 编辑一张图片
                value:
                  model: microsoft/mai-image-2.7-flash/edit
                  input:
                    prompt: >-
                      Replace the background with a sunlit marble kitchen
                      counter and keep the product unchanged.
                    image_urls:
                      - https://cdn.vidgo.ai/temp/reference-product.png
              combine:
                summary: 以 2K 组合参考图
                value:
                  model: microsoft/mai-image-2.7-flash/edit
                  input:
                    prompt: >-
                      Put the label from the second image on the bottle from the
                      first image, studio lighting.
                    image_urls:
                      - https://cdn.vidgo.ai/temp/reference-product.png
                      - https://cdn.vidgo.ai/temp/reference-label.png
                    size: '4:3'
                    resolution: 2K
              transparent:
                summary: 透明抠图
                value:
                  model: microsoft/mai-image-2.7-flash/edit
                  input:
                    prompt: Remove the background and keep only the product.
                    image_urls:
                      - https://cdn.vidgo.ai/temp/reference-product.png
                    background: transparent
                    output_format: png
      responses:
        '200':
          description: 任务提交结果。任务 ID 标识一项异步任务；生成可能仍在进行中。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmitResponse'
        '400':
          description: 请求参数无效
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: 未授权
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    SubmitRequest:
      type: object
      required:
        - model
        - input
      additionalProperties: false
      properties:
        model:
          type: string
          example: microsoft/mai-image-2.7-flash/edit
        callback_url:
          type: string
          format: uri
          description: 可选的 Webhook URL，用于接收完成或失败通知。
          example: https://your-domain.com/callback
        input:
          type: object
          required:
            - prompt
            - image_urls
          additionalProperties: false
          properties:
            prompt:
              type: string
              minLength: 1
              maxLength: 32000
              description: |-
                描述图片或所需编辑的提示词。图中需要出现的文字请放在引号里。

                至少包含一个非空白字符。
            image_urls:
              type: array
              minItems: 1
              maxItems: 5
              items:
                type: string
                format: uri
                description: 使用公开可访问的 HTTP(S) 下载链接。
              description: 必填，1–5 张参考图（JPEG、PNG 或 WebP）。一张图时编辑该图，多张图时组合。
            size:
              type: string
              description: |-
                宽高比预设或自定义 WIDTHxHEIGHT。

                预设：`1:1`、`4:3`、`3:4`、`3:2`、`2:3`、`16:9`、`9:16`。

                自定义尺寸要求两边都能被 16 整除、每边至少 768、总像素最多 4194304。

                省略时，输出沿用第一张参考图的宽高比，约 100 万像素。
            resolution:
              type: string
              enum:
                - 1K
                - 2K
              default: 1K
              description: 宽高比预设使用的分辨率档位。1K 约 100 万像素，2K 约 400 万像素。用于比例预设。
            background:
              type: string
              enum:
                - opaque
                - transparent
              default: opaque
              description: 背景类型。transparent 输出带透明通道的图片，要求 output_format 为 png 或 webp。
            output_format:
              type: string
              enum:
                - png
                - jpeg
                - webp
              default: png
              description: 输出图片格式。
    SubmitResponse:
      type: object
      required:
        - code
        - data
      properties:
        code:
          type: integer
          example: 200
        data:
          type: object
          required:
            - task_id
            - status
            - created_time
          properties:
            task_id:
              type: string
              example: task-example-001
            status:
              type: string
              example: not_started
            created_time:
              type: string
              format: date-time
              example: '2026-11-19T10:30:00'
    ErrorResponse:
      type: object
      required:
        - detail
      properties:
        detail:
          type: string
          description: 错误信息。参见[错误码](/zh/api-manual/error-codes)。
          example: prompt is required
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: '使用 `Authorization: Bearer VIDGO_API_KEY`。'

````

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