Downloading video and audio
Turn a video into an MP4, WebM, MP3, M4A, Opus or WAV file and get a direct download URL.
A download is a job: the server fetches the video, transcodes it if needed, stores the file and gives you a URL. If anyone has asked for the same file before, the job is already finished when it comes back.
From the CLI
ayt download dQw4w9WgXcQ # 720p MP4 into the current directory
ayt download dQw4w9WgXcQ --quality 1080p -o talk.mp4
ayt download dQw4w9WgXcQ --audio # 128 kbps MP3
ayt download dQw4w9WgXcQ --audio --format mp3 --bitrate 192 -o song.mp3
ayt download dQw4w9WgXcQ --format opus # an audio format implies --audio
ayt download dQw4w9WgXcQ --url-only --json # do not save; print the job with its URLThe command blocks until the file is on disk. In an agent, --url-only --json is often the better
shape: the agent gets a URL it can hand to another tool, and nothing large lands in its workspace.
Over HTTP
curl -X POST "https://api.agentic-yt.crafter.run/v1/videos/dQw4w9WgXcQ/download?wait=60" \
-H "Authorization: Bearer $AGENTIC_YT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"kind":"audio","format":"mp3","audio_bitrate":192}'Body
Every field is optional; {} is a 720p MP4.
| Field | Default | Values |
|---|---|---|
kind | video | video (with audio) or audio. |
format | mp4 for video, mp3 for audio | Video: mp4, webm. Audio: mp3, wav, m4a, opus. |
quality | 720p | 144p, 240p, 360p, 480p, 720p, 1080p, best. Video only. |
audio_bitrate | 128 | 64, 96, 128, 160, 192, 256, 320 kbps. Audio only; ignored for wav. |
use_account | omitted | See below. |
quality is a maximum height. If the video has no stream at that height you get the next lower
one, not an error. best means the best available up to 1080p — nothing above 1080p is served.
format must match kind: {"kind":"video","format":"mp3"} is a
validation_failed whose message lists the formats that are
valid.
Query
wait (0–60, default 0) holds the request up to that many seconds for the job to finish. See
Jobs and long-polling.
Response
{
"id": "0b6f6c1e-9d0a-4f43-8a39-0a2f5f3f6f11",
"type": "download",
"status": "succeeded",
"progress": 100,
"video_id": "dQw4w9WgXcQ",
"params": { "kind": "audio", "format": "mp3", "quality": "720p", "audio_bitrate": 192 },
"result": {
"assets": [
{
"url": "https://…",
"bytes": 5112345,
"mime": "audio/mpeg",
"filename": "dQw4w9WgXcQ_192k.mp3",
"cache_hit": false,
"expires_at": "2026-12-03T14:05:00.000Z"
}
]
},
"error": null,
"cache_hit": false,
"poll_url": "https://api.agentic-yt.crafter.run/v1/jobs/0b6f6c1e-9d0a-4f43-8a39-0a2f5f3f6f11",
"created_at": "2026-11-26T14:04:41.000Z",
"started_at": "2026-11-26T14:04:42.000Z",
"finished_at": "2026-11-26T14:05:00.000Z"
}200— the job is terminal: a cache hit, or it finished withinwait. Readstatus.202— it is stillqueuedorrunning. Followpoll_url.
params is your request with every default filled in — the exact thing the job runs with.
Using the file
result.assets[0].url is a direct link: a plain GET with no Authorization header downloads the
file, and it supports range requests, so it can be streamed.
The URL is signed and temporary. expires_at says when it stops working (up to 7 days out).
The file itself does not expire with the link: fetch the job again — or repeat the same download
request, which will be a cache hit — and you get a fresh URL.
| Format | MIME type |
|---|---|
mp4 | video/mp4 |
webm | video/webm |
mp3 | audio/mpeg |
m4a | audio/mp4 |
opus | audio/ogg |
wav | audio/wav |
Choosing well
- To understand a video, get the transcript, not the file.
- To transcribe it yourself,
--audio --format mp3 --bitrate 64is small and plenty for speech. - For a specific part, clip it; a 40-second clip of a 3-hour video is faster and far smaller.
- For one image, use frames.
wavis uncompressed — roughly 10 MB per minute. Ask for it only when a tool requires it.
Using your YouTube account
use_account controls whether your connected YouTube account is
involved:
| Value | Behaviour |
|---|---|
| omitted | Anonymous first; your account only as a fallback if that is refused. |
true (--account) | Use your account. Fails with account_required if none is connected. |
false (--no-account) | Never use it. |
A file fetched with your account is cached privately: only your account gets cache hits on it.
Errors to expect
too_long— the video is over 4 hours. Clip a section.video_unavailable— private, deleted, region-locked or age-restricted.youtube_blocked— YouTube refused. Retry later, or withuse_account: true.account_required— you setuse_account: truewith no account connected.rate_limited— you already have 3 jobs in flight.
These can arrive two ways: as an HTTP error on the POST, or — when the problem is only discovered
while the job runs — as a job with status: "failed" and the same body under error. Check both.
Operations covered