Api.Airforce
API REFERENCE

视频

使用异步任务模型生成视频剪辑 - 提交提示、轮询状态、获取结果。

视频生成是异步的:提交一个 prompt,获得一个 task id,轮询其 status,然后获取生成完成的片段。text-to-video、image-to-video 和参考模式都共用同一个请求结构。

你可以请求的时长、分辨率和 aspect ratio 取决于所选的模型 —— 请从 models endpoint 读回这些信息,而不要假设它们是固定的一组取值。

视频生成在后台运行 - 没有流渲染。流程始终是:创建任务 → 轮询状态 → 下载 MP4。任务将在 24 小时后过期。

1. 创建任务

提交任务并返回 task ID。费用根据 时长 × 模型每秒价格 估算,并在任务处理时结算。

POSThttps://api.airforce/v1/video/generations

视频模型

· live
ParameterTypeRequiredDescription
modelstringRequiredVideo model ID. Use /v1/models and filter by output_modalities.includes("video").
promptstringRequiredScene description.
modestringOptional"text" (default), "image" (animate a first-frame image), "reference" (style transfer from one or more frames).
duration_secondsintegerOptionalClip length. Range depends on the model — typically 5, 8 or 10 s. Defaults to the model's minimum.
aspect_ratiostringOptional"16:9", "9:16", "1:1", "4:3" — must be in the model's supported list.
qualitystringOptional"480p", "720p", "1080p" — must be in the model's supported list.
input_imagesarrayOptional[{ url? } | { b64_json? }] — required for "image" and "reference" modes.

任何其他键(例如 seedsound)都会原样转发给上游提供方——它们不会在此处校验,是否支持取决于具体模型。

示例

文字转视频

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"}]
  }'

回复

ParameterTypeRequiredDescription
task_idstringOptionalPersistent task identifier. Use it on every follow-up endpoint.
statusstringOptional"queued" right after creation.
modelstringOptionalEcho of requested model.
createdintegerOptionalUnix timestamp.
expires_atintegerOptionalUnix timestamp after which the result is purged (exactly created + 86400).
progressintegerOptional0 right after creation.
cost_centsnumberOptionalEstimated 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。

GEThttps://api.airforce/v1/video/tasks/:task_id
ParameterTypeRequiredDescription
statusstringOptional"queued" | "processing" | "completed" | "failed" | "expired".
progressintegerOptional0–100 while processing.
result_urlstringOptionalMP4 download URL once status is "completed", set by the upstream provider. Valid until expires_at.
errorstringOptionalFailure message. Set (non-null) when status is "failed".
cost_centsnumberOptionalCost 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 端点相同的有效负载形状。

GEThttps://api.airforce/v1/video/tasks/:task_id/stream
event: 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. 列出并删除

GEThttps://api.airforce/v1/video/tasks

返回您最近的任务(最新的在前)。对于仪表板呈现历史视图很有用。

返回你最近的至多 100 个 task,最新的在前,格式为 { "data": [ ...tasks ] }。没有查询参数——请在客户端进行筛选和分页。

curl https://api.airforce/v1/video/tasks \
  -H "Authorization: Bearer sk-air-YOUR_API_KEY"
DELETEhttps://api.airforce/v1/video/tasks/:task_id

从你的历史记录中移除该任务记录。

幂等操作——始终返回 { "deleted": true }。此操作仅删除你的历史记录;它不会单独清除已存储的媒体。


成本和限制

每个视频模型都会公开您可以读取的功能元数据 /v1/models:

ParameterTypeRequiredDescription
video_caps.aspect_ratiosarrayOptionalAllowed aspect_ratio values.
video_caps.qualitiesarrayOptionalAllowed quality values.
video_caps.min_duration_s / max_duration_sintegerOptionalAllowed range for duration_seconds.
video_caps.modesarrayOptionalSubset of ["text", "image", "reference"] supported.
video_caps.price_per_second_centsintegerOptionalCost = 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);
    }
  }
}