Video generation task
Create an asynchronous task, save the task ID, poll and get the results.
Asynchronous process
Video generation usually includes three stages: creation, query and download. Just because the creation request is successful does not mean that the video has been generated. Confirm the model, duration, resolution, reference materials and price before submitting.
Create task
Model usage that supports the OpenAI video protocol on this site:
curl --fail-with-body https://dunduntoken.com/v1/videos \
-H "Authorization: Bearer $DUNDUN_API_KEY" -H "Content-Type: application/json" \
-d '{"model":"VIDEO_MODEL_ID","prompt":"固定镜头,清晨湖面的薄雾缓慢散开"}'
This is an example of a minimal structure, specific models may also require duration, dimensions, or footage fields. Some providers use native protocols and cannot just change the URL inheritance request body.
Query task
Task ID in persistence response, query GET /v1/videos/{id} using a valid API key for the same account. Queued, running, completed, and failed are distinguished by return status; progress percentage cannot be used instead of final status.
Download results
After the task is completed, the results are read according to the protocol, and the unified content endpoint is GET /v1/videos/{id}/content. Authentication download only sends the key to the trusted website address; if the response points to other storage domain names, the website Authorization will not be automatically forwarded.
Verify MIME type, file size and playability after saving the file. The URL may expire, please transfer it in time. See Task Reliability for polling, downloading, and retry recommendations.
Query command
Once created successfully, save the actual id to DUNDUN_VIDEO_ID from the response, do not use the example string for polling:
curl --fail-with-body "https://dunduntoken.com/v1/videos/$DUNDUN_VIDEO_ID" -H "Authorization: Bearer $DUNDUN_API_KEY"
The status of unified video objects is usually queued, in_progress, completed, failed. Unknown values should be logged and handled with caution, not done by default. Native interfaces have their own state names and packaging structures.
Download after completion
curl --fail-with-body -H "Authorization: Bearer $DUNDUN_API_KEY" "https://dunduntoken.com/v1/videos/$DUNDUN_VIDEO_ID/content" --output result.mp4
The sample does not automatically follow third-party redirects. If a redirect is received, check the Location domain name and return protocol; create a new request without the credentials of this site when downloading external results. Check the file to avoid mistaking the error response for an MP4.
Reference with pictures
The unified video portal supports JSON or multipart, but the specific model determines the supported material fields. Only if the selected model declares that it accepts input_reference, the corresponding file will be uploaded. Multiple images, first and last frames, sound and video references cannot be created using the same field.
Failure and Recovery
The task will not be re-created if the query times out. When the task fails, the error and ID are saved, and the material, parameters and records are checked before retrying. The query is restored from the saved ID after process restart. The generation task ID, supplier material ID and model name cannot be mixed.