Skip to Content
agentic-yt

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 flags

Conventions

  • 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, --end and --at accept 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

FlagEffect
--jsonPrint 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, --yesAnswer yes to confirmation prompts. Required when there is no TTY.
-V, --versionPrint 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.

FlagEffect
-o, --output <path>Where to write. A file name, or a directory (the server-provided filename is used). Default: the current directory.
--no-waitPrint the job and exit immediately. Follow it with ayt jobs get <id> --wait.
--url-onlyWait 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.
--accountUse your connected YouTube account. The result is private to you.
--no-accountNever 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 URL

See 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 health

Lists 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]
FlagValues
--audioAudio only. MP3 unless --format says otherwise.
--formatVideo: mp4 (default), webm. Audio: mp3 (default), wav, m4a, opus — an audio format implies --audio.
--quality144p, 240p, 360p, 480p, 720p (default), 1080p, best.
--bitrateAudio kbps: 64, 96, 128 (default), 160, 192, 256, 320.
--atOne or more timestamps, space- or comma-separated, up to 50.
--widthResize 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 disconnect

Read 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 quota

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

CommandCalls
ayt healthGET /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 whoamiGET /v1/me
ayt usage [--days N]GET /v1/me/usage
ayt account statusGET /v1/me/youtube-account
ayt account connect --cookies <file> | --from-browser <browser> [--label L]PUT /v1/me/youtube-account
ayt account disconnectDELETE /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 loginPOST /v1/cli/device
ayt loginPOST /v1/cli/device/token

Exit codes

An agent can branch on these without parsing anything.

CodeMeaningTypical cause
0Success
1Generic or API errornot_found, video_unavailable, youtube_blocked, too_long, internal, network failure
2Usage or validation errorBad flag, bad id or URL, validation_failed
3Credential problemNo token, or unauthorized
4A human must connect a YouTube accountaccount_required
5Slow downquota_exceeded, rate_limited
6The job failed or was canceledjob_failed
130InterruptedCtrl-C

Environment

VariablePurpose
AGENTIC_YT_TOKENPersonal access token; beats the saved one.
AGENTIC_YT_URLAPI base URL (default https://api.agentic-yt.crafter.run).
AGENTIC_YT_PROFILEProfile to use; beaten by --profile.
AGENTIC_YT_CONFIGConfig file (default ~/.agentic-yt/config.json, mode 0600).

On this page