CLI reference
Every agentic-yt (ayt) command, its flags, output modes and exit codes.
The CLI is installed as agentic-yt with the alias ayt. Both names run the same program.
npm install -g agentic-yt # or: npx agentic-yt <command>
ayt --help # every command
ayt <command> --help # one command's flagsConventions
- References. Every
<ref>is a bare id or any YouTube URL —watch?v=,youtu.be/, shorts, embeds, playlist links,@handle. Quote URLs so the shell does not eat&and?. - Times.
--start,--endand--ataccept seconds (90), a clock (1:30,00:01:30.5) or YouTube-style units (1m30s). - Streams. Results go to stdout; progress and messages go to stderr. Piping stdout is always safe.
Global flags
| Flag | Effect |
|---|---|
--json | Print exactly one JSON document on stdout — the API response, unmodified. Errors too: {"error":{"code","message","hint"}}. |
--profile <name> | Use a named profile from the config file. |
-y, --yes | Answer yes to confirmation prompts. Required when there is no TTY. |
-V, --version | Print the version. |
Global flags are accepted before or after the subcommand: ayt --json video <ref> and
ayt video <ref> --json are the same.
For agents: always pass --json
Without it the CLI prints tables meant for people, and their layout is not a contract. With it, the output has the same field names as the API reference.
Flags shared by download, clip and frames
These three create a job. By default they block until the file is on your disk.
| Flag | Effect |
|---|---|
-o, --output <path> | Where to write. A file name, or a directory (the server-provided filename is used). Default: the current directory. |
--no-wait | Print the job and exit immediately. Follow it with ayt jobs get <id> --wait. |
--url-only | Wait for the job, then print the asset URL(s) instead of downloading. |
--timeout <minutes> | Stop waiting after this long (default 30). The job keeps running. |
--account | Use your connected YouTube account. The result is private to you. |
--no-account | Never use your connected YouTube account, even as a fallback. |
Commands
Signing in
ayt login # approve a code in the browser
ayt login --token ayt_pat_… # store a token you already have
ayt login --no-browser # print the URL instead of opening it
ayt logout # forget the saved token (does not revoke it)
ayt whoami # account, token source, profile, API URLSee Authentication.
Looking things up
ayt search <query…> [--type video|channel|playlist] [--limit N] [--cursor C]
ayt video <ref> [--fresh]
ayt formats <ref>
ayt thumbnail <ref> [--quality default|medium|high|standard|maxres] [-o file]
ayt transcript <ref> [--lang en] [--translate-to es] [--format json|srt|vtt|txt] [-o file]
ayt languages <ref>
ayt comments <ref> [--sort top|new] [--limit N] [--cursor C]
ayt channel <ref> [--videos [--sort new|popular] [--limit N] [--cursor C]]
ayt playlist <ref> [--videos [--limit N] [--cursor C]]
ayt resolve <url>
ayt healthLists return next_cursor; pass it back as --cursor for the next page. --limit is 1–100,
default 20.
Producing files
ayt download <ref> [--audio] [--format F] [--quality Q] [--bitrate K]
ayt clip <ref> --start <time> --end <time> [--audio] [--format F] [--quality Q] [--bitrate K]
ayt frames <ref> --at <time…> [--format jpg|png] [--width W]| Flag | Values |
|---|---|
--audio | Audio only. MP3 unless --format says otherwise. |
--format | Video: mp4 (default), webm. Audio: mp3 (default), wav, m4a, opus — an audio format implies --audio. |
--quality | 144p, 240p, 360p, 480p, 720p (default), 1080p, best. |
--bitrate | Audio kbps: 64, 96, 128 (default), 160, 192, 256, 320. |
--at | One or more timestamps, space- or comma-separated, up to 50. |
--width | Resize frames to this width, 16–1920. Default: source size. |
Jobs
ayt jobs list [--status queued|running|succeeded|failed|canceled] [--type download|clip|frames]
ayt jobs get <id> [--wait] [-o path] [--timeout <minutes>]
ayt jobs cancel <id>Your YouTube account
ayt account connect --cookies ./cookies.txt [--label "secondary"]
ayt account connect --from-browser chrome # reads cookies locally; needs yt-dlp installed
ayt account status
ayt account disconnectRead Your own YouTube account first — there is a real risk to the account you connect.
You
ayt me # account, token, limits
ayt me playlists | subscriptions | liked | watch-later [--limit N] [--cursor C]
ayt usage [--days N] # requests, cache hits, bytes, remaining quotaThe four ayt me … lists need a connected YouTube account.
The escape hatch
ayt api <method> <path> [-q key=value]… [-d '<json>' | -d @file]
ayt api GET /v1/videos/dQw4w9WgXcQ/formats
ayt api POST /v1/videos/dQw4w9WgXcQ/frames -q wait=30 -d '{"timestamps":[42]}'Calls any endpoint with your token attached and prints the response. Use it for anything a dedicated command does not expose.
Command → operation
Generated from the route table, so it cannot list a command for an endpoint that does not exist.
| Command | Calls |
|---|---|
| ayt health | GET /v1/health |
| ayt resolve <url> | GET /v1/resolve |
| ayt search <query…> [--type video|channel|playlist] [--limit N] [--cursor C] | GET /v1/search |
| ayt video <ref> [--fresh] | GET /v1/videos/{id} |
| ayt formats <ref> | GET /v1/videos/{id}/formats |
| ayt thumbnail <ref> [--quality maxres] [-o file] | GET /v1/videos/{id}/thumbnail |
| ayt transcript <ref> [--lang en] [--translate-to es] [--format json|srt|vtt|txt] [-o file] | GET /v1/videos/{id}/transcript |
| ayt languages <ref> | GET /v1/videos/{id}/transcript/languages |
| ayt comments <ref> [--sort top|new] [--limit N] [--cursor C] | GET /v1/videos/{id}/comments |
| ayt channel <ref> | GET /v1/channels/{id} |
| ayt channel <ref> --videos [--sort new|popular] [--limit N] [--cursor C] | GET /v1/channels/{id}/videos |
| ayt playlist <ref> | GET /v1/playlists/{id} |
| ayt playlist <ref> --videos [--limit N] [--cursor C] | GET /v1/playlists/{id}/videos |
| ayt download <ref> [--audio] [--format F] [--quality Q] [--bitrate K] [--account|--no-account] [-o path] [--no-wait|--url-only] | POST /v1/videos/{id}/download |
| ayt clip <ref> --start T --end T [--audio] [--format F] [--quality Q] [--bitrate K] [-o path] [--no-wait|--url-only] | POST /v1/videos/{id}/clip |
| ayt frames <ref> --at T [T…] [--format jpg|png] [--width W] [-o dir] [--no-wait|--url-only] | POST /v1/videos/{id}/frames |
| ayt jobs list [--status S] [--type T] [--limit N] [--cursor C] | GET /v1/jobs |
| ayt jobs get <id> [--wait] [-o path] | GET /v1/jobs/{id} |
| ayt jobs cancel <id> | DELETE /v1/jobs/{id} |
| ayt me · ayt whoami | GET /v1/me |
| ayt usage [--days N] | GET /v1/me/usage |
| ayt account status | GET /v1/me/youtube-account |
| ayt account connect --cookies <file> | --from-browser <browser> [--label L] | PUT /v1/me/youtube-account |
| ayt account disconnect | DELETE /v1/me/youtube-account |
| ayt me playlists [--limit N] [--cursor C] | GET /v1/me/playlists |
| ayt me subscriptions [--limit N] [--cursor C] | GET /v1/me/subscriptions |
| ayt me liked [--limit N] [--cursor C] | GET /v1/me/liked |
| ayt me watch-later [--limit N] [--cursor C] | GET /v1/me/watch-later |
| ayt login | POST /v1/cli/device |
| ayt login | POST /v1/cli/device/token |
Exit codes
An agent can branch on these without parsing anything.
| Code | Meaning | Typical cause |
|---|---|---|
0 | Success | |
1 | Generic or API error | not_found, video_unavailable, youtube_blocked, too_long, internal, network failure |
2 | Usage or validation error | Bad flag, bad id or URL, validation_failed |
3 | Credential problem | No token, or unauthorized |
4 | A human must connect a YouTube account | account_required |
5 | Slow down | quota_exceeded, rate_limited |
6 | The job failed or was canceled | job_failed |
130 | Interrupted | Ctrl-C |
Environment
| Variable | Purpose |
|---|---|
AGENTIC_YT_TOKEN | Personal access token; beats the saved one. |
AGENTIC_YT_URL | API base URL (default https://api.agentic-yt.crafter.run). |
AGENTIC_YT_PROFILE | Profile to use; beaten by --profile. |
AGENTIC_YT_CONFIG | Config file (default ~/.agentic-yt/config.json, mode 0600). |