Skip to content

Import a YouTube video and dub it

This is the shortest path from a YouTube URL to a dubbed language. You will:

  1. Create a video
  2. Poll the import job
  3. Start a plus dub
  • A scoped API key (videos:write, jobs:read, dubs:write)
  • Enough credits for a Plus dub of the video’s duration
Terminal window
export BRAIV_API_BASE=https://api.braiv.co/v1
export BRAIV_API_KEY=braiv_live_...
Terminal window
VIDEO=$(curl -sS -X POST "$BRAIV_API_BASE/videos" \
-H "Authorization: Bearer $BRAIV_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"source":{"type":"youtube","url":"https://www.youtube.com/watch?v=dQw4w9WgXcQ"}}')
VIDEO_ID=$(echo "$VIDEO" | jq -r .videoId)
JOB_ID="import_$VIDEO_ID"

The response includes videoId and an import_* job.

Terminal window
for i in $(seq 1 60); do
STATUS=$(curl -sS "$BRAIV_API_BASE/jobs/$JOB_ID" \
-H "Authorization: Bearer $BRAIV_API_KEY" | jq -r .status)
if [ "$STATUS" = "ready" ] || [ "$STATUS" = "failed" ]; then break; fi
sleep 10
done
Terminal window
curl -sS -X POST "$BRAIV_API_BASE/videos/$VIDEO_ID/dubs" \
-H "Authorization: Bearer $BRAIV_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"languages":["es"],"product":"plus"}'

Poll dub_{videoId}_es_plus the same way. When GET /videos/{videoId}/dubs/es?product=plus returns completion: full_ready, you can download a language MP4.