Api.Airforce
API REFERENCE

Băng hình

Tạo các video clip với mô hình tác vụ không đồng bộ — gửi lời nhắc, thăm dò trạng thái, tìm nạp kết quả.

Tạo video là bất đồng bộ: gửi một prompt, nhận một task id, poll trạng thái của nó, rồi lấy clip đã hoàn thành. Các chế độ text-to-video, image-to-video và tham chiếu đều dùng chung một cấu trúc request.

Thời lượng, độ phân giải và aspect ratio mà bạn có thể yêu cầu phụ thuộc vào model đã chọn — hãy đọc chúng từ endpoint models thay vì giả định một tập cố định.

Quá trình tạo video chạy ở chế độ nền - không có kết xuất phát trực tuyến. Quy trình luôn là: tạo tác vụ → trạng thái thăm dò → tải xuống MP4. Nhiệm vụ hết hạn sau 24 giờ.

1. Tạo nhiệm vụ

Gửi tác vụ và trả về một task ID. Chi phí được ước tính từ thời lượng × giá mỗi giây của mô hình và được quyết toán khi tác vụ được xử lý.

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

Mô hình video

· 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.

Bất kỳ key nào khác (ví dụ seed, sound) đều được chuyển tiếp nguyên trạng đến nhà cung cấp thượng nguồn — chúng không được xác thực ở đây và mức độ hỗ trợ tùy thuộc vào model.

Ví dụ

Chuyển văn bản thành video

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

Chuyển hình ảnh thành video (khung hình đầu tiên)

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

Phản ứng

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. Thăm dò trạng thái

Thăm dò ý kiến ​​cứ sau 5–15 giây. Nhiệm vụ thường hoàn thành trong 30 giây - 4 phút tùy thuộc vào thời lượng và kiểu máy. Điểm cuối tương tự trả về URL kết quả khi trạng thái chuyển sang "hoàn thành".

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. Tiến trình truyền phát (tùy chọn)

Bỏ qua vòng bỏ phiếu với luồng Sự kiện do máy chủ gửi. Phát ra một sự kiện cho mỗi thay đổi tiến trình và đóng khi tác vụ ở trạng thái cuối. Hình dạng tải trọng giống như điểm cuối 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. Liệt kê và xóa

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

Trả về các tác vụ gần đây của bạn (mới nhất trước). Hữu ích cho bảng điều khiển để hiển thị chế độ xem lịch sử.

Trả về tối đa 100 task gần nhất của bạn, mới nhất trước, dưới dạng { "data": [ ...tasks ] }. Không có tham số truy vấn — hãy lọc và phân trang ở phía client.

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

Xóa bản ghi tác vụ khỏi lịch sử của bạn.

Idempotent — luôn trả về { "deleted": true }. Thao tác này chỉ xóa bản ghi lịch sử của bạn; nó không xóa riêng phần media đã được lưu trữ.


Chi phí & hạn chế

Mỗi mô hình video hiển thị siêu dữ liệu về khả năng mà bạn có thể đọc từ đó /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.

Kịch bản đầu cuối

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);
    }
  }
}