YouTube API + CLI for AI agents
YouTube, as a tool call.
One API and one CLI so your agent can search YouTube, read metadata and transcripts, download video or audio, cut clips and grab frames — without installing yt-dlp or ffmpeg, and without waiting twice for the same file.
Invite-only while it is young. 30 operations, one contract, an OpenAPI document to prove it.
The gap
Agents are good at YouTube. Sandboxes are not.
Getting a transcript or a clip out of a video usually means a Python toolchain, an ffmpeg binary, and an IP address YouTube has not blocked yet. Most places an agent runs have none of the three.
agentic-yt keeps that machinery on a server and hands the agent a URL.
Capabilities
Six things an agent asks of a video, each one command.
Search
$ ayt search <query>
Videos, channels or playlists, with ids, durations and view counts, paged by cursor. Any YouTube URL an agent finds elsewhere works as an id everywhere else.
Metadata
$ ayt video <video>
Title, description, chapters, tags, counters, thumbnails and the list of formats a video can be downloaded in. Channels and playlists too.
Transcripts
$ ayt transcript <video>
Timed segments as JSON, or rendered as SRT, VTT or plain text. Pick a caption language, or machine-translate into another.
Video and audio
$ ayt download <video> --audio
MP4 or WebM up to 1080p; MP3, M4A, Opus or WAV for audio. You get a direct download URL, not a stream to babysit.
Clips
$ ayt clip <video> --start 1:30 --end 2:10
Cut the forty seconds that matter instead of downloading two hours. Times are seconds, 1:30 or 00:01:30.5 — whichever the agent already has.
Frames
$ ayt frames <video> --at 0:42
Still images at exact timestamps, up to 50 per request, as JPG or PNG — so a model with vision can look at the moment being discussed.
Also: comments, channel uploads, playlist contents, and — if you connect your own account — your playlists, subscriptions, liked videos and Watch Later. All of it is in the docs.
Built for agents
Designed for a reader that cannot ask you.
- Errors that say what to do next
- Every failure is one envelope with one of 12 closed codes, a message, a hint written for the agent, and a link to the page about it.
- --json on every command
- The CLI prints exactly what the API returned. No table to scrape, no colour codes, the same field names as the reference.
- A skill, not a prompt you maintain
- One command installs the skill that teaches an agent which command answers which question, and how to recover from each error code.
- llms.txt
- The documentation as one index, generated from the same tree as the site, so an agent can find the right page without crawling.
- Long-polling instead of sleep loops
- Downloads, clips and frames are jobs. Pass wait (up to 60s) and the request holds until the job is done — one call, no polling code.
{
"error": {
"code": "too_long",
"message": "This video is 5h 12m; the maximum is 4h.",
"hint": "The video exceeds the maximum duration. Use POST /v1/videos/{id}/clip for a section.",
"docs_url": "https://agentic-yt.crafter.run/docs/errors#too_long"
}
}The agent does not have to guess whether to retry, re-authenticate or change the request: the errors page lists the right move for every code.
The cache
The first request does the work. Every later one is instant.
A file is identified by what it is — video, kind, format, quality and time range — not by who asked. When your agent requests an MP3 that any earlier request already produced, the job comes back finished, with cache_hit: true and a URL.
- Titles, descriptions and chapters are kept 7 days; view and like counts, 1 hour.
- Transcripts are kept 30 days. Downloads, clips and frames stay until space is needed.
fresh=trueon metadata bypasses the cache when you need the live number.- Anything fetched with your own YouTube account is cached privately, for you only.
{
"id": "0b6f6c1e-…",
"type": "download",
"status": "succeeded",
"cache_hit": true,
"result": {
"assets": [{
"filename": "dQw4w9WgXcQ_128k.mp3",
"mime": "audio/mpeg",
"url": "https://…",
"cache_hit": true
}]
}
}Install
Three commands, then ask.
- 01
Install the CLI
The binary is agentic-yt; ayt is the short alias used everywhere in the docs.
$ npm install -g agentic-yt - 02
Give your agent the skill
Works with any agent that reads skills. It teaches the commands, the JSON shapes and the error playbook.
$ npx skills add crafter-station/agentic-yt - 03
Sign in
Prints a code, opens this site, and stores a token once you approve. In CI, set AGENTIC_YT_TOKEN instead.
$ ayt login
curl "https://api.agentic-yt.crafter.run/v1/videos/dQw4w9WgXcQ/transcript?format=txt" \
-H "Authorization: Bearer $AGENTIC_YT_TOKEN"The CLI is a thin client over the API, and the API is described by an OpenAPI document generated from the same route table the server validates against.
Worth knowing
It is not the official API.
agentic-yt reads YouTube the way a browser does, which is what makes transcripts, downloads and clips possible at all. It is also why YouTube sometimes refuses, and why there are limits: videos up to 4 hours, 1080p at most, 3 jobs at a time per account, 1,000 uncached requests a day by default.
You can connect your own YouTube account as a fallback for videos an anonymous visitor cannot see. Use a secondary one — automated access can get an account restricted. What you do with the files is on you: respect the rights of the people who made them.