> ## 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 2.7 First-Last Frame to Video

> Submit an asynchronous Ali `wan2.7-i2v` first-and-last-frame video generation task.

Use `first_frame` to specify the start frame, `last_frame` to specify the end frame, optionally paired with `driving_audio` for audio-driven generation.

Supported `media` combinations:
- `first_frame + last_frame`
- `first_frame + last_frame + driving_audio`

The `prompt` field is optional for this capability. `size` only supports `720P` and `1080P`. `seconds` only supports integer strings from `2` to `15`. Also supports official fields `negative_prompt`, `prompt_extend`, `watermark`, and `seed`.



## OpenAPI

````yaml api-reference/en/zmodelVideo/ali/wan2.7-i2v-first-last-frame.json POST /v1/videos
openapi: 3.0.1
info:
  title: Wan 2.7 First & Last Frame
  version: 1.0.0
  description: >-
    Ali `wan2.7-i2v` first and last frame video generation capability
    documentation. The unified API endpoint is `/v1/videos`.


    This document covers the first-and-last-frame video generation scenario and
    uses the top-level `media` array to express the upstream provider's new
    `input.media` protocol.


    Supported `media.type` values for this scenario are `first_frame`,
    `last_frame`, and `driving_audio`.


    Supported `media` combinations:

    - `first_frame + last_frame`

    - `first_frame + last_frame + driving_audio`


    The `prompt` field is optional for this capability. `size` only supports
    `720P` and `1080P`. `seconds` only supports integer strings from `2` to
    `15`. Also supports official fields `negative_prompt`, `prompt_extend`,
    `watermark`, and `seed`.
  license:
    name: Project License
    url: https://github.com/QuantumNous/new-api/blob/main/LICENSE
servers:
  - url: https://api.powertokens.ai
    description: Baze API server endpoint
security: []
tags:
  - name: Wan 2.7 Video
    description: Ali wan2.7-i2v first and last frame video generation capability
paths:
  /v1/videos:
    post:
      tags:
        - Wan 2.7 Video
      summary: Create Wan 2.7 First & Last Frame task
      description: >-
        Submit an asynchronous Ali `wan2.7-i2v` first-and-last-frame video
        generation task.


        Use `first_frame` to specify the start frame, `last_frame` to specify
        the end frame, optionally paired with `driving_audio` for audio-driven
        generation.


        Supported `media` combinations:

        - `first_frame + last_frame`

        - `first_frame + last_frame + driving_audio`


        The `prompt` field is optional for this capability. `size` only supports
        `720P` and `1080P`. `seconds` only supports integer strings from `2` to
        `15`. Also supports official fields `negative_prompt`, `prompt_extend`,
        `watermark`, and `seed`.
      operationId: aliWan27I2VFirstLastFrame
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Wan27FirstLastFrameRequest'
            examples:
              first_last_frame:
                summary: First frame + Last frame
                value:
                  model: wan2.7-i2v
                  prompt: A cat walking from one end of the hallway to the other.
                  media:
                    - type: first_frame
                      url: https://example.com/assets/start.png
                    - type: last_frame
                      url: https://example.com/assets/end.png
                  seconds: '5'
                  size: 1080P
              first_last_frame_with_audio:
                summary: First frame + Last frame + Driving audio
                value:
                  model: wan2.7-i2v
                  prompt: >-
                    A person slowly lifts their head and smiles, accompanied by
                    a narration.
                  negative_prompt: blurry, low quality
                  prompt_extend: true
                  watermark: false
                  seed: 42
                  media:
                    - type: first_frame
                      url: https://example.com/assets/portrait-start.png
                    - type: last_frame
                      url: https://example.com/assets/portrait-end.png
                    - type: driving_audio
                      url: https://example.com/assets/narration.mp3
                  seconds: '8'
                  size: 720P
      responses:
        '200':
          description: >-
            Submitted successfully. Returns an OpenAI-compatible video task
            object.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoTaskResponse'
        '400':
          description: >-
            Invalid request parameters, e.g. unsupported `media` combination, or
            `size` / `seconds` out of supported range.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_request:
                  summary: Invalid request
                  value:
                    error:
                      message: unsupported wan2.7-i2v media combination
                      type: invalid_request_error
                      code: invalid_request
        '401':
          description: Authentication failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit triggered or insufficient account quota.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: An internal error occurred while processing the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    Wan27FirstLastFrameRequest:
      type: object
      required:
        - model
        - media
      properties:
        model:
          type: string
          enum:
            - wan2.7-i2v
          description: 'Model name. Available value: `wan2.7-i2v`.'
        prompt:
          type: string
          description: >-
            Text prompt describing the desired video content and visual
            characteristics. Supports Chinese and English, up to 5000 characters
            (each character or letter counts as one). Excess characters will be
            automatically truncated.
        size:
          type: string
          enum:
            - 720P
            - 1080P
          description: >-
            Specifies the output resolution tier for controlling video clarity
            (total pixels).


            The model automatically scales to a similar total pixel count based
            on the selected resolution tier. The video aspect ratio will attempt
            to stay consistent with the input material (first frame or first
            clip).
          default: 1080P
        seconds:
          type: string
          description: >-
            Video duration as a string. Supports integer strings from `2` to
            `15`.
          default: '5'
          enum:
            - '2'
            - '3'
            - '4'
            - '5'
            - '6'
            - '7'
            - '8'
            - '9'
            - '10'
            - '11'
            - '12'
            - '13'
            - '14'
            - '15'
        negative_prompt:
          type: string
          description: >-
            Negative prompt describing content you do not want in the video.
            Supports Chinese and English, up to 500 characters. Excess
            characters will be automatically truncated. Example: `low
            resolution, worst quality, deformed, extra fingers, bad
            proportions`.
        prompt_extend:
          type: boolean
          description: >-
            Whether to enable intelligent prompt rewriting. When enabled, a
            large language model rewrites the input prompt intelligently,
            significantly improving results for short prompts but increasing
            processing time. `true` (default): enable. `false`: disable.
        watermark:
          type: boolean
          description: >-
            Whether to add a watermark. 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]. When unspecified, the system
            auto-generates a random seed. For better reproducibility, set a
            fixed seed. Note: due to the probabilistic nature of model
            generation, the same seed does not guarantee identical results every
            time.
        media:
          type: array
          description: >-
            List of media assets (images, audio) for video generation. Each
            element is a media object with `type` and `url`.


            Supported combinations (invalid combinations will return an error):

            - **First & last frame**: `first_frame` + `last_frame`

            - **First & last frame + audio**: `first_frame` + `last_frame` +
            `driving_audio`


            Each `type` can appear at most once in the array.
          items:
            $ref: '#/components/schemas/Wan27MediaInput'
    VideoTaskResponse:
      type: object
      properties:
        id:
          type: string
          description: Public task ID.
        task_id:
          type: string
          description: Backward-compatible alias for the public task ID.
        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: Creation time as a Unix timestamp (seconds).
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type: string
    Wan27MediaInput:
      type: object
      required:
        - type
        - url
      properties:
        type:
          type: string
          enum:
            - first_frame
            - last_frame
            - driving_audio
          description: >-
            Media asset type.

            - `first_frame`: First frame image.

            - `last_frame`: Last frame image.

            - `driving_audio`: Driving audio.


            Each type can appear at most once per request (e.g. cannot include
            two `first_frame` entries).
        url:
          type: string
          description: >-
            Media asset URL. Supports images and audio.


            **Audio** (type=`driving_audio`)


            Audio file URL.


            - **With audio provided**: The model uses this audio as the driving
            source to generate the video (e.g., lip sync, action cues, etc.).

            - **Without audio provided**: The model automatically generates
            matching background music or sound effects based on the video
            content.


            Audio restrictions:


            - Formats: WAV, MP3.

            - Duration: 2~30s.

            - File size: up to 15MB.

            - Truncation handling: If the audio length exceeds the `duration`
            value (e.g., 5 seconds), the first 5 seconds are automatically kept
            and the rest is discarded. If the audio is shorter than the video
            duration, the part beyond the audio length is a silent video. For
            example, audio is 3 seconds, video duration is 5 seconds, the output
            video has audio in the first 3 seconds and is silent in the last 2
            seconds.


            Supported input formats:


            Public URL:


            Supports HTTP and HTTPS protocols.


            Example: `https://xxx/xxx.mp3`.


            Temporary URL:


            Supports OSS protocol. Must obtain the temporary URL via file
            upload.


            Example: `oss://dashscope-instant/xxx/xxx.mp3`.


            **Image** (type=`first_frame` or `last_frame`): First or last frame
            URL, or Base64 encoded data.


            Image restrictions:

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

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

            - Aspect ratio: 1:8 ~ 8:1.

            - File size: up to 20MB.


            Supported input formats:


            Public URL:


            Supports HTTP or HTTPS protocols.


            Example: `https://xxx/xxx.png`.


            Temporary URL:


            Supports OSS protocol. Must obtain the temporary URL via file
            upload.


            Example: `oss://dashscope-instant/xxx/xxx.png`.


            Base64 encoded image string:


            Data format: data:{MIME_type};base64,{base64_data}.


            Example: data:image/png;base64,GDU7MtCZzEbTbmRZ...... (truncated for
            demonstration).


            Base64 encoded data format


            Format: data:{MIME_type};base64,{base64_data}.


            {base64_data}: The Base64 encoded string of the image file.


            {MIME_type}: The media type of the image, corresponding to the file
            format.


            Image format to MIME Type mapping:


            | Image Format | MIME Type |

            | --- | --- |

            | JPEG | image/jpeg |

            | JPG | image/jpeg |

            | PNG | image/png |

            | BMP | image/bmp |

            | WEBP | image/webp |
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: 'Pass `Authorization: Bearer <token>` in the request header.'

````