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

# Wan 2.7 Video Generation

> Video generation API compatible with the Alibaba Wan 2.7 protocol, supporting text-to-video, image-to-video, and video editing

This endpoint is fully compatible with the Alibaba Wan (DashScope) protocol, so you can reuse the parameter structure from the official documentation. The `X-DashScope-Async` header is not required because async semantics are built into the gateway. `model` must be a platform model identifier (e.g. `wan2.7-t2v` / `wan2.7-i2v` / `wan2.7-r2v` / `wan2.7-videoedit`), which the gateway rewrites to the channel model name after routing.

## Request structure

The request body consists of three parts:

* `model`: platform model identifier (required)
* `input`: input content, including `prompt` / `negative_prompt` / `audio_url` and the media element list `media` (first frame / last frame / reference image / reference video / video to edit; accepts public URLs or base64 data URIs, with `reference_voice` to specify the subject's voice timbre)
* `parameters`: generation parameters, including `resolution` / `ratio` / `duration` / `watermark` / `seed` / `prompt_extend` / `audio_setting`

<Note>
  `audio_setting` is only effective for video editing models: `auto` (default) lets the model decide whether to regenerate audio based on the prompt; `origin` forcibly keeps the original sound of the input video.
</Note>

## Authentication

Include the `Authorization` header in the format `Bearer YOUR_API_KEY`.

## Supported Video Models

| Model Identifier | Model Type      | Model Description                   |
| ---------------- | --------------- | ----------------------------------- |
| wan2.7-t2v       | Text to Video   | Based on text generation video      |
| wan2.7-i2v       | Image to Video  | Based on image generation video     |
| wan2.7-r2v       | Reference Video | Based on reference generation video |
| wan2.7-videoedit | Video Edit      | Edit input video                    |

## Quick example

<CodeGroup>
  ```python Python theme={null}
  import requests

  url = "https://api.haitoken.ai/v1/alibaba/video/generations"
  headers = {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json"
  }
  data = {
      "model": "wan2.7-t2v",
      "input": {
          "prompt": "A golden retriever runs along the beach at sunset, camera slowly tracking"
      },
      "parameters": {
          "resolution": "720P",
          "ratio": "16:9",
          "duration": 5,
          "watermark": False,
          "prompt_extend": True
      }
  }

  response = requests.post(url, json=data, headers=headers)
  print(response.json())
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.haitoken.ai/v1/alibaba/video/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      model: 'wan2.7-t2v',
      input: {
        prompt: 'A golden retriever runs along the beach at sunset, camera slowly tracking'
      },
      parameters: {
        resolution: '720P',
        ratio: '16:9',
        duration: 5,
        watermark: false,
        prompt_extend: true
      }
    })
  });

  const data = await response.json();
  console.log(data);
  ```

  ```curl cURL theme={null}
  curl -X POST 'https://api.haitoken.ai/v1/alibaba/video/generations' \
    -H 'Authorization: Bearer YOUR_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
      "model": "wan2.7-t2v",
      "input": {
        "prompt": "A golden retriever runs along the beach at sunset, camera slowly tracking"
      },
      "parameters": {
        "resolution": "720P",
        "ratio": "16:9",
        "duration": 5,
        "watermark": false,
        "prompt_extend": true
      }
    }'
  ```
</CodeGroup>

A successful creation returns the task ID:

```json theme={null}
{
  "request_id": "8f3d2c1a-9b7e-4f5a-8c2d-1e6f0a9b3c5d",
  "output": {
    "task_id": "cgt-20260730120000-a1b2c3",
    "task_status": "PENDING"
  }
}
```

## Next steps

* See [Query Wan video task](/docs/en/api-reference/video/wan-status) to retrieve generation results
* See [Video generation](/docs/en/api-reference/video/generation) for the unified protocol
* See the [HappyHorse protocol](/docs/en/api-reference/video/happyHorse) for HappyHorse compatible parameters
* See the [model list](/docs/en/api-reference/models/list-models) for available video models


## OpenAPI

````yaml en/api-reference/video/wan/openapi.json POST /v1/alibaba/video/generations
openapi: 3.0.1
info:
  title: Default Module
  description: ''
  version: 1.0.0
servers: []
security: []
tags: []
paths:
  /v1/alibaba/video/generations:
    post:
      tags: []
      summary: Create video generation task (Alibaba Wan compatible protocol)
      description: >-
        <p>

        Body is identical to the official Wan API (no X-DashScope-Async header
        required; async semantics are built into the gateway);

        model must be a platform model identifier (rewritten to the channel
        model name after routing).
      parameters:
        - name: Authorization
          in: header
          description: API Key token (Bearer sk-xxx)
          required: true
          example: 'Bearer '
          schema:
            type: string
        - name: Content-Type
          in: header
          description: ''
          example: application/json
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AlibabaCreateTaskRequest'
              description: ''
            examples: {}
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AlibabaCreateTaskResponse'
          headers: {}
      deprecated: false
      security: []
components:
  schemas:
    AlibabaCreateTaskRequest:
      type: object
      properties:
        model:
          type: string
          description: >-
            Platform model identifier (e.g. wan2.7-t2v / wan2.7-i2v / wan2.7-r2v
            / wan2.7-videoedit),

            rewritten to the channel model name by the gateway after routing
        input:
          $ref: '#/components/schemas/Input'
          description: Input content (prompt and media elements)
        parameters:
          $ref: '#/components/schemas/Parameters'
          description: Generation parameters
      required:
        - model
    AlibabaCreateTaskResponse:
      type: object
      properties:
        request_id:
          type: string
          description: Gateway request ID
        output:
          $ref: '#/components/schemas/TaskOutput'
          description: Task output
    Input:
      type: object
      properties:
        negative_prompt:
          type: string
          description: Negative prompt
        audio_url:
          type: string
          description: Audio URL (e.g. driving audio) or base64 data URI
        prompt:
          type: string
          description: Text prompt
        media:
          type: array
          items:
            $ref: '#/components/schemas/MediaItem'
            description: Media element
          description: >-
            Media element list (first frame / last frame / reference image /
            reference video / video to edit)
    Parameters:
      type: object
      properties:
        audio_setting:
          type: string
          description: >-
            Video sound setting (only effective for video editing models)

            auto (default): the model intelligently decides based on the prompt.
            If the prompt involves sound descriptions, audio may be regenerated;
            otherwise the original sound of the input material may be kept.

            origin: forcibly keeps the original sound of the input video without
            regeneration.
        prompt_extend:
          type: boolean
          description: Whether to enable intelligent prompt rewriting
        resolution:
          type: string
          description: 'Resolution tier: 480P / 720P / 1080P'
        ratio:
          type: string
          description: 'Aspect ratio: 16:9 / 9:16 / 1:1'
        duration:
          type: integer
          description: Generation duration (seconds)
        watermark:
          type: boolean
          description: Whether to include a watermark
        seed:
          type: integer
          description: Random seed
          format: int64
    TaskOutput:
      type: object
      properties:
        task_id:
          type: string
          description: Task ID
        task_status:
          type: string
          description: 'Task status: PENDING'
    MediaItem:
      type: object
      properties:
        reference_voice:
          type: string
          description: >-
            Audio URL. Used to specify the voice timbre of the subject in the
            reference material (image/video)
        type:
          type: string
          description: |-
            Element type: first_frame / last_frame / reference_image /
            reference_video / video (video to edit)
        url:
          type: string
          description: >-
            Media URL or base64 data URI (base64 is stored to OBS by the gateway
            and replaced)
      required:
        - type
        - url

````