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 imagem

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

Gere vídeos de até 15 segundos em 1080P a partir de imagens, áudio e clipes de vídeo, com sincronização de áudio opcional e controle do primeiro ao último quadro.

Mudanças de wan2.6

OpenAPI

openapi: 3.1.0
info:
  title: Wan 2.7 Image-to-Video API
  description: "The Wan 2.7 image-to-video model now supports multi-modal input — including images, audio, and video — and performs three main tasks: video generation from the first frame, video generation from the first and last frames, and video continuation. 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: createWan27ImageToVideo
      summary: Create image-to-video task
      description: Submit an image-to-video task. Returns a `task_id` for polling. Requires DashScope Java SDK 2.22.14 or later.
      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/Wan27ImageToVideoRequest"
      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 - First frame + audio
          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-i2v",
              "input": {
                "prompt": "A scene of urban fantasy art. A dynamic graffiti art character. A boy made of spray paint comes to life on a concrete wall. He sings an English rap song at high speed while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The light comes from a single street lamp, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of the rap, with no other dialogue or noise.",
                "media": [
                  {
                    "type": "first_frame",
                    "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png"
                  },
                  {
                    "type": "driving_audio",
                    "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3"
                  }
                ]
              },
              "parameters": {
                "resolution": "720P",
                "duration": 10,
                "prompt_extend": true,
                "watermark": true
              }
            }'
        - lang: curl
          label: cURL - First and last frames
          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-i2v",
              "input": {
                "prompt": "Realistic style, a small black cat looks up at the sky curiously. The camera angle gradually rises from eye level, finally capturing its curious gaze from a top-down view.",
                "media": [
                  {
                    "type": "first_frame",
                    "url": "https://wanx.alicdn.com/material/20250318/first_frame.png"
                  },
                  {
                    "type": "last_frame",
                    "url": "https://wanx.alicdn.com/material/20250318/last_frame.png"
                  }
                ]
              },
              "parameters": {
                "resolution": "720P",
                "duration": 10,
                "prompt_extend": false,
                "watermark": true
              }
            }'
        - lang: curl
          label: cURL - Video continuation
          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-i2v",
              "input": {
                "prompt": "A girl takes a selfie in the mirror, then leaves with her backpack.",
                "media": [
                  {
                    "type": "first_clip",
                    "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260129/hfugmr/wan-r2v-role1.mp4"
                  }
                ]
              },
              "parameters": {
                "resolution": "720P",
                "duration": 10,
                "prompt_extend": true,
                "watermark": true
              }
            }'
        - 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-i2v',
                prompt='A cat slowly turns its head and looks at the camera',
                media=[
                  {
                    "type": "first_frame",
                    "url": "https://cdn.translate.alibaba.com/r/wanx-demo-1.png"
                  }
                ],
                resolution='720P',
                duration=5,
                prompt_extend=True,
                watermark=True)
              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-i2v',
                prompt='A cat slowly turns its head and looks at the camera',
                media=[
                  {
                    "type": "first_frame",
                    "url": "https://cdn.translate.alibaba.com/r/wanx-demo-1.png"
                  }
                ],
                resolution='720P',
                duration=5,
                prompt_extend=True,
                watermark=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))
              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 Wan27I2V {
              static {
                Constants.baseHttpApiUrl = "https://maas.qwencloudapi.com/api/v1";
              }
              public static void main(String[] args) {
                try {
                  VideoSynthesis vs = new VideoSynthesis();
                  List<VideoSynthesisParam.Media> media = new ArrayList<VideoSynthesisParam.Media>() {{
                    add(VideoSynthesisParam.Media.builder()
                      .url("https://cdn.translate.alibaba.com/r/wanx-demo-1.png")
                      .type("first_frame").build());
                  }};
                  Map<String, Object> parameters = new HashMap<>();
                  parameters.put("resolution", "720P");
                  parameters.put("duration", 5);
                  parameters.put("prompt_extend", true);
                  parameters.put("watermark", true);
                  VideoSynthesisParam param = VideoSynthesisParam.builder()
                    .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                    .model("wan2.7-i2v")
                    .prompt("A cat slowly turns its head and looks at the camera")
                    .media(media)
                    .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 Wan27I2V {
              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();
                  List<VideoSynthesisParam.Media> media = new ArrayList<VideoSynthesisParam.Media>() {{
                    add(VideoSynthesisParam.Media.builder()
                      .url("https://cdn.translate.alibaba.com/r/wanx-demo-1.png")
                      .type("first_frame").build());
                  }};
                  Map<String, Object> parameters = new HashMap<>();
                  parameters.put("resolution", "720P");
                  parameters.put("duration", 5);
                  parameters.put("prompt_extend", true);
                  parameters.put("watermark", true);
                  VideoSynthesisParam param = VideoSynthesisParam.builder()
                    .apiKey(apiKey)
                    .model("wan2.7-i2v")
                    .prompt("A cat slowly turns its head and looks at the camera")
                    .media(media)
                    .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:
    Wan27ImageToVideoRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          description: "Model identifier. Supported values: `wan2.7-i2v`, `wan2.7-i2v-2026-04-25`."
          enum:
            - wan2.7-i2v
            - wan2.7-i2v-2026-04-25
          example: wan2.7-i2v
        input:
          type: object
          required:
            - media
          description: The basic input information, such as the prompt.
          properties:
            prompt:
              type: string
              description: The text prompt. Describes the elements and visual features of the video you want. Supports Chinese and English, up to 5,000 characters (auto-truncated if exceeded).
              example: A kitten runs on the grass.
            negative_prompt:
              type: string
              description: The negative prompt. Describes content you do not want in the video (e.g., `low quality, blurry, extra fingers`). Supports Chinese and English. The prompt can be up to 500 characters long (auto-truncated if exceeded).
              example: low resolution, error, worst quality, low quality, deformed, extra fingers, bad proportions
            media:
              type: array
              description: |-
                A list of media assets. Specifies reference materials (images, audio, and video) for video generation. Each element in the array is a media object that contains the `type` and `url`. Each `type` can appear at most once.

                Only the following asset combinations are supported. Invalid combinations result in an error.
                - `first_frame`
                - `first_frame` + `driving_audio`
                - `first_frame` + `last_frame`
                - `first_frame` + `last_frame` + `driving_audio`
                - `first_clip`
                - `first_clip` + `last_frame`
              items:
                type: object
                required:
                  - type
                  - url
                properties:
                  type:
                    type: string
                    description: |-
                      The type of media asset. Valid values:

                      - `first_frame`: The URL of the first or last frame, or Base64-encoded data. Video generation from the first frame and video generation from the first and last frames are supported. JPEG/JPG/PNG/BMP/WEBP, 240-8000 px per side, 1:8 to 8:1 ratio, max 20 MB.
                      - `last_frame`: Last frame image. Same limits as `first_frame`.
                      - `driving_audio`: The URL of the audio file. Pass audio: The model uses the audio as a driving source to generate the video, such as for lip-syncing and action timing. Do not pass audio: The model automatically generates matching background music or sound effects based on the video content. WAV/MP3, 2-30 s, max 15 MB.
                      - `first_clip`: The URL of the video file. The model generates a continuation based on the video content. The `duration` parameter controls the maximum duration of the continuation. MP4/MOV, 2-10 s, 240-4096 px per side, 1:8 to 8:1 ratio, max 100 MB.
                    enum:
                      - first_frame
                      - last_frame
                      - driving_audio
                      - first_clip
                  url:
                    type: string
                    format: uri
                    description: The URL of the media asset. Assets include images, audio, and video.
        parameters:
          $ref: "#/components/schemas/Wan27ImageToVideoParameters"
    Wan27ImageToVideoParameters:
      type: object
      description: Video processing parameters, such as resolution, duration, prompt rewriting, and watermarks.
      properties:
        resolution:
          type: string
          description: The resolution tier for the generated video. Controls the video definition (total pixels). The resolution directly affects the cost. Before you make a call, confirm the resolution you need. The model automatically scales the video to a total pixel count close to the selected resolution tier. The video's aspect ratio should be as consistent as possible with the input material (first frame or first video segment).
          enum:
            - 720P
            - 1080P
          default: 1080P
        duration:
          type: integer
          description: Video duration in seconds (integer, 2-15). Longer videos cost more -- billing is per second. For video continuation (`first_clip`), this is the total output duration including the input clip. For example, if `duration=15` and the input is 3 s, the model generates 12 s of new content.
          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
    Wan27I2VTaskStatusResponse:
      type: object
      description: Task status response for wan2.7 image-to-video.
      properties:
        request_id:
          type: string
          description: Request ID for troubleshooting. Include this when contacting support.
          example: 2ca1c497-f9e0-449d-9a3f-xxxxxx
        output:
          type: object
          properties:
            task_id:
              type: string
              description: Task ID. Queryable for 24 hours after submission.
              example: af6efbc0-4bef-4194-8246-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-25 11:07:28.590
            scheduled_time:
              type: string
              description: When the task started executing (UTC+8, `YYYY-MM-DD HH:mm:ss.SSS`).
              example: 2025-09-25 11:07:35.349
            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-25 11:17:11.650
            orig_prompt:
              type: string
              description: The original prompt text, corresponding to the request parameter `prompt`.
            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: integer
              description: Billable video duration in seconds.
            input_video_duration:
              type: integer
              description: Duration of the input video in seconds. `0` for first-frame tasks.
            output_video_duration:
              type: integer
              description: Output video duration in seconds.
            video_count:
              type: integer
              description: Number of videos generated. Always `1`.
            SR:
              type: integer
              description: Resolution tier used (e.g., `720` for 720P, `1080` for 1080P).
    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