AI 视频
文生视频生成,支持状态轮询与取消。
概览
基础路径:
https://api.infrai.cc/v1/video鉴权头:
Authorization: Bearer $INFRAI_API_KEYbash
# Call any /v1/video capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/video/... \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json"方法
video.generate
POST /v1/video/generate
启动一个文生视频任务。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
prompt | string | 必填 | 目标视频的文本描述。 |
reference_image_url | string | 可选 | 可选参考图像 URL。 |
duration_seconds | number | 可选 | 片段时长(秒)。 |
aspect | "16:9" | "9:16" | "1:1" | 可选 | 宽高比。 |
resolution | "720p" | "1080p" | "4k" | 可选 | 输出分辨率(720p/1080p/4k);按供应商能力门控。 |
prefer | "balanced" | "cheapest" | "smartest" | 可选 | 优化轴:balanced(最佳性价比)| cheapest | smartest。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
VideoJob { job_id, state, video_url?, thumbnail_url?, error? }示例
一次性前置(每个范例都假定已完成):
bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."bash
curl -X POST https://api.infrai.cc/v1/video/generate \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt": "a timelapse of a city skyline at dusk", "prefer": "balanced", "resolution": "1080p", "duration_seconds": 5, "aspect_ratio": "16:9"}'video.status
GET /v1/video/status/{id}
轮询视频任务的状态。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 必填 | 任务标识。 |
返回
VideoJob示例
一次性前置(每个范例都假定已完成):
bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."bash
curl -X GET https://api.infrai.cc/v1/video/status/ID \
-H "Authorization: Bearer $INFRAI_API_KEY"video.cancel
POST /v1/video/cancel/{id}
取消正在运行的视频任务。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 必填 | 任务标识。 |
返回
{ ok: boolean }示例
一次性前置(每个范例都假定已完成):
bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."bash
curl -X POST https://api.infrai.cc/v1/video/cancel/ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"job_id": "..."}'video.get
GET /v1/video/get/{id}
获取视频任务的完整详情(状态、视频地址、时长、分辨率、厂商、模型等)。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 必填 | 任务标识。 |
返回
VideoJob { job_id, state, video_url?, thumbnail_url?, duration_seconds, resolution, vendor, model, error? }示例
一次性前置(每个范例都假定已完成):
bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."bash
curl -X GET https://api.infrai.cc/v1/video/get/ID \
-H "Authorization: Bearer $INFRAI_API_KEY"video.list
GET /v1/video/list
分页列出当前账户的视频生成任务。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
cursor | string | 可选 | 分页游标,取自上一页返回的 next_cursor。 |
limit | number | 可选 | 单页返回的最大任务数。 |
返回
VideoJobPage { items: VideoJob[], next_cursor?: string }示例
一次性前置(每个范例都假定已完成):
bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."bash
curl -X GET https://api.infrai.cc/v1/video/list \
-H "Authorization: Bearer $INFRAI_API_KEY"video.delete
DELETE /v1/video/delete/{id}
删除指定视频任务及其产物(幂等写)。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 必填 | 任务标识。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
{ ok: boolean }示例
一次性前置(每个范例都假定已完成):
bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."bash
curl -X DELETE https://api.infrai.cc/v1/video/delete/ID \
-H "Authorization: Bearer $INFRAI_API_KEY"video.delete_all
POST /v1/video/delete_all
批量删除当前账户的全部视频任务及其产物。
返回
{ deleted: number }示例
一次性前置(每个范例都假定已完成):
bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."bash
curl -X POST https://api.infrai.cc/v1/video/delete_all \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'video.download_url
GET /v1/video/download_url/{id}
为指定视频任务签发带过期时间的临时下载链接。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 必填 | 任务标识。 |
返回
{ url: string, expires_at: string }示例
一次性前置(每个范例都假定已完成):
bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."bash
curl -X GET https://api.infrai.cc/v1/video/download_url/ID \
-H "Authorization: Bearer $INFRAI_API_KEY"video.set_retention
POST /v1/video/set_retention/{id}
设置单个视频任务的保留窗口(天),上限 90 天。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 必填 | 任务标识。 |
days | number | 必填 | 保留窗口天数,正整数,硬上限 90 天。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
{ job_id: string, retention_days: number, expires_at: string }示例
一次性前置(每个范例都假定已完成):
bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."bash
curl -X POST https://api.infrai.cc/v1/video/set_retention/ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"job_id": "...", "days": 0}'video.capabilities
GET /v1/video/capabilities
查询各视频厂商支持的模型、分辨率、最大时长及扩展/超分能力。
返回
VideoCapabilities { vendors: Array<{ vendor, models, resolutions, max_duration_seconds, supports_extend, supports_upscale }> }示例
一次性前置(每个范例都假定已完成):
bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."bash
curl -X GET https://api.infrai.cc/v1/video/capabilities \
-H "Authorization: Bearer $INFRAI_API_KEY"全部能力
本模块全部已路由能力——完整的对外 REST 契约。上方方法是带讲解的入门示例,此表是完整参考。
| 能力 | 端点 | 说明 |
|---|---|---|
video.cancel | POST /v1/video/cancel/{id} | Cancel an in-progress video generation job. |
video.capabilities | GET /v1/video/capabilities | Query each video provider's supported models, resolutions, max duration, and extend/upscale capabilities. |
video.delete | DELETE /v1/video/delete/{id} | Delete a video job and its artifacts (idempotent write). |
video.delete_all | POST /v1/video/delete_all | Bulk-delete all video jobs and their artifacts for the current account. |
video.download_url | GET /v1/video/download_url/{id} | Issue a time-limited, expiring download URL for a video job's output. |
video.generate | POST /v1/video/generate | Generate a video from a text or image prompt asynchronously (idempotent). |
video.get | GET /v1/video/get/{id} | Retrieve a video job's full details (status, video URL, duration, resolution, provider, model). |
video.list | GET /v1/video/list | List the current account's video generation jobs with pagination. |
video.set_retention | POST /v1/video/set_retention/{id} | Set a video job's retention window in days, up to a 90-day maximum. |
video.status | GET /v1/video/status/{id} | Query a video generation job's status and output URL. |
完整示例
本模块的生产级端到端范例:先一次性配置,再运行业务流程,尽量覆盖本模块的多数 API。
一次性前置(每个范例都假定已完成):
bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."bash
# 1) Auth: every call is a raw HTTPS request to the Infrai gateway carrying
# only your project key. No SDK, no install.
# Get your key: sign in with Google/GitHub at the console for a project key
# + $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..." # from the console
# 2) video.generate
curl -X POST https://api.infrai.cc/v1/video/generate \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt": "a timelapse of a city skyline at dusk", "prefer": "balanced", "resolution": "1080p", "duration_seconds": 5, "aspect_ratio": "16:9"}'
# 3) video.status
curl -X GET https://api.infrai.cc/v1/video/status/ID \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 4) video.cancel
curl -X POST https://api.infrai.cc/v1/video/cancel/ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"job_id": "..."}'
# 5) video.get
curl -X GET https://api.infrai.cc/v1/video/get/ID \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 6) video.list
curl -X GET https://api.infrai.cc/v1/video/list \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 7) video.delete
curl -X DELETE https://api.infrai.cc/v1/video/delete/ID \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 8) video.delete_all
curl -X POST https://api.infrai.cc/v1/video/delete_all \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
# 9) video.download_url
curl -X GET https://api.infrai.cc/v1/video/download_url/ID \
-H "Authorization: Bearer $INFRAI_API_KEY"