Skip to main content
This guide uses ByteDance Seedance 2.5 to create a video from a text prompt. You can also provide reference images or videos when using the BytePlus Seedance channel.

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, and uuidgen. 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.
The base URL includes /v1. Append paths such as /videos directly to it.

2. Prepare the request

Save the following JSON as request.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.
The following request submits a generation task and may incur charges.
HTTP 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.
Start by polling every 5 seconds and set a local timeout.
  • While the task is processing or settlement is pending, keep querying the same task.
  • When status is succeeded and settlement_status is settled, use video_url to play or download the video and billing.total to read the final USD charge.
  • If settlement_status is awaiting_balance, top up the balance and query the same task again.
  • For failed, cancelled, or expired, 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.
Honor 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.
HTTP 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 with submit_for_review=true. Save the returned asset_id.
Replace the placeholder with that asset ID and query the review status using credentials for the same DGrid user.
Poll while the status is 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.
The asset must have been submitted for review through DGrid by the same user. You can reference an 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.