Api.Airforce
API REFERENCE

Video

Genereer videoclips met een asynchroon taakmodel: dien een prompt in, peil de status en haal het resultaat op.

Videogeneratie is asynchroon: dien een prompt in, ontvang een task id, poll op de status en haal vervolgens de voltooide clip op. Text-to-video, image-to-video en reference-modi delen allemaal één request-shape.

De duur, resoluties en aspect ratios die je kunt aanvragen hangen af van het gekozen model — lees ze terug uit het models-endpoint in plaats van uit te gaan van een vaste set.

Het genereren van video's wordt op de achtergrond uitgevoerd; er is geen streaming-weergave. De stroom is altijd: maak taak → pollstatus → download MP4. Taken vervallen na 24 uur.

1. Maak een taak

Verstuurt de taak en geeft een task ID terug. De kosten worden geschat op basis van duur × prijs per seconde van het model en afgerekend wanneer de taak wordt verwerkt.

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

Videomodellen

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

Alle andere keys (bijv. seed, sound) worden ongewijzigd doorgestuurd naar de upstream-provider — ze worden hier niet gevalideerd en de ondersteuning is modelafhankelijk.

Voorbeelden

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

Afbeelding-naar-video (eerste frame)

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

Antwoord

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. Poll op status

Poll elke 5-15 seconden. Taken worden doorgaans binnen 30 seconden tot 4 minuten voltooid, afhankelijk van de duur en het model. Hetzelfde eindpunt retourneert de resultaat-URL wanneer de status verandert in 'voltooid'.

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. Streamvoortgang (optioneel)

Sla de polling-lus over met een server-verzonden gebeurtenissenstream. Zendt één gebeurtenis uit per voortgangswijziging en sluit zodra de taak zich in een terminalstatus bevindt. Dezelfde payloadvorm als het GET-eindpunt.

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. Lijst en verwijder

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

Retourneert uw recente taken (nieuwste eerst). Handig voor het dashboard om een ​​historieweergave weer te geven.

Geeft tot je 100 meest recente tasks terug, nieuwste eerst, als { "data": [ ...tasks ] }. Er zijn geen query-parameters — filter en pagineer client-side.

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

Verwijdert het taakrecord uit je geschiedenis.

Idempotent — geeft altijd { "deleted": true } terug. Dit verwijdert alleen je history-record; het wist niet apart de opgeslagen media.


Kosten en beperkingen

Elk videomodel bevat metagegevens over mogelijkheden waaruit u kunt lezen /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.

End-to-end-script

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