Video
Genereer videoclips met een asynchroon taakmodel: dien een prompt in, peil de status en haal het resultaat op.
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
Verzendt de taak en retourneert een taak-ID. De kosten worden vooraf gedebiteerd op basis van de duur x de prijs per seconde voor het gekozen model.
https://api.airforce/v1/video/generationsVideomodellen
…· 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 | integer | Optional | Reproducibility seed where supported. |
| sound | boolean | Optional | Enable native audio track on models that produce sound (e.g. wan). |
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
| 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 (typically created + 86400). |
| cost_cents | number | Optional | Up-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. 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'.
https://api.airforce/v1/video/tasks/:task_id| Parameter | Type | Required | Description |
|---|---|---|---|
| status | string | Optional | "queued" | "running" | "completed" | "failed" | "expired". |
| progress | integer | Optional | 0–100 while running. Absent for queued tasks. |
| result_url | string | Optional | MP4 download URL once status is "completed". Pre-signed; valid until expires_at. |
| thumbnail_url | string | Optional | Optional poster frame. |
| error | object | Optional | Set when status is "failed". { type, message }. |
| cost_cents | number | Optional | Final 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
}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.
https://api.airforce/v1/video/tasks/:task_id/streamevent: 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. Lijst en verwijder
https://api.airforce/v1/video/tasksRetourneert uw recente taken (nieuwste eerst). Handig voor het dashboard om een historieweergave weer te geven.
| Parameter | Type | Required | Description |
|---|---|---|---|
| limit | integer | Optional | Max items returned. Default 50, max 200. Pass as a query string. |
| status | string | Optional | Filter 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"https://api.airforce/v1/video/tasks/:task_idVerwijdert de taak uit uw geschiedenis. De MP4 wordt ook verwijderd uit de CDN-opslag. Geen restitutie: de kosten zijn al afgeschreven.
Kosten en beperkingen
Elk videomodel bevat metagegevens over mogelijkheden waaruit u kunt lezen /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 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.
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?.message ?? task.status);
}
}
}