API REFERENCE
影片
使用非同步任務模型產生影片剪輯 - 提交提示、輪詢狀態、取得結果。
影片生成是非同步的:送出 prompt、收到 task id、輪詢其 status,再取得完成的片段。text-to-video、image-to-video 與參考模式都共用同一種 request 結構。
你可請求的時長、解析度與 aspect ratio 取決於所選的模型 — 請從 models endpoint 讀回它們,而非假設有一組固定值。
視訊生成在背景運行 - 沒有流渲染。流程始終是:建立任務 → 輪詢狀態 → 下載 MP4。任務將在 24 小時後過期。
1. 創建任務
提交任務並回傳 task ID。費用依 時長 × 模型每秒價格 估算,並在任務處理時結算。
POST
https://api.airforce/v1/video/generations視訊模型
…· live| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Required | Video model ID. Use /v1/models and filter by output_modalities.includes("video"). |
| prompt | string | Required | Scene description. |
| mode | string | Optional | "text" (default), "image" (animate a first-frame image), "reference" (style transfer from one or more frames). |
| duration_seconds | integer | Optional | Clip length. Range depends on the model — typically 5, 8 or 10 s. Defaults to the model's minimum. |
| aspect_ratio | string | Optional | "16:9", "9:16", "1:1", "4:3" — must be in the model's supported list. |
| quality | string | Optional | "480p", "720p", "1080p" — must be in the model's supported list. |
| input_images | array | Optional | [{ url? } | { b64_json? }] — required for "image" and "reference" modes. |
任何其他鍵(例如 seed、sound)都會原封不動地轉發給上游供應商——它們在此處不會經過驗證,且支援與否取決於模型。
範例
文字轉視頻
curl https://api.airforce/v1/video/generations \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "wan-2.6",
"prompt": "A red fox darting across snowy hills at dawn",
"duration_seconds": 8,
"aspect_ratio": "16:9",
"quality": "720p",
"sound": true
}'影像到影片(第一幀)
curl https://api.airforce/v1/video/generations \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-1",
"mode": "image",
"prompt": "Camera pulls back as the dragon takes off",
"duration_seconds": 5,
"aspect_ratio": "16:9",
"input_images": [{"url": "https://example.com/dragon.jpg"}]
}'回覆
| Parameter | Type | Required | Description |
|---|---|---|---|
| task_id | string | Optional | Persistent task identifier. Use it on every follow-up endpoint. |
| status | string | Optional | "queued" right after creation. |
| model | string | Optional | Echo of requested model. |
| created | integer | Optional | Unix timestamp. |
| expires_at | integer | Optional | Unix timestamp after which the result is purged (exactly created + 86400). |
| progress | integer | Optional | 0 right after creation. |
| cost_cents | number | Optional | Estimated cost for the job. Final billing is settled when the job is processed. |
{
"task_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"status": "queued",
"model": "wan-2.6",
"created": 1715000000,
"expires_at": 1715086400,
"progress": 0,
"cost_cents": 320
}2. 輪詢狀態
每 5-15 秒輪詢一次。任務通常在 30 秒至 4 分鐘內完成,具體取決於持續時間和模型。當狀態翻轉為「已完成」時,同一端點會傳回結果 URL。
GET
https://api.airforce/v1/video/tasks/:task_id| Parameter | Type | Required | Description |
|---|---|---|---|
| status | string | Optional | "queued" | "processing" | "completed" | "failed" | "expired". |
| progress | integer | Optional | 0–100 while processing. |
| result_url | string | Optional | MP4 download URL once status is "completed", set by the upstream provider. Valid until expires_at. |
| error | string | Optional | Failure message. Set (non-null) when status is "failed". |
| cost_cents | number | Optional | Cost for the job, settled when it is processed. |
{
"task_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"status": "completed",
"progress": 100,
"result_url": "https://.../video.mp4",
"model": "wan-2.6",
"duration_seconds": 8,
"expires_at": 1715086400,
"cost_cents": 320
}2b.串流進度(可選)
使用伺服器傳送事件流跳過輪詢循環。每次進度變更都會發出事件,並在任務處於最終狀態時關閉。與 GET 端點相同的有效負載形狀。
GET
https://api.airforce/v1/video/tasks/:task_id/streamevent: state
data: {"task_id":"f47ac10b-...","status":"processing","progress":12}
event: state
data: {"task_id":"f47ac10b-...","status":"processing","progress":58}
event: state
data: {"task_id":"f47ac10b-...","status":"completed","progress":100,"result_url":"https://.../video.mp4"}
event: done
data: [DONE]3. 列出並刪除
GET
https://api.airforce/v1/video/tasks返回您最近的任務(最新的在前)。對於儀表板呈現歷史視圖很有用。
回傳您最近的最多 100 個 task,最新的在前,格式為 { "data": [ ...tasks ] }。沒有查詢參數——請在用戶端進行篩選與分頁。
curl https://api.airforce/v1/video/tasks \
-H "Authorization: Bearer sk-air-YOUR_API_KEY"DELETE
https://api.airforce/v1/video/tasks/:task_id從你的歷史記錄中移除該任務記錄。
具冪等性——一律回傳 { "deleted": true }。這只會刪除您的歷史記錄;並不會另外清除已儲存的媒體。
成本和限制
每個視訊模型都會公開您可以讀取的功能元數據 /v1/models:
| Parameter | Type | Required | Description |
|---|---|---|---|
| video_caps.aspect_ratios | array | Optional | Allowed aspect_ratio values. |
| video_caps.qualities | array | Optional | Allowed quality values. |
| video_caps.min_duration_s / max_duration_s | integer | Optional | Allowed range for duration_seconds. |
| video_caps.modes | array | Optional | Subset of ["text", "image", "reference"] supported. |
| video_caps.price_per_second_cents | integer | Optional | Cost = duration_seconds × this value. |
- Cost is estimated at creation and settled when the job is processed; failed or expired tasks are not charged.
- Max 4 concurrent video tasks per API key.
- Result URLs are pre-signed and stop working at
expires_at. Download or copy the MP4 to your own storage if you need it longer.
端對端腳本
async function generateVideo(prompt) {
const create = await fetch('https://api.airforce/v1/video/generations', {
method: 'POST',
headers: {
Authorization: `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'wan-2.6',
prompt,
duration_seconds: 8,
aspect_ratio: '16:9',
quality: '720p',
}),
}).then(r => r.json());
const { task_id } = create;
// Poll until done.
while (true) {
await new Promise(r => setTimeout(r, 8_000));
const task = await fetch(
`https://api.airforce/v1/video/tasks/${task_id}`,
{ headers: { Authorization: `Bearer ${API_KEY}` } },
).then(r => r.json());
if (task.status === 'completed') return task.result_url;
if (task.status === 'failed' || task.status === 'expired') {
throw new Error(task.error ?? task.status);
}
}
}