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

Wan 2.7 -- Gere um vídeo a partir de texto

Enviar tarefa de texto para vídeo (wan2.7)

Gere vídeos de até 15 segundos em 1080P a partir de prompts de texto, com sincronização de áudio opcional e narrativa multi-shot.

Mudanças de wan2.6

OpenAPI

openapi: 3.1.0
info:
  title: Wan 2.7 Text-to-Video API
  description: Generate videos from text using the Wan 2.7 model. 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: Singapore
security:
  - BearerAuth: []
paths:
  /services/aigc/video-generation/video-synthesis:
    post:
      operationId: createWan27TextToVideo
      summary: Create text-to-video task
      description: Submit a text-to-video task. Returns a `task_id` for polling.
      parameters:
        - name: X-DashScope-Async
          in: header
          required: true
          description: Must be set to `enable` for asynchronous task submission.
          schema:
            type: string
            enum:
              - enable
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Wan27TextToVideoRequest"
      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: cURL - Multi-shot narrative
          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": "wan2.7-t2v-2026-06-12",
              "input": {
                "prompt": "A tense detective story with cinematic storytelling. Shot 1 [0\u20133 seconds] wide shot: Rainy New York street at night, neon lights flicker, a detective in a black trench coat walks briskly. Shot 2 [3\u20136 seconds] medium shot: The detective enters an old building, rain wets his coat, the door closes slowly behind him. Shot 3 [6\u20139 seconds] close-up: The detective\u2019s focused eyes, distant sirens sound, he frowns slightly. Shot 4 [9\u201312 seconds] medium shot: The detective moves carefully down a dim hallway, his flashlight illuminating the way. Shot 5 [12\u201315 seconds] close-up: The detective discovers a key clue, his face shows sudden realization."
              },
              "parameters": {
                "resolution": "720P",
                "ratio": "16:9",
                "prompt_extend": true,
                "watermark": true,
                "duration": 15
              }
            }'
        - lang: curl
          label: cURL - Provide an audio file
          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": "wan2.7-t2v-2026-06-12",
              "input": {
                "prompt": "An epic and cute scene. A small, adorable cartoon kitten general, wearing exquisitely detailed golden armor and a slightly oversized helmet, stands bravely on a cliff. He rides a small but heroic warhorse and says: \u2018The long clouds of Qinghai darken the snowy mountains, a lone city gazes at Yumen Pass from afar. Through a hundred battles in the yellow sand, the golden armor is worn, but we will not return until we have broken Loulan\u2019. Below the cliff, a vast and endless army of mice with makeshift weapons is charging forward. This is a dramatic, large-scale battle scene inspired by ancient Chinese war epics. In the distance, dark clouds gather in the sky over the snowy mountains. The overall atmosphere is a comical and epic fusion of \u2018cute\u2019 and \u2018domineering\u2019.",
                "audio_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250923/hbiayh/%E4%BB%8E%E5%86%9B%E8%A1%8C.mp3"
              },
              "parameters": {
                "resolution": "1080P",
                "ratio": "16:9",
                "prompt_extend": true,
                "duration": 10
              }
            }'
        - lang: curl
          label: cURL - Automatic dubbing
          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": "wan2.7-t2v-2026-06-12",
              "input": {
                "prompt": "An epic and cute scene. A small, adorable cartoon kitten general, wearing exquisitely detailed golden armor and a slightly oversized helmet, stands bravely on a cliff. He rides a small but heroic warhorse and says: \u2018The long clouds of Qinghai darken the snowy mountains, a lone city gazes at Yumen Pass from afar. Through a hundred battles in the yellow sand, the golden armor is worn, but we will not return until we have broken Loulan\u2019. Below the cliff, a vast and endless army of mice with makeshift weapons is charging forward. This is a dramatic, large-scale battle scene inspired by ancient Chinese war epics. In the distance, dark clouds gather in the sky over the snowy mountains. The overall atmosphere is a comical and epic fusion of \u2018cute\u2019 and \u2018domineering\u2019."
              },
              "parameters": {
                "resolution": "720P",
                "ratio": "16:9",
                "prompt_extend": true,
                "duration": 10
              }
            }'
        - lang: curl
          label: cURL - Use a negative prompt
          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": "wan2.7-t2v-2026-06-12",
              "input": {
                "prompt": "A kitten running in the moonlight",
                "negative_prompt": "flower"
              },
              "parameters": {
                "resolution": "720P",
                "ratio": "16:9"
              }
            }'
        - lang: python
          label: Python - Synchronous call
          source: |-
            import os
            from http import HTTPStatus
            from dashscope import VideoSynthesis
            import dashscope

            dashscope.base_http_api_url = 'https://maas.qwencloudapi.com/api/v1'
            api_key = os.getenv("DASHSCOPE_API_KEY")

            def sample_sync_call():
              print('Please wait...')
              rsp = VideoSynthesis.call(
                api_key=api_key,
                model='wan2.7-t2v',
                prompt='A cat walks along the street, the camera follows the cat.',
                resolution='720P',
                ratio='16:9',
                prompt_extend=True,
                watermark=True,
                duration=5)
              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_sync_call()
        - lang: python
          label: Python - Asynchronous call
          source: |-
            import os
            from http import HTTPStatus
            from dashscope import VideoSynthesis
            import dashscope

            dashscope.base_http_api_url = 'https://maas.qwencloudapi.com/api/v1'
            api_key = os.getenv("DASHSCOPE_API_KEY")

            def sample_async_call():
              rsp = VideoSynthesis.async_call(
                api_key=api_key,
                model='wan2.7-t2v',
                prompt='A cat walks along the street, the camera follows the cat.',
                resolution='720P',
                ratio='16:9',
                prompt_extend=True,
                watermark=True,
                duration=5)
              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))
              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()
        - lang: java
          label: Java - Synchronous call
          source: |-
            import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
            import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisParam;
            import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisResult;
            import com.alibaba.dashscope.exception.ApiException;
            import com.alibaba.dashscope.exception.InputRequiredException;
            import com.alibaba.dashscope.exception.NoApiKeyException;
            import com.alibaba.dashscope.utils.JsonUtils;
            import com.alibaba.dashscope.utils.Constants;
            import java.util.*;

            public class Wan27T2V {
              static {
                Constants.baseHttpApiUrl = "https://maas.qwencloudapi.com/api/v1";
              }
              public static void main(String[] args) {
                try {
                  VideoSynthesis vs = new VideoSynthesis();
                  Map<String, Object> parameters = new HashMap<>();
                  parameters.put("resolution", "720P");
                  parameters.put("ratio", "16:9");
                  parameters.put("prompt_extend", true);
                  parameters.put("watermark", true);
                  parameters.put("duration", 5);
                  VideoSynthesisParam param = VideoSynthesisParam.builder()
                    .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                    .model("wan2.7-t2v")
                    .prompt("A cat walks along the street, the camera follows the cat.")
                    .parameters(parameters)
                    .build();
                  System.out.println("Please wait...");
                  VideoSynthesisResult result = vs.call(param);
                  System.out.println(JsonUtils.toJson(result));
                } catch (ApiException | NoApiKeyException | InputRequiredException e) {
                  System.out.println(e.getMessage());
                }
              }
            }
        - lang: java
          label: Java - Asynchronous call
          source: |-
            import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
            import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisParam;
            import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisResult;
            import com.alibaba.dashscope.exception.ApiException;
            import com.alibaba.dashscope.exception.InputRequiredException;
            import com.alibaba.dashscope.exception.NoApiKeyException;
            import com.alibaba.dashscope.utils.JsonUtils;
            import com.alibaba.dashscope.utils.Constants;
            import java.util.*;

            public class Wan27T2V {
              static {
                Constants.baseHttpApiUrl = "https://maas.qwencloudapi.com/api/v1";
              }
              public static void main(String[] args) {
                try {
                  String apiKey = System.getenv("DASHSCOPE_API_KEY");
                  VideoSynthesis vs = new VideoSynthesis();
                  Map<String, Object> parameters = new HashMap<>();
                  parameters.put("resolution", "720P");
                  parameters.put("ratio", "16:9");
                  parameters.put("prompt_extend", true);
                  parameters.put("watermark", true);
                  parameters.put("duration", 5);
                  VideoSynthesisParam param = VideoSynthesisParam.builder()
                    .apiKey(apiKey)
                    .model("wan2.7-t2v")
                    .prompt("A cat walks along the street, the camera follows the cat.")
                    .parameters(parameters)
                    .build();
                  VideoSynthesisResult task = vs.asyncCall(param);
                  System.out.println(JsonUtils.toJson(task));
                  System.out.println("Please wait...");
                  VideoSynthesisResult result = vs.wait(task, apiKey);
                  System.out.println(JsonUtils.toJson(result));
                } catch (ApiException | NoApiKeyException | InputRequiredException e) {
                  System.out.println(e.getMessage());
                }
              }
            }
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: DashScope API Key. Get one from the [QwenCloud console](https://home.qwencloud.com/api-keys).
  schemas:
    Wan27TextToVideoRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          description: "Model identifier. Supported values: `wan2.7-t2v`, `wan2.7-t2v-2026-06-12`."
          enum:
            - wan2.7-t2v
            - wan2.7-t2v-2026-06-12
          example: wan2.7-t2v
        input:
          type: object
          required:
            - prompt
          description: Input content for video generation.
          properties:
            prompt:
              type: string
              description: "Describe the video you want. Supports Chinese and English, up to 5,000 characters (auto-truncated if exceeded). For multi-shot videos, describe each shot with timestamps: `Shot 1 [0-3 seconds] wide shot: ...`."
              example: A kitten running in the moonlight.
            negative_prompt:
              type: string
              description: Describe what to exclude from the video (e.g., `low quality, blurry, extra fingers`). Supports Chinese and English, up to 500 characters (auto-truncated if exceeded).
              example: low resolution, error, worst quality, low quality, deformed, extra fingers, bad proportions
            audio_url:
              type: string
              format: uri
              description: Audio file URL for lip-sync and action-to-audio alignment. The model matches mouth movements and actions to the audio track. Supports WAV and MP3 via HTTP/HTTPS, 2-30 seconds, up to 15 MB. Audio longer than `duration` is truncated; audio shorter than the video leaves the remainder silent. If omitted, the model generates matching background music or sound effects automatically.
        parameters:
          $ref: "#/components/schemas/Wan27TextToVideoParameters"
    Wan27TextToVideoParameters:
      type: object
      description: Video generation parameters.
      properties:
        resolution:
          type: string
          description: |-
            Video clarity tier. Higher resolution costs more.

            Actual output dimensions depend on `ratio`:
            - **720P**: 16:9=1280x720, 9:16=720x1280, 1:1=960x960, 4:3=1104x832, 3:4=832x1104
            - **1080P**: 16:9=1920x1080, 9:16=1080x1920, 1:1=1440x1440, 4:3=1648x1248, 3:4=1248x1648
          enum:
            - 720P
            - 1080P
          default: 1080P
        ratio:
          type: string
          description: "Aspect ratio of the generated video. Default: `16:9`."
          enum:
            - 16:9
            - 9:16
            - 1:1
            - 4:3
            - 3:4
          default: 16:9
        duration:
          type: integer
          description: Video duration in seconds (integer, 2-15). Longer videos cost more -- billing is per second.
          minimum: 2
          maximum: 15
          default: 5
        prompt_extend:
          type: boolean
          description: Rewrite the prompt using a Large Language Model before generation. Improves results for short or vague prompts but adds latency. Set to `false` to use your prompt verbatim.
          default: true
        watermark:
          type: boolean
          description: Add an "AI Generated" watermark in the lower-right corner.
          default: false
        seed:
          type: integer
          description: Seed for reproducible results. Same seed + same parameters produces similar (not identical) output.
          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}`.
              example: 0385dc79-5ff8-4d82-bcb6-xxxxxx
            task_status:
              type: string
              description: Initial task status, typically `PENDING`.
              enum:
                - PENDING
                - RUNNING
                - SUCCEEDED
                - FAILED
    Wan27TaskStatusResponse:
      type: object
      description: Task status response for wan2.7 text-to-video.
      properties:
        request_id:
          type: string
          description: Request ID for troubleshooting. Include this when contacting support.
          example: caa62a12-8841-41a6-8af2-xxxxxx
        output:
          type: object
          properties:
            task_id:
              type: string
              description: Task ID. Queryable for 24 hours after submission.
              example: eff1443c-ccab-4676-aad3-xxxxxx
            task_status:
              type: string
              description: "Task lifecycle: `PENDING` -> `RUNNING` -> `SUCCEEDED` or `FAILED`. `CANCELED` if manually stopped. `UNKNOWN` if expired."
              enum:
                - PENDING
                - RUNNING
                - SUCCEEDED
                - FAILED
                - CANCELED
                - UNKNOWN
            submit_time:
              type: string
              description: When the task was submitted (UTC+8, `YYYY-MM-DD HH:mm:ss.SSS`).
              example: 2025-09-29 14:18:52.331
            scheduled_time:
              type: string
              description: When the task started executing (UTC+8, `YYYY-MM-DD HH:mm:ss.SSS`).
              example: 2025-09-29 14:18:59.290
            end_time:
              type: string
              description: When the task finished (UTC+8, `YYYY-MM-DD HH:mm:ss.SSS`). Only present for `SUCCEEDED` or `FAILED` tasks.
              example: 2025-09-29 14:23:39.407
            orig_prompt:
              type: string
              description: Your original prompt text before any rewriting by `prompt_extend`.
            video_url:
              type: string
              format: uri
              description: URL of the generated video (MP4, H.264 encoding). Only present when `task_status` is `SUCCEEDED`. **Valid for 24 hours** -- download promptly.
              example: https://dashscope-result-sh.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx
            code:
              type: string
              description: Error code. Only present when `task_status` is `FAILED`.
            message:
              type: string
              description: Error message. Only present when `task_status` is `FAILED`.
        usage:
          type: object
          description: Resource consumption. Only present when `task_status` is `SUCCEEDED`.
          properties:
            duration:
              type: number
              description: Billable video duration in seconds. Equals `output_video_duration`.
            input_video_duration:
              type: integer
              description: Always `0` for text-to-video (no input video).
            output_video_duration:
              type: integer
              description: Output video duration in seconds. Matches the requested `duration`.
            video_count:
              type: integer
              description: Number of videos generated. Always `1`.
            ratio:
              type: string
              description: Aspect ratio used (e.g., `16:9`). Matches the requested `ratio`.
            SR:
              type: integer
              description: Resolution tier used (e.g., `720` for 720P, `1080` for 1080P). Matches the requested `resolution`.
    DashScopeErrorResponse:
      type: object
      description: DashScope API error response.
      properties:
        request_id:
          type: string
          description: Unique request identifier for tracing and support.
        code:
          type: string
          description: Machine-readable error code (e.g., `InvalidParameter`, `Throttling`, `Unauthorized`).
          example: InvalidParameter
        message:
          type: string
          description: Human-readable error message.
          example: Invalid model name