1. Set up your Model API Key
Use a production DGrid Model API Key with access to the model and enough available balance to cover the estimated cost. Store the key on your server. The examples use Bash, cURL 7.76 or later, anduuidgen. Bash hides the key as you type it. The Model API authenticates with a Model API Key. Use a Management API Key for management operations.
/v1. Append paths such as /videos directly to it.
2. Prepare the request
Save the following JSON asrequest.json. This example requests a 5-second video at 720p with a 16:9 aspect ratio. Seedance 2.5 supports up to 30 seconds per generation, subject to supported input combinations. For other models, use the request format and parameters for that model.
3. Create the video task
Generate an idempotency key once for this task. Save it with the original request body.202 means DGrid accepted the task. Save the response id for polling. The estimated_amount field shows the estimated cost in USD.
If creation times out or returns a temporary 503 before you receive an ID, retry with the same API key, idempotency key, and request body. Once you have the ID, query the existing task. See Create video for the full request and retry rules.
4. Retrieve the video
Replace the placeholder with the returned task ID. Use the API key that created the task.- While the task is processing or settlement is pending, keep querying the same task.
- When
statusissucceededandsettlement_statusissettled, usevideo_urlto play or download the video andbilling.totalto read the final USD charge. - If
settlement_statusisawaiting_balance, top up the balance and query the same task again. - For
failed,cancelled, orexpired, stop polling and show the error. - For
submission_unknown,configuration_blocked, or an unrecognized status, save the task ID and contact DGrid support before submitting another task.
Retry-After when the API rate-limits a request. A local timeout ends polling. You can resume later with the same ID. See Retrieve video for all task states and response fields.
5. Add reference assets (optional)
You can skip this step for text-to-video. The following workflows apply to the BytePlus Seedance channel.Use an HTTPS URL
Upload a local image with the following command. To upload a video, change the file path to./reference.mp4.
201 returns a signed url valid for 24 hours. Keep its full query string. You can also use a server-accessible HTTPS URL. An external video must be a direct MP4 link that supports HTTP Range requests and allows the server to read the duration.
Keep the text prompt in content and add the applicable media items. Replace each URL placeholder and remove any unused item.
Use a reviewed asset ID
Upload the file withsubmit_for_review=true. Save the returned asset_id.
Processing. If it becomes Failed, stop polling and check the response for error_code. Once it becomes Active, put asset:// followed by the asset ID in the corresponding media URL.
Active asset on the BytePlus Seedance channel after its signed upload URL expires. The asset remains subject to review status checks.
Save the updated request as request.json, generate a new idempotency key for the new task, and repeat steps 3 and 4. If you are retrying a previous task whose acceptance is uncertain, preserve its original request body, including the asset URLs. See Upload reference asset for file limits and review errors.
