https://api2.laozhang.ai/v1/videosCall Method: Three steps (Create Task → Query Status → Get Video)Advantages: More Stable | Task Queue | Long-running Tasks SupportWhy Choose Async API?
Higher Stability
No Charge on Failure ⭐
- ✓ Content violation → No charge
- ✓ Queue timeout → No charge
- ✓ Generation failure → No charge
Flexible Polling
Parameterized Control
Sync vs Async Comparison
Quick Start
Async calling consists of three steps:Create Video Task
Query Task Status
Download Video
Complete Example
API Endpoints
1. Create Video Task
https://api2.laozhang.ai/v1/videosCreate a new video generation taskRequest Parameters
sora-2: Base model, 720P resolution, extremely high stability, $0.15/callsora-2-pro: HD model, 1080P resolution, generation time ~10 minutes, $0.8/call
Response Fields
2. Query Task Status
https://api2.laozhang.ai/v1/videos/{video_id}Query current status and progress of video generation taskPath Parameters
Response Fields
Task Status
3. Get Video Content
https://api2.laozhang.ai/v1/videos/{video_id}/contentDownload completed video filePath Parameters
Response
Returns binary stream of video file (MP4 format)Complete Code Examples
Python Example (with Polling Logic)
JavaScript/Node.js Example
Best Practices
Polling Interval
Polling Interval
- Video generation typically takes 2-5 minutes
- 3-5 seconds provides timely progress feedback
- Avoids excessive requests
Timeout Handling
Timeout Handling
- Task timeout doesn’t auto-cancel
- Can continue querying same video_id later
- Task validity period is 24 hours
Retry Strategy
Retry Strategy
- ✓ Network errors → Retry
- ✓ Service busy (503) → Retry
- ✗ Content violation → Don’t retry, modify prompt
- ✗ Insufficient balance → Don’t retry, confirm account credit first
Batch Generation
Batch Generation
- Creating tasks: High concurrency OK (10-30)
- Querying status: Recommended concurrency ≤ 10
- Downloading videos: Recommended concurrency ≤ 5
Pricing
- ✓ Charges are based on console order status and the returned generation result
- ✗ Failed, timeout, and cancelled tasks should be checked in console order status
- ✗ Content safety issues should be checked in console order status (important difference from Sync API⭐)
- ✗ Status query billing follows console records
FAQ
How long is task validity?
How long is task validity?
- After creating task,
expires_atfield shows expiration time - Can query task status anytime within 24 hours
- After video generation completes, file is stored for 24 hours
- After 24 hours, task and video will be automatically cleaned
- Download video immediately after completion
- Don’t rely on server for long-term storage
How to cancel a running task?
How to cancel a running task?
- Once created, task will auto-queue for execution
- If no longer needed, simply ignore it
- Incomplete tasks won’t be charged
- Wait for task to naturally complete or fail
- Task auto-expires after 24 hours
Why do I get 404 when querying?
Why do I get 404 when querying?
- Incorrect video_id - Check if fully copied
- Task expired - Over 24 hours
- Network issues - Retry request
Can async and sync APIs be mixed?
Can async and sync APIs be mixed?
- Different endpoints
- Different calling methods
- Same pricing
- Share same API Key and balance
- Quick testing → Use sync API
- Production environment → Use async API (more stable)
- Batch generation → Use async API
Why isn't progress field updating?
Why isn't progress field updating?
- Normal - Some processing stages update slowly
- Queue waiting - May be queued during peak hours
- Task stuck - Rare cases where task may get stuck
- Continue waiting 5-10 minutes
- If no change after 10 minutes, contact support
- Provide video_id for troubleshooting
Does image-to-video support image URLs?
Does image-to-video support image URLs?
- ✗ Image URLs
- ✗ Base64 encoding
- ✗ Online image links
multipart/form-data format, supporting only local file streams.What image formats are supported?
What image formats are supported?
- ✓ JPG / JPEG
- ✓ PNG
- ✓ WebP
- File size: < 5MB (recommended)
- Resolution: Recommended 1280x720 or similar ratio
- Source: Must be local file
Is prompt required for image-to-video?
Is prompt required for image-to-video?
Is image-to-video more expensive?
Is image-to-video more expensive?
- Image-to-video and text-to-video cost the same
- Only charged when successfully generated
- No charge on failure (including format errors, content violations, etc.)
Does image affect generation time?
Does image affect generation time?
- Typical time: 2-5 minutes
- Factors: Video length, queue size, complexity
- Recommended < 5MB: Fast upload, fast processing
- Large images: Only affects upload time (seconds), no significant impact on generation time
Error Handling
Common Error Codes
Error Response Format
Technical Support
Need Help?
- Email: hi@laozhang.ai
- Telegram: https://t.me/laozhang_cn
- Documentation: https://docs.laozhang.ai