Skip to main content

llm-getyoutubetranscript

PyPI License

YouTube transcripts for LLM. Pull the YouTube transcript of any video into a prompt, let a model fetch transcripts on its own, or print one from the command line. It uses the GetYouTubeTranscript API, so there are no proxies, cookies or headless browsers to set up.

llm -f yt:https://youtu.be/5e37ZT3SQbk "summarize this video in five bullet points"

Installation

Install this plugin in the same environment as LLM:

llm install llm-getyoutubetranscript

Set up your API key

  1. Create a free key at getyoutubetranscript.com/dashboard. New accounts get 100 credits and no card is needed.

  2. Store it in LLM's key store:

    llm keys set getyoutubetranscript
    

    Or export it as an environment variable (a key in the key store wins over the variable):

    export GETYOUTUBETRANSCRIPT_API_KEY=sk_live_...
    

Each transcript costs 1 credit. Failed and rate-limited requests are never charged.

Fragments

Use the yt: fragment prefix with a video URL or an 11-character video ID:

llm -f yt:dQw4w9WgXcQ "summarize this"
llm -f 'yt:https://www.youtube.com/watch?v=dQw4w9WgXcQ' "what are the main arguments?"
llm -f yt:https://youtu.be/dQw4w9WgXcQ "write a blog post from this"

Quote the whole argument if the URL contains ? or &, so your shell leaves it alone.

The fragment starts with the video title, channel and URL, followed by the transcript, so the model knows what it is reading.

Timestamps

yt-timed: puts a [m:ss] timestamp ([h:mm:ss] past an hour) on every caption line. Use it when you want answers that point to moments in the video:

llm -f yt-timed:dQw4w9WgXcQ "list the key moments with their timestamps"

Other languages

Add @ and a caption language code to the end of the argument:

llm -f yt:dQw4w9WgXcQ@es "resume este video"
llm -f yt-timed:https://youtu.be/dQw4w9WgXcQ@pt-BR "resuma os pontos principais"

Without a language the API default (English) is used.

Combine videos and other fragments

Fragments stack, so you can compare videos or mix a transcript with other context:

llm -f yt:VIDEO_ONE -f yt:VIDEO_TWO "how do these two talks disagree?"
llm -f yt:dQw4w9WgXcQ -f ./notes.md "does the talk cover everything in my notes?"

LLM stores each fragment by content hash in its log database, so follow-up prompts in a conversation (llm -c "and the third point?") do not fetch the transcript again.

See all registered loaders with llm fragments loaders.

If another installed plugin also registers yt: (for example llm-youtube-transcript), LLM keeps both and renames one prefix to yt_1:. Run llm fragments loaders to see which prefix points to which plugin.

Tool

The plugin registers a youtube_transcript tool, so a model can decide for itself when to fetch a transcript:

llm -T youtube_transcript "Summarize https://youtu.be/dQw4w9WgXcQ in three sentences" --td
llm chat -T youtube_transcript

The tool takes video (URL or ID), an optional language and an optional timestamps flag. Use a model that supports tool calling.

Command

llm youtube-transcript prints a transcript to stdout. It is handy for piping into other tools or saving subtitle files:

llm youtube-transcript dQw4w9WgXcQ                      # plain text
llm youtube-transcript dQw4w9WgXcQ --format timed       # [m:ss] lines
llm youtube-transcript dQw4w9WgXcQ --format srt > video.srt
llm youtube-transcript dQw4w9WgXcQ -l es --format vtt > video.es.vtt
llm youtube-transcript dQw4w9WgXcQ --format json

Formats: text, timed, srt, vtt, json.

Errors

Problems come back as one clear line, not a traceback. For example an unknown video, a missing or invalid key, or an account out of credits:

Error: Could not load fragment yt:aaaaaaaaaaa: This video is unavailable, private, or has been removed.

Development

git clone https://github.com/tubeagentkit/llm-getyoutubetranscript
cd llm-getyoutubetranscript
python -m venv venv
source venv/bin/activate
pip install -e '.[test]'
python -m pytest

License

MIT

Metadata

Release files for llm-getyoutubetranscript 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-getyoutubetranscript 0.1.0
File Size Uploaded
llm_getyoutubetranscript-0.1.0.tar.gz 9.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-getyoutubetranscript 0.1.0
File Interpreter ABI Platform
llm_getyoutubetranscript-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.6 kB

Release files / llm_getyoutubetranscript-0.1.0.tar.gz

Download URL llm_getyoutubetranscript-0.1.0.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9d1aad64737d80762ea8c330a959f860f453382cd83cde6e08f285f175757258
BLAKE2b-256 checksum
How to use checksums
f0ddad3855d432ccc9bbe8039b4b985836eec4b32de93ecc1d14be7811fff554
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / llm_getyoutubetranscript-0.1.0-py3-none-any.whl

Download URL llm_getyoutubetranscript-0.1.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
098a80ece772405c947b014a4c61e5745910d425e4ce84a54ec38a47300640dc
BLAKE2b-256 checksum
How to use checksums
a2bd957cda2b3d3ab61f174a2f7b5014e4eb265feabc779cc8fc12402e9f7539
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page