Documentation Index
Fetch the complete documentation index at: https://docs.toapis.com/llms.txt
Use this file to discover all available pages before exploring further.
- Query async video generation task execution status and results
- Real-time status updates and progress tracking
- Get generated videos when task completes
- Multi-language support (zh/en/ko/ja)
All video generation tasks are executed asynchronously. After submitting a task, you need to query the status and results via the query endpoint.
Authorizations
All endpoints require Bearer Token authenticationGet your API Key:Visit the API Key Management Page to get your API KeyAdd it to the request header:Authorization: Bearer YOUR_API_KEY
Path Parameters
Task ID returned by the video generation API
curl --request GET \
--url 'https://toapis.com/v1/videos/generations/task_01K9S419324DREZFBWNSVXYR6H' \
--header 'Authorization: Bearer <token>'
{
"id": "video_7497f4d5-3a88-44c7-923a-967fa7d941a0",
"object": "generation.task",
"model": "sora-2",
"status": "queued",
"progress": 0,
"created_at": 1768380222
}
Response
Object type, always generation.task
Task status
queued - Queued for processing
in_progress - Processing
completed - Successfully completed
failed - Failed
Task progress percentage (0-100)
Video generation model used
Task creation time (Unix timestamp)
Task completion time (Unix timestamp, only returned when completed)
Video URL expiration time (Unix timestamp, only returned on completion)
Task result (only returned on success)
Result type, always video
Error information (only returned on failure)
Task Status Reference
| Status | Description | Is Final | Recommended Action |
|---|
submitted | Task submitted, waiting in queue | ❌ | Wait 5-10 seconds, then query again |
in_progress | Task is processing | ❌ | Wait 10-15 seconds, then query again |
completed | Task completed successfully | ✅ | Get video from url field |
failed | Task processing failed | ✅ | Check error info |
Polling Strategy
Initial wait: 5 seconds
Polling interval: 10 seconds
Max wait: 600 seconds (10 minutes)
Typical time: 1-5 minutes
Python Polling Example
import time
import requests
def poll_video_task(task_id, api_key, max_wait=600):
"""Poll video generation task until completion or timeout"""
start_time = time.time()
interval = 10 # 10 second interval
# Initial 5 second wait
time.sleep(5)
while time.time() - start_time < max_wait:
response = requests.get(
f'https://toapis.com/v1/videos/generations/{task_id}',
headers={'Authorization': f'Bearer {api_key}'}
)
data = response.json()
print(f"Status: {data['status']}, Progress: {data.get('progress', 0)}%")
if data['status'] == 'completed':
return {
'url': data['url'],
'thumbnail': data.get('thumbnail'),
'duration': data.get('duration')
}
elif data['status'] == 'failed':
raise Exception(f"Generation failed: {data['error']['message']}")
time.sleep(interval)
raise TimeoutError("Task timeout")
Resource Expiration
Generated video URLs are valid for 24 hours
- Please download and save videos within the validity period
expires_at field indicates video expiration time (Unix timestamp)
- Expired videos cannot be accessed; to regenerate, submit a new task
- Thumbnails expire simultaneously with videos
Error Codes
| HTTP Code | Error Type | Description |
|---|
| 400 | invalid_request | Invalid request parameters |
| 401 | unauthorized | Authentication failed, check API Key |
| 402 | insufficient_quota | Insufficient balance |
| 404 | task_not_found | Task not found |
| 422 | content_policy_violation | Content policy violation |
| 429 | rate_limit_exceeded | Rate limit exceeded |
| 500 | internal_error | Internal server error |
Video generation takes longer, recommendations:
- Use Webhook Callbacks: If supported, configure callback URL to avoid frequent polling
- Set Reasonable Polling Interval: Recommended 10 seconds, too frequent wastes request quota
- Set Timeout: Long videos may take 5-10 minutes, set reasonable timeout
- Download Promptly: Videos expire after 24 hours, save to your storage immediately