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

# Common video generation

> Create and query video generation tasks with a unified protocol supporting text-to-video, image-to-video, first/last frames, and reference media

The generic video generation API works asynchronously: you submit a creation request to get a `task_id`, then poll the query endpoint until the task succeeds and returns the video URL.

## Features

* Access multiple video models through one unified protocol by specifying the platform model identifier in `model`
* Supports text-to-video and image-to-video (first frame / last frame / reference image / reference video / reference audio)
* Supports negative prompts, resolution, aspect ratio, duration, watermark, and random seed
* Media inputs accept public URLs and base64 data URIs
* Supports `callback_url` result callbacks (only effective for the seedance channel; when empty, the gateway injects the default callback)

## Authentication

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

## Supported video models

Available video models in the Model Square, please refer to [Model List](https://portal.haitoken.ai/en/models).

## Quick example

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

  url = "https://api.haitoken.ai/v1/video/generations"
  headers = {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json"
  }
  data = {
      "model": "seedance-2.0",
      "prompt": "A golden retriever runs along the beach at sunset, camera slowly tracking",
      "duration": 5,
      "resolution": "720p",
      "ratio": "16:9",
      "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/video/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      model: 'seedance-2.0',
      prompt: 'A golden retriever runs along the beach at sunset, camera slowly tracking',
      duration: 5,
      resolution: '720p',
      ratio: '16:9',
      watermark: false
    })
  });

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

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

A successful creation returns the task ID:

```json theme={null}
{
  "task_id": "cgt-20260730120000-a1b2c3",
  "status": "queued"
}
```

## Next steps

* See [Query video task](/docs/en/api-reference/video/generation-status) to retrieve generation results
* See the [Seedance protocol](/docs/en/api-reference/video/seedance) for native Seedance parameters
* 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/generation/openapi.json POST /v1/video/generations
openapi: 3.0.1
info:
  title: Default Module
  description: ''
  version: 1.0.0
servers: []
security: []
tags: []
paths:
  /v1/video/generations:
    post:
      tags: []
      summary: Create video generation task
      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/VideoGenerationRequest'
              description: ''
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoGenerationResponse'
                description: Generic video generation task creation response
      deprecated: false
      security: []
components:
  schemas:
    VideoGenerationRequest:
      type: object
      properties:
        negative_prompt:
          type: string
          description: Negative prompt
        generate_audio:
          type: boolean
          description: Whether to generate audio; not supported by some models
        callback_url:
          type: string
          description: >-
            Result callback URL (only effective for the seedance channel; when
            empty, the gateway injects the default callback)
        model:
          type: string
          description: Platform model identifier
        prompt:
          type: string
          description: Text prompt
        medias:
          type: array
          items:
            $ref: '#/components/schemas/MediaInput'
            description: Media input item
          description: >-
            Reference media input list (first frame / last frame / reference
            image / reference video / reference audio; URL or base64 data URI)
        duration:
          type: integer
          description: Generation duration (seconds)
        resolution:
          type: string
          description: Resolution tier, e.g. 480p/720p/1080p/4k (subject to model support)
        ratio:
          type: string
          description: Aspect ratio, e.g. 16:9/9:16/1:1/adaptive
        watermark:
          type: boolean
          description: Whether to include a watermark
        seed:
          type: integer
          description: Random seed
          format: int64
      required:
        - model
    VideoGenerationResponse:
      type: object
      properties:
        task_id:
          type: string
          description: 'Task ID '
        status:
          type: string
          description: 'Task status: queued / running'
    MediaInput:
      type: object
      properties:
        type:
          type: string
          description: 'Media type: image/video/audio'
        url:
          type: string
          description: Media URL or base64 data URI
        role:
          type: string
          description: >-
            Role: first_frame / last_frame / reference_image / reference_video /
            reference_audio (defaults to first_frame)
      required:
        - type
        - url

````