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

Wan - Recuperar o resultado do primeiro e último quadro

Verifique o status da tarefa de vídeo

Obtenha o status e os resultados de uma tarefa de geração de imagem para vídeo (primeiro e último quadro).

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 & Last Frames) API
  description: Generate a smoothly transitioning video from a first frame image, a last frame image, and a text prompt using the Wan kf2v model.
  version: 1.0.0
servers:
  - url: https://maas.qwencloudapi.com/api/v1
    description: Singapore
security:
  - BearerAuth: []
paths:
  /tasks/{task_id}:
    get:
      operationId: getI2VFirstLastTaskStatus
      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 ID of the task to query.
          schema:
            type: string
      responses:
        "200":
          description: Task status retrieved successfully
          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 parameters
          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:
    I2VFirstLastRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          description: Model name.
          enum:
            - wan2.2-kf2v-flash
            - wan2.1-kf2v-plus
          example: wan2.2-kf2v-flash
        input:
          type: object
          required:
            - first_frame_url
            - last_frame_url
          description: Input data including frame images and optional prompt.
          properties:
            prompt:
              type: string
              description: Text prompt describing the desired video content. Supports Chinese and English. Maximum 800 characters; excess is auto-truncated. If the subject or scene changes between the first and last frames, describe the transition (e.g., camera movement or subject movement).
              maxLength: 800
              example: Realistic style, a small black cat looks up at the sky curiously, the camera gradually rises from eye level, and finally captures its curious gaze from a top-down view.
            negative_prompt:
              type: string
              description: Describes content you do NOT want in the video. Supports Chinese and English. Maximum 500 characters; excess is auto-truncated.
              maxLength: 500
              example: low resolution, error, worst quality, low quality, deformed, extra fingers, bad proportions
            first_frame_url:
              type: string
              description: "URL of the first frame image. The output video aspect ratio matches this image. Must be publicly accessible (HTTP or HTTPS). **Image requirements**: Format: JPEG, JPG, PNG (no alpha), BMP, or WEBP. Resolution: 240-8000 px per side. Max file size: 10 MB."
              example: https://wanx.alicdn.com/material/20250318/first_frame.png
            last_frame_url:
              type: string
              description: "URL of the last frame image. Must be publicly accessible (HTTP or HTTPS). Resolution may differ from the first frame; alignment is not required. **Image requirements**: Format: JPEG, JPG, PNG (no alpha), BMP, or WEBP. Resolution: 240-8000 px per side. Max file size: 10 MB."
              example: https://wanx.alicdn.com/material/20250318/last_frame.png
        parameters:
          $ref: "#/components/schemas/I2VFirstLastParameters"
    I2VFirstLastParameters:
      type: object
      description: Video generation parameters.
      properties:
        resolution:
          type: string
          description: "Resolution tier for the generated video. Adjusts definition (total pixels) without changing aspect ratio. The video aspect ratio matches the first frame image. **Resolution affects cost**: 1080P > 720P > 480P. Available values depend on the model: `wan2.2-kf2v-flash`: 480P, 720P, 1080P (default: 720P). `wan2.1-kf2v-plus`: 480P, 720P (default: 720P)."
          enum:
            - 480P
            - 720P
            - 1080P
          default: 720P
          example: 720P
        duration:
          type: integer
          description: Duration of the generated video in seconds. Fixed at 5; cannot be changed.
          enum:
            - 5
          default: 5
        prompt_extend:
          type: boolean
          description: "Enable prompt rewriting. When enabled, a large language model rewrites the input prompt to improve results for short prompts, but increases processing time. Default: `true`."
          default: true
        watermark:
          type: boolean
          description: 'Add an "AI-generated" watermark to the bottom-right corner of the video. Default: `false`.'
          default: false
        seed:
          type: integer
          description: "Random number seed for reproducibility. Range: [0, 2147483647]. If omitted, a random seed is used. Results may still vary due to model randomness."
          minimum: 0
          maximum: 2147483647
    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
    TaskStatusResponse:
      type: object
      description: Response from querying task status.
      properties:
        request_id:
          type: string
          description: Unique request identifier for tracing and troubleshooting.
          example: ec016349-6b14-9ad6-8009-xxxxxx
        output:
          type: object
          description: Task output information.
          properties:
            task_id:
              type: string
              description: The ID of the task.
              example: 3f21a745-9f4b-4588-b643-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-04-18 10:36:58.394
            scheduled_time:
              type: string
              description: "Time when the task started running (UTC+8). Format: YYYY-MM-DD HH:mm:ss.SSS."
              example: 2025-04-18 10:37:13.802
            end_time:
              type: string
              description: "Time when the task completed (UTC+8). Format: YYYY-MM-DD HH:mm:ss.SSS."
              example: 2025-04-18 10:45:23.004
            video_url:
              type: string
              description: URL of the generated video (MP4, H.264). Returned only when `task_status` is `SUCCEEDED`. Valid for 24 hours.
              example: https://dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com/xxx.mp4?xxxxx
            orig_prompt:
              type: string
              description: The original input prompt.
            actual_prompt:
              type: string
              description: The optimized prompt used when prompt rewriting is enabled. Not returned when prompt rewriting is disabled.
            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: Usage statistics. Only returned for successful tasks.
          properties:
            video_duration:
              type: integer
              description: "Video duration in seconds. Value: 5. Billing formula: Cost = Video duration (seconds) x Unit price."
              example: 5
            video_count:
              type: integer
              description: Number of videos generated. Fixed at 1.
              example: 1
            video_ratio:
              type: string
              description: Video aspect ratio. Returned only by wan2.1 models. Fixed at `standard`.
              example: standard
            SR:
              type: integer
              description: "Video resolution tier. Returned only by wan2.2 models. Values: 480, 720, or 1080."
              enum:
                - 480
                - 720
                - 1080
              example: 480
    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`, `InvalidApiKey`, `Throttling`).
          example: InvalidApiKey
        message:
          type: string
          description: Human-readable error message.
          example: No API-key provided.