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

# HappyHorse 1.0 動画生成

>  - Alibaba Cloud Bailian HappyHorse 1.0 動画生成モデル（統一エンドポイント、単一モデル自動ルーティング）
- パラメータに応じて自動ルーティング：T2V（prompt のみ）/ I2V（first_frame_image）/ R2V（image_urls）/ EDIT（video_url）
- 720P/1080P 解像度、3〜15 秒の任意の整数秒に対応
- 解像度 × 秒数のみで課金、機能種別に依存しない 

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.apimart.ai/v1/videos/generations \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "happyhorse-1.0",
      "prompt": "道を歩く少女、映画のような映像",
      "resolution": "1080P",
      "size": "16:9",
      "duration": 5,
      "seed": 42
    }'
  ```

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

  url = "https://api.apimart.ai/v1/videos/generations"

  payload = {
      "model": "happyhorse-1.0",
      "prompt": "道を歩く少女、映画のような映像",
      "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://api.apimart.ai/v1/videos/generations";

  const payload = {
    model: "happyhorse-1.0",
    prompt: "道を歩く少女、映画のような映像",
    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://api.apimart.ai/v1/videos/generations"

      payload := map[string]interface{}{
          "model":      "happyhorse-1.0",
          "prompt":     "道を歩く少女、映画のような映像",
          "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://api.apimart.ai/v1/videos/generations";

          String payload = """
          {
            "model": "happyhorse-1.0",
            "prompt": "道を歩く少女、映画のような映像",
            "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://api.apimart.ai/v1/videos/generations";

  $payload = [
      "model" => "happyhorse-1.0",
      "prompt" => "道を歩く少女、映画のような映像",
      "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://api.apimart.ai/v1/videos/generations")

  payload = {
    model: "happyhorse-1.0",
    prompt: "道を歩く少女、映画のような映像",
    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://api.apimart.ai/v1/videos/generations")!

  let payload: [String: Any] = [
      "model": "happyhorse-1.0",
      "prompt": "道を歩く少女、映画のような映像",
      "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://api.apimart.ai/v1/videos/generations";

          var payload = @"{
              ""model"": ""happyhorse-1.0"",
              ""prompt"": ""道を歩く少女、映画のような映像"",
              ""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": "リクエストパラメータが無効です",
      "type": "invalid_request_error"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "code": 401,
      "message": "認証に失敗しました。APIキーを確認してください",
      "type": "authentication_error"
    }
  }
  ```

  ```json 402 theme={null}
  {
    "error": {
      "code": 402,
      "message": "残高が不足しています。チャージしてください",
      "type": "payment_required"
    }
  }
  ```

  ```json 429 theme={null}
  {
    "error": {
      "code": 429,
      "message": "リクエストが多すぎます。しばらくしてからお試しください",
      "type": "rate_limit_error"
    }
  }
  ```

  ```json 500 theme={null}
  {
    "error": {
      "code": 500,
      "message": "サーバー内部エラー。しばらくしてからお試しください",
      "type": "server_error"
    }
  }
  ```
</ResponseExample>

## 認証

<ParamField header="Authorization" type="string" required>
  すべてのAPIエンドポイントでBearer Token認証が必要です

  APIキーの取得：

  [APIキー管理ページ](https://apimart.ai/keys)からAPIキーを取得してください

  リクエストヘッダーに追加：

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

## モードルーティング

`happyhorse-1.0` はテキストから動画 / 画像から動画 / 参照画像から動画 / 動画編集の統一エンドポイントです。バックエンドが受信したパラメータに基づいて自動的にモードを判定します。**全モードは統一ルール（解像度 × 秒）で課金されます**：

| 渡すフィールド                                                                 | ルーティング先       | モード説明              |
| ----------------------------------------------------------------------- | ------------- | ------------------ |
| `prompt` のみ                                                             | テキストから動画（T2V） | テキスト説明のみから動画生成     |
| `prompt` + `first_frame_image`                                          | 画像から動画（I2V）   | 画像を先頭フレームとして動かす    |
| `prompt` + `image_urls`（1〜9 枚）                                          | 参照画像から動画（R2V） | 一連の参照画像から新しいシーンを生成 |
| `prompt` + `video_url`（任意で `image_urls` 0〜5 枚をスタイル参照 / `audio_setting`） | 動画編集（EDIT）    | 元動画の改変・スタイル変換      |

**ルーティング優先度**（高→低）：`video_url` > `first_frame_image` > `image_urls` > `prompt` のみ。

**フィールド排他ルール**：3 つのメディアフィールド（`first_frame_image` / `image_urls` / `video_url`）は**ペアで相互排他**です。唯一の有効な組み合わせは `video_url + image_urls`（EDIT モード + 参照画像）です。排他フィールドを同時指定すると 400 `mixed_media_not_allowed` が返されます。

## リクエストパラメータ

<ParamField body="model" type="string" required>
  動画生成モデル名。`happyhorse-1.0` で固定
</ParamField>

<ParamField body="prompt" type="string">
  動画内容の説明、最大 2500 文字。特殊トークンを含めることはできません

  * **T2V / R2V / EDIT モード**：必須
  * **I2V モード**：任意だが、カメラワークやアクションの指示のため推奨

  例：`"道を歩く少女、映画のような映像"`
</ParamField>

<ParamField body="first_frame_image" type="string">
  先頭フレーム画像。**I2V**（画像から動画）をトリガー。URL または base64（`data:image/<mime>;base64,<payload>`、ゲートウェイが自動的に OSS にアップロード）に対応

  `image_urls` / `video_url` と相互排他

  <Note>
    **先頭フレーム画像の要件：**

    * フォーマット：JPEG / JPG / PNG / BMP / WEBP
    * 短辺ピクセル：≥ 300px
    * アスペクト比：`1:2.5` 〜 `2.5:1`
    * ファイルサイズ：≤ 10MB
  </Note>
</ParamField>

<ParamField body="image_urls" type="array<string>">
  画像配列：

  * **R2V モード**（`image_urls` のみ指定）：1〜9 枚、被写体／スタイル参照として新しいシーンを生成
  * **EDIT モード**（`video_url` と併せて指定）：0〜5 枚、スタイル参照画像として使用

  URL または base64 に対応

  `first_frame_image` と相互排他、`video_url` とは併用可能

  <Note>
    **参照画像の要件：**

    * フォーマット：JPEG / JPG / PNG / BMP / WEBP
    * 短辺ピクセル：≥ 720p 推奨
    * アスペクト比：短辺／長辺 ≥ 0.4
    * ファイルサイズ：≤ 10MB
    * 枚数：R2V は 1〜9 枚必須、EDIT は最大 5 枚
  </Note>
</ParamField>

<ParamField body="video_url" type="string">
  ソース動画 URL。**EDIT**（動画編集）をトリガー。**base64 は非対応**、HTTP/HTTPS 直リンクを指定してください

  `first_frame_image` と相互排他、`image_urls`（≤ 5 枚）とは併用可能

  <Note>
    **ソース動画の要件：**

    * 長さ：3〜60 秒（> 15s の場合、上流が 0 から 15s まで自動切り出し）
    * 解像度：最小 480p、短辺 ≥ 360
    * アスペクト比：`1:8` 〜 `8:1`
    * フォーマット：MP4 / MOV（H.264 推奨）
    * フレームレート：> 8 fps
    * ファイルサイズ：≤ 100MB
  </Note>

  <Warning>
    **EDIT モードでは生成動画の長さがソース動画と同一になります**（ソースが 15 秒を超える場合は切り出された 15 秒で計算）。このとき `duration` パラメータは無効です。出力の長さを制御したい場合は、アップロード前にソース動画を目的の長さにトリミングしてください。
  </Warning>
</ParamField>

<ParamField body="audio_setting" type="string" default="auto">
  音声設定。**EDIT モードのみ有効**（`video_url` の指定が必須）

  選択肢：

  * `auto` - 自動生成音声（デフォルト）
  * `origin` - 元動画の音声トラックを保持

  <Warning>
    EDIT モード以外で本フィールドを指定すると 400 `audio_setting_only_for_edit` が返されます
  </Warning>
</ParamField>

<ParamField body="resolution" type="string" default="1080P">
  動画解像度（課金に影響）

  選択肢：

  * `720P` - 標準
  * `1080P` - 高解像度（デフォルト）
</ParamField>

<ParamField body="duration" type="integer" default="5">
  動画の長さ（秒、課金に影響）

  対応範囲：`3`〜`15` の任意の整数

  デフォルト：`5`

  <Warning>
    **EDIT モード（`video_url` を指定）では本パラメータは無効です**：生成動画の長さはソース動画と同一になります（ソースが 15 秒を超える場合は切り出された 15 秒で課金）。出力の長さを制御したい場合は、事前にソース動画をトリミングしてください。
  </Warning>
</ParamField>

<ParamField body="size" type="string" default="16:9">
  画面のアスペクト比

  対応フォーマット：

  * `16:9` - 横向きワイド（デフォルト）
  * `9:16` - 縦向き
  * `1:1` - 正方形
  * `4:3` - 横向き
  * `3:4` - 縦向き

  <Warning>
    **I2V / EDIT モードでは無視されます** — 出力アスペクト比は入力メディア（先頭フレーム画像 / ソース動画）により自動決定されます
  </Warning>
</ParamField>

<ParamField body="watermark" type="boolean" default="false">
  生成された動画にウォーターマークを追加するかどうか

  * `true`：ウォーターマークを追加
  * `false`：ウォーターマークを追加しない（デフォルト）
</ParamField>

<ParamField body="seed" type="integer">
  生成内容のランダム性を制御するシード

  範囲：`[0, 2147483647]`。省略時はランダム

  <Note>
    * 同一リクエストで異なるseed値を受け取ると（seedを指定しない場合など）、異なる結果が生成されます
    * 同一リクエストで同じseed値を受け取ると、類似した結果が生成されますが、完全一致は保証されません
  </Note>
</ParamField>

## レスポンス

<ResponseField name="code" type="integer">
  レスポンスステータスコード。成功時は 200
</ResponseField>

<ResponseField name="data" type="array">
  レスポンスデータ配列

  <Expandable title="配列要素">
    <ResponseField name="status" type="string">
      タスクステータス。初回送信時は `submitted`
    </ResponseField>

    <ResponseField name="task_id" type="string">
      タスクの一意識別子。タスクステータスおよび結果の取得に使用
    </ResponseField>
  </Expandable>
</ResponseField>

## 使用例

### 例 1：テキストから動画 T2V（最小リクエスト）

```json theme={null}
{
  "model": "happyhorse-1.0",
  "prompt": "道を歩く少女、映画のような映像"
}
```

### 例 2：テキストから動画 T2V（フルパラメータ）

```json theme={null}
{
  "model": "happyhorse-1.0",
  "prompt": "夕日に照らされた海沿いの道路、スローモーションのカメラプッシュイン、映画のような映像",
  "resolution": "1080P",
  "size": "16:9",
  "duration": 8,
  "seed": 42
}
```

### 例 3：画像から動画 I2V（first\_frame\_image）

```json theme={null}
{
  "model": "happyhorse-1.0",
  "prompt": "画像のシーンを動かしてください",
  "first_frame_image": "https://example.com/first_frame.png",
  "resolution": "1080P",
  "duration": 5
}
```

### 例 4：参照画像から動画 R2V（複数参照画像）

```json theme={null}
{
  "model": "happyhorse-1.0",
  "prompt": "画像1の主人公が画像2のシーンを駆け抜け、その後画像3の道具を手に取る。3D カートゥーン風で、滑らかなアクションを保つ。",
  "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
}
```

### 例 5：動画編集 EDIT（元音声保持 + スタイル参照）

```json theme={null}
{
  "model": "happyhorse-1.0",
  "prompt": "動画内のキャラクターをカートゥーン風に変換しつつ、元の動きを保持する",
  "video_url": "https://example.com/source.mp4",
  "image_urls": [
    "https://example.com/style_ref.jpg"
  ],
  "resolution": "1080P",
  "audio_setting": "origin",
  "seed": 42
}
```

### 例 6：720P で料金節約

```json theme={null}
{
  "model": "happyhorse-1.0",
  "prompt": "夕日の浜辺に打ち寄せる波",
  "resolution": "720P",
  "size": "16:9",
  "duration": 5
}
```

## モード選択ガイド

| 要件                    | 推奨方法                                                 |
| --------------------- | ---------------------------------------------------- |
| テキストのみから動画生成          | `prompt` のみ指定（T2V）                                   |
| 画像を"動かす"（先頭フレームとして使用） | `first_frame_image` を指定（I2V）                         |
| 一連の参照画像から新しいシーンを生成    | `image_urls`（1〜9 枚、R2V）を指定                           |
| 既存動画の改変・スタイル変換        | `video_url`（EDIT）を指定、`image_urls` 0〜5 枚をスタイル参照として併用可 |
| 料金節約                  | `resolution: "720P"` を指定                             |

## 使用上のヒント

1. **統一エンドポイントの動作**：渡されたフィールドでモードが決まります。3 つのメディアフィールド（`first_frame_image` / `image_urls` / `video_url`）はペアで相互排他です
2. **`size` は T2V/R2V のみ有効**：I2V / EDIT モードでは `size` が無視され、出力アスペクト比は入力メディアにより決定されます
3. **長さ**：5〜10 秒が最適。短すぎると動きが不連続、長すぎると上流処理時間が大幅に増加します
4. **先頭フレーム画像の品質**：鮮明、構図が明確、被写体が中央 — I2V の効果が大きく向上します
5. **プロンプト記述**：動き / カメラワーク / 雰囲気を記述（例「ゆっくりプッシュイン、映画のような、暖色」）すると、静的なシーン記述のみより良い結果になります
6. **EDIT 入力動画**：> 15 秒の場合、上流が 0 から 15s まで自動切り出します。他のセグメントが必要な場合は事前に動画を分割してください

<Note>
  **タスク結果の取得**

  動画生成は非同期タスクで、送信時に `task_id` が返されます。[タスクステータス取得](/ja/api-reference/tasks/status) エンドポイントで生成進捗と結果を取得してください。
</Note>
