> ## 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.

# HappyHorse Video Generation

> Video generation API compatible with the HappyHorse 1.1 protocol, supporting text-to-video, image-to-video, and video editing

This endpoint is compatible with the HappyHorse protocol, and the request body follows the official Alibaba structure. 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` and the media element list `media` (`first_frame` / `reference_image` / `video` to edit; accepts public URLs or base64 data)
* `parameters`: generation parameters, including `resolution` (`480P` / `720P` / `1080P`), `ratio` (`16:9` default / `9:16` / `1:1` / `4:3` / `3:4` / `5:4` / `4:5` / `9:21` / `21:9`), `duration`, `watermark`, and `seed`

## Authentication

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

## Supported video models

| Model No                  | Model Type      | Model Description                   |
| ------------------------- | --------------- | ----------------------------------- |
| happyhorse-1.1-t2v        | Text to Video   | Based on text generation video      |
| happyhorse-1.1-i2v        | Image to Video  | Based on image generation video     |
| happyhorse-1.1-r2v        | Reference Video | Based on reference generation video |
| happyhorse-1.0-video-edit | 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-i2v",
      "input": {
          "prompt": "A golden retriever runs along the beach at sunset, camera slowly tracking",
          "media": [
              {
                  "type": "first_frame",
                  "url": "https://example.com/images/dog.png"
              }
          ]
      },
      "parameters": {
          "resolution": "720P",
          "ratio": "16:9",
          "duration": 5,
          "watermark": False
      }
  }

  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-i2v',
      input: {
        prompt: 'A golden retriever runs along the beach at sunset, camera slowly tracking',
        media: [
          {
            type: 'first_frame',
            url: 'https://example.com/images/dog.png'
          }
        ]
      },
      parameters: {
        resolution: '720P',
        ratio: '16:9',
        duration: 5,
        watermark: false
      }
    })
  });

  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-i2v",
      "input": {
        "prompt": "A golden retriever runs along the beach at sunset, camera slowly tracking",
        "media": [
          {
            "type": "first_frame",
            "url": "https://example.com/images/dog.png"
          }
        ]
      },
      "parameters": {
        "resolution": "720P",
        "ratio": "16:9",
        "duration": 5,
        "watermark": false
      }
    }'
  ```
</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 HappyHorse video task](/docs/en/api-reference/video/happy-horse-status) to retrieve generation results
* See [Video generation](/docs/en/api-reference/video/generation) for the unified protocol
* See the [Wan protocol](/docs/en/api-reference/video/wan) for native Alibaba Wan parameters
* See the [model list](/docs/en/api-reference/models/list-models) for available video models


## OpenAPI

````yaml en/api-reference/video/happyHorse/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 (HappyHorse compatible protocol)
      description: >-
        <p>

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

        model must be a platform model identifier
      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:
              description: ''
              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:
                  description: Input content (prompt and media elements)
                  type: object
                  properties:
                    prompt:
                      type: string
                      description: Text prompt
                    media:
                      type: array
                      items:
                        description: Media element
                        type: object
                        properties:
                          type:
                            type: string
                            description: >-
                              Element type: first_frame / reference_image /
                              video (video to edit)
                          url:
                            type: string
                            description: Media URL or base64 data
                        required:
                          - type
                          - url
                      description: >-
                        Media element list (first frame / last frame / reference
                        image / reference video / video to edit)
                parameters:
                  description: Generation parameters
                  type: object
                  properties:
                    resolution:
                      type: string
                      description: 'Resolution tier: 480P / 720P / 1080P'
                    ratio:
                      type: string
                      description: >-
                        Aspect ratio: 16:9 (default) / 9:16 / 1:1 / 4:3 / 3:4 /
                        5:4 / 4:5 / 9:21 / 21:9
                    duration:
                      type: integer
                      description: Generation duration (seconds)
                    watermark:
                      type: boolean
                      description: Whether to include a watermark
                    seed:
                      type: integer
                      description: Random seed
                      format: int64
              required:
                - model
            examples: {}
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AlibabaCreateTaskResponse'
          headers: {}
      deprecated: false
      security: []
components:
  schemas:
    AlibabaCreateTaskResponse:
      type: object
      properties:
        request_id:
          type: string
          description: Gateway request ID
        output:
          $ref: '#/components/schemas/TaskOutput'
          description: Task output
    TaskOutput:
      type: object
      properties:
        task_id:
          type: string
          description: Task ID
        task_status:
          type: string
          description: 'Task status: PENDING'

````