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

# 生成图片

> Qwen-Image 图像生成与编辑（阿里云百炼 DashScope 协议）。`input.messages` 中的唯一一条消息只含 1 条 `text` 时为文生图；再加 1 ~ 3 张 `image` 时为图生图 / 图片编辑。请求是同步的，阻塞到出图完成后在 `output.choices[0].message.content` 中返回图片链接（PNG，24 小时内有效）。



## OpenAPI

````yaml /openapi/zh/qwen-image-3-0-pro.json post /api/v1/services/aigc/multimodal-generation/generation
openapi: 3.1.0
info:
  description: >-
    Qwen-Image 3.0 Pro：阿里云 Qwen 图像生成与编辑 3.0 旗舰模型，文字渲染、真实质感和语义遵循全面升级，支持文生图和 1 ~ 3
    张图的图片编辑。
  title: Qwen-Image 3.0 Pro
  version: v1
servers:
  - url: https://api.dreamto.ai
security:
  - bearerAuth: []
tags:
  - name: Qwen-Image 3.0 Pro
paths:
  /api/v1/services/aigc/multimodal-generation/generation:
    post:
      tags:
        - Qwen-Image 3.0 Pro
      summary: 生成图片
      description: >-
        Qwen-Image 图像生成与编辑（阿里云百炼 DashScope 协议）。`input.messages` 中的唯一一条消息只含 1 条
        `text` 时为文生图；再加 1 ~ 3 张 `image` 时为图生图 / 图片编辑。请求是同步的，阻塞到出图完成后在
        `output.choices[0].message.content` 中返回图片链接（PNG，24 小时内有效）。
      operationId: qwenImageGenerate
      requestBody:
        content:
          application/json:
            examples:
              文生图:
                description: '`content` 只放一个 `text`；`size` 用 `宽*高` 指定 1328*1328（1:1，1K 档）。'
                summary: 文生图
                value:
                  model: qwen-image-3.0-pro
                  input:
                    messages:
                      - role: user
                        content:
                          - text: 一只橘猫坐在洒满阳光的木质窗台上，窗外是雨后的城市街景，玻璃上挂着水珠，柔和的自然光，写实摄影风格
                  parameters:
                    size: 1328*1328
                    'n': 1
                    prompt_extend: true
                    watermark: false
              中文海报:
                description: >-
                  把要出现的文字放在引号里；16:9 横版（1664*928），用 `negative_prompt`
                  排除不想要的元素，关闭改写以严格按提示词出图。
                summary: 中文海报
                value:
                  model: qwen-image-3.0-pro
                  input:
                    messages:
                      - role: user
                        content:
                          - text: >-
                              一张中秋节海报，深蓝色夜空中一轮金色满月，下方是江南水乡的屋檐和石桥，画面正中用烫金书法字体写着“月满人团圆”，底部一行小字“2026
                              中秋”
                  parameters:
                    negative_prompt: 低分辨率，文字错误，模糊，水印
                    size: 1664*928
                    prompt_extend: false
              智能改写（Agent 模式）:
                description: >-
                  简短的提示词配合 `prompt_extend_mode: agent`（仅文生图）和 `enable_thinking:
                  true`，由模型更细致地扩写后出图，耗时更长。
                summary: 智能改写（Agent 模式）
                value:
                  model: qwen-image-3.0-pro
                  input:
                    messages:
                      - role: user
                        content:
                          - text: 一家开在森林里的咖啡馆
                  parameters:
                    prompt_extend: true
                    prompt_extend_mode: agent
                    enable_thinking: true
              图片编辑:
                description: '`content` 放 1 张 `image` 和 1 条编辑指令，`n: 2` 一次返回 2 张候选图。'
                summary: 图片编辑
                value:
                  model: qwen-image-3.0-pro
                  input:
                    messages:
                      - role: user
                        content:
                          - image: https://your-cdn.example.com/portrait.png
                          - text: 保持人物的五官和发型不变，把服装换成米白色西装，背景换成现代简约的咖啡馆
                  parameters:
                    'n': 2
                    prompt_extend: true
              多图融合:
                description: 最多 3 张图片，按数组顺序称为“图1”“图2”“图3”。
                summary: 多图融合
                value:
                  model: qwen-image-3.0-pro
                  input:
                    messages:
                      - role: user
                        content:
                          - image: https://your-cdn.example.com/girl.png
                          - image: https://your-cdn.example.com/necklace.png
                          - image: https://your-cdn.example.com/bag.png
                          - text: 图1中的女孩戴上图2中的项链，左肩背着图3中的包
                  parameters:
                    size: 1104*1472
                    seed: 42
              Base64 图片输入:
                description: 图片也可以用 `data:{MIME 类型};base64,{数据}` 传入，例如修改图中的文字。
                summary: Base64 图片输入
                value:
                  model: qwen-image-3.0-pro
                  input:
                    messages:
                      - role: user
                        content:
                          - image: data:image/png;base64,<BASE64_IMAGE_DATA>
                          - text: >-
                              把便签上的“Take a Breather”改成“Relax and
                              Recharge”，字体和颜色保持不变
                  parameters:
                    prompt_extend: false
              2K 输出:
                description: '`size: 2048*2048`（总像素超过 2,250,000，按 2K 档计费），固定 `seed` 便于复现。'
                summary: 2K 输出
                value:
                  model: qwen-image-3.0-pro
                  input:
                    messages:
                      - role: user
                        content:
                          - text: 微距摄影：一片带着露珠的绿叶，叶脉清晰，背景是柔和的散景，清晨逆光
                  parameters:
                    size: 2048*2048
                    watermark: false
                    seed: 20261117
            schema:
              $ref: '#/components/schemas/QwenImageRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              examples:
                文生图结果:
                  description: 1 张 1024*1024 图片，1K 档；未开启改写时 `rewrite_status` 为 `not_use`。
                  summary: 文生图结果
                  value:
                    request_id: req_7c1e9a4b2d3f5a6b8c9d0e1f
                    output:
                      choices:
                        - finish_reason: stop
                          message:
                            role: assistant
                            content:
                              - type: image
                                image: >-
                                  https://dashscope-463f.oss-accelerate.aliyuncs.com/1d/bd/20261117/2299ae9b/qwen_image3_serving_output_0.png?Expires=1794997226&Signature=...
                      rewrite_status: not_use
                    usage:
                      output_width: 1024
                      output_height: 1024
                      input_image_count: 0
                      input_image_type: qima_input_1k
                      output_image_count: 1
                      output_image_type: qima_output_1k
                图片编辑结果（2 张）:
                  description: >-
                    `n: 2` 时多张图片都在 `choices[0].message.content`
                    中；`input_image_count` 为输入图片数。
                  summary: 图片编辑结果（2 张）
                  value:
                    request_id: req_7c1e9a4b2d3f5a6b8c9d0e1f
                    output:
                      choices:
                        - finish_reason: stop
                          message:
                            role: assistant
                            content:
                              - type: image
                                image: >-
                                  https://dashscope-463f.oss-accelerate.aliyuncs.com/1d/bd/20261117/2299ae9b/qwen_image3_serving_output_0.png?Expires=1794997284&Signature=...
                              - type: image
                                image: >-
                                  https://dashscope-463f.oss-accelerate.aliyuncs.com/1d/bd/20261117/2299ae9b/qwen_image3_serving_output_1.png?Expires=1794997284&Signature=...
                      rewrite_status: success
                    usage:
                      output_width: 1328
                      output_height: 1328
                      input_image_count: 1
                      input_image_type: qima_input_1k
                      output_image_count: 2
                      output_image_type: qima_output_1k
                2K 结果:
                  description: >-
                    输出总像素超过 2,250,000 时 `output_image_type` 为 `qima_output_2k`，按
                    2K 档计费。
                  summary: 2K 结果
                  value:
                    request_id: req_7c1e9a4b2d3f5a6b8c9d0e1f
                    output:
                      choices:
                        - finish_reason: stop
                          message:
                            role: assistant
                            content:
                              - type: image
                                image: >-
                                  https://dashscope-463f.oss-accelerate.aliyuncs.com/1d/bd/20261117/2299ae9b/qwen_image3_serving_output_0.png?Expires=1794997390&Signature=...
                      rewrite_status: success
                    usage:
                      output_width: 2048
                      output_height: 2048
                      input_image_count: 0
                      input_image_type: qima_input_2k
                      output_image_count: 1
                      output_image_type: qima_output_2k
              schema:
                $ref: '#/components/schemas/QwenImageResponse'
          description: >-
            生成成功。图片链接在 `output.choices[0].message.content[].image`，`usage`
            为本次的计费数量；`request_id` 与响应头 `X-Request-Id` 相同。
          headers:
            X-Request-Id:
              description: 本次请求的 ID，排查问题时请提供。
              schema:
                type: string
        '400':
          content:
            application/json:
              examples:
                example:
                  value:
                    request_id: req_7c1e9a4b2d3f5a6b8c9d0e1f
                    code: InvalidParameter
                    message: input.messages[0].content accepts at most 3 images.
              schema:
                $ref: '#/components/schemas/QwenImageErrorResponse'
          description: >-
            请求错误，不扣费：网关校验失败（`code` 为 `InvalidParameter`，`message`
            为英文原因），或模型侧拒绝（保留官方 `code`，如
            `InvalidParameter`、`DataInspectionFailed`）。
        '401':
          content:
            application/json:
              examples:
                example:
                  value:
                    request_id: req_7c1e9a4b2d3f5a6b8c9d0e1f
                    code: InvalidApiKey
                    message: Invalid API key.
              schema:
                $ref: '#/components/schemas/QwenImageErrorResponse'
          description: API Key 缺失或无效（`code` 为 `InvalidApiKey`），不扣费。
        '402':
          content:
            application/json:
              examples:
                example:
                  value:
                    request_id: req_7c1e9a4b2d3f5a6b8c9d0e1f
                    code: Arrearage
                    message: Insufficient balance.
              schema:
                $ref: '#/components/schemas/QwenImageErrorResponse'
          description: DreamTo 账户余额不足以支付本次请求可能产生的最高费用（`code` 为 `Arrearage`），请充值后重试，不扣费。
        '429':
          content:
            application/json:
              examples:
                example:
                  value:
                    request_id: req_7c1e9a4b2d3f5a6b8c9d0e1f
                    code: Throttling
                    message: Requests are being throttled. Please retry later.
              schema:
                $ref: '#/components/schemas/QwenImageErrorResponse'
          description: >-
            请求过于频繁（`code` 为 `Throttling`），包括模型服务限流和超过 DreamTo 账号或 API Key
            的频率限制，请稍后重试，不扣费。
        '500':
          content:
            application/json:
              examples:
                example:
                  value:
                    request_id: req_7c1e9a4b2d3f5a6b8c9d0e1f
                    code: InternalError
                    message: >-
                      The service is temporarily unavailable. Please retry
                      later.
              schema:
                $ref: '#/components/schemas/QwenImageErrorResponse'
          description: 服务暂时不可用（`code` 为 `InternalError`），可稍后重试，不扣费。
components:
  schemas:
    QwenImageRequest:
      additionalProperties: false
      description: 生成图片的请求体（DashScope 协议）。
      properties:
        model:
          description: |-
            模型名称。

            **可选值：**
            - `qwen-image-3.0-pro`：Qwen-Image 3.0 旗舰模型，文字渲染、质感和语义遵循最强
          enum:
            - qwen-image-3.0-pro
          type: string
        input:
          $ref: '#/components/schemas/QwenImageInput'
          description: 输入内容：提示词和可选的参考图。
        parameters:
          $ref: '#/components/schemas/QwenImageParameters'
          description: 可选，控制生成效果的参数；不传时全部使用默认值。
      required:
        - model
        - input
      type: object
    QwenImageResponse:
      additionalProperties: false
      description: 生成成功的响应。
      properties:
        request_id:
          description: 请求 ID（DreamTo 生成），与响应头 `X-Request-Id` 相同，排查问题时请提供。
          type: string
        output:
          $ref: '#/components/schemas/QwenImageOutput'
          description: 生成结果。
        usage:
          $ref: '#/components/schemas/QwenImageUsage'
          description: 本次调用的计费数量（图片张数和档位，不是 Token），只在成功时返回。
      required:
        - request_id
        - output
        - usage
      type: object
    QwenImageErrorResponse:
      additionalProperties: false
      description: 错误响应（官方 DashScope 错误结构）。
      properties:
        request_id:
          description: 请求 ID（DreamTo 生成），与响应头 `X-Request-Id` 相同。
          type: string
        code:
          description: |-
            错误码，例如：
            - `InvalidParameter`：参数错误（含网关校验失败）
            - `DataInspectionFailed`：输入或输出内容未通过审核
            - `Throttling`：请求过于频繁
            - `InternalError`：服务异常，可稍后重试
          type: string
        message:
          description: 错误原因（英文）。
          type: string
      required:
        - request_id
        - code
        - message
      type: object
    QwenImageInput:
      additionalProperties: false
      description: 输入内容。
      properties:
        messages:
          description: 消息列表，只支持单轮：必须且只能有 1 条消息。
          items:
            $ref: '#/components/schemas/QwenImageMessage'
          maxItems: 1
          minItems: 1
          type: array
      required:
        - messages
      type: object
    QwenImageParameters:
      additionalProperties: false
      description: 生成参数。
      properties:
        negative_prompt:
          description: 反向提示词，描述不希望出现在画面中的内容，如“低分辨率，文字错误，模糊，多余的手指”。Qwen-Image 3.0 系列支持。
          type: string
        size:
          description: >-
            输出分辨率，格式为 `宽*高`，如 `1024*1024`、`1664*928`。文生图和图片编辑都要求总像素在 `512*512` ~
            `2048*2048` 之间、宽高比在 1:8 ~ 8:1
            之间（像素范围由模型服务校验）。不传时由模型根据提示词推荐分辨率。总像素不超过 2,250,000 按 1K 档计费，超过按 2K
            档计费。
          type: string
        'n':
          default: 1
          description: 生成图片数量，1 ~ 6，默认 1。按张计费，所有图片在同一个 `choices[0].message.content` 中返回。
          format: int64
          maximum: 6
          minimum: 1
          type: integer
        prompt_extend:
          default: true
          description: >-
            是否开启提示词智能改写，默认 `true`（推荐）。开启后模型按 `prompt_extend_mode`
            优化提示词，对简短描述的提升明显；提示词已很详细或对耗时敏感时可关闭。
          type: boolean
        prompt_extend_mode:
          default: direct
          description: >-
            提示词改写方式，默认 `direct`；`prompt_extend` 为 `true` 时生效。


            **可选值：**

            - `direct`：直接改写（Direct Prompt Enhancement），适合大多数场景，文生图和图片编辑都支持（默认）

            - `agent`：Agent 改写（Agent Prompt Enhancement），改写更精细；仅支持文生图，图片编辑时传入返回
            400
          enum:
            - direct
            - agent
          type: string
        enable_thinking:
          default: true
          description: >-
            是否开启思考模式，默认 `true`。增强模型推理以提升画面质量，但会增加生成时间；需要 `prompt_extend:
            true`。支持 Direct 文生图、Direct 图片编辑和 Agent 文生图。
          type: boolean
        watermark:
          default: false
          description: 是否添加水印，默认 `false`。
          type: boolean
        seed:
          description: 随机种子，`0` ~ `2147483647`；不传时随机。固定种子可使结果更稳定。
          format: int64
          maximum: 2147483647
          minimum: 0
          type: integer
      type: object
    QwenImageOutput:
      additionalProperties: false
      description: 生成结果。
      properties:
        choices:
          description: 结果列表，通常只有 1 项；`n` 大于 1 时多张图片都在这一项的 `message.content` 中。
          items:
            $ref: '#/components/schemas/QwenImageChoice'
          type: array
        rewrite_status:
          description: 提示词改写状态，取决于请求是否开启改写及改写结果，例如 `not_use`（未开启改写）、`success`（改写成功）。
          type: string
      required:
        - choices
      type: object
    QwenImageUsage:
      additionalProperties: false
      description: 计费数量。
      properties:
        output_width:
          description: 输出图片宽度（像素）。
          format: int64
          type: integer
        output_height:
          description: 输出图片高度（像素）。
          format: int64
          type: integer
        input_image_count:
          description: 输入图片数量：文生图为 0，图片编辑为实际传入的张数；按张计费。
          format: int64
          type: integer
        input_image_type:
          description: >-
            输入图片的档位，由输出图片的总像素决定：不超过 2,250,000 为 `qima_input_1k`，超过为
            `qima_input_2k`。两个档位的输入单价相同。
          type: string
        output_image_count:
          description: 实际输出的图片数量，按张计费。
          format: int64
          type: integer
        output_image_type:
          description: >-
            输出图片的计费档位，由输出图片的总像素决定：不超过 2,250,000 为 `qima_output_1k`（1K 档），超过为
            `qima_output_2k`（2K 档）。
          type: string
      required:
        - output_width
        - output_height
        - input_image_count
        - output_image_count
      type: object
    QwenImageMessage:
      additionalProperties: false
      description: 一条用户消息。
      properties:
        role:
          description: |-
            消息角色，固定为 `user`。

            **可选值：**
            - `user`：用户消息
          enum:
            - user
          type: string
        content:
          description: |-
            消息内容数组，每项是 `{"text": ...}` 或 `{"image": ...}`：
            - **文生图**：只放 1 个 `text`。
            - **图生图 / 图片编辑**：1 ~ 3 个 `image` 加 1 个 `text`。图片按数组顺序称为“图1”“图2”“图3”。

            `text` 必须恰好 1 个，缺少或多于 1 个都会返回 400。
          items:
            $ref: '#/components/schemas/QwenImageContent'
          maxItems: 4
          minItems: 1
          type: array
      required:
        - role
        - content
      type: object
    QwenImageChoice:
      additionalProperties: false
      description: 一个结果。
      properties:
        finish_reason:
          description: |-
            结束原因。

            **可选值：**
            - `stop`：正常完成
          enum:
            - stop
          type: string
        message:
          $ref: '#/components/schemas/QwenImageResponseMessage'
          description: 模型返回的消息。
      required:
        - finish_reason
        - message
      type: object
    QwenImageContent:
      additionalProperties: false
      description: 一个内容项：只设置 `text` 或 `image` 其中之一。
      properties:
        text:
          description: >-
            正向提示词，描述要生成或修改的画面内容、风格和构图。支持中文和英文，建议不超过 4500
            Token，不能为空。图中需要出现的文字请放在引号里。
          type: string
        image:
          description: >-
            输入图片，公网 `http` / `https` 链接或 Base64 Data URI（`data:{MIME
            类型};base64,{数据}`）。要求：JPG、JPEG、PNG、BMP、TIFF、WEBP 或 GIF（动图只取第一帧）；宽、高均为
            1 ~ 8000 像素，效果最佳为 384 ~ 2048 像素；长边与短边之比不超过 10:1；不超过 10 MB。
          type: string
      type: object
    QwenImageResponseMessage:
      additionalProperties: false
      description: 模型返回的消息。
      properties:
        role:
          description: |-
            消息角色。

            **可选值：**
            - `assistant`：模型回复
          enum:
            - assistant
          type: string
        content:
          description: 生成的图片列表，每项一张图片。
          items:
            $ref: '#/components/schemas/QwenImageResponseImage'
          type: array
      required:
        - role
        - content
      type: object
    QwenImageResponseImage:
      additionalProperties: false
      description: 一张生成的图片。
      properties:
        type:
          description: |-
            内容类型。

            **可选值：**
            - `image`：图片
          enum:
            - image
          type: string
        image:
          description: 图片链接（PNG），24 小时内有效，请及时下载保存。
          type: string
      required:
        - image
      type: object
  securitySchemes:
    bearerAuth:
      description: 'DreamTo 控制台创建的 API Key，格式 `Authorization: Bearer <API Key>`。'
      scheme: bearer
      type: http

````

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