YouTube dataset for AI training: build one with permission

By the YouTubeTranscriptAPI engineering team · Published · Updated

We asked YouTube's own training-permission API about 200 recent videos from ten of its biggest channels. Not one allowed AI training.

To build a YouTube dataset for AI training, start with videos you have permission to use, then fetch their transcripts, clean the auto captions, remove duplicates and split train and validation by channel. Permission comes from YouTube's Trainability API, a Creative Commons license, or your own channel. Our free script does all five steps.

Building a YouTube transcript dataset: collect video IDs, check permission, fetch transcripts, clean, de-duplicate, chunk and split by channel, write JSONL with a data card
Permission first. It's the only free step, and the one most guides skip.

Most guides on this topic start with scraping. I think that's backwards.

Fetching transcripts is the easy part. Finding out later that you can't use them is the expensive part, and a few AI companies have learned that in public.

We make YouTubeTranscriptAPI, so we sell the fetching part. But the most useful step in this guide costs nothing and doesn't involve us at all.

Everything below was checked or run on November 25, 2026.

How do you build a YouTube dataset for AI training?

You build a YouTube dataset for AI training in five steps: collect candidate video IDs, keep only videos you're allowed to use, fetch their transcripts, clean and de-duplicate the text, then chunk it into JSONL with train and validation splits. The permission check is free and should come first, so you never pay to fetch a transcript you can't train on.

Here's the shape of it:

1. Collect video IDs from channels, playlists or a list you already have. 2. Check permission for each video, using one of the sources in the next section. 3. Fetch transcripts with timestamps for the videos that pass. 4. Clean the auto captions, drop short and looping transcripts, and remove near-duplicates. 5. Chunk, split by channel and write JSONL plus a data card that records where every row came from.

Our script, build_transcript_dataset.py, runs all five. It uses only Python's standard library, and its dry-run mode does the permission check without spending a credit.

Videos without captions cost nothing either. If a video has no transcript, our API returns a 404 and the script moves on.

Can you legally train AI on YouTube transcripts?

Whether you can legally train AI on YouTube transcripts depends on where the text comes from. YouTube's Terms of Service, dated December 15, 2023, bar downloading content except as YouTube expressly authorizes or with written permission. Creators own their words. Training on videos you own, CC-licensed videos or videos whose owners opted in is far safer than training on anything public.

In July 2024, Proof News reported that a dataset called YouTube Subtitles held transcripts of 173,536 videos from more than 48,000 channels. Anthropic, Nvidia, Apple and Salesforce had used it. Creators like David Pakman said nobody asked them.

Lawsuits followed. YouTuber David Millette sued OpenAI and Nvidia in 2024, per Tom's Hardware. He later dropped the Nvidia case, but other class actions from creators have been filed since.

The rules are in YouTube's Terms of Service. Fair use arguments exist, and courts haven't settled them for AI training.

I'm not a lawyer, and this isn't legal advice. If you're training a model you'll sell, get one.

The practical answer is to build from sources where permission is written down. That's what the rest of this guide does.

How do you check if a YouTube video allows AI training?

You check if a YouTube video allows AI training with YouTube's Video Third-Party Trainability API. Call it with the video ID and it returns who may train on the video: "all", "none" or a list of named companies. It needs no API key and no quota. In our test of 200 popular videos, every one came back "None".

Google's guide to the Trainability API shows the whole call:

bash
curl "https://youtube.googleapis.com/youtube/v3/videoTrainability?id=aircAruvnKk"

Creators turn this on in YouTube Studio. YouTube's help page says the setting is off by default, and creators can allow all companies or pick specific ones.

We ran it on the 20 newest videos from each of ten channels: MKBHD, Veritasium, TED, Kurzgesagt, Linus Tech Tips, 3Blue1Brown, CrashCourse, freeCodeCamp, Andrew Huberman and Lex Fridman. All 200 returned "None". The whole check took 31 seconds.

Trainability check on 200 recent videos from ten large channels: 200 returned None, 0 allowed all companies, 0 named specific companies
0 of 200. The default is off, and big channels leave it there.

Watch the casing. The docs say "none" in lowercase, but the live API returns "None". Compare case-insensitively, or your filter will let everything through.

So where do permitted transcripts come from? There are three real sources.

Videos whose owners opted in come back as "all", or as a list that includes your company.

Creative Commons videos are the second source. The YouTube Data API's videos resource has a status.license field that reads "creativeCommon" for them. One videos.list call checks 50 videos for 1 quota unit.

Third, your own channel, a client's channel or content you've licensed. Here, permission is a contract, not an API field.

The script supports all three with --permission trainability creative-commons allowlist.

What if the videos you want don't allow training?

If the videos you want don't allow training, ask. Creators can switch on third-party training in YouTube Studio and name your company, and the Trainability API will then list you. For a bigger catalog, sign a license with the channel or its network. Otherwise, switch to Creative Commons sources or an existing open dataset.

I'd start with smaller, specialist channels. A focused channel in your domain is often worth more to a fine-tune than a famous one, and its owner may well say yes.

Send a short note. Say what you're training, whether the model is commercial and what you'll pay or credit. Then ask them to add your company in the setting.

YouTube's help page says it isn't handling payments between AI companies and creators. So any money changes hands directly, under your own agreement.

Keep the email or contract with your data card. If the setting changes later, you still have the permission you relied on.

For anything with a business model behind it, get a written license as well. A creator can switch the setting off at any time, and a contract can spell out what happens to models already trained.

Which existing YouTube datasets can you use instead?

Before you build, check whether a ready-made YouTube dataset fits. YouTube-Commons from Pleias has transcripts of over 2 million CC-BY videos. YODAS from ESPnet has hundreds of thousands of hours of CC-licensed speech. Vendors like Bright Data and Oxylabs sell YouTube data too, from a $250 metadata sample to $5,000 a month for video.

DatasetWhat's in itLicense or terms
YouTube-Commons (Pleias)Transcripts of 2,063,066 CC-BY videosCC-BY 4.0, credit each channel
YODAS (ESPnet)369,510 hours of captioned speechCC BY 3.0, CC-licensed videos only
YouTube Subtitles (part of The Pile)173,536 videos' subtitlesCollected without creator consent, per Proof News
Bright DataVideo and channel metadataCommercial, $250 per 100,000 records
OxylabsVideos, audio and transcriptsCommercial, from $5,000 a month

The YouTube-Commons card on Hugging Face lists 22.7 million original and machine-translated transcripts, about 45 billion words, 71% English. Every row credits its channel, as CC-BY requires.

YODAS is built for speech recognition. Its authors say they kept only CC-licensed videos, and creators can ask for removal.

Vendor prices come from AIMultiple's May 2026 review. Oxylabs says it collects creator consent for its training datasets. I couldn't check that claim myself.

If general English conversation is what you need, start with YouTube-Commons. Build your own when you need a specific domain, your own channel or fresh videos.

How do you clean YouTube auto captions for training?

You clean YouTube auto captions by removing sound tags like [Music], collapsing the repeated lines that rolling captions produce, and dropping transcripts that are too short or loop the same phrase. Then decide whether to restore punctuation. Auto captions arrive as short, unpunctuated fragments, and a model trained on raw fragments learns to write that way.

The script does the mechanical part.

It strips tags like [Music], [Applause] and music notes. It removes a caption line when it repeats the one before, which rolling auto captions do constantly.

It drops transcripts under 200 words, which are usually intros or Shorts. It also drops any transcript where more than 30% of word trigrams repeat. That catches the looping output speech recognition sometimes produces on music or noise.

What it doesn't do is rewrite. Punctuation and casing need a language model, and that's a judgment call.

Zen van Riel, who fine-tuned a model on his own channel, found raw captions taught the model run-on sentences and misheard product names. He ran a local model over every chunk to fix punctuation without changing words. That's worth copying if your model will write prose.

If you're building retrieval or search, raw cleaned text is usually fine. Embeddings care less about commas.

Keep the timestamps either way. They let every training row link back to the second it came from.

How do you remove duplicates and avoid train/test leakage?

You remove duplicates with an exact hash plus near-duplicate detection like MinHash, because re-uploads and reposted clips happen on YouTube. Then split train and validation by channel, not by video. Otherwise one speaker's phrasing sits on both sides of the split, and your validation score looks better than the model really is.

Lee et al. (ACL 2022) found that de-duplicating training data made models emit memorized text ten times less often. They also found train-test overlap in over 4% of the validation sets of standard datasets.

The script hashes each transcript for exact copies. It then compares MinHash signatures of five-word shingles and treats a similarity of 0.8 or more as a duplicate. In our unit tests, a 700-word transcript with two words changed was caught, and unrelated transcripts scored under 0.2.

De-duplication and splitting: exact hashes catch identical copies, MinHash at 0.8 catches near-duplicates like re-uploads, and whole channels go to either train or validation
Split by channel so validation measures something new.

The split works by hashing the channel ID. Every video from a channel lands on the same side, and the split stays the same between runs.

Ten percent of channels go to validation by default. Change it with --val.

What format should a YouTube transcript dataset use?

A YouTube transcript dataset should use JSONL, one chunk per line, with the text, the video ID, a timestamped link, the channel, the language and the permission behind it. Chunks of about 500 words with some overlap suit most fine-tuning and retrieval setups. Keep a data card that records counts, filters and permission sources for every build.

Here's one row from the script's train.jsonl, shortened:

json
{"id": "abc123xyz00-0003", "video_id": "abc123xyz00", "url": "https://www.youtube.com/watch?v=abc123xyz00&t=731s", "title": "Lecture 4", "channel": "UCAuUUnT6oDeKwE6v1NGQxug", "language": "en", "permission": "allowlist", "start": 731.2, "end": 912.6, "text": "so the gradient here tells us ..."}

Keep the permission field. YouTube-Commons does the same with a license column on every row, and when someone asks where row 40,000 came from, the answer is in the row.

The default chunk is 512 words with 64 words of overlap. Shorter chunks train faster; van Riel cut his to about 140 tokens for a chat model.

The script also writes manifest.csv, one line per video with its status: kept, no permission, no captions, too short, repetitive or duplicate. And it writes DATACARD.md with the totals.

How do you build the dataset with a script?

You build the dataset with our script by passing channels, playlists or a list of video IDs and a permission mode, then running it once as a dry run. The dry run checks permission for free and tells you exactly how many credits the real run will cost. The real run fetches only permitted videos and writes JSONL, a manifest and a data card.

Set your key and start with a dry run:

bash
export YTT_API_KEY=tk_live_...
python build_transcript_dataset.py --channel @YourChannel --permission allowlist --allowlist mine.txt --dry-run

Put your channel ID in mine.txt, drop --dry-run, and run it again.

For other people's videos, use --permission trainability, and add --company "Your Co" if creators named you. Add creative-commons with a YouTube Data API key in YT_DATA_API_KEY.

Illustrative build, not a measured run: 400 candidate videos, permission check keeps 120, 8 have no captions, 112 transcripts fetched, cleaning and de-duplication keep 97, written as train and validation JSONL
Illustrative numbers. Yours depend on the channels and permissions you start with.

The script fetches one video at a time. A video we've already stored comes back in about a second, and a new one takes 10 to 30 seconds, so a build of 1,000 new videos can take a few hours. Run it overnight.

It also caches every API response in a raw folder. If you run out of credits mid-build, top up and re-run, and it picks up where it stopped without paying twice.

We tested it with ten unit tests against mocked API responses, covering permission matching, the "None" casing, near-duplicates, looping text, chunk overlap, channel splits and resume. We also ran a dry run against the live Trainability API.

To see what the API returns, read the transcript endpoint docs, plus the channel and playlist listings.

What does a YouTube transcript dataset cost to build?

A YouTube transcript dataset costs 1 credit per transcript plus 20 credits per channel or playlist listing of up to 100 videos on our API. The permission check is free, and videos without captions cost nothing. So 10,000 permitted transcripts from 100 channels costs about 12,000 credits, which fits in one Annual plan.

Here's the math. A hundred channel listings at 20 credits each is 2,000 credits, and 10,000 transcripts is 10,000 more.

Credits for a 10,000-transcript dataset: 2,000 for 100 channel listings plus 10,000 for transcripts, 12,000 total, inside the 15,000 credits of an Annual plan
The permission check and missing captions are free.

On our side, Monthly is $3 for 1,000 credits, and Annual is $30 for 15,000 credits a year. Those are founding prices, for accounts that subscribe within 7 days of signing up, and they stay that way while you're subscribed. After that window, new subscriptions are $7 a month or $60 a year.

Top-ups are $2.50 per 1,000 credits on Monthly and $2 per 1,000 on Annual. The pricing page has the current numbers.

Scraping it yourself is possible, and our guide to scraping YouTube transcripts at scale covers the blocks and proxy costs. For a one-off build from a home connection, that can be cheaper.

Either way, the permission check costs nothing.

Frequently asked questions

It depends on the source. YouTube's terms bar downloading content except as YouTube authorizes or with permission, and creators own their words. Training on your own videos, Creative Commons videos or videos whose owners opted in through YouTube's third-party training setting is far safer. Several creators have sued AI companies over YouTube data. Get legal advice for commercial models.

How do I check if a YouTube video allows AI training?

Call YouTube's Video Third-Party Trainability API with the video ID: youtube.googleapis.com/youtube/v3/videoTrainability?id=VIDEO_ID. It needs no key or quota and returns "all", "none" or a list of companies. Compare case-insensitively, because the live API returns "None". In our sample of 200 popular videos, none allowed training.

Are there free YouTube transcript datasets?

Yes. YouTube-Commons from Pleias has transcripts of over 2 million CC-BY videos under a CC-BY 4.0 license, with every channel credited. YODAS from ESPnet has hundreds of thousands of hours of CC-licensed speech with captions. Both are on Hugging Face. Avoid the YouTube Subtitles part of The Pile, which was collected without creators' consent.

Should I use auto-generated or manual captions for training?

Prefer manual captions when you can get them, because they're punctuated and usually more accurate. Most videos only have auto captions, though. Clean them first: remove sound tags and repeated lines, drop looping transcripts, and consider a language-model pass to restore punctuation if your model will write prose. For retrieval, cleaned auto captions are usually enough.

What format should a YouTube transcript dataset be in?

Use JSONL with one chunk per line. Include the text, video ID, a timestamped link, channel, language and the permission the video came with. Chunks of about 500 words with some overlap suit most fine-tuning and retrieval work. Keep a manifest of every video's status and a data card with counts, filters and sources.

How do I avoid train/test leakage with YouTube data?

Split by channel, not by video. If videos from one channel land on both sides, the model sees the same speaker and phrasing in training and validation, and your scores look better than they are. Also remove near-duplicates before splitting, because re-uploads and clips of the same talk are common on YouTube.

Start with permission, then fetch

Run the free permission check before anything else. Point build_transcript_dataset.py at your own channel or a CC-licensed playlist with --dry-run, see how many videos pass, and only then get 100 free credits to fetch the first batch. If your YouTube dataset needs to cover a whole channel, our guide to YouTube channel transcripts shows the listing step in detail.