Skip to Content
agentic-yt

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 URL

The 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.

FieldDefaultValues
kindvideovideo (with audio) or audio.
formatmp4 for video, mp3 for audioVideo: mp4, webm. Audio: mp3, wav, m4a, opus.
quality720p144p, 240p, 360p, 480p, 720p, 1080p, best. Video only.
audio_bitrate12864, 96, 128, 160, 192, 256, 320 kbps. Audio only; ignored for wav.
use_accountomittedSee 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 within wait. Read status.
  • 202 — it is still queued or running. Follow poll_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.

FormatMIME type
mp4video/mp4
webmvideo/webm
mp3audio/mpeg
m4aaudio/mp4
opusaudio/ogg
wavaudio/wav

Choosing well

  • To understand a video, get the transcript, not the file.
  • To transcribe it yourself, --audio --format mp3 --bitrate 64 is 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.
  • wav is 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:

ValueBehaviour
omittedAnonymous 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

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.

On this page