> ## Documentation Index
> Fetch the complete documentation index at: https://docs.powertokens.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Wan Reference to Video

> Submit an asynchronous Ali `wan2.7-r2v` reference-to-video generation task.

This capability uses the top-level `media` array as the public multimodal input. Supported `media.type` values are `reference_image`, `reference_video`, and `first_frame`.

Current public rules:
- `prompt` is required;
- include at least one `reference_image` or `reference_video` item;
- you may provide at most five `reference_image` / `reference_video` items in total;
- `first_frame` is optional and can appear at most once;
- `size` supports only `720P` and `1080P`;
- `ratio` supports `16:9`, `9:16`, `1:1`, `4:3`, and `3:4`;
- `seconds` accepts integer strings from `2` to `15`, but when any `reference_video` is included the allowed range is `2` to `10`.

Prompt referencing follows the submitted `media` order. Refer to image references as `Image 1`, `Image 2`, and to video references as `Video 1`, `Video 2`, counting separately within each media type. If only one reference image or video is provided, you can simply use "reference image" or "reference video" in the prompt.



## OpenAPI

````yaml api-reference/en/zmodelVideo/ali/reference-to-video.json POST /v1/videos
openapi: 3.0.1
info:
  title: Wan Reference-to-Video
  version: 1.0.0
  description: >-
    Customer-facing channel document for Ali `wan2.7-r2v`. The public unified
    endpoint is `/v1/videos`.
  license:
    name: Project License
    url: https://github.com/QuantumNous/new-api/blob/main/LICENSE
servers:
  - url: https://api.powertokens.ai
    description: Baze API service endpoint
security: []
tags:
  - name: Wan 2.7 Video
    description: Ali wan2.7-r2v reference-to-video capability
paths:
  /v1/videos:
    post:
      tags:
        - Wan 2.7 Video
      summary: Create Wan Reference-to-Video Task
      description: >-
        Submit an asynchronous Ali `wan2.7-r2v` reference-to-video generation
        task.


        This capability uses the top-level `media` array as the public
        multimodal input. Supported `media.type` values are `reference_image`,
        `reference_video`, and `first_frame`.


        Current public rules:

        - `prompt` is required;

        - include at least one `reference_image` or `reference_video` item;

        - you may provide at most five `reference_image` / `reference_video`
        items in total;

        - `first_frame` is optional and can appear at most once;

        - `size` supports only `720P` and `1080P`;

        - `ratio` supports `16:9`, `9:16`, `1:1`, `4:3`, and `3:4`;

        - `seconds` accepts integer strings from `2` to `15`, but when any
        `reference_video` is included the allowed range is `2` to `10`.


        Prompt referencing follows the submitted `media` order. Refer to image
        references as `Image 1`, `Image 2`, and to video references as `Video
        1`, `Video 2`, counting separately within each media type. If only one
        reference image or video is provided, you can simply use "reference
        image" or "reference video" in the prompt.
      operationId: aliReferenceToVideoCreate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReferenceToVideoRequest'
            examples:
              reference_to_video:
                summary: Single image reference
                value:
                  model: wan2.7-r2v
                  prompt: >-
                    Image 1 walks toward the camera and waves with a relaxed
                    smile.
                  media:
                    - type: reference_image
                      url: https://example.com/assets/subject-reference.png
                  seconds: '5'
                  size: 1080P
                  ratio: '16:9'
                  prompt_extend: true
                  watermark: false
              reference_to_video_multimodal:
                summary: Mixed image, video, voice, and first frame references
                value:
                  model: wan2.7-r2v
                  prompt: >-
                    Video 1 sits at the table and starts speaking. Image 1 walks
                    into frame from the left, while the first frame keeps the
                    opening composition stable.
                  negative_prompt: blurry, distorted hands, low quality
                  prompt_extend: false
                  watermark: true
                  seed: 42
                  media:
                    - type: reference_image
                      url: https://example.com/assets/character-a.png
                      reference_voice: https://example.com/assets/character-a-voice.mp3
                    - type: reference_video
                      url: https://example.com/assets/character-b.mp4
                    - type: first_frame
                      url: https://example.com/assets/opening-frame.png
                  seconds: '8'
                  size: 720P
                  ratio: '9:16'
      responses:
        '200':
          description: >-
            Submission successful. Returns the unified OpenAI-style video task
            object.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoTaskResponse'
        '400':
          description: >-
            Invalid request parameters, such as missing reference media,
            unsupported `media.type`, invalid `size` / `ratio` / `seconds`, or
            incompatible field combinations.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_request:
                  summary: Invalid request
                  value:
                    code: invalid_request
                    message: >-
                      wan2.7-r2v requires at least one reference_image or
                      reference_video
                    data: null
        '401':
          description: Authentication failed, e.g. missing or invalid token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    code: access_denied
                    message: Invalid token
                    data: null
        '413':
          description: Request body too large.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                request_too_large:
                  summary: Request body too large
                  value:
                    code: read_request_body_failed
                    message: Request body too large, please reduce the input and retry
                    data: null
        '429':
          description: Rate limit triggered or insufficient account quota.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                quota_exceeded:
                  summary: Insufficient quota or rate limited
                  value:
                    code: insufficient_user_quota
                    message: Insufficient account quota, please try again later
                    data: null
        '500':
          description: An internal error occurred while processing the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal processing failure
                  value:
                    code: gen_relay_info_failed
                    message: Internal processing failed, please try again later
                    data: null
        '502':
          description: The upstream provider returned an abnormal response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_gateway:
                  summary: Upstream provider response error
                  value:
                    code: bad_response_status_code
                    message: The upstream provider returned an invalid response
                    data: null
        '503':
          description: >-
            The upstream provider is temporarily unavailable, or no channel is
            currently available for this model.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                service_unavailable:
                  summary: Service temporarily unavailable
                  value:
                    code: get_channel_failed
                    message: >-
                      No available channel for the current model, please try
                      again later
                    data: null
      security:
        - BearerAuth: []
components:
  schemas:
    ReferenceToVideoRequest:
      type: object
      required:
        - model
        - prompt
        - media
      properties:
        model:
          type: string
          enum:
            - wan2.7-r2v
          description: 'Ali wan2.7-r2v model. Available value: `wan2.7-r2v`.'
        prompt:
          type: string
          description: >-
            Text prompt describing the desired video content and visual
            characteristics. Supports Chinese and English; each character,
            letter, or punctuation mark counts as one character. Excess
            characters are automatically truncated.


            - `wan2.7-r2v`: up to 5000 characters.


            Reference naming conventions:

            - For Chinese prompts, reference images with markers like "图1", "图2"
            and reference videos with markers like "视频1", "视频2".

            - For English prompts, use markers like "Image 1", "Video 1"
            (capitalized first letter, space between letter and number).

            - The order matches the `media` array order. Images and videos are
            counted separately, e.g. "图1" and "视频1" can exist simultaneously.

            - If only one reference image or video is provided, you can simply
            use "reference image" or "reference video".


            Scene description examples:

            - Direct reference: "图1 in 图2" (Image 1 is playing in Image 2).

            - Combined description: "The cat from Image 1 plays in the room from
            Image 2".


            Multi-panel/storyboard images:

            When the reference image is a multi-panel (storyboard) image,
            describe the content in a multi-shot narrative format. You do not
            need to describe every panel; provide key shot content and the model
            will automatically identify the panel logic and intelligently fill
            in the details. For best results, it is recommended to provide only
            one multi-panel image per request.
        size:
          type: string
          enum:
            - 720P
            - 1080P
          description: >-
            Important: `size` directly affects cost. Confirm the model pricing
            before calling.


            Output video resolution tier, controlling video clarity (total
            pixels).


            `wan2.7-r2v`: available values `720P`, `1080P`. Default: `1080P`.
          default: 1080P
        seconds:
          type: string
          description: >-
            Important: `seconds` directly affects cost. Confirm the model
            pricing before calling.


            Video duration in seconds.


            - `wan2.7-r2v`: default `5`.

            - When reference assets include a video: range [2, 10].

            - When reference assets do not include a video: range [2, 15].
          default: '5'
          enum:
            - '2'
            - '3'
            - '4'
            - '5'
            - '6'
            - '7'
            - '8'
            - '9'
            - '10'
            - '11'
            - '12'
            - '13'
            - '14'
            - '15'
        ratio:
          type: string
          enum:
            - '16:9'
            - '9:16'
            - '1:1'
            - '4:3'
            - '3:4'
          description: >-
            Video aspect ratio.


            Behavior logic:

            - If no first frame image is provided: generates video at the
            specified `ratio`.

            - If a first frame image is provided: the `ratio` parameter is
            ignored and the video is generated at an approximate ratio matching
            the first frame image's aspect ratio.


            Available values and corresponding output resolutions:


            **720P:**

            - `16:9` → 1280×720

            - `9:16` → 720×1280

            - `1:1` → 960×960

            - `4:3` → 1104×832

            - `3:4` → 832×1104


            **1080P:**

            - `16:9` → 1920×1080

            - `9:16` → 1080×1920

            - `1:1` → 1440×1440

            - `4:3` → 1648×1248

            - `3:4` → 1248×1648
          default: '16:9'
        negative_prompt:
          type: string
          description: >-
            Negative prompt describing content you do not want to see in the
            video. Limits unwanted visual elements. Supports Chinese and
            English, up to 500 characters.


            Example: low resolution, error, worst quality, low quality,
            deformed, extra fingers, bad proportions, etc.
        prompt_extend:
          type: boolean
          description: >-
            Whether to enable intelligent prompt rewriting. When enabled, a
            large language model rewrites the input prompt for better results.
            Particularly effective for short prompts, but increases processing
            time.

            - `true` (default): enable intelligent rewriting.

            - `false`: disable intelligent rewriting.
        watermark:
          type: boolean
          description: >-
            Whether to add a watermark to the video. The watermark is positioned
            at the bottom-right corner with the text 'AI生成'.

            - `false` (default): no watermark.

            - `true`: add watermark.
          default: false
        seed:
          type: integer
          minimum: 0
          maximum: 2147483647
          description: >-
            Random seed, range [0, 2147483647]. If not specified, the system
            automatically generates a random seed. To improve reproducibility of
            generation results, it is recommended to fix the seed value.


            Note: Due to the probabilistic nature of model generation, the same
            seed does not guarantee identical results every time.
        media:
          type: array
          description: >-
            Array of media assets, including images, videos, and audio. Supports
            image/video input as visual reference, and images can provide
            multi-view references for characters, props, scenes, etc.


            Each element in the array is a media object containing `type` and
            `url` fields.


            The order in the array defines the reference mapping order in the
            prompt. Images and videos are counted separately, so "Image 1" and
            "Video 1" can exist simultaneously.

            - The 1st `reference_video` in the array corresponds to "Video 1",
            the 2nd to "Video 2", etc.

            - The 1st `reference_image` in the array corresponds to "Image 1",
            the 2nd to "Image 2", etc.
          items:
            $ref: '#/components/schemas/ReferenceToVideoMediaInput'
    VideoTaskResponse:
      type: object
      properties:
        id:
          type: string
          description: Public task ID.
        task_id:
          type: string
          description: Public task ID alias.
        object:
          type: string
          example: video
        model:
          type: string
          description: Model name.
        status:
          type: string
          enum:
            - queued
            - in_progress
            - completed
            - failed
            - unknown
          description: Unified video task status.
        progress:
          type: integer
          description: Task progress percentage.
        created_at:
          type: integer
          format: int64
          description: Unix timestamp in seconds.
    ErrorResponse:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Error code.
          example: invalid_request
        message:
          type: string
          description: Error message.
        data:
          nullable: true
          description: Additional error data. Currently usually null.
    ReferenceToVideoMediaInput:
      type: object
      required:
        - type
        - url
      properties:
        type:
          type: string
          enum:
            - reference_image
            - reference_video
            - first_frame
          description: >-
            Media asset type. Available values:


            reference_image: Reference image. Provides subject
            (person/animal/object) and scene reference.


            reference_video: Reference video. Provides subject
            (person/animal/object) and voice reference. B-roll/empty scene
            videos are not recommended.


            first_frame: First frame image. Generates video based on the first
            frame, typically containing the subject (person/animal/object).
            Supports combined use with subject reference for consistency, or
            voice reference.


            First frame: already contains the subject to reference; you can pair
            it with subject reference for enhanced consistency, or use voice
            reference.


            First frame: does not yet contain the subject to reference; you can
            use subject reference to define the characteristics of the new
            subject appearing during the video.


            Material constraints:


            First frame image: max 1.


            At least 1 reference image or reference video must be provided.
            Total reference images + reference videos ≤ 5.


            When a reference asset contains a subject character, it should
            contain only a single character.
        url:
          type: string
          description: >-
            Media asset URL. Each value points to an image or video.


            **For reference image (`type=reference_image`):**

            Reference image URL or Base64 encoded data. The reference image can
            be a subject (person/animal/object) or a background. When it
            contains a subject, it should include only one character.


            Image constraints:

            - Formats: JPEG, JPG, PNG (no alpha channel), BMP, WEBP.

            - Resolution: width and height range [240, 8000] pixels.

            - Aspect ratio: 1:8 to 8:1.

            - File size: up to 20MB.


            Supported input formats:

            - Public URL: HTTP or HTTPS, e.g. `https://xxx/xxx.png`.

            - Temporary URL (OSS): `oss://dashscope-instant/xxx/xxx.png` (must
            be obtained by uploading the file).

            - Base64 encoded string: `data:{MIME_type};base64,{base64_data}`,
            e.g. `data:image/png;base64,...`.


            **For reference video (`type=reference_video`):**

            Reference video URL. The video should contain a subject
            (person/animal/object). B-roll or empty scene videos are not
            recommended. When it contains a subject, it should include only one
            character. If the video has audio, the voice can also be referenced.


            Video constraints:

            - Formats: mp4, mov.

            - Duration: 1 to 30 seconds.

            - Resolution: width and height range [240, 4096] pixels.

            - Aspect ratio: 1:8 to 8:1.

            - File size: up to 100MB.


            Supported input formats:

            - Public URL: HTTP or HTTPS, e.g. `https://xxx/xxx.mp4`.

            - Temporary URL (OSS): `oss://dashscope-instant/xxx/xxx.mp4` (must
            be obtained by uploading the file).
        reference_voice:
          type: string
          description: >-
            Audio URL for voice reference. Used to specify the voice of the
            subject character in the reference asset (image/video). Used
            together with `reference_image` or `reference_video`. The audio is
            only used for voice timbre reference, unrelated to the speech
            content. It is recommended to match the language of the reference
            audio with the prompt language for better results.


            **Voice activation logic:**

            - Default behavior: If the `reference_video` contains audio and no
            `reference_voice` is specified, the original video audio is used by
            default.

            - Priority: If both `reference_video` (with audio) and
            `reference_voice` are provided, `reference_voice` takes priority and
            overrides the video's original audio.


            Audio constraints:

            - Formats: wav, mp3.

            - Duration: 1 to 10 seconds.

            - File size: up to 15MB.


            Supported input formats:

            - Public URL: HTTP or HTTPS, e.g. `https://xxx/xxx.mp3`.

            - Temporary URL (OSS): `oss://dashscope-instant/xxx/xxx.mp3` (must
            be obtained by uploading the file).
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: 'Pass `Authorization: Bearer <token>` in the request header.'

````