> ## 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.1 動画生成

>  - Alibaba Cloud Bailian HappyHorse 1.1 動画生成モデル（統一エンドポイント、単一モデル自動ルーティング）
- パラメータに応じて自動ルーティング：T2V（prompt のみ）/ I2V（first_frame_image）/ R2V（image_urls）
- 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.1",
      "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.1",
      "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.1",
    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.1",
          "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.1",
            "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.1",
      "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.1",
    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.1",
      "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.1"",
              ""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.1` はテキストから動画 / 画像から動画 / 参照画像から動画の統一エンドポイントです。バックエンドが受信したパラメータに基づいて自動的にモードを判定します。**全モードは統一ルール（解像度 × 秒）で課金されます**：

| 渡すフィールド                        | ルーティング先       | モード説明              |
| ------------------------------ | ------------- | ------------------ |
| `prompt` のみ                    | テキストから動画（T2V） | テキスト説明のみから動画生成     |
| `prompt` + `first_frame_image` | 画像から動画（I2V）   | 画像を先頭フレームとして動かす    |
| `prompt` + `image_urls`（1〜9 枚） | 参照画像から動画（R2V） | 一連の参照画像から新しいシーンを生成 |

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

**フィールド排他ルール**：2 つのメディアフィールド（`first_frame_image` / `image_urls`）は**相互排他**です。排他フィールドを同時指定すると 400 `mixed_media_not_allowed` が返されます。

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

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

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

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

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

  `image_urls` と相互排他

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

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

<ParamField body="image_urls" type="array<string>">
  画像配列（**R2V モード**）：1〜9 枚、被写体／スタイル参照として新しいシーンを生成

  URL または base64 に対応

  `first_frame_image` と相互排他

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

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

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

  選択肢：

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

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

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

  デフォルト：`5`
</ParamField>

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

  対応フォーマット：

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

  <Warning>
    **I2V モードでは無視されます** — 出力アスペクト比は入力メディア（先頭フレーム画像）により自動決定されます
  </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.1",
  "prompt": "道を歩く少女、映画のような映像"
}
```

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

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

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

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

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

```json theme={null}
{
  "model": "happyhorse-1.1",
  "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：720P で料金節約

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

## モード選択ガイド

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

## 使用上のヒント

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

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

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