> ## 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 根据提示词快速生成一张 1K 或 2K 图片，支持 7 种宽高比、最高 400 万像素的自定义尺寸和透明输出。

> [!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-edit.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/text-to-image** — MAI Image 2.7 Flash 文生图，每次一张图片。

## 功能

* 7 种宽高比预设，`1K`（约 100 万像素）或 `2K`（约 400 万像素）。
* 自定义 `WIDTHxHEIGHT` 尺寸，最多 4,194,304 像素。
* 透明背景；PNG、JPEG 或 WebP 输出。
* 提示词最多 32,000 个字符。

## 必填参数

* `prompt` (string)：图片描述。1–32,000 个字符的文本。图中需要出现的文字请放在引号里。

## 可选参数

* `size` (string)：宽高比预设或自定义 `WIDTHxHEIGHT`。默认 `1:1`。参见[尺寸](#尺寸)。
* `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` 用于比例预设。

## 示例

* **1K 方图**：带引号标签文字的产品静物，使用默认参数。
* **2K 16:9**：约 400 万像素（2720x1536）的风景图。
* **透明抠图**：自定义 `3072x1344`，`background: transparent`，WebP。

## 注意事项

* 每次请求返回一张图片。`input` 接收上文列出的字段，其他字段返回 400。`model` 和 `callback_url` 放在请求根级，与 `input` 并列。
* `background: transparent` 搭配 `output_format: jpeg` 会返回 400。
* 使用参考图编辑请用 [MAI Image 2.7 Flash 图像编辑](https://docs.vidgo.ai/zh/api-manual/image-series/microsoft-mai-image-2-7-flash-edit.md)。
* 按 token 计费：提示词文本 token 和输出图片 token（输出宽 × 高 / 1024）。价格随输出尺寸变化，`2K` 和更大的自定义尺寸费用更高。提交时按本次请求的上限预扣，任务完成后按实际输出尺寸结算，最多为预扣金额，多余部分退还。任务失败会全额退还。当前费率见[定价页](https://vidgo.ai/apis/api-pricing)。


## OpenAPI

````yaml zh/api-manual/image-series/microsoft-mai-image-2-7-flash-text-to-image.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 根据提示词快速生成一张 1K 或 2K 图片，支持 7 种宽高比、最高 400
    万像素的自定义尺寸和透明输出。
  version: 1.0.0
servers:
  - url: https://api.vidgo.ai
    description: 生产环境服务器
security:
  - BearerAuth: []
paths:
  /api/generate/submit:
    post:
      tags:
        - MAI Image 2.7 Flash Text to Image
      summary: 提交 MAI Image 2.7 Flash 文生图 任务
      operationId: submitMAIImage27FlashTextToImageTask
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubmitRequest'
            examples:
              square-1k:
                summary: 1K 方图
                value:
                  model: microsoft/mai-image-2.7-flash/text-to-image
                  input:
                    prompt: >-
                      A ceramic teapot on a linen tablecloth, soft window light,
                      the label reads "Morning Ritual"
              wide-2k:
                summary: 2K 16:9
                value:
                  model: microsoft/mai-image-2.7-flash/text-to-image
                  input:
                    prompt: >-
                      A misty mountain village at sunrise, terraced fields,
                      cinematic photography
                    size: '16:9'
                    resolution: 2K
              transparent-custom:
                summary: 自定义尺寸 + 透明背景
                value:
                  model: microsoft/mai-image-2.7-flash/text-to-image
                  input:
                    prompt: A glossy red sneaker, side view, isolated product cutout
                    size: 3072x1344
                    background: transparent
                    output_format: webp
      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/text-to-image
        callback_url:
          type: string
          format: uri
          description: 可选的 Webhook URL，用于接收完成或失败通知。
          example: https://your-domain.com/callback
        input:
          type: object
          required:
            - prompt
          additionalProperties: false
          properties:
            prompt:
              type: string
              minLength: 1
              maxLength: 32000
              description: |-
                描述图片或所需编辑的提示词。图中需要出现的文字请放在引号里。

                至少包含一个非空白字符。
            size:
              type: string
              default: '1:1'
              description: |-
                宽高比预设或自定义 WIDTHxHEIGHT。

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

                自定义尺寸要求两边都能被 16 整除、每边至少 768、总像素最多 4194304。
            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.