# 提交影片生成任務

**API:** Model API

**Endpoint:** `POST /api/v1/videos/generations`

採用 OpenRouter 風格的平鋪影片輸入。Felo 的模型 ID、頻道、任務 ID 與回應格式維持不變。舊的 input 包裝與供應商原生欄位會被拒絕。不支援回呼、續接生成、供應商選項與影片超解析度。模型與頻道的能力可能會進一步限制這些參數。回傳 HTTP 202 與 Felo 的 task_id。輪詢 GET /api/v1/videos/generations/{task_id}。不支援的欄位回傳 HTTP 400。

## Base URL

- `https://openapi.felo.ai` — 正式環境

## Authentication

- `FeloBearerAuth` (http bearer) — 以 `Authorization: Bearer <key>` 形式傳送的 Felo API 金鑰。
- `FeloApiKey` (apiKey in header `X-API-Key`) — 以 `X-API-Key: <key>` 形式傳送的 Felo API 金鑰。

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `X-Request-Id` | header | no | string | 選用的呼叫方請求 ID，會回傳以供診斷使用。 |
| `X-Felo-Channel` | header | no | string, default: "default" | 依序排列、以逗號分隔的公開頻道代碼。省略此標頭即使用 default；default 必須單獨使用。在錢包模式下，default 會反向掃描模型實際生效的公開頻道順序，略過未發布或不可用的頻道，並選用第一個可用頻道所屬的供應商。它會納入該供應商底下具有相同上游模型 ID 與服務層級的可用端點。明確指定的頻道會依用戶端指定的順序驗證；只會提交第一個頻道所屬的供應商群組。不會自動回退至其他供應商。舊版的供應商標頭無法覆寫頻道路由。 |

## Request body

Required: **yes**

### application/json

Schema: `VideoGenerationRequest` (`#/components/schemas/VideoGenerationRequest`)

```json
{
  "type": "object",
  "required": [
    "model"
  ],
  "additionalProperties": false,
  "description": "採用 OpenRouter 風格的平鋪影片輸入。Felo 的模型 ID、頻道、任務 ID 與回應格式維持不變。舊的 input 包裝與供應商原生欄位會被拒絕。不支援回呼、續接生成、供應商選項與影片超解析度。模型與頻道的能力可能會進一步限制這些參數。",
  "properties": {
    "model": {
      "type": "string",
      "minLength": 1,
      "pattern": "\\S"
    },
    "prompt": {
      "type": "string"
    },
    "duration": {
      "type": "integer",
      "minimum": 1
    },
    "resolution": {
      "type": "string",
      "enum": [
        "360p",
        "480p",
        "720p",
        "768p",
        "1080p",
        "1K",
        "2K",
        "4K"
      ]
    },
    "aspect_ratio": {
      "type": "string",
      "enum": [
        "16:9",
        "9:16",
        "1:1",
        "4:3",
        "3:4",
        "3:2",
        "2:3",
        "21:9",
        "9:21"
      ]
    },
    "generate_audio": {
      "type": "boolean"
    },
    "character_orientation": {
      "type": "string",
      "enum": [
        "image",
        "video"
      ],
      "description": "Required by supported Kling motion-control models: orientation source."
    },
    "seed": {
      "type": "integer"
    },
    "size": {
      "type": "string",
      "pattern": "^[1-9][0-9]*x[1-9][0-9]*$"
    },
    "frame_images": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "image_url"
            ]
          },
          "image_url": {
            "type": "object",
            "additionalProperties": false,
            "oneOf": [
              {
                "required": [
                  "url"
                ]
              },
              {
                "required": [
                  "file_id"
                ]
              }
            ],
            "properties": {
              "url": {
                "type": "string",
                "minLength": 1,
                "pattern": "\\S",
                "not": {
                  "pattern": "^\\s*felo_file_"
                }
              },
              "file_id": {
                "type": "string",
                "maxLength": 80,
                "pattern": "^felo_file_[A-Za-z0-9_-]{1,70}$",
                "description": "Uploaded Felo file owned by the authenticated user."
              }
            }
          },
          "frame_type": {
            "type": "string",
            "enum": [
              "first_frame",
              "last_frame"
            ]
          }
        },
        "required": [
          "type",
          "image_url",
          "frame_type"
        ]
      }
    },
    "input_references": {
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "image_url"
                ]
              },
              "image_url": {
                "type": "object",
                "additionalProperties": false,
                "oneOf": [
                  {
                    "required": [
                      "url"
                    ]
                  },
                  {
                    "required": [
                      "file_id"
                    ]
                  }
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "minLength": 1,
                    "pattern": "\\S",
                    "not": {
                      "pattern": "^\\s*felo_file_"
                    }
                  },
                  "file_id": {
                    "type": "string",
                    "maxLength": 80,
                    "pattern": "^felo_file_[A-Za-z0-9_-]{1,70}$",
                    "description": "Uploaded Felo file owned by the authenticated user."
                  }
                }
              }
            },
            "required": [
              "type",
              "image_url"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "video_url"
                ]
              },
              "video_url": {
                "type": "object",
                "additionalProperties": false,
                "oneOf": [
                  {
                    "required": [
                      "url"
                    ]
                  },
                  {
                    "required": [
                      "file_id"
                    ]
                  }
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "minLength": 1,
                    "pattern": "\\S",
                    "not": {
                      "pattern": "^\\s*felo_file_"
                    }
                  },
                  "file_id": {
                    "type": "string",
                    "maxLength": 80,
                    "pattern": "^felo_file_[A-Za-z0-9_-]{1,70}$",
                    "description": "Uploaded Felo file owned by the authenticated user."
                  }
                }
              }
            },
            "required": [
              "type",
              "video_url"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "audio_url"
                ]
              },
              "audio_url": {
                "type": "object",
                "additionalProperties": false,
                "oneOf": [
                  {
                    "required": [
                      "url"
                    ]
                  },
                  {
                    "required": [
                      "file_id"
                    ]
                  }
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "minLength": 1,
                    "pattern": "\\S",
                    "not": {
                      "pattern": "^\\s*felo_file_"
                    }
                  },
                  "file_id": {
                    "type": "string",
                    "maxLength": 80,
                    "pattern": "^felo_file_[A-Za-z0-9_-]{1,70}$",
                    "description": "Uploaded Felo file owned by the authenticated user."
                  }
                }
              }
            },
            "required": [
              "type",
              "audio_url"
            ]
          }
        ]
      }
    },
    "user": {
      "type": "string",
      "maxLength": 256
    },
    "session_id": {
      "type": "string",
      "maxLength": 256
    },
    "trace": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "trace_id": {
          "type": "string"
        },
        "trace_name": {
          "type": "string"
        },
        "span_name": {
          "type": "string"
        },
        "generation_name": {
          "type": "string"
        },
        "parent_span_id": {
          "type": "string"
        }
      }
    },
    "provider": {
      "type": "object",
      "required": [
        "options"
      ],
      "additionalProperties": false,
      "properties": {
        "options": {
          "type": "object",
          "minProperties": 1,
          "maxProperties": 1,
          "additionalProperties": {
            "type": "object"
          },
          "description": "Options keyed by the slug published in the model catalog provider_options."
        }
      }
    }
  }
}
```

Example:

```json
{
  "model": "veo-3.1-lite",
  "prompt": "A cinematic camera move",
  "duration": 4,
  "resolution": "720p",
  "generate_audio": false,
  "frame_images": [
    {
      "type": "image_url",
      "frame_type": "first_frame",
      "image_url": {
        "url": "https://example.com/first.png"
      }
    }
  ]
}
```

## Responses

### 202 — 已接受任務

**application/json**

Schema: `VideoGenerationAccepted` (`#/components/schemas/VideoGenerationAccepted`)

### 400 — 請求無效（未知模型、混用輸入模式、欄位無效）

**application/json**

Schema: `GenerationError` (`#/components/schemas/GenerationError`)

### 401 — Felo API 金鑰無效或未提供

**application/json**

Schema: `GenerationError` (`#/components/schemas/GenerationError`)

### 402 — 餘額不足／未符合計費要求

**application/json**

Schema: `GenerationError` (`#/components/schemas/GenerationError`)

### 403 — 此帳戶無使用權限（需要訂閱，或使用者已遭停權）。已停用的模型同樣會在上游呼叫前遭到拒絕。已受理的請求與任務將繼續執行。

**application/json**

Schema: `GenerationError` (`#/components/schemas/GenerationError`)

### 429 — 已達請求或消費上限

**application/json**

Schema: `GenerationError` (`#/components/schemas/GenerationError`)

### 502 — 上游供應商失敗

**application/json**

Schema: `GenerationError` (`#/components/schemas/GenerationError`)

### 503 — 生成服務或計費服務暫時無法使用

**application/json**

Schema: `GenerationError` (`#/components/schemas/GenerationError`)

## Schema definitions

### GenerationError

`#/components/schemas/GenerationError`

```json
{
  "type": "object",
  "description": "相容於 OpenAI 的錯誤封裝。",
  "properties": {
    "error": {
      "type": "object",
      "required": [
        "message",
        "type"
      ],
      "properties": {
        "message": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "invalid_request_error",
            "server_error"
          ]
        },
        "param": {
          "type": "string",
          "nullable": true
        },
        "code": {
          "type": "string"
        }
      }
    }
  }
}
```

### VideoGenerationAccepted

`#/components/schemas/VideoGenerationAccepted`

```json
{
  "type": "object",
  "required": [
    "task_id",
    "status",
    "kind",
    "outputs"
  ],
  "properties": {
    "task_id": {
      "type": "string",
      "description": "用於輪詢的任務 ID。"
    },
    "status": {
      "type": "string",
      "enum": [
        "queued"
      ]
    },
    "kind": {
      "type": "string",
      "enum": [
        "video"
      ]
    },
    "outputs": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "在任務成功前為空。"
    }
  }
}
```
