# 提交视频生成任务

**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": "任务成功前为空。"
    }
  }
}
```
