Api.Airforce
API REFERENCE

فيديو

أنشئ مقاطع فيديو باستخدام نموذج مهمة غير متزامنة — أرسل مطالبة، واستطلاعًا للحالة، واحصل على النتيجة.

يتم تشغيل إنشاء الفيديو في الخلفية، ولا يوجد عرض متدفق. التدفق دائمًا هو: إنشاء مهمة ← حالة الاستطلاع ← تنزيل MP4. تنتهي المهام بعد 24 ساعة.

1. قم بإنشاء مهمة

يرسل المهمة ويعيد معرف المهمة. يتم خصم التكلفة مقدمًا بناءً على المدة × سعر الثانية للنموذج المختار.

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.
seedintegerOptionalReproducibility seed where supported.
soundbooleanOptionalEnable native audio track on models that produce sound (e.g. wan).

أمثلة

تحويل النص إلى فيديو

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 (typically created + 86400).
cost_centsnumberOptionalUp-front cost debited from your balance. Refunded if the task ultimately fails.
{
  "task_id": "vid_01HXY1234ABCD",
  "status": "queued",
  "model": "wan-2.6",
  "created": 1715000000,
  "expires_at": 1715086400,
  "cost_cents": 320
}

2. استطلاع للحالة

قم بالاستطلاع كل 5-15 ثانية. تكتمل المهام عادةً خلال 30 ثانية إلى 4 دقائق حسب المدة والنموذج. تقوم نقطة النهاية نفسها بإرجاع عنوان URL للنتيجة عندما تنقلب الحالة إلى "مكتمل".

GEThttps://api.airforce/v1/video/tasks/:task_id
ParameterTypeRequiredDescription
statusstringOptional"queued" | "running" | "completed" | "failed" | "expired".
progressintegerOptional0–100 while running. Absent for queued tasks.
result_urlstringOptionalMP4 download URL once status is "completed". Pre-signed; valid until expires_at.
thumbnail_urlstringOptionalOptional poster frame.
errorobjectOptionalSet when status is "failed". { type, message }.
cost_centsnumberOptionalFinal cost. Equals the create-time cost on success.
{
  "task_id": "vid_01HXY1234ABCD",
  "status": "completed",
  "progress": 100,
  "result_url": "https://cdn.api.airforce/video/vid_01HXY1234ABCD.mp4",
  "thumbnail_url": "https://cdn.api.airforce/video/vid_01HXY1234ABCD.jpg",
  "model": "wan-2.6",
  "duration_seconds": 8,
  "expires_at": 1715086400,
  "cost_cents": 320
}

2ب. تقدم البث (اختياري)

تخطي حلقة الاستقصاء باستخدام دفق الأحداث المرسلة من الخادم. يصدر حدثًا واحدًا لكل تغيير في التقدم ويتم إغلاقه بمجرد أن تصبح المهمة في حالة نهائية. نفس شكل الحمولة مثل نقطة نهاية GET.

GEThttps://api.airforce/v1/video/tasks/:task_id/stream
event: progress
data: {"task_id":"vid_01HXY...","status":"running","progress":12}

event: progress
data: {"task_id":"vid_01HXY...","status":"running","progress":58}

event: completed
data: {"task_id":"vid_01HXY...","status":"completed","progress":100,"result_url":"https://cdn.api.airforce/video/vid_01HXY....mp4"}

3. القائمة والحذف

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

إرجاع المهام الأخيرة (الأحدث أولاً). مفيد للوحة المعلومات لعرض عرض السجل.

ParameterTypeRequiredDescription
limitintegerOptionalMax items returned. Default 50, max 200. Pass as a query string.
statusstringOptionalFilter to one status, e.g. ?status=running.
curl "https://api.airforce/v1/video/tasks?limit=20&status=completed" \
  -H "Authorization: Bearer sk-air-YOUR_API_KEY"
DELETEhttps://api.airforce/v1/video/tasks/:task_id

إزالة المهمة من السجل الخاص بك. يتم حذف MP4 أيضًا من تخزين CDN. لا يوجد استرداد - تم خصم التكلفة بالفعل.


التكلفة والقيود

يعرض كل نموذج فيديو بيانات تعريف القدرة التي يمكنك القراءة منها /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 debited at task creation. Failed tasks (status "failed" or "expired") refund the cost.
  • 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?.message ?? task.status);
    }
  }
}