Python and JS packages
YouTube transcripts in LangChain
LangChain's built-in YouTube loader calls YouTube directly, which often fails with RequestBlocked or IpBlocked on cloud servers. These packages fetch transcripts through the GetYouTubeTranscript API instead, and add agent tools for transcripts and YouTube search.
Set it up
- 1
Install the package
Python:
pip install langchain-getyoutubetranscript - 2
Or for LangChain.js
JavaScript and TypeScript:
npm install @tubeagentkit/langchain-getyoutubetranscript @langchain/core zod - 3
Get an API key
Sign in at getyoutubetranscript.com and create a key on the developers page (100 free credits, no card). Keys start with sk_live_. Set it as an environment variable:
export GETYOUTUBETRANSCRIPT_API_KEY=sk_live_...
Give an agent YouTube tools
from langchain.agents import create_agent
from langchain_getyoutubetranscript import GetYouTubeTranscriptSearchTool, GetYouTubeTranscriptTool
agent = create_agent(
model="anthropic:claude-sonnet-4-5",
tools=[GetYouTubeTranscriptSearchTool(), GetYouTubeTranscriptTool()],
)
agent.invoke(
{"messages": [{"role": "user", "content": "Find a short talk on transformers and summarize it with timestamps."}]}
)What you can build
- RAG over a channel: load transcripts with GetYouTubeTranscriptLoader (one Document per video) and index them.
- A research agent that searches YouTube, reads the top results and cites [m:ss] timestamps.
- Timestamped chunks: with timestamps=True, metadata["segments"] holds {start, duration, text} per caption line.
Good to know
- API errors (no captions, invalid video, out of credits) come back to the agent as a short message instead of raising.
Links
Questions about LangChain
How is this different from LangChain's YoutubeLoader?
YoutubeLoader scrapes YouTube from your own server, which YouTube often blocks on cloud hosts. This loader asks the GetYouTubeTranscript API, which fetches captions on its own servers.
Does the JS package have the same features?
Yes: youtubeTranscriptTool(), youtubeSearchTool() and GetYouTubeTranscriptLoader, with the same timestamps option.
What does it cost?
Each transcript, search or channel page uses one credit from your account, and failed requests are not charged. New accounts get 100 free credits, no card, and paid plans add more credits each month.