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

wan3.0-video Geração de Vídeo

wan3.0-video Modelo de geração de vídeo tudo-em-um. Suporta texto para vídeo, primeiro quadro/primeiro+último quadro, referência tudo-em-um, áudio e muito mais.

Python SDK

```python expandable
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os

# If you have not set environment variables, replace the following line with your API Key: api_key="sk-xxx"
# Get API Key: https://www.alibabacloud.com/help/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")

media = [{'type': 'file', 'url': 'https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260806/ebapmr/glass.pptx'}]

def sample_async_call():
    # Submit video generation task asynchronously
    rsp = VideoSynthesis.async_call(api_key=api_key,
                                model='wan3.0-video',
                                prompt='A high-end smart glasses product advertisement with a minimalist, futuristic, and fashionable style. The color palette features black, silver-gray, and ice-blue tones with subtle white light accents and parameter UI graphics. Opening in pure black background, a pair of smart glasses slowly emerges from darkness with refined highlights on the temple edges. The camera captures ultra-close details of lenses, nose pads, hinges, temples, and material textures, showcasing metal and high-performance composite materials. The product then rotates slowly in mid-air with minimalist motion graphics displaying core parameters. Then the camera pulls back as all parts precisely reassemble into the complete product, transitioning to a young model wearing demonstration in minimalist spaces and urban lighting environments.',
                                media=media,
                                resolution='480P',
                                ratio='adaptive',
                                duration=10,
                                prompt_extend=True)
    print(rsp)
    if rsp.status_code == HTTPStatus.OK:
        print("task_id: %s" % rsp.output.task_id)
    else:
        print('Failed, status_code: %s, code: %s, message: %s' %
              (rsp.status_code, rsp.code, rsp.message))

    # Query task status
    status = VideoSynthesis.fetch(task=rsp, api_key=api_key)
    if status.status_code == HTTPStatus.OK:
        print(status.output.task_status)
    else:
        print('Failed, status_code: %s, code: %s, message: %s' %
              (status.status_code, status.code, status.message))

    # Wait for task completion
    rsp = VideoSynthesis.wait(task=rsp, api_key=api_key)
    print(rsp)
    if rsp.status_code == HTTPStatus.OK:
        print(rsp.output.video_url)
    else:
        print('Failed, status_code: %s, code: %s, message: %s' %
              (rsp.status_code, rsp.code, rsp.message))

if __name__ == '__main__':
    sample_async_call()
```

OpenAPI

openapi: 3.1.0
info:
  title: Wan 3.0 Video Generation API
  description: Wan 3.0 is an All-in-One video generation model that supports text-to-video, image-to-video (first-frame / first+last-frame), reference-to-video, and file-to-video, generating videos up to 30 seconds. Submit a task asynchronously, then poll `GET /tasks/{task_id}` for the result.
  version: 1.0.0
servers:
  - url: https://maas.qwencloudapi.com/api/v1
    description: QwenCloud
security:
  - BearerAuth: []
paths:
  /services/aigc/video-generation/video-synthesis:
    post:
      operationId: createWan30VideoTask
      summary: Create video generation task
      description: Submit a video generation task. Returns a `task_id` for polling. Supports text-to-video, first-frame/first+last-frame, all-in-one reference modes, and file-to-video.
      parameters:
        - name: X-DashScope-Async
          in: header
          required: true
          description: 'Must be set to `enable` for asynchronous task submission. Missing this header causes: "current user api does not support synchronous calls".'
          schema:
            type: string
            enum:
              - enable
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Wan30VideoRequest"
      responses:
        "200":
          description: Task submitted successfully
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AsyncTaskSubmitResponse"
        "400":
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DashScopeErrorResponse"
      x-codeSamples:
        - lang: curl
          label: File to video
          source: |-
            curl --location 'https://maas.qwencloudapi.com/api/v1/services/aigc/video-generation/video-synthesis' \
                -H 'X-DashScope-Async: enable' \
                -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
                -H 'Content-Type: application/json' \
                -d '{
                "model": "wan3.0-video",
                "input": {
                    "prompt": "A premium smart glasses product ad with a minimalist, futuristic, and fashionably sophisticated style. Restrained lighting with black, silver-gray, and ice-blue as the primary palette, accented by soft white light and parametric UI graphics. Opening on a pure black background, smart glasses slowly emerge from darkness with refined highlights along the temple edges, the frame outlined by cool rim lighting. The camera captures ultra-close-up shots of the lens, nose pads, hinges, temples, and material details, showcasing the delicate texture of metal and high-performance composites. Subsequently the product rotates slowly in mid-air while minimalist motion graphics display core specs. Then the camera quickly converges, all components precisely reassembling into the complete product, cutting to a young model wearing them—sharp features, confident demeanor, in clean urban fashion, naturally turning, raising a hand, walking, and smiling in a minimal space with city light and shadow. The closing shot shows the product suspended on a solid background as the camera slowly pushes into the brand logo and core slogan.",
                    "media": [
                        {
                            "type": "file",
                            "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260806/ebapmr/glass.pptx"
                        }
                    ]
                },
                "parameters": {
                    "resolution": "480P",
                    "ratio": "adaptive",
                    "duration": 10,
                    "prompt_extend": true
                }
            }'
        - lang: curl
          label: Reference to video
          source: |-
            curl --location 'https://maas.qwencloudapi.com/api/v1/services/aigc/video-generation/video-synthesis' \
                -H 'X-DashScope-Async: enable' \
                -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
                -H 'Content-Type: application/json' \
                -d '{
                "model": "wan3.0-video",
                "input": {
                    "prompt": "Video1 holds Image3, playing a soothing folk song on the chair in Image4, saying: \"The sunshine is wonderful today.\" Image1 holds Image2, walks past Video1, places Image2 on the table next to Video1, and says: \"That sounds great, can you play it again?\"",
                    "media": [
                        {
                            "type": "reference_image",
                            "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260408/sjuytr/wan-r2v-object-girl.jpg"
                        },
                        {
                            "type": "reference_video",
                            "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260129/qigswt/wan-r2v-role2.mp4"
                        },
                        {
                            "type": "reference_image",
                            "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260129/rtjeqf/wan-r2v-object3.png"
                        },
                        {
                            "type": "reference_image",
                            "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260129/qpzxps/wan-r2v-object4.png"
                        },
                        {
                            "type": "reference_image",
                            "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260129/wfjikw/wan-r2v-backgroud5.png"
                        }
                    ]
                },
                "parameters": {
                    "resolution": "480P",
                    "ratio": "adaptive",
                    "duration": 5,
                    "prompt_extend": true
                }
            }'
        - lang: curl
          label: Text-to-video
          source: |-
            curl --location 'https://maas.qwencloudapi.com/api/v1/services/aigc/video-generation/video-synthesis' \
                -H 'X-DashScope-Async: enable' \
                -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
                -H 'Content-Type: application/json' \
                -d '{
                "model": "wan3.0-video",
                "input": {
                    "prompt": "A kitten running on rooftops under moonlight, neon lights flickering in the distance, cinematic quality, smooth camera movement."
                },
                "parameters": {
                    "resolution": "480P",
                    "ratio": "adaptive",
                    "duration": 5,
                    "prompt_extend": true
                }
            }'
        - lang: curl
          label: First-frame to video
          source: |-
            curl --location 'https://maas.qwencloudapi.com/api/v1/services/aigc/video-generation/video-synthesis' \
                -H 'X-DashScope-Async: enable' \
                -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
                -H 'Content-Type: application/json' \
                -d '{
                "model": "wan3.0-video",
                "input": {
                    "prompt": "An urban fantasy art scene. A dynamic graffiti character—a spray-painted boy—comes alive from a concrete wall, rapping energetically with a classic hip-hop pose under a railway bridge at night, illuminated by a lone streetlight with cinematic atmosphere.",
                    "media": [
                        {
                            "type": "first_frame",
                            "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png"
                        }
                    ]
                },
                "parameters": {
                    "resolution": "480P",
                    "ratio": "adaptive",
                    "duration": 5,
                    "prompt_extend": true
                }
            }'
        - lang: curl
          label: First+last-frame to video
          source: |-
            curl --location 'https://maas.qwencloudapi.com/api/v1/services/aigc/video-generation/video-synthesis' \
                -H 'X-DashScope-Async: enable' \
                -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
                -H 'Content-Type: application/json' \
                -d '{
                "model": "wan3.0-video",
                "input": {
                    "prompt": "A young girl transitions from a smile to laughter, camera slowly pushing in, background lighting shifting from cool to warm tones.",
                    "media": [
                        {
                            "type": "first_frame",
                            "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png"
                        },
                        {
                            "type": "last_frame",
                            "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260408/sjuytr/wan-r2v-object-girl.jpg"
                        }
                    ]
                },
                "parameters": {
                    "resolution": "480P",
                    "ratio": "adaptive",
                    "duration": 5,
                    "prompt_extend": true
                }
            }'
        - lang: curl
          label: Video editing
          source: |-
            curl --location 'https://maas.qwencloudapi.com/api/v1/services/aigc/video-generation/video-synthesis' \
                -H 'X-DashScope-Async: enable' \
                -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
                -H 'Content-Type: application/json' \
                -d '{
                "model": "wan3.0-video",
                "input": {
                    "prompt": "Transform the entire scene into a clay art style",
                    "media": [
                        {
                            "type": "reference_video",
                            "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/ldnfdf/wan2.7-videoedit-style-change.mp4"
                        }
                    ]
                },
                "parameters": {
                    "resolution": "720P",
                    "prompt_extend": true
                }
            }'
        - lang: curl
          label: Video extension
          source: |-
            curl --location 'https://maas.qwencloudapi.com/api/v1/services/aigc/video-generation/video-synthesis' \
                -H 'X-DashScope-Async: enable' \
                -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
                -H 'Content-Type: application/json' \
                -d '{
                "model": "wan3.0-video",
                "input": {
                    "prompt": "Extend Video 1 forward: the baker brings out the brushed bread, sets the brush aside, and the camera follows the baker to the oven in the back for baking",
                    "media": [
                        {
                            "type": "reference_video",
                            "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/ldnfdf/wan2.7-videoedit-style-change.mp4"
                        }
                    ]
                },
                "parameters": {
                    "resolution": "720P",
                    "ratio": "adaptive",
                    "prompt_extend": true
                }
            }'
        - lang: python
          label: Python SDK
          source: |-
            from http import HTTPStatus
            from dashscope import VideoSynthesis
            import dashscope
            import os

            # If you have not set environment variables, replace the following line with your API Key: api_key="sk-xxx"
            # Get API Key: https://home.qwencloud.com
            api_key = os.getenv("DASHSCOPE_API_KEY")

            media = [{'type': 'file', 'url': 'https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260806/ebapmr/glass.pptx'}]

            def sample_async_call():
                # Submit video generation task asynchronously
                rsp = VideoSynthesis.async_call(api_key=api_key,
                                            model='wan3.0-video',
                                            prompt='A high-end smart glasses product advertisement with a minimalist, futuristic, and fashionable style. The color palette features black, silver-gray, and ice-blue tones with subtle white light accents and parameter UI graphics. Opening in pure black background, a pair of smart glasses slowly emerges from darkness with refined highlights on the temple edges. The camera captures ultra-close details of lenses, nose pads, hinges, temples, and material textures, showcasing metal and high-performance composite materials. The product then rotates slowly in mid-air with minimalist motion graphics displaying core parameters. Then the camera pulls back as all parts precisely reassemble into the complete product, transitioning to a young model wearing demonstration in minimalist spaces and urban lighting environments.',
                                            media=media,
                                            resolution='480P',
                                            ratio='adaptive',
                                            duration=10,
                                            prompt_extend=True)
                print(rsp)
                if rsp.status_code == HTTPStatus.OK:
                    print("task_id: %s" % rsp.output.task_id)
                else:
                    print('Failed, status_code: %s, code: %s, message: %s' %
                          (rsp.status_code, rsp.code, rsp.message))

                # Query task status
                status = VideoSynthesis.fetch(task=rsp, api_key=api_key)
                if status.status_code == HTTPStatus.OK:
                    print(status.output.task_status)
                else:
                    print('Failed, status_code: %s, code: %s, message: %s' %
                          (status.status_code, status.code, status.message))

                # Wait for task completion
                rsp = VideoSynthesis.wait(task=rsp, api_key=api_key)
                print(rsp)
                if rsp.status_code == HTTPStatus.OK:
                    print(rsp.output.video_url)
                else:
                    print('Failed, status_code: %s, code: %s, message: %s' %
                          (rsp.status_code, rsp.code, rsp.message))

            if __name__ == '__main__':
                sample_async_call()
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: QwenCloud API Key. See [Get an API Key](/api-reference/preparation/api-key).
  schemas:
    Wan30VideoRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          description: |-
            Model name. Valid values:

            - `wan3.0-video-prime`: High-speed version with capabilities aligned to the standard version, with significantly improved end-to-end speed.
            - `wan3.0-video`: Standard version.
          enum:
            - wan3.0-video-prime
            - wan3.0-video
          example: wan3.0-video
        input:
          type: object
          description: Input information. Either `prompt` or `media` is required.
          properties:
            prompt:
              type: string
              description: Text prompt describing the desired video content. Either this or `media` is required. Supports Chinese and English, up to 20,000 characters (auto-truncated beyond). In all-in-one reference mode, use "Image1", "Video1", "Audio1" etc. in the prompt to refer to media items by their array order.
              maxLength: 20000
              example: A kitten running on rooftops under moonlight, neon lights flickering in the distance, cinematic quality, smooth camera movement.
            media:
              type: array
              description: Media array supporting images, videos, audio, files, and web links as input. Either this or `prompt` is required. In reference mode, array order defines the numbering in prompts (images and videos are counted separately). `reference_xx`/`file`/`link` types and `first_frame`/`last_frame` types are mutually exclusive.
              items:
                $ref: "#/components/schemas/MediaItem"
        parameters:
          $ref: "#/components/schemas/Wan30VideoParameters"
    MediaItem:
      type: object
      required:
        - type
        - url
      properties:
        type:
          type: string
          description: |-
            Media type. `reference_xx`/`file`/`link` types and `first_frame`/`last_frame` types are mutually exclusive within the same request.

            Media limits by type:
            - `reference_image` / `first_frame` / `last_frame` (image): JPEG/JPG/PNG/BMP/WEBP; resolution [240, 8000] per side; aspect ratio ≤ 8:1; file size ≤ 20MB.
            - `reference_video` (video): mp4/mov; duration [1, 15]s per clip, total ≤ 15s; frame rate ≥ 16 fps; resolution [240, 4096] per side; aspect ratio ≤ 8:1; file size ≤ 100MB per clip.
            - `reference_audio` (audio): wav/mp3; duration [1, 15]s per clip, total ≤ 15s; file size ≤ 15MB.
            - `file`: docx/doc/xlsx/xls/pptx/ppt/pdf/txt/key/pages/numbers/md; file size ≤ 100MB; page limit ≤ 50 pages (validated for pdf/docx/doc/pptx/ppt/key/pages).
          enum:
            - first_frame
            - last_frame
            - reference_image
            - reference_video
            - reference_audio
            - file
            - link
        url:
          type: string
          description: Media URL or Base64-encoded data. Supports public URLs (HTTP/HTTPS) and Base64 encoding (`data:{MIME_type};base64,{data}`).
    Wan30VideoParameters:
      type: object
      description: Video generation parameters.
      properties:
        resolution:
          type: string
          description: Output video resolution tier.
          enum:
            - 480P
            - 720P
            - 1080P
          default: 1080P
        ratio:
          type: string
          description: Output video aspect ratio. `adaptive` automatically selects the best ratio based on input media and intent.
          enum:
            - adaptive
            - 21:9
            - 16:9
            - 4:3
            - 1:1
            - 3:4
            - 9:16
          default: adaptive
        duration:
          type: integer
          description: "Output video duration in seconds. Without video input: integer in [2, 30]. With video input: input + output duration must not exceed 30s. Set to `-1` for smart duration mode (model selects optimal length)."
          default: 5
        audio:
          type: boolean
          description: "Whether the output video includes audio. `true` (default): includes sound. `false`: no audio track. Pricing is the same regardless of this setting."
          default: true
        seed:
          type: integer
          description: "Random seed. Used to reproduce generation results. Value range: -1 or [0, 2147483647]. When set to -1 or not specified, the system automatically generates a random seed. Even with the same seed value, generation results may not be perfectly identical."
          minimum: -1
          maximum: 2147483647
        watermark:
          type: boolean
          description: Whether to add a watermark.
          default: false
        prompt_extend:
          type: boolean
          description: Whether to enable intelligent prompt rewriting. When enabled, a large language model rewrites the input prompt to improve video generation quality. Recommended for shorter prompts; increases latency slightly. When a document (`file`) or webpage (`link`) is provided as input, `prompt_extend` must be set to `true`.
          default: true
    AsyncTaskSubmitResponse:
      type: object
      description: Async task submission response.
      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, valid for 24 hours. Use with `GET /tasks/{task_id}`. Do not re-create the task; poll instead.
              example: 0385dc79-5ff8-4d82-bcb6-xxxxxx
            task_status:
              type: string
              description: Initial task status, typically `PENDING`.
              enum:
                - PENDING
                - RUNNING
                - SUCCEEDED
                - FAILED
                - CANCELED
                - UNKNOWN
    Wan30VideoTaskStatusResponse:
      type: object
      description: Wan 3.0 video generation task status response.
      properties:
        request_id:
          type: string
          description: Unique request identifier for tracing and troubleshooting.
          example: 78c9b768-0285-996c-b682-xxxxxx
        output:
          type: object
          properties:
            task_id:
              type: string
              description: Task ID.
              example: 17ed7e50-00cf-4509-aea1-xxxxxx
            task_status:
              type: string
              description: "Task status. Flow: `PENDING` (queued) -> `RUNNING` (processing) -> `SUCCEEDED` / `FAILED`. Manually canceled: `CANCELED`. Expired: `UNKNOWN`."
              enum:
                - PENDING
                - RUNNING
                - SUCCEEDED
                - FAILED
                - CANCELED
                - UNKNOWN
            submit_time:
              type: string
              description: "Task submission time. Format: YYYY-MM-DD HH:mm:ss.SSS."
              example: 2026-08-06 10:01:35.452
            scheduled_time:
              type: string
              description: "Task execution start time. Format: YYYY-MM-DD HH:mm:ss.SSS."
              example: 2026-08-06 10:01:35.507
            end_time:
              type: string
              description: "Task completion time. Format: YYYY-MM-DD HH:mm:ss.SSS. Only returned for `SUCCEEDED` or `FAILED`."
              example: 2026-08-06 10:13:33.838
            orig_prompt:
              type: string
              description: Original input prompt text.
            video_url:
              type: string
              format: uri
              description: Generated video URL. Only returned when `task_status` is `SUCCEEDED`. Valid for 24 hours — download promptly.
              example: https://dashscope-result-sg.oss-ap-southeast-1.aliyuncs.com/xxx/video.mp4
            code:
              type: string
              description: Error code. Only returned when `task_status` is `FAILED`.
            message:
              type: string
              description: Error message. Only returned when `task_status` is `FAILED`.
        usage:
          type: object
          description: Usage statistics. Only counted for successful results.
          properties:
            video_count:
              type: integer
              description: Number of generated videos. Fixed at 1.
            duration:
              type: number
              description: Total video duration in seconds. When no input reference video is provided, it equals the output video duration; when an input reference video is provided, it equals the sum of the input video duration and the output video duration.
            input_video_duration:
              type: number
              description: Input video duration in seconds. Returns 0.0 when no video is provided as input.
            output_video_duration:
              type: number
              description: Output video duration in seconds.
            fps:
              type: integer
              description: "Generated video frame rate. Default value: 30."
            SR:
              type: integer
              description: Generated video resolution tier (e.g. 720 for 720P).
            ratio:
              type: string
              description: Generated video aspect ratio (e.g. 16:9).
    DashScopeErrorResponse:
      type: object
      description: API error response.
      properties:
        request_id:
          type: string
          description: Unique request identifier for tracing and troubleshooting.
        code:
          type: string
          description: Error code.
          example: InvalidApiKey
        message:
          type: string
          description: Error description.
          example: Invalid API-key provided.