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

# HappyHorse 1.0 Video Generation

>  - Alibaba Cloud Bailian HappyHorse 1.0 video generation model (unified entry, single-model auto-routing)
- Auto-routes by parameters: T2V (prompt only) / I2V (first_frame_image) / R2V (image_urls) / EDIT (video_url)
- Supports 720P/1080P resolutions and any integer duration from 3 to 15 seconds
- Billed by resolution × duration (seconds) only, regardless of capability 

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://gccai.heqingsong.uk/v1/videos/generations \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "happyhorse-1.0",
      "prompt": "A little girl walking down the road, cinematic feel",
      "resolution": "1080P",
      "size": "16:9",
      "duration": 5,
      "seed": 42
    }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://gccai.heqingsong.uk/v1/videos/generations"

  payload = {
      "model": "happyhorse-1.0",
      "prompt": "A little girl walking down the road, cinematic feel",
      "resolution": "1080P",
      "size": "16:9",
      "duration": 5,
      "seed": 42
  }

  headers = {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
  }

  response = requests.post(url, json=payload, headers=headers)

  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const url = "https://gccai.heqingsong.uk/v1/videos/generations";

  const payload = {
    model: "happyhorse-1.0",
    prompt: "A little girl walking down the road, cinematic feel",
    resolution: "1080P",
    size: "16:9",
    duration: 5,
    seed: 42
  };

  const headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
  };

  fetch(url, {
    method: "POST",
    headers: headers,
    body: JSON.stringify(payload)
  })
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "io/ioutil"
      "net/http"
  )

  func main() {
      url := "https://gccai.heqingsong.uk/v1/videos/generations"

      payload := map[string]interface{}{
          "model":      "happyhorse-1.0",
          "prompt":     "A little girl walking down the road, cinematic feel",
          "resolution": "1080P",
          "size":       "16:9",
          "duration":   5,
          "seed":       42,
      }

      jsonData, _ := json.Marshal(payload)

      req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      req.Header.Set("Authorization", "Bearer <token>")
      req.Header.Set("Content-Type", "application/json")

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()

      body, _ := ioutil.ReadAll(resp.Body)
      fmt.Println(string(body))
  }
  ```

  ```java Java theme={null}
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.net.URI;

  public class Main {
      public static void main(String[] args) throws Exception {
          String url = "https://gccai.heqingsong.uk/v1/videos/generations";

          String payload = """
          {
            "model": "happyhorse-1.0",
            "prompt": "A little girl walking down the road, cinematic feel",
            "resolution": "1080P",
            "size": "16:9",
            "duration": 5,
            "seed": 42
          }
          """;

          HttpClient client = HttpClient.newHttpClient();
          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create(url))
              .header("Authorization", "Bearer <token>")
              .header("Content-Type", "application/json")
              .POST(HttpRequest.BodyPublishers.ofString(payload))
              .build();

          HttpResponse<String> response = client.send(request,
              HttpResponse.BodyHandlers.ofString());

          System.out.println(response.body());
      }
  }
  ```

  ```php PHP theme={null}
  <?php

  $url = "https://gccai.heqingsong.uk/v1/videos/generations";

  $payload = [
      "model" => "happyhorse-1.0",
      "prompt" => "A little girl walking down the road, cinematic feel",
      "resolution" => "1080P",
      "size" => "16:9",
      "duration" => 5,
      "seed" => 42
  ];

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      "Authorization: Bearer <token>",
      "Content-Type: application/json"
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  echo $response;
  ?>
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'
  require 'uri'

  url = URI("https://gccai.heqingsong.uk/v1/videos/generations")

  payload = {
    model: "happyhorse-1.0",
    prompt: "A little girl walking down the road, cinematic feel",
    resolution: "1080P",
    size: "16:9",
    duration: 5,
    seed: 42
  }

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(url)
  request["Authorization"] = "Bearer <token>"
  request["Content-Type"] = "application/json"
  request.body = payload.to_json

  response = http.request(request)
  puts response.body
  ```

  ```swift Swift theme={null}
  import Foundation

  let url = URL(string: "https://gccai.heqingsong.uk/v1/videos/generations")!

  let payload: [String: Any] = [
      "model": "happyhorse-1.0",
      "prompt": "A little girl walking down the road, cinematic feel",
      "resolution": "1080P",
      "size": "16:9",
      "duration": 5,
      "seed": 42
  ]

  var request = URLRequest(url: url)
  request.httpMethod = "POST"
  request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")
  request.setValue("application/json", forHTTPHeaderField: "Content-Type")
  request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

  let task = URLSession.shared.dataTask(with: request) { data, response, error in
      if let error = error {
          print("Error: \(error)")
          return
      }

      if let data = data, let responseString = String(data: data, encoding: .utf8) {
          print(responseString)
      }
  }

  task.resume()
  ```

  ```csharp C# theme={null}
  using System;
  using System.Net.Http;
  using System.Text;
  using System.Threading.Tasks;

  class Program
  {
      static async Task Main(string[] args)
      {
          var url = "https://gccai.heqingsong.uk/v1/videos/generations";

          var payload = @"{
              ""model"": ""happyhorse-1.0"",
              ""prompt"": ""A little girl walking down the road, cinematic feel"",
              ""resolution"": ""1080P"",
              ""size"": ""16:9"",
              ""duration"": 5,
              ""seed"": 42
          }";

          using var client = new HttpClient();
          client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");

          var content = new StringContent(payload, Encoding.UTF8, "application/json");
          var response = await client.PostAsync(url, content);
          var result = await response.Content.ReadAsStringAsync();

          Console.WriteLine(result);
      }
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 200,
    "data": [
      {
        "status": "submitted",
        "task_id": "task_01J9HA7JPQ9A0Z6JZ3V8M9W6PZ"
      }
    ]
  }
  ```

  ```json 400 theme={null}
  {
    "error": {
      "code": 400,
      "message": "Invalid request parameters",
      "type": "invalid_request_error"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "code": 401,
      "message": "Invalid authentication credentials",
      "type": "authentication_error"
    }
  }
  ```

  ```json 402 theme={null}
  {
    "error": {
      "code": 402,
      "message": "Insufficient balance. Please top up your account",
      "type": "payment_required"
    }
  }
  ```

  ```json 429 theme={null}
  {
    "error": {
      "code": 429,
      "message": "Rate limit exceeded. Please try again later",
      "type": "rate_limit_error"
    }
  }
  ```

  ```json 500 theme={null}
  {
    "error": {
      "code": 500,
      "message": "Internal server error. Please try again later",
      "type": "server_error"
    }
  }
  ```
</ResponseExample>

## Authorization

<ParamField header="Authorization" type="string" required>
  All API endpoints require Bearer Token authentication

  Get your API Key:

  Visit the [API Key Management Page](https://gccai.heqingsong.uk/keys) to get your API Key

  Add it to the request header:

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## Mode Routing

`happyhorse-1.0` is the unified entry for Text-to-Video / Image-to-Video / Reference-Image-to-Video / Video Edit. The backend automatically determines the mode based on incoming parameters. **All modes are billed by the same rule (resolution × seconds only)**:

| Fields you pass                                                                    | Routes To                      | Mode Description                           |
| ---------------------------------------------------------------------------------- | ------------------------------ | ------------------------------------------ |
| `prompt` only                                                                      | Text-to-Video (T2V)            | Generate video purely from text            |
| `prompt` + `first_frame_image`                                                     | Image-to-Video (I2V)           | Animate from a first-frame image           |
| `prompt` + `image_urls` (1–9 images)                                               | Reference-Image-to-Video (R2V) | Generate a new scene from reference images |
| `prompt` + `video_url` (optional `image_urls` 0–5 as style refs / `audio_setting`) | Video Edit (EDIT)              | Rewrite / restylize a source video         |

**Routing priority** (high to low): `video_url` > `first_frame_image` > `image_urls` > `prompt` only.

**Mutual exclusion rules**: the three media fields (`first_frame_image` / `image_urls` / `video_url`) are **mutually exclusive in pairs**. The only valid combination is `video_url + image_urls` (EDIT mode + reference images). Passing two mutually exclusive fields returns 400 `mixed_media_not_allowed`.

## Request Parameters

<ParamField body="model" type="string" required>
  Video generation model name, fixed as `happyhorse-1.0`
</ParamField>

<ParamField body="prompt" type="string">
  Video content description, up to 2500 characters; cannot contain special tokens

  * **T2V / R2V / EDIT modes**: required
  * **I2V mode**: optional, but recommended to guide camera movement and actions

  Example: `"A little girl walking down the road, cinematic feel"`
</ParamField>

<ParamField body="first_frame_image" type="string">
  First-frame image, triggers **I2V** (Image-to-Video). Supports URL or base64 (`data:image/<mime>;base64,<payload>`, the gateway uploads it to OSS automatically)

  Mutually exclusive with `image_urls` / `video_url`

  <Note>
    **First-frame image requirements:**

    * Format: JPEG / JPG / PNG / BMP / WEBP
    * Short side: ≥ 300px
    * Aspect ratio: `1:2.5` to `2.5:1`
    * File size: ≤ 10MB
  </Note>
</ParamField>

<ParamField body="image_urls" type="array<string>">
  Image array:

  * **R2V mode** (only `image_urls` provided): 1–9 images, used as subject/style references to generate a new scene
  * **EDIT mode** (provided together with `video_url`): 0–5 images, used as style reference

  Supports URL or base64

  Mutually exclusive with `first_frame_image`; can be combined with `video_url`

  <Note>
    **Reference image requirements:**

    * Format: JPEG / JPG / PNG / BMP / WEBP
    * Short side: ≥ 720p recommended
    * Aspect ratio: short / long ≥ 0.4
    * File size: ≤ 10MB
    * Count: R2V must be 1–9; EDIT up to 5
  </Note>
</ParamField>

<ParamField body="video_url" type="string">
  Source video URL, triggers **EDIT** (Video Edit). **Base64 is not supported** — provide an HTTP/HTTPS direct link

  Mutually exclusive with `first_frame_image`; can be combined with `image_urls` (≤ 5)

  <Note>
    **Source video requirements:**

    * Duration: 3–60 seconds (> 15s will be auto-truncated by the upstream from 0 to 15s)
    * Resolution: minimum 480p, short side ≥ 360
    * Aspect ratio: `1:8` to `8:1`
    * Format: MP4 / MOV (H.264 recommended)
    * Frame rate: > 8 fps
    * File size: ≤ 100MB
  </Note>

  <Warning>
    **In EDIT mode, the generated video's duration matches the source video** (capped at the truncated 15s when the source is longer). The `duration` parameter has no effect here. To control the output length, trim the source video to the target duration before uploading.
  </Warning>
</ParamField>

<ParamField body="audio_setting" type="string" default="auto">
  Audio setting, **only effective in EDIT mode** (must pass `video_url`)

  Options:

  * `auto` - Auto-generate audio (default)
  * `origin` - Keep the source video's audio track

  <Warning>
    Passing this field outside EDIT mode returns 400 `audio_setting_only_for_edit`
  </Warning>
</ParamField>

<ParamField body="resolution" type="string" default="1080P">
  Video resolution (affects billing)

  Options:

  * `720P` - Standard
  * `1080P` - High definition (default)
</ParamField>

<ParamField body="duration" type="integer" default="5">
  Video duration in seconds (affects billing)

  Supported range: any integer from `3` to `15`

  Default: `5`

  <Warning>
    **Has no effect in EDIT mode (when `video_url` is provided)**: the generated video's duration matches the source video (billed by the truncated 15s when the source is longer than 15s). To control the output length, trim the source video first.
  </Warning>
</ParamField>

<ParamField body="size" type="string" default="16:9">
  Aspect ratio

  Supported formats:

  * `16:9` - Landscape widescreen (default)
  * `9:16` - Portrait
  * `1:1` - Square
  * `4:3` - Landscape
  * `3:4` - Portrait

  <Warning>
    **Ignored in I2V / EDIT modes** — the output aspect ratio is determined automatically by the input media (first-frame image / source video)
  </Warning>
</ParamField>

<ParamField body="watermark" type="boolean" default="false">
  Whether to add a watermark to the generated video

  * `true`: Add watermark
  * `false`: Do not add watermark (default)
</ParamField>

<ParamField body="seed" type="integer">
  Random seed used to control the randomness of generated content

  Value range: `[0, 2147483647]`. If omitted, a random seed is used.

  <Note>
    * For identical requests, the model generates different results when receiving different seed values (e.g., omitting seed)
    * For identical requests, the model generates similar results when receiving the same seed value, but exact consistency is not guaranteed
  </Note>
</ParamField>

## Response

<ResponseField name="code" type="integer">
  Response status code, 200 on success
</ResponseField>

<ResponseField name="data" type="array">
  Response data array

  <Expandable title="Array Elements">
    <ResponseField name="status" type="string">
      Task status, `submitted` when initially submitted
    </ResponseField>

    <ResponseField name="task_id" type="string">
      Unique task identifier for querying task status and results
    </ResponseField>
  </Expandable>
</ResponseField>

## Use Cases

### Case 1: Text-to-Video T2V (Simplest Request)

```json theme={null}
{
  "model": "happyhorse-1.0",
  "prompt": "A little girl walking down the road, cinematic feel"
}
```

### Case 2: Text-to-Video T2V (Full Parameters)

```json theme={null}
{
  "model": "happyhorse-1.0",
  "prompt": "A coastal road at sunset, slow-motion camera push-in, cinematic feel",
  "resolution": "1080P",
  "size": "16:9",
  "duration": 8,
  "seed": 42
}
```

### Case 3: Image-to-Video I2V (first\_frame\_image)

```json theme={null}
{
  "model": "happyhorse-1.0",
  "prompt": "Bring the scene in the image to life",
  "first_frame_image": "https://example.com/first_frame.png",
  "resolution": "1080P",
  "duration": 5
}
```

### Case 4: Reference-Image-to-Video R2V (multiple references)

```json theme={null}
{
  "model": "happyhorse-1.0",
  "prompt": "The protagonist from image 1 runs through the scene from image 2, then picks up the prop from image 3. Keep a 3D cartoon style with smooth motion.",
  "image_urls": [
    "https://example.com/img_01.jpg",
    "https://example.com/img_02.png",
    "https://example.com/img_03.jpeg"
  ],
  "resolution": "1080P",
  "size": "16:9",
  "duration": 5
}
```

### Case 5: Video Edit EDIT (keep original audio + style reference)

```json theme={null}
{
  "model": "happyhorse-1.0",
  "prompt": "Convert the character in the video to a cartoon style, preserving the original motion",
  "video_url": "https://example.com/source.mp4",
  "image_urls": [
    "https://example.com/style_ref.jpg"
  ],
  "resolution": "1080P",
  "audio_setting": "origin",
  "seed": 42
}
```

### Case 6: 720P to Save Cost

```json theme={null}
{
  "model": "happyhorse-1.0",
  "prompt": "Waves crashing on the beach at sunset",
  "resolution": "720P",
  "size": "16:9",
  "duration": 5
}
```

## Mode Selection Guide

| Requirement                                            | Recommended Approach                                                              |
| ------------------------------------------------------ | --------------------------------------------------------------------------------- |
| Generate video from text only                          | Pass only `prompt` (T2V)                                                          |
| Make an image "come alive" (use it as the first frame) | Pass `first_frame_image` (I2V)                                                    |
| Generate a new scene from a set of reference images    | Pass `image_urls` (1–9, R2V)                                                      |
| Rewrite / restylize an existing video                  | Pass `video_url` (EDIT), optionally combine with `image_urls` (0–5) as style refs |
| Save cost                                              | Use `resolution: "720P"`                                                          |

## Usage Tips

1. **Unified entry logic**: input fields decide the mode. Note that the three media fields (`first_frame_image` / `image_urls` / `video_url`) are mutually exclusive in pairs
2. **`size` only effective in T2V/R2V**: in I2V / EDIT modes `size` is ignored — the output aspect ratio is determined by the input media
3. **Duration**: 5–10 seconds is the sweet spot. Too short causes choppy motion; too long significantly increases upstream processing time
4. **First-frame image quality**: clear, well-composed, subject centered — significantly improves I2V output
5. **Prompt writing**: describe motion / camera / atmosphere (e.g., "slow push-in, cinematic, warm tones") for better results than purely static scene descriptions
6. **EDIT input video**: > 15 seconds will be auto-truncated by the upstream from 0 to 15s. If you need other segments, slice the video yourself first

<Note>
  **Query Task Results**

  Video generation is an async task that returns a `task_id` upon submission. Use the [Get Task Status](/en/api-reference/tasks/status) endpoint to query generation progress and results.
</Note>
