The Sora 2 Async API uses a standard asynchronous processing mechanism, ideal for scenarios requiring fine-grained control over the video generation workflow. Unlike the synchronous streaming API, the async API separates video generation into three independent steps, allowing more flexible task management and download timing.
The Async API is particularly suitable for batch processing, background tasks, and scenarios requiring long wait times. If you need real-time progress feedback, we recommend using the Synchronous Streaming API.
curl -X POST "https://api.apiyi.com/v1/videos" \ -H "Authorization: YOUR_API_KEY" \ -H "Accept: application/json" \ -F "prompt=A cute golden retriever chasing a frisbee on a park lawn, sunny day, background with green trees and blue sky" \ -F "model=sora-2" \ -F "size=1280x720" \ -F "seconds=10"
import requestsBASE_URL = "https://api.apiyi.com/v1/videos"API_KEY = "YOUR_API_KEY"# Submit text-to-video requestfiles = { 'prompt': (None, 'A cute golden retriever chasing a frisbee on a park lawn, sunny day, background with green trees and blue sky'), 'model': (None, 'sora-2'), 'size': (None, '1280x720'), 'seconds': (None, '10')}headers = { 'Accept': 'application/json', 'Authorization': API_KEY}response = requests.post(BASE_URL, headers=headers, files=files)result = response.json()video_id = result['id']print(f"Video ID: {video_id}")print(f"Status: {result['status']}")
const axios = require('axios');const FormData = require('form-data');const BASE_URL = 'https://api.apiyi.com/v1/videos';const API_KEY = 'YOUR_API_KEY';async function submitRequest() { const formData = new FormData(); formData.append('prompt', 'A cute golden retriever chasing a frisbee on a park lawn, sunny day, background with green trees and blue sky'); formData.append('model', 'sora-2'); formData.append('size', '1280x720'); formData.append('seconds', '10'); const response = await axios.post(BASE_URL, formData, { headers: { ...formData.getHeaders(), 'Authorization': API_KEY } }); const videoId = response.data.id; console.log(`Video ID: ${videoId}`); console.log(`Status: ${response.data.status}`); return videoId;}submitRequest();
Upload a reference image to generate video based on the image.
curl -X POST "https://api.apiyi.com/v1/videos" \ -H "Authorization: YOUR_API_KEY" \ -H "Accept: application/json" \ -F "prompt=Animate the animals in the reference image, making them chase around the field" \ -F "model=sora-2" \ -F "size=1280x720" \ -F "seconds=10" \ -F "input_reference=@/path/to/image.png"
import requestsBASE_URL = "https://api.apiyi.com/v1/videos"API_KEY = "YOUR_API_KEY"# Submit image-to-video requestwith open('/path/to/image.png', 'rb') as f: files = { 'prompt': (None, 'Animate the animals in the reference image, making them chase around the field'), 'model': (None, 'sora-2'), 'size': (None, '1280x720'), 'seconds': (None, '10'), 'input_reference': ('image.png', f, 'image/png') } headers = { 'Accept': 'application/json', 'Authorization': API_KEY } response = requests.post(BASE_URL, headers=headers, files=files) result = response.json() video_id = result['id'] print(f"Video ID: {video_id}")
{ "id": "video_abc123def456", "status": "submitted", "progress": 0, "prompt": "A cute golden retriever chasing a frisbee on a park lawn, sunny day, background with green trees and blue sky", "model": "sora-2", "size": "1280x720", "seconds": "10", "created_at": 1704067200, "url": null, "completed_at": null}
{ "id": "video_abc123def456", "status": "in_progress", "progress": 45, "prompt": "A cute golden retriever chasing a frisbee on a park lawn, sunny day, background with green trees and blue sky", "model": "sora-2", "size": "1280x720", "seconds": "10", "created_at": 1704067200, "url": null, "completed_at": null}
{ "id": "video_abc123def456", "status": "completed", "progress": 100, "prompt": "A cute golden retriever chasing a frisbee on a park lawn, sunny day, background with green trees and blue sky", "model": "sora-2", "size": "1280x720", "seconds": "10", "created_at": 1704067200, "url": "https://api.apiyi.com/v1/videos/video_abc123def456/content", "completed_at": 1704067500}
A good prompt should include: scene description, subject action, camera style, artistic style.
Good Example:
A cute golden retriever chasing a red frisbee on green grass, sunny day,background with blue sky, white clouds and green trees, smooth motion,close-up camera following the dog's action, cinematic quality, warm tones
Can I submit multiple video generation tasks simultaneously?
Yes, up to 5 concurrent tasks are supported. You can submit multiple requests simultaneously and poll their status separately. Be careful not to exceed the request rate limit (10 requests/minute).
How long are video files stored?
It’s recommended to download videos immediately after generation to avoid file expiration. Contact technical support for specific storage duration.
How to handle generation failures?
Check the error message in the response. Common causes:
Content policy violation (modify prompt or change image)
Insufficient quota (recharge or upgrade plan)
Invalid parameters (check parameter format and values)