Video generation
Submit text-to-video or image-to-video jobs, poll their status, and download the final file.
Prepare the model and inputs
Filter the Models and pricing page by Video. Confirm whether the model supports text-to-video, image-to-video, duration, and size. Image-to-video models usually need a publicly reachable image URL or a file upload supported by that model.
Video jobs are asynchronous A successful create response means the job was accepted. Keep polling until it completes or fails.
Create a video job
The video API uses a job-based flow. Include at least model and prompt; use image_url, seconds, and size only when the model lists support for them.
curl https://api.moloop.io/v1/videos \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "YOUR_VIDEO_MODEL_ID",
"prompt": "A slow camera move across a quiet mountain lake at dawn",
"seconds": "5",
"size": "1280x720"
}'For image-to-video, put the image in the image_url or file field required by the model. Do not place large files in JSON as Base64 unless the model documentation explicitly requires it.
Poll and download
Save the job ID from the create response and poll at the interval returned by the service. Common states include queued, in_progress, completed, and failed; use the actual response as the authority.
curl "https://api.moloop.io/v1/videos/YOUR_VIDEO_ID" \
-H "Authorization: Bearer YOUR_API_KEY"
# 完成后下载视频文件
curl "https://api.moloop.io/v1/videos/YOUR_VIDEO_ID/content" \
-H "Authorization: Bearer YOUR_API_KEY" \
--output generated-video.mp4Request content only after completed; do not download while the job is still running.
After downloading, verify the HTTP status, Content-Type, and file size before storing the object.
For failed jobs, retain the error and job ID, then create a new job after correcting the inputs.
Duration, size, and billing
| Item | Guidance |
|---|---|
| Duration | Test prompts with short clips first; longer clips usually cost more. |
| Size | Use sizes supported by the model instead of guessing from the player ratio. |
| Concurrency | Set a per-account job limit and back off on 429 responses. |
| Billing | Video is commonly charged by duration, size, or job. The model catalog and logs are authoritative. |
Troubleshooting
400: check that the model supports the video endpoint and that seconds, size, and image format are valid.
404: confirm you are using the job ID returned by create and did not duplicate the path.
A job stays queued: lower concurrency, retain the job ID, and inspect upstream status in request logs.
Download fails: wait for completed and retry content, and make sure the client does not parse the binary response as JSON.