वीडियो
एसिंक कार्य मॉडल के साथ वीडियो क्लिप बनाएं - एक संकेत सबमिट करें, स्थिति के लिए मतदान करें, परिणाम प्राप्त करें।
Video generation asynchronous है: एक prompt submit करें, एक task id पाएँ, उसके status के लिए poll करें, फिर तैयार clip को fetch करें। Text-to-video, image-to-video और reference modes सभी एक ही request shape साझा करते हैं।
आप जिन durations, resolutions और aspect ratios का अनुरोध कर सकते हैं वे चुने गए मॉडल पर निर्भर करते हैं — एक तय सेट मान लेने के बजाय इन्हें models endpoint से पढ़ें।
वीडियो जनरेशन पृष्ठभूमि में चलता है - कोई स्ट्रीमिंग रेंडर नहीं है। प्रवाह हमेशा होता है: कार्य बनाएं → मतदान स्थिति → MP4 डाउनलोड करें। कार्य 24 घंटे के बाद समाप्त हो जाते हैं.
1. एक कार्य बनाएँ
जॉब सबमिट करता है और एक task ID लौटाता है। लागत अवधि × मॉडल की प्रति-सेकंड कीमत से अनुमानित होती है और जॉब प्रोसेस होने पर वसूली जाती है।
https://api.airforce/v1/video/generationsवीडियो मॉडल
…· 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, sound) अपस्ट्रीम प्रोवाइडर को जैसी हैं वैसी ही फ़ॉरवर्ड कर दी जाती हैं — इन्हें यहाँ वैलिडेट नहीं किया जाता और समर्थन मॉडल पर निर्भर करता है।
उदाहरण
टेक्स्ट-टू-वीडियो
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"}]
}'प्रतिक्रिया
| 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 (exactly created + 86400). |
| progress | integer | Optional | 0 right after creation. |
| cost_cents | number | Optional | Estimated 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 लौटाता है।
https://api.airforce/v1/video/tasks/:task_id| Parameter | Type | Required | Description |
|---|---|---|---|
| status | string | Optional | "queued" | "processing" | "completed" | "failed" | "expired". |
| progress | integer | Optional | 0–100 while processing. |
| result_url | string | Optional | MP4 download URL once status is "completed", set by the upstream provider. Valid until expires_at. |
| error | string | Optional | Failure message. Set (non-null) when status is "failed". |
| cost_cents | number | Optional | Cost 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
}2बी. स्ट्रीम प्रगति (वैकल्पिक)
सर्वर-भेजे गए इवेंट स्ट्रीम के साथ पोलिंग लूप को छोड़ें। प्रति प्रगति परिवर्तन एक ईवेंट उत्सर्जित करता है और कार्य के अंतिम स्थिति में आने पर बंद हो जाता है। GET समापन बिंदु के समान पेलोड आकार।
https://api.airforce/v1/video/tasks/:task_id/streamevent: 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. सूची बनाएं और हटाएं
https://api.airforce/v1/video/tasksआपके हाल के कार्य लौटाता है (नवीनतम पहले)। इतिहास दृश्य प्रस्तुत करने के लिए डैशबोर्ड के लिए उपयोगी।
आपके 100 सबसे हालिया tasks तक लौटाता है, सबसे नए पहले, { "data": [ ...tasks ] } के रूप में। कोई क्वेरी पैरामीटर नहीं हैं — फ़िल्टर और पेजिनेट क्लाइंट-साइड करें।
curl https://api.airforce/v1/video/tasks \
-H "Authorization: Bearer sk-air-YOUR_API_KEY"https://api.airforce/v1/video/tasks/:task_idटास्क रिकॉर्ड को आपके इतिहास से हटा देता है।
Idempotent — हमेशा { "deleted": true } लौटाता है। यह केवल आपके इतिहास रिकॉर्ड को हटाता है; यह संग्रहीत मीडिया को अलग से शुद्ध नहीं करता।
लागत और बाधाएँ
प्रत्येक वीडियो मॉडल क्षमता मेटाडेटा को उजागर करता है जिसे आप पढ़ सकते हैं /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 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);
}
}
}