QwenCloudBRASIL
Tradução de apoio para consulta. Código e identificadores técnicos preservados. Consultar referência original ↗

Qwen síncrono

Geração de imagens em tempo real

Obtenha uma chave de API e defini-lo como uma variável de ambiente. Se estiver usando o SDK, instale-o.

OpenAPI

openapi: 3.1.0
info:
  title: qwen-image-3.0 API
  description: qwen-image-3.0 text-to-image generation API. Supports synchronous calls for all models and asynchronous calls for legacy models.
  version: 1.0.0
servers:
  - url: https://maas.qwencloudapi.com/api/v1
    description: Singapore
security:
  - BearerAuth: []
paths:
  /services/aigc/multimodal-generation/generation:
    post:
      operationId: createQwenImageSync
      summary: Generate images synchronously
      description: |-
        Generate images synchronously using Qwen-Image.

        ## Use with the OpenAI Agents SDK

        Image generation models such as qwen-image-3.0 are called through the DashScope native API and do not support OpenAI-compatible (compatible-mode) mode, so they cannot be used directly as the reasoning model of an Agent in the OpenAI Agents SDK.

        In agent frameworks such as the OpenAI Agents SDK, you can wrap image generation as a tool (function tool) and let a text chat model that supports OpenAI-compatible mode (such as qwen-plus) act as the Agent's reasoning core to orchestrate it.

        Before running, install the dependencies: `pip install openai-agents dashscope`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/QwenImageSyncRequest"
      responses:
        "200":
          description: Image generated successfully
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/QwenImageSyncResponse"
        "400":
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DashScopeErrorResponse"
      x-codeSamples:
        - lang: curl
          label: cURL
          source: |-
            curl --location 'https://maas.qwencloudapi.com/api/v1/services/aigc/multimodal-generation/generation' \
            --header 'Content-Type: application/json' \
            --header "Authorization: Bearer $DASHSCOPE_API_KEY" \
            --data '{
              "model": "qwen-image-3.0-pro",
              "input": {
                "messages": [
                  {
                    "role": "user",
                    "content": [
                      {
                        "text": "A vertical outdoor portrait photograph carrying the warm atmosphere of a late-afternoon street scene from top to bottom. The upper left and top of the frame are largely covered by dark green vines and small orange flowers cascading naturally from the building cornice; sunlit leaves catch yellow-green highlights while shaded ones deepen to dark green, forming a dense yet soft background layering. Across the upper-left to upper-centre area is a dark blue horizontal sign, its surface dim with a slightly matte texture, bearing the large white blackletter words Il Messaggero. The text sits slightly above centre on the left, partly veiled by the foreground foliage, set in a high-contrast typeface with decorative sharp terminals and pronounced stroke variation. Beneath the sign is the glass display window of a newsstand, its black metal framing dividing the case into multiple rectangular sections filled with newspapers, magazines and book covers, most of them illegible from the shallow depth of field and light reflections, creating a background texture of pale paper interlaced with dark frames. The upper right is a zone of strong backlight, sunlight pouring in from the end of the street, background buildings blurred into soft beige-grey planes with a pronounced shallow depth of field. Right of centre stands a young adult woman shown from above the knee up, glancing back at the camera with a smile, body turned slightly right, shoulders and back toward the viewer, her posture natural and relaxed. Her long, thick black wavy hair is traced with a golden rim light from the backlight, the ends fanning outward on the right, light and airy. Her skin is fair, her face a soft oval, brows finely shaped, eyes bright with sheer eye makeup and distinct lashes, natural highlights across her face, lips a soft coral red, smiling to show her teeth, expression warm and open. She wears small earrings and a black spaghetti-strap backless dress in deep black with a clean silhouette, the thin straps extending from shoulder to back, the line of her back clearly defined. From the lower left to the centre of the frame she holds a large bouquet of roses in both arms, mostly orange, apricot, pink and pale peach, petals curling in layers with sunlit edges, green leaves and long stems trailing from beneath, a vivid colour contrast against the black dress. The right background is a sunlit city street, its ground in warm grey and golden tones; distant buildings, street fixtures and a blurred red circular traffic sign sit in the lower-right distance, reduced by the out-of-focus falloff to colour blocks and outlines. The whole photograph carries a warm filmic treatment with fine grain, soft contrast and pronounced backlit edge light; the subject is the visual focus, while the newsstand, flowering vines, street and sunlight together create a romantic, bright, urban-stroll atmosphere."
                      }
                    ]
                  }
                ]
              },
              "parameters": {
                "negative_prompt": "",
                "prompt_extend": true,
                "watermark": false,
                "size": "2048*2048"
              }
            }'
        - lang: python
          label: Python (DashScope SDK)
          source: |-
            from http import HTTPStatus
            from urllib.parse import urlparse, unquote
            from pathlib import PurePosixPath
            import requests
            import os
            import dashscope
            from dashscope import MultiModalConversation

            dashscope.base_http_api_url = 'https://maas.qwencloudapi.com/api/v1'

            prompt = ("A vertical outdoor portrait photograph carrying the warm atmosphere "
                      "of a late-afternoon street scene from top to bottom. The upper left "
                      "and top of the frame are largely covered by dark green vines and "
                      "small orange flowers cascading naturally from the building cornice; "
                      "sunlit leaves catch yellow-green highlights while shaded ones "
                      "deepen to dark green, forming a dense yet soft background layering. "
                      "Across the upper-left to upper-centre area is a dark blue "
                      "horizontal sign, its surface dim with a slightly matte texture, "
                      "bearing the large white blackletter words Il Messaggero. The text "
                      "sits slightly above centre on the left, partly veiled by the "
                      "foreground foliage, set in a high-contrast typeface with decorative "
                      "sharp terminals and pronounced stroke variation. Beneath the sign "
                      "is the glass display window of a newsstand, its black metal framing "
                      "dividing the case into multiple rectangular sections filled with "
                      "newspapers, magazines and book covers, most of them illegible from "
                      "the shallow depth of field and light reflections, creating a "
                      "background texture of pale paper interlaced with dark frames. The "
                      "upper right is a zone of strong backlight, sunlight pouring in from "
                      "the end of the street, background buildings blurred into soft "
                      "beige-grey planes with a pronounced shallow depth of field. Right "
                      "of centre stands a young adult woman shown from above the knee up, "
                      "glancing back at the camera with a smile, body turned slightly "
                      "right, shoulders and back toward the viewer, her posture natural "
                      "and relaxed. Her long, thick black wavy hair is traced with a "
                      "golden rim light from the backlight, the ends fanning outward on "
                      "the right, light and airy. Her skin is fair, her face a soft oval, "
                      "brows finely shaped, eyes bright with sheer eye makeup and distinct "
                      "lashes, natural highlights across her face, lips a soft coral red, "
                      "smiling to show her teeth, expression warm and open. She wears "
                      "small earrings and a black spaghetti-strap backless dress in deep "
                      "black with a clean silhouette, the thin straps extending from "
                      "shoulder to back, the line of her back clearly defined. From the "
                      "lower left to the centre of the frame she holds a large bouquet of "
                      "roses in both arms, mostly orange, apricot, pink and pale peach, "
                      "petals curling in layers with sunlit edges, green leaves and long "
                      "stems trailing from beneath, a vivid colour contrast against the "
                      "black dress. The right background is a sunlit city street, its "
                      "ground in warm grey and golden tones; distant buildings, street "
                      "fixtures and a blurred red circular traffic sign sit in the "
                      "lower-right distance, reduced by the out-of-focus falloff to colour "
                      "blocks and outlines. The whole photograph carries a warm filmic "
                      "treatment with fine grain, soft contrast and pronounced backlit "
                      "edge light; the subject is the visual focus, while the newsstand, "
                      "flowering vines, street and sunlight together create a romantic, "
                      "bright, urban-stroll atmosphere.")

            api_key = os.getenv("DASHSCOPE_API_KEY")

            messages = [
              {
                "role": "user",
                "content": [{"text": prompt}]
              }
            ]

            response = MultiModalConversation.call(
              api_key=api_key,
              model="qwen-image-3.0-pro",
              messages=messages,
              result_format='message',
              stream=False,
              watermark=False,
              prompt_extend=True,
              negative_prompt="",
              size='2048*2048'
            )

            if response.status_code == HTTPStatus.OK:
              content = response.output.choices[0].message.content
              for item in content:
                if 'image' in item:
                  image_url = item['image']
                  file_name = PurePosixPath(
                    unquote(urlparse(image_url).path)
                  ).parts[-1]
                  with open(f'./{file_name}', 'wb+') as f:
                    f.write(requests.get(image_url).content)
                  print(f"Image saved: {file_name}")
            else:
              print(f"Failed: {response.code}, {response.message}")
        - lang: java
          label: Java (DashScope SDK)
          source: |-
            import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversation;
            import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationParam;
            import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationResult;
            import com.alibaba.dashscope.common.MultiModalMessage;
            import com.alibaba.dashscope.common.Role;
            import com.alibaba.dashscope.utils.Constants;
            import com.alibaba.dashscope.utils.JsonUtils;

            import java.util.*;

            public class QwenImageSync {
              static {
                    Constants.baseHttpApiUrl = "https://maas.qwencloudapi.com/api/v1";
              }

              static String apiKey = System.getenv("DASHSCOPE_API_KEY");

              public static void main(String[] args) throws Exception {
                String prompt = "A vertical outdoor portrait photograph carrying the warm atmosphere "
                  + "of a late-afternoon street scene from top to bottom. The upper left "
                  + "and top of the frame are largely covered by dark green vines and "
                  + "small orange flowers cascading naturally from the building cornice; "
                  + "sunlit leaves catch yellow-green highlights while shaded ones "
                  + "deepen to dark green, forming a dense yet soft background layering. "
                  + "Across the upper-left to upper-centre area is a dark blue "
                  + "horizontal sign, its surface dim with a slightly matte texture, "
                  + "bearing the large white blackletter words Il Messaggero. The text "
                  + "sits slightly above centre on the left, partly veiled by the "
                  + "foreground foliage, set in a high-contrast typeface with decorative "
                  + "sharp terminals and pronounced stroke variation. Beneath the sign "
                  + "is the glass display window of a newsstand, its black metal framing "
                  + "dividing the case into multiple rectangular sections filled with "
                  + "newspapers, magazines and book covers, most of them illegible from "
                  + "the shallow depth of field and light reflections, creating a "
                  + "background texture of pale paper interlaced with dark frames. The "
                  + "upper right is a zone of strong backlight, sunlight pouring in from "
                  + "the end of the street, background buildings blurred into soft "
                  + "beige-grey planes with a pronounced shallow depth of field. Right "
                  + "of centre stands a young adult woman shown from above the knee up, "
                  + "glancing back at the camera with a smile, body turned slightly "
                  + "right, shoulders and back toward the viewer, her posture natural "
                  + "and relaxed. Her long, thick black wavy hair is traced with a "
                  + "golden rim light from the backlight, the ends fanning outward on "
                  + "the right, light and airy. Her skin is fair, her face a soft oval, "
                  + "brows finely shaped, eyes bright with sheer eye makeup and distinct "
                  + "lashes, natural highlights across her face, lips a soft coral red, "
                  + "smiling to show her teeth, expression warm and open. She wears "
                  + "small earrings and a black spaghetti-strap backless dress in deep "
                  + "black with a clean silhouette, the thin straps extending from "
                  + "shoulder to back, the line of her back clearly defined. From the "
                  + "lower left to the centre of the frame she holds a large bouquet of "
                  + "roses in both arms, mostly orange, apricot, pink and pale peach, "
                  + "petals curling in layers with sunlit edges, green leaves and long "
                  + "stems trailing from beneath, a vivid colour contrast against the "
                  + "black dress. The right background is a sunlit city street, its "
                  + "ground in warm grey and golden tones; distant buildings, street "
                  + "fixtures and a blurred red circular traffic sign sit in the "
                  + "lower-right distance, reduced by the out-of-focus falloff to colour "
                  + "blocks and outlines. The whole photograph carries a warm filmic "
                  + "treatment with fine grain, soft contrast and pronounced backlit "
                  + "edge light; the subject is the visual focus, while the newsstand, "
                  + "flowering vines, street and sunlight together create a romantic, "
                  + "bright, urban-stroll atmosphere.";

                MultiModalMessage userMessage = MultiModalMessage.builder()
                  .role(Role.USER.getValue())
                  .content(List.of(Map.of("text", prompt)))
                  .build();

                Map<String, Object> parameters = new HashMap<>();
                parameters.put("watermark", false);
                parameters.put("prompt_extend", true);
                parameters.put("negative_prompt", "");
                parameters.put("size", "2048*2048");

                MultiModalConversationParam param = MultiModalConversationParam.builder()
                  .apiKey(apiKey)
                  .model("qwen-image-3.0-pro")
                  .messages(List.of(userMessage))
                  .parameters(parameters)
                  .build();

                MultiModalConversation conversation = new MultiModalConversation();
                MultiModalConversationResult result = conversation.call(param);
                System.out.println(JsonUtils.toJson(result));
              }
            }
        - lang: python
          label: Python (OpenAI Agents SDK)
          source: |-
            import os
            import asyncio
            import dashscope
            from openai import AsyncOpenAI
            from dashscope import MultiModalConversation
            from agents import Agent, Runner, function_tool, OpenAIChatCompletionsModel

            API_KEY = os.getenv("DASHSCOPE_API_KEY")
            dashscope.base_http_api_url = "https://maas.qwencloudapi.com/api/v1"
            client = AsyncOpenAI(api_key=API_KEY, base_url="https://maas.qwencloudapi.com/compatible-mode/v1")

            @function_tool
            def generate_image(prompt: str) -> str:
              """Generate an image from a text description and return its URL. prompt: the text description of the image."""
              rsp = MultiModalConversation.call(
                api_key=API_KEY,
                model="qwen-image-3.0",
                messages=[{"role": "user", "content": [{"text": prompt}]}],
                result_format="message",
              )
              if rsp.status_code != 200:
                return f"Generation failed: {rsp.code} {rsp.message}"
              return rsp.output.choices[0].message.content[0]["image"]

            agent = Agent(
              name="Image Assistant",
              instructions="You are an image generation assistant. When the user wants an image, call the generate_image tool and return the image URL to the user.",
              model=OpenAIChatCompletionsModel(model="qwen-plus", openai_client=client),
              tools=[generate_image],
            )

            async def main():
              result = await Runner.run(agent, "Draw a corgi running on the grass")
              print(result.final_output)

            if __name__ == "__main__":
              asyncio.run(main())
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: DashScope API Key. Create one in the [QwenCloud console](https://home.qwencloud.com/api-keys).
  schemas:
    QwenImageSyncRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          description: Model name.
          enum:
            - qwen-image-3.0-pro
            - qwen-image-3.0
            - qwen-image-2.1-pro
            - qwen-image-2.1-turbo
            - qwen-image-2.0-pro
            - qwen-image-2.0-pro-2026-06-22
            - qwen-image-2.0-pro-2026-04-22
            - qwen-image-2.0-pro-2026-03-03
            - qwen-image-2.0
            - qwen-image-2.0-2026-03-03
          example: qwen-image-3.0-pro
        input:
          type: object
          required:
            - messages
          description: Input data containing the messages array.
          properties:
            messages:
              type: array
              description: Single-turn only. Exactly one message with role `user`.
              minItems: 1
              maxItems: 1
              items:
                $ref: "#/components/schemas/QwenImageMessage"
        parameters:
          $ref: "#/components/schemas/QwenImageSyncParameters"
    QwenImageMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - user
          description: Must be `user`.
        content:
          type: array
          description: Message content array. Must contain exactly one text object.
          minItems: 1
          maxItems: 1
          items:
            $ref: "#/components/schemas/QwenImageContentPart"
    QwenImageContentPart:
      type: object
      required:
        - text
      properties:
        text:
          type: string
          description: Positive prompt describing the desired content, style, and composition. The qwen-image-3.0 series and qwen-image-2.1-pro accept up to 4,500 tokens (recommended maximum). The qwen-image-2.0 series accept up to 1,300 tokens. Other models accept up to 800 tokens. The system truncates excess tokens.
          example: A vertical outdoor portrait photograph. A dark blue sign in the upper left bears the large white blackletter words Il Messaggero, and below it the glass display window of a newsstand is filled with newspapers and magazine covers.
    QwenImageSyncParameters:
      type: object
      description: Image generation parameters.
      properties:
        negative_prompt:
          type: string
          description: Describes content you do NOT want in the image. Max 500 characters. Excess is auto-truncated. qwen-image-2.1-pro does not support this parameter.
          maxLength: 500
        size:
          type: string
          description: |-
            Output resolution as `width*height`.

            - **qwen-image-3.0 series and qwen-image-2.1-pro**: total pixels between 512\*512 and 2048\*2048, aspect ratio between 1:8 and 8:1; when omitted, the model auto-recommends a resolution based on the prompt.
            - **qwen-image-2.0 series**: total pixels between 512\*512 and 2048\*2048; default `2048*2048`.
          example: 2048*2048
        n:
          type: integer
          description: "Number of images to generate. All models supported by this operation allow 1-6 images. Default: 1."
          minimum: 1
          maximum: 6
          default: 1
        prompt_extend:
          type: boolean
          description: "Enable prompt rewriting. `true` (default): the model rewrites the prompt before generating; for the qwen-image-3.0 series and qwen-image-2.1-pro the rewriting follows the mode set by `prompt_extend_mode`. `false`: use your prompt as-is."
          default: true
        prompt_extend_mode:
          type: string
          description: |-
            Prompt rewriting mode. Supported by the qwen-image-3.0 series and qwen-image-2.1-pro only.

            - `direct` (default): direct prompt enhancement (DPE). Suitable for most scenarios.
            - `agent`: agent prompt enhancement (APE). Finer-grained rewriting; text-to-image only.
          enum:
            - direct
            - agent
          default: direct
        watermark:
          type: boolean
          description: 'Add a "Qwen-Image" watermark to the bottom-right corner. Default: `false`.'
          default: false
        enable_thinking:
          type: boolean
          description: "Enable thinking mode. Default: `true`. When enabled, the model enhances reasoning to improve image quality, but increases generation time. Only effective when `prompt_extend=true`. Supported for Direct T2I, Direct I2I, and Agent T2I; I2I Agent is not yet supported."
          default: true
        seed:
          type: integer
          description: "Random number seed. Range: [0, 2147483647]. Same seed produces more consistent (but not identical) results. If omitted, a random seed is used."
          minimum: 0
          maximum: 2147483647
    QwenImage30AsyncParameters:
      type: object
      description: Image generation parameters.
      properties:
        negative_prompt:
          type: string
          description: Describes content you do NOT want in the image. Max 500 characters. Excess is auto-truncated. Only qwen-image-3.0 series models support this parameter; qwen-image-2.1-pro does not.
          maxLength: 500
        size:
          type: string
          description: Output resolution as `width*height`. The qwen-image-3.0 series and qwen-image-2.1-pro support total pixels between 512\*512 and 2048\*2048 and an aspect ratio between 1:8 and 8:1; when omitted, the model auto-recommends a resolution based on the prompt.
          example: 2048*2048
        n:
          type: integer
          description: "Number of images to generate. All models supported by this operation allow 1-6 images. Default: 1."
          minimum: 1
          maximum: 6
          default: 1
        prompt_extend:
          type: boolean
          description: "Enable prompt rewriting. `true` (default): the model rewrites the prompt before generating; for the qwen-image-3.0 series and qwen-image-2.1-pro the rewriting follows the mode set by `prompt_extend_mode`. `false`: use your prompt as-is."
          default: true
        prompt_extend_mode:
          type: string
          description: |-
            Prompt rewriting mode. Supported by the qwen-image-3.0 series and qwen-image-2.1-pro only.

            - `direct` (default): direct prompt enhancement (DPE). Suitable for most scenarios.
            - `agent`: agent prompt enhancement (APE). Finer-grained rewriting; text-to-image only.
          enum:
            - direct
            - agent
          default: direct
        watermark:
          type: boolean
          description: 'Add a "Qwen-Image" watermark to the bottom-right corner. Default: `false`.'
          default: false
        enable_thinking:
          type: boolean
          description: "Enable thinking mode. Default: `true`. When enabled, the model enhances reasoning to improve image quality, but increases generation time. Only effective when `prompt_extend=true`. Supported for Direct T2I, Direct I2I, and Agent T2I; I2I Agent is not yet supported."
          default: true
        seed:
          type: integer
          description: "Random number seed. Range: [0, 2147483647]. Same seed produces more consistent (but not identical) results. If omitted, a random seed is used."
          minimum: 0
          maximum: 2147483647
    QwenImage30AsyncRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          description: Model name.
          enum:
            - qwen-image-3.0-pro
            - qwen-image-3.0
            - qwen-image-2.1-pro
            - qwen-image-2.1-turbo
          example: qwen-image-3.0-pro
        input:
          type: object
          required:
            - messages
          description: Input data containing the messages array.
          properties:
            messages:
              type: array
              description: Request content array. Only single-turn conversations are supported; the array contains exactly one object.
              items:
                $ref: "#/components/schemas/QwenImageMessage"
        parameters:
          $ref: "#/components/schemas/QwenImage30AsyncParameters"
    QwenImageSyncResponse:
      type: object
      description: Synchronous qwen-image-3.0 generation response.
      example:
        output:
          choices:
            - finish_reason: stop
              message:
                content:
                  - image: https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.png?Expires=xxx
                role: assistant
        usage:
          output_height: 2048
          output_width: 2048
          input_image_count: 0
          input_image_type: qima_input_2k
          output_image_count: 1
          output_image_type: qima_output_2k
        request_id: d0250a3d-b07f-49e1-bdc8-6793f4929xxx
      properties:
        output:
          type: object
          properties:
            choices:
              type: array
              description: List of generated results. Contains one element per generated image.
              items:
                $ref: "#/components/schemas/QwenImageChoice"
            task_metric:
              type: object
              description: Task result statistics. Not returned for qwen-image-2.0 and qwen-image-3.0 series.
              properties:
                TOTAL:
                  type: integer
                  description: Total number of tasks.
                SUCCEEDED:
                  type: integer
                  description: Number of successful tasks.
                FAILED:
                  type: integer
                  description: Number of failed tasks.
        usage:
          type: object
          description: "Usage statistics (successful results only). Fields vary by model series: the qwen-image-3.0 series returns the `output_*` / `input_*` fields; other series return `image_count` / `width` / `height`."
          properties:
            output_width:
              type: integer
              description: Width of the final output image, in pixels. Returned by the qwen-image-3.0 series only.
            output_height:
              type: integer
              description: Height of the final output image, in pixels. Returned by the qwen-image-3.0 series only.
            input_image_count:
              type: integer
              description: Number of input images in the request. 0 for text-to-image; the actual input count for image editing. Returned by the qwen-image-3.0 series only.
            input_image_type:
              type: string
              description: "Input image billing tier, determined by the output resolution pixel area: `qima_input_1k` when the area is 2,250,000 or less, `qima_input_2k` when greater. Returned by the qwen-image-3.0 series only."
            output_image_count:
              type: integer
              description: Number of output images actually returned. Returned by the qwen-image-3.0 series only.
            output_image_type:
              type: string
              description: "Output image billing tier, determined by the output resolution pixel area: `qima_output_1k` when the area is 2,250,000 or less, `qima_output_2k` when greater. Returned by the qwen-image-3.0 series only."
            image_count:
              type: integer
              description: Number of images generated. Not returned by the qwen-image-3.0 series, which uses `output_image_count` instead.
            width:
              type: integer
              description: Width of the generated image, in pixels. Not returned by the qwen-image-3.0 series, which uses `output_width` instead.
            height:
              type: integer
              description: Height of the generated image, in pixels. Not returned by the qwen-image-3.0 series, which uses `output_height` instead.
        request_id:
          type: string
          description: Unique request identifier for tracing and troubleshooting.
          example: abf1645b-b630-433a-92f6-xxxxxx
    QwenImageChoice:
      type: object
      properties:
        finish_reason:
          type: string
          description: "`stop` means normal completion."
          example: stop
        message:
          type: object
          properties:
            role:
              type: string
              description: Always `assistant`.
              enum:
                - assistant
            content:
              type: array
              description: Response content array.
              items:
                $ref: "#/components/schemas/QwenImageResponseContentPart"
    QwenImageResponseContentPart:
      type: object
      properties:
        image:
          type: string
          description: URL of the generated image (PNG). **Valid for 24 hours.** Download promptly.
    AsyncTaskSubmitResponse:
      type: object
      description: Response from an asynchronous task submission.
      example:
        output:
          task_status: PENDING
          task_id: 0385dc79-5ff8-4d82-bcb6-xxxxxx
        request_id: 4909100c-7b5a-9f92-bfe5-xxxxxx
      properties:
        request_id:
          type: string
          description: Unique request identifier.
        output:
          type: object
          properties:
            task_id:
              type: string
              description: Task ID for polling status. Use with `GET /tasks/{task_id}`.
            task_status:
              type: string
              description: Initial task status, typically `PENDING`.
              enum:
                - PENDING
                - RUNNING
                - SUCCEEDED
                - FAILED
                - CANCELED
                - UNKNOWN
    AsyncTaskStatusResponse:
      type: object
      description: Async task status and results.
      example:
        request_id: 7434edb2-3cba-44e6-a772-xxxxxx
        output:
          task_id: 878f591e-ebdf-4e45-97eb-xxxxxx
          task_status: SUCCEEDED
          submit_time: 2025-09-09 11:38:54.741
          scheduled_time: 2025-09-09 11:38:54.781
          end_time: 2025-09-09 11:39:19.484
          results:
            - orig_prompt: Healing-style hand-drawn poster...
              actual_prompt: Childhood-inspired hand-drawn poster design...
              url: https://dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com/7d/xxx.png?Expires=xxxx
        usage:
          image_count: 1
      properties:
        request_id:
          type: string
          description: Unique request identifier.
        output:
          type: object
          properties:
            task_id:
              type: string
              description: Task ID.
            task_status:
              type: string
              description: |-
                Current task status.

                - `PENDING`: Task is queued
                - `RUNNING`: Task is processing
                - `SUCCEEDED`: Task completed successfully
                - `FAILED`: Task failed
                - `CANCELED`: Task was canceled
                - `UNKNOWN`: Task does not exist or status is unknown
              enum:
                - PENDING
                - RUNNING
                - SUCCEEDED
                - FAILED
                - CANCELED
                - UNKNOWN
            submit_time:
              type: string
              description: Time when the task was submitted.
            scheduled_time:
              type: string
              description: Time when the task was scheduled for execution.
            end_time:
              type: string
              description: Time when the task completed.
            code:
              type: string
              description: Error code. Present when `task_status` is `FAILED`.
            message:
              type: string
              description: Error message. Present when `task_status` is `FAILED`.
            results:
              type: array
              description: Generated image results. Present when `task_status` is `SUCCEEDED`.
              items:
                $ref: "#/components/schemas/AsyncTaskResult"
            task_metrics:
              $ref: "#/components/schemas/TaskMetrics"
        usage:
          type: object
          description: Usage statistics.
          properties:
            image_count:
              type: integer
              description: Number of successfully generated images.
    AsyncTaskResult:
      type: object
      description: A single result from an async task.
      properties:
        orig_prompt:
          type: string
          description: The original prompt submitted by the user.
        actual_prompt:
          type: string
          description: The prompt actually used for generation (may differ from original if `prompt_extend` is enabled).
        url:
          type: string
          description: URL of the generated image. **Valid for 24 hours.**
    TaskMetrics:
      type: object
      description: Task completion metrics.
      properties:
        TOTAL:
          type: integer
          description: Total number of images requested.
        SUCCEEDED:
          type: integer
          description: Number of images successfully generated.
        FAILED:
          type: integer
          description: Number of images that failed to generate.
    DashScopeErrorResponse:
      type: object
      description: DashScope API error response.
      properties:
        request_id:
          type: string
          description: Unique request identifier.
        code:
          type: string
          description: Error code (e.g., `InvalidParameter`, `Throttling`, `Unauthorized`).
          example: InvalidParameter
        message:
          type: string
          description: Human-readable error message.
          example: num_images_per_prompt must be 1