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

Wan — Recuperar o resultado do primeiro quadro

Verifique o status da tarefa de vídeo

Estratégia de votação

  1. Crie uma tarefa para receber um task_id.
  2. Faça pesquisas a cada 15 segundos até task_status é SUCCEEDED ou FAILED.
  3. Em caso de sucesso, recupere o vídeo de video_url.

Notas importantes

OpenAPI

openapi: 3.1.0
info:
  title: Wan Image-to-Video (First Frame) API
  description: Generate videos from a first-frame image and text prompt using Wan image-to-video models. Supports audio synchronization, multi-shot narrative, and multiple resolution tiers.
  version: 1.0.0
servers:
  - url: https://maas.qwencloudapi.com/api/v1
    description: Singapore
security:
  - BearerAuth: []
paths:
  /tasks/{task_id}:
    get:
      operationId: getI2VFirstFrameTaskStatus
      summary: Query task result
      description: Query the status and result of the video generation task.
      parameters:
        - name: task_id
          in: path
          required: true
          description: The task ID returned by the POST endpoint.
          schema:
            type: string
      responses:
        "200":
          description: Task status retrieved
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TaskStatusResponse"
              examples:
                SUCCEEDED:
                  summary: Task succeeded
                  value:
                    request_id: c1209113-8437-424f-a386-xxxxxx
                    output:
                      task_id: 966cebcd-dedc-4962-af88-xxxxxx
                      task_status: SUCCEEDED
                      video_url: https://dashscope-result-sh.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx
                      task_metrics:
                        TOTAL: 1
                        SUCCEEDED: 1
                        FAILED: 0
                    usage:
                      video_count: 1
                      video_duration: 5
                FAILED:
                  summary: Task failed
                  value:
                    request_id: c1209113-8437-424f-a386-xxxxxx
                    output:
                      task_id: 966cebcd-dedc-4962-af88-xxxxxx
                      task_status: FAILED
                      code: InvalidParameter
                      message: The specified parameter is not valid.
                      task_metrics:
                        TOTAL: 1
                        SUCCEEDED: 0
                        FAILED: 1
                RUNNING:
                  summary: Task running
                  value:
                    request_id: c1209113-8437-424f-a386-xxxxxx
                    output:
                      task_id: 966cebcd-dedc-4962-af88-xxxxxx
                      task_status: RUNNING
                      task_metrics:
                        TOTAL: 1
                        SUCCEEDED: 0
                        FAILED: 0
        "400":
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DashScopeErrorResponse"
      x-codeSamples:
        - lang: curl
          label: cURL - Query task result
          source: |-
            # Replace {task_id} with the actual task ID from the submit response
            curl -X GET 'https://maas.qwencloudapi.com/api/v1/tasks/{task_id}' \
              -H "Authorization: Bearer $DASHSCOPE_API_KEY"
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: DashScope API Key. Create one in the [QwenCloud console](https://home.qwencloud.com/api-keys).
  schemas:
    I2VFirstFrameRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          description: Model name.
          enum:
            - wan2.6-i2v-flash
            - wan2.6-i2v
            - wan2.5-i2v-preview
            - wan2.2-i2v-flash
            - wan2.2-i2v-plus
            - wan2.1-i2v-turbo
            - wan2.1-i2v-plus
          example: wan2.6-i2v-flash
        input:
          type: object
          required:
            - img_url
          description: Input data including the first-frame image, prompt, and optional audio.
          properties:
            prompt:
              type: string
              description: |-
                Text prompt describing the desired content and visual characteristics for the generated video. Both Chinese and English are supported. Length limits vary by model:
                - wan2.6 and wan2.5 models: up to 1,500 characters.
                - wan2.2 and wan2.1 models: up to 800 characters.

                Text exceeding the limit is truncated automatically. For prompt tips, see Text-to-video/image-to-video prompt guide.
              example: A cat running on the grass
            negative_prompt:
              type: string
              description: Negative prompt describing content to exclude from the video. Both Chinese and English are supported. Maximum 500 characters; excess is truncated automatically.
              maxLength: 500
              example: low resolution, error, worst quality, low quality
            img_url:
              type: string
              description: |-
                URL or Base64 string of the first-frame image.

                **Image constraints:**
                - Format: JPEG, JPG, PNG (no alpha channel), BMP, WEBP.
                - Resolution: Width and height must be between 240 and 8,000 pixels.
                - File size: Up to 20 MB for Wan2.6 and Wan2.5 series models; up to 10 MB for Wan2.2 and Wan2.1 series models.

                **Supported input formats:**
                1. Public URL (HTTP/HTTPS supported).
                2. Base64-encoded image: `data:{MIME_type};base64,{base64_data}`.
              example: https://cdn.translate.alibaba.com/r/wanx-demo-1.png
            audio_url:
              type: string
              description: |-
                URL of an audio file. The model synchronizes video generation with this audio. Supported by wan2.6 and wan2.5 models only.

                **Audio constraints:**
                - Format: wav, mp3.
                - Duration: 3–30 seconds.
                - File size: Up to 15 MB.
                - If the audio exceeds the video `duration`, it is truncated. If shorter, the remaining video is silent.
              example: https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3
        parameters:
          $ref: "#/components/schemas/I2VFirstFrameParameters"
    I2VFirstFrameParameters:
      type: object
      description: Video generation parameters.
      properties:
        resolution:
          type: string
          description: |-
            Resolution tier of the generated video. The model scales output to a similar total pixel count. The aspect ratio closely matches the input image. Resolution directly affects cost (1080P > 720P > 480P).

            Default values and options by model:
            - wan2.6-i2v-flash: 720P, 1080P (default: 1080P)
            - wan2.6-i2v: 720P, 1080P (default: 1080P)
            - wan2.5-i2v-preview: 480P, 720P, 1080P (default: 1080P)
            - wan2.2-i2v-flash: 480P, 720P, 1080P (default: 720P)
            - wan2.2-i2v-plus: 480P, 1080P (default: 1080P)
            - wan2.1-i2v-turbo: 480P, 720P (default: 720P)
            - wan2.1-i2v-plus: 720P (fixed)
          enum:
            - 480P
            - 720P
            - 1080P
          example: 720P
        duration:
          type: integer
          description: |-
            Duration of the generated video in seconds. Longer durations cost more (billed per second).

            Valid values by model:
            - wan2.6-i2v-flash: integer 2–15 (default: 5)
            - wan2.6-i2v: integer 2–15 (default: 5)
            - wan2.5-i2v-preview: 5, 10 (default: 5)
            - wan2.2-i2v-plus: fixed 5 (not configurable)
            - wan2.2-i2v-flash: fixed 5 (not configurable)
            - wan2.1-i2v-plus: fixed 5 (not configurable)
            - wan2.1-i2v-turbo: 3, 4, 5 (default: 5)
          example: 5
        prompt_extend:
          type: boolean
          description: Whether to enable prompt rewriting. When enabled, an LLM rewrites the input prompt, which can improve generation quality for shorter prompts but increases processing time.
          default: true
          example: true
        shot_type:
          type: string
          description: Whether the video uses a single continuous shot or multiple switching shots. Supported by wan2.6 models only. Takes effect only when `prompt_extend` is `true`. When specified, overrides shot-related descriptions in the prompt.
          enum:
            - single
            - multi
          default: single
          example: single
        audio:
          type: boolean
          description: "Whether to generate a video with sound. Supported by wan2.6-i2v-flash only. Priority: `audio` > `audio_url`. If `audio=false`, the output is silent even if `audio_url` is provided. Audio setting affects pricing."
          default: true
          example: true
        watermark:
          type: boolean
          description: Whether to add an "AI Generated" watermark in the lower-right corner.
          default: false
          example: false
        seed:
          type: integer
          description: "Random number seed for reproducibility. Range: [0, 2147483647]. If omitted, a random seed is used. Identical seeds do not guarantee identical results."
          minimum: 0
          maximum: 2147483647
          example: 12345
    AsyncTaskSubmitResponse:
      type: object
      description: Response from an asynchronous task submission.
      properties:
        request_id:
          type: string
          description: Unique request identifier for tracing and troubleshooting.
          example: 4909100c-7b5a-9f92-bfe5-xxxxxx
        output:
          type: object
          properties:
            task_id:
              type: string
              description: Task ID for polling status. Use with `GET /tasks/{task_id}`. Valid for 24 hours.
              example: 0385dc79-5ff8-4d82-bcb6-xxxxxx
            task_status:
              type: string
              description: Initial task status, typically `PENDING`.
              enum:
                - PENDING
                - RUNNING
                - SUCCEEDED
                - FAILED
                - CANCELED
                - UNKNOWN
              example: PENDING
    TaskStatusResponse:
      type: object
      description: Response from polling a task's status.
      properties:
        request_id:
          type: string
          description: Unique request identifier.
          example: 2ca1c497-f9e0-449d-9a3f-xxxxxx
        output:
          type: object
          properties:
            task_id:
              type: string
              description: The task ID.
              example: af6efbc0-4bef-4194-8246-xxxxxx
            task_status:
              type: string
              description: "Current task status. Transitions: PENDING → RUNNING → SUCCEEDED or FAILED. UNKNOWN means the task does not exist or has expired."
              enum:
                - PENDING
                - RUNNING
                - SUCCEEDED
                - FAILED
                - CANCELED
                - UNKNOWN
            submit_time:
              type: string
              description: "Time when the task was submitted. UTC+8 format: YYYY-MM-DD HH:mm:ss.SSS."
              example: 2025-09-25 11:07:28.590
            scheduled_time:
              type: string
              description: "Time when the task started running. UTC+8 format: YYYY-MM-DD HH:mm:ss.SSS."
              example: 2025-09-25 11:07:35.349
            end_time:
              type: string
              description: "Time when the task completed. UTC+8 format: YYYY-MM-DD HH:mm:ss.SSS."
              example: 2025-09-25 11:17:11.650
            video_url:
              type: string
              description: URL of the generated video. Returned only when `task_status` is `SUCCEEDED`. Valid for 24 hours. Download promptly. MP4 format with H.264 encoding.
              example: https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.mp4?Expires=xxx
            orig_prompt:
              type: string
              description: The original input prompt.
            actual_prompt:
              type: string
              description: When `prompt_extend=true`, returns the optimized prompt used for generation. Not returned if `prompt_extend=false`. The wan2.6 model never returns this field.
            code:
              type: string
              description: Error code. Returned only when the task fails.
            message:
              type: string
              description: Detailed error message. Returned only when the task fails.
        usage:
          type: object
          description: Output statistics. Returned only for successful tasks. Fields vary by model version.
          properties:
            duration:
              type: integer
              description: "Total video duration used for billing. For wan2.6 models: `input_video_duration + output_video_duration`."
            input_video_duration:
              type: integer
              description: Duration of input video in seconds. Fixed at 0 for image-to-video. Returned by wan2.6 models.
            output_video_duration:
              type: integer
              description: Duration of output video in seconds. Returned by wan2.6 models.
            video_count:
              type: integer
              description: Number of generated videos. Fixed at 1.
              example: 1
            SR:
              type: integer
              description: Resolution tier of the generated video (e.g., 720). Returned by wan2.6, wan2.5, and wan2.2 models.
              example: 720
            audio:
              type: boolean
              description: Whether the output video has sound. Returned by wan2.6-i2v-flash only.
            video_duration:
              type: integer
              description: Duration of generated video in seconds. Returned by wan2.1 models only.
            video_ratio:
              type: string
              description: Aspect ratio of generated video. Fixed at `standard`. Returned by wan2.1 models only.
    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., `InvalidApiKey`, `InvalidParameter`, `Throttling`).
          example: InvalidApiKey
        message:
          type: string
          description: Human-readable error message.
          example: No API-key provided.