Skip to content
dhanu docs
Browse pages

API reference

Generate a video

POST /api/pub/v1/videos, start rendering a short clip on a task.

POSThttps://api.dhanu.ai/api/pub/v1/videos

Starts rendering a short video clip from a prompt on an existing task, so it appears on that task’s media board like a clip the assistant made. Rendering takes minutes, so the call returns at once with the video in generating and the job to wait on. The bytes exist once the video is ready: poll read a video, wait on the job, or subscribe to the video.ready webhook. Test keys answer with a ready fixture and render nothing.

Request

FieldTypeRequiredNotes
taskIdstringYesThe task the video belongs to (from POST /tasks).
promptstringYesAt least 1 characters, up to 2000 characters.
negativePromptstringNoUp to 2000 characters.
aspectRatiostringNoOne of 16:9, 9:16.
resolutionstringNoOne of 720p, 1080p.
durationSecondsintegerNoAt least 1, at most 60.
curl -X POST https://api.dhanu.ai/api/pub/v1/videos \
  -H "Authorization: Bearer $DHANU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "taskId": "…", "prompt": "A slow dolly over Kathmandu at dawn", "aspectRatio": "16:9" }'
const { video, jobId } = await dhanu.videos.generate({
  taskId,
  prompt: "A slow dolly over Kathmandu at dawn",
  aspectRatio: "16:9",
});
await dhanu.jobs.wait(jobId);
const clip = await dhanu.videos.download(video.id);
started = dhanu.videos.generate(task_id=task_id, prompt="A slow dolly over Kathmandu at dawn", aspect_ratio="16:9")
dhanu.jobs.wait(started.job_id)
clip = dhanu.videos.download(started.video.id)

Response

202 Accepted

{
  "video": { "id": "…", "taskId": "…", "title": "A slow dolly over Kathmandu at dawn", "status": "generating", "error": null, "aspectRatio": "16:9", "resolution": "720p", "durationSeconds": null, "createdAt": "…", "updatedAt": "…" },
  "jobId": "…"
}

Errors

CodeStatusMeaning
invalid_api_key401The bearer key is missing or unknown.
api_key_revoked401The key was revoked.
api_key_expired401The key passed its expiry date.
api_key_ip_not_allowed403The caller's IP is outside the key's allowlist.
developer_access_revoked403The key's creator lost developer access in the workspace.
api_key_project_scope403The key covers no active projects, or projectId is outside its scope.
invalid_request_body422The body did not match the schema; error.issues names each field.
project_id_required422A multi-project key called without projectId.
insufficient_credits402The workspace credit balance is zero or below.
key_spend_limit_reached402The key reached its monthly spend cap.
invalid_generation_prompt422The prompt was empty or longer than 2000 characters.
not_found404No such resource in the key's workspace.