Products/YouTube/YouTube Transcript/Integration
YouTube Transcript Integration
YouTube transcript API for LangChain and LlamaIndex
LangChain's community YoutubeLoader and LlamaIndex's YoutubeTranscriptReader both wrap the same youtube_transcript_api library, so both inherit its cloud IP blocking. LangChain's own issue tracker has issue
2 USD / 1,000 transcripts, pay as you go, with no charge for a NO_TRANSCRIPT or other error row.
Copy-paste example
import requests
from langchain_core.documents import Document
def load_youtube_transcript(video_id: str) -> Document:
response = requests.get(
"https://api.vakitek.co.uk/v1/youtube/transcript",
params={"video": video_id, "format": "json"},
headers={"X-API-Key": "YOUR_VAKITEK_API_KEY"},
)
response.raise_for_status()
item = response.json()["data"][0]
if "error" in item:
raise RuntimeError(item["error"])
return Document(page_content=item["text"], metadata={"video_id": video_id})Step by step
- Get a Vakitek API key from the dashboard.
- Write a small loader function (above) that returns a LangChain Document, or a LlamaIndex-compatible node, from the API response, instead of importing YoutubeLoader or YoutubeTranscriptReader.
- Call it once per video id in your existing ingestion loop; the function signature can match the one your pipeline already expects.
- Check the item error field before building a Document, so a video with no captions does not get embedded as an empty chunk.
- For many videos at once, POST a videos list to the same path, up to 25 per call, and build one Document per returned item.
Your options compared
| Option | Trade-offs |
|---|---|
| LangChain YoutubeLoader and LlamaIndex YoutubeTranscriptReader | Both wrap youtube_transcript_api, so both inherit its cloud IP blocking. LangChain issue |
| Custom loader calling the Vakitek API (this guide) | A few lines of code return a Document the same way the official loaders do, with residential proxy handling server-side at 2 USD / 1,000 transcripts. |
| youtube_transcript_api plus your own rotating proxies | Keeps the official loader working, but you buy and maintain the proxy pool, and llama-index-readers-youtube-transcript (6,228 downloads a month) still calls the same underlying library underneath it. |
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| The ingestion job raises an HTTPError with status 401. | The X-API-Key header is missing, wrong, or the key was revoked. | Confirm the key against the one shown once in the Vakitek dashboard. Missing, unknown and revoked keys all return the same 401 UNAUTHORIZED body. |
| A Document gets built with empty page_content. | The video has no captions, is private, or hit another typed error. | Check the item error field (for example NO_TRANSCRIPT or PRIVATE) before constructing the Document, instead of assuming text is always present. |
| A batch ingestion call with more than 25 videos fails. | The POST batch endpoint caps a single request at 25 videos. | The API returns 422 with error INVALID_INPUT and max 25. Chunk your video id list into groups of 25 or fewer. |
| Large ingestion runs start failing with status 429. | The per-key rate limit was exceeded. | Add backoff between batches. 429 responses carry error RATE_LIMITED. |
Questions
Why does YoutubeLoader fail only when deployed, not locally?
LangChain issue
Does LlamaIndex have the same problem?
LlamaIndex's YoutubeTranscriptReader also wraps youtube_transcript_api, so it is exposed to the same class of cloud IP blocking, though no LlamaIndex-specific issue number is cited here.
Can I keep using LangChain's Document format?
Yes. The loader function above returns a standard LangChain Document; swap in your framework's own document type if you use LlamaIndex instead.
Try YouTube Transcript with 5 USD of free credit.
Sources
- llama-index-readers-youtube-transcript monthly downloads: https://pypi.org/project/llama-index-readers-youtube-transcript/
- LangChain issue 26185, YoutubeLoader fails in the cloud: https://github.com/langchain-ai/langchain/issues/26185
