API reference
Generate a video
POST /api/pub/v1/videos, start rendering a short clip on a task.
POST
https://api.dhanu.ai/api/pub/v1/videosStarts 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
| Field | Type | Required | Notes |
|---|---|---|---|
taskId | string | Yes | The task the video belongs to (from POST /tasks). |
prompt | string | Yes | At least 1 characters, up to 2000 characters. |
negativePrompt | string | No | Up to 2000 characters. |
aspectRatio | string | No | One of 16:9, 9:16. |
resolution | string | No | One of 720p, 1080p. |
durationSeconds | integer | No | At 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
| Code | Status | Meaning |
|---|---|---|
invalid_api_key | 401 | The bearer key is missing or unknown. |
api_key_revoked | 401 | The key was revoked. |
api_key_expired | 401 | The key passed its expiry date. |
api_key_ip_not_allowed | 403 | The caller's IP is outside the key's allowlist. |
developer_access_revoked | 403 | The key's creator lost developer access in the workspace. |
api_key_project_scope | 403 | The key covers no active projects, or projectId is outside its scope. |
invalid_request_body | 422 | The body did not match the schema; error.issues names each field. |
project_id_required | 422 | A multi-project key called without projectId. |
insufficient_credits | 402 | The workspace credit balance is zero or below. |
key_spend_limit_reached | 402 | The key reached its monthly spend cap. |
invalid_generation_prompt | 422 | The prompt was empty or longer than 2000 characters. |
not_found | 404 | No such resource in the key's workspace. |