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

# FLUX 3 動画生成

>  - 非同期処理モード、後続の照会用にタスク ID を返します
- 統一エントリ：テキストから動画 / 画像から動画 / 動画継続 / ドラフト二段階
- 出力は H.264 + AAC、同期音声付き、長さ 5~20 秒
- 解像度 hd / fhd、7 種類のアスペクト比 

<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": "flux-3-video",
      "prompt": "An orange cat jumps onto a sunlit wooden table, its tail brushes a glass that wobbles but does not fall. Cinematic, shallow depth of field.",
      "duration": 5,
      "resolution": "hd",
      "aspect_ratio": "16:9"
    }'
  ```

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

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

  payload = {
      "model": "flux-3-video",
      "prompt": "An orange cat jumps onto a sunlit wooden table, its tail brushes a glass that wobbles but does not fall. Cinematic, shallow depth of field.",
      "duration": 5,
      "resolution": "hd",
      "aspect_ratio": "16:9",
  }

  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: "flux-3-video",
    prompt: "An orange cat jumps onto a sunlit wooden table, its tail brushes a glass that wobbles but does not fall. Cinematic, shallow depth of field.",
    duration: 5,
    resolution: "hd",
    aspect_ratio: "16:9",
  };

  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":        "flux-3-video",
          "prompt":       "An orange cat jumps onto a sunlit wooden table",
          "duration":     5,
          "resolution":   "hd",
          "aspect_ratio": "16:9",
      }

      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))
  }
  ```
</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 422 theme={null}
  {
    "error": {
      "code": 422,
      "message": "パラメータの競合または無効な値です",
      "type": "invalid_request_error"
    }
  }
  ```

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

## 認証

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

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

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

## 生成モード

`flux-3-video` は**統一エントリ**です。フィールドからモードを推定するか、`mode` で明示指定できます。

| モード               | トリガー                                  | 説明                        |
| ----------------- | ------------------------------------- | ------------------------- |
| **テキストから動画（t2v）** | `prompt` のみ                           | 純粋なテキスト                   |
| **画像から動画（i2v）**   | `image_urls`                          | キーフレーム、下記参照               |
| **動画継続（v2v）**     | `video_url` / `video_urls`            | 単価が高い。画像と動画の両方がある場合は継続が優先 |
| **ドラフト → 本編**     | `draft:true` または `draft_from_task_id` | 低価格プレビュー後、正規価格で本編         |

`mode` の値：`t2v` / `i2v` / `v2v` / `draft_enhance`、または公式表記 `text-to-video` / `image-continuation` / `video-continuation`。**明示的な `mode` が最優先**です。

### 画像から動画のキーフレーム意味

`image_urls` の順序が意味を持ちます — 並べ替えや重複排除をしないでください：

| 枚数    | 意味                                            |
| ----- | --------------------------------------------- |
| 1     | **開始フレーム**                                    |
| 2     | 1 枚目が開始、2 枚目が**終了フレーム**                       |
| 3\~10 | 先頭が開始、末尾が終了、中間フレームは**均等配置**（`duration` を明示推奨） |

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

<ParamField body="model" type="string" required>
  固定値：`flux-3-video`
</ParamField>

<ParamField body="prompt" type="string" required>
  プロンプト。`draft_from_task_id` 使用時は**送信禁止**（送信すると拒否されます）。
</ParamField>

<ParamField body="duration" type="integer" default="5">
  長さ（秒）、整数 **5\~20**、デフォルト `5`

  <Warning>
    **`duration: "auto"` は非対応**です（課金に固定秒数が必要）。省略、`"auto"`、非整数 → エラーなく **5 秒**として扱い、自動適応はしません。
  </Warning>

  <Note>
    **動画継続**では、実際の出力がリクエスト秒数より短くなる場合があります（例：5 秒要求で 4 秒）。要求秒数で仮請求し、完了後に差分を返金します。最終金額は照会の `cost` が基準です。テキスト/画像から動画ではこの差は出ません。
  </Note>
</ParamField>

<ParamField body="resolution" type="string" default="hd">
  解像度

  * `hd`（デフォルト、`720p` も可）
  * `fhd`（`1080p` も可）

  実測：`hd` は 16:9 で約 1280×704、`fhd` は約 1920×1088。

  <Warning>
    ドラフトモード（`draft:true`）は **`hd` のみ**許可。
  </Warning>
</ParamField>

<ParamField body="aspect_ratio" type="string" default="auto">
  アスペクト比

  選択肢：`21:9`、`2:1`、`16:9`、`4:3`、`1:1`、`3:4`、`9:16`、または `auto`（デフォルト、プロンプトと素材から自動選択）
</ParamField>

<ParamField body="image_urls" type="string[]">
  画像から動画のキーフレーム、**1\~10**、公開 http(s) URL または base64
</ParamField>

<ParamField body="video_url" type="string">
  継続用の入力動画（mp4、公開 URL または base64）
</ParamField>

<ParamField body="video_urls" type="string[]">
  `video_url` と同じ、**先頭**の要素を使用（互換用）
</ParamField>

<ParamField body="audio" type="boolean" default="true">
  同期音声を生成、デフォルト `true`。`false` は無音動画（**値引きなし**）
</ParamField>

<ParamField body="draft" type="boolean" default="false">
  ドラフトモード：約 **1/3 価格**の低品質プレビュー、`resolution: hd` のみ
</ParamField>

<ParamField body="draft_from_task_id" type="string">
  ドラフト → 本編：**自分の**成功済みドラフトタスク ID

  * 変更可能なのは `resolution` のみ、プロンプト・長さ・画像・動画は変更不可
  * 本編の正規価格で課金、ドラフト料金は相殺されません
  * `draft:true` と**相互排他**
</ParamField>

<ParamField body="safety_tolerance" type="integer" default="2">
  モデレーション許容度 **0\~4**、デフォルト `2`（大きいほど緩い）

  <Note>
    FLUX.2 画像（0~~5）や Kontext（0~~6）と混同しないでください。
  </Note>
</ParamField>

<ParamField body="mode" type="string">
  明示モード（任意）、生成モードを参照
</ParamField>

## ドラフトモード

反復が高コストな場合の二段階ワークフロー：

```
Step 1  draft:true            → 約 1/3 価格の低品質プレビュー
Step 2  draft_from_task_id    → ドラフト見た目に合わせた正規価格の本編
```

### ドラフト作成

```json theme={null}
{
  "model": "flux-3-video",
  "prompt": "An orange cat jumps onto a sunlit wooden table",
  "duration": 5,
  "draft": true
}
```

### ドラフトから本編

```json theme={null}
{
  "model": "flux-3-video",
  "draft_from_task_id": "task_01K_DRAFT...",
  "resolution": "fhd"
}
```

ドラフトから本編へは、ドラフトに保存されたパラメータ（モード / プロンプト / シード / 素材）でフル品質レンダリングします。継続ドラフトの本編は継続の本編単価で課金されます。

## リクエスト例

### テキストから動画（縦向き）

```json theme={null}
{
  "model": "flux-3-video",
  "prompt": "Rainy Tokyo street at night, neon in puddles, a person walks with an umbrella.",
  "duration": 8,
  "resolution": "fhd",
  "aspect_ratio": "9:16"
}
```

### 画像から動画（開始 + 終了フレーム）

```json theme={null}
{
  "model": "flux-3-video",
  "prompt": "Slow push-in as a flower opens from bud to bloom",
  "image_urls": [
    "https://example.com/bud.jpg",
    "https://example.com/bloom.jpg"
  ],
  "duration": 5
}
```

### 動画継続

```json theme={null}
{
  "model": "flux-3-video",
  "prompt": "Camera keeps following as the lead turns toward a distant lighthouse",
  "video_url": "https://example.com/clip.mp4",
  "duration": 5
}
```

### 無音動画

```json theme={null}
{
  "model": "flux-3-video",
  "prompt": "...",
  "audio": false
}
```

## 制約

| 制限                 | 値                             |
| ------------------ | ----------------------------- |
| 長さ                 | 整数 5\~20（`auto` 非対応、`21` は拒否） |
| キーフレーム             | 1\~10                         |
| 解像度                | `hd` / `fhd` のみ、ドラフトは `hd` のみ |
| アスペクト比             | 7 種類または `auto`                |
| `safety_tolerance` | 0\~4                          |

### よくある送信エラー（通常は課金なし）

| ケース                                            | 説明                 |
| ---------------------------------------------- | ------------------ |
| `prompt` 欠落                                    | ドラフト本編化以外では必須      |
| 無効な `resolution` / `aspect_ratio` / `duration` | 範囲外                |
| キーフレーム > 10                                    | 上限超過               |
| 明示 `i2v` で画像なし / `v2v` で動画なし                   | モードと素材の不一致         |
| `draft:true` + `fhd`                           | ドラフトは hd のみ        |
| 無効 / 非ドラフト / 未完了の `draft_from_task_id`         | 本編化の前提条件           |
| 本編化時に prompt / duration を変更                    | `resolution` のみ変更可 |
| `draft` と `draft_from_task_id` の両方             | 相互排他               |

モデレーション失敗は `failed` 終了となり**全額返金**されます。

## 機能カバレッジ

| 機能                   | 状態                                 |
| -------------------- | ---------------------------------- |
| t2v / i2v / v2v      | ✅ 自動または明示 `mode`                   |
| ドラフト / ドラフト本編化       | ✅ `draft` / `draft_from_task_id`   |
| 同期音声                 | ✅ デフォルトオン、`audio:false` でオフ（値引きなし） |
| 時刻付きキーフレーム `[秒, 画像]` | ❌ 均等配置のキーフレーム配列のみ                  |
| `duration: "auto"`   | ❌ 非対応                              |

## Response

<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">
      ポーリング用のタスク ID
    </ResponseField>
  </Expandable>
</ResponseField>

<Note>
  **結果の照会**

  動画生成は非同期です。[タスク状態の取得](/ja/api-reference/tasks/status) でポーリングしてください。

  推奨間隔 **5\~10 秒**、クライアントタイムアウト **15 分**（20 秒 fhd はより遅い）。実測 `t2v` + `hd` + 5 秒で約 60 秒。

  成功時は `result.videos[0].url` を使用。成果物はプラットフォーム CDN にミラーされます。`cost` が最終請求額です。失敗時は全額返金。
</Note>
