Train an agent with the Video API
An agent that can watch YouTube needs three things: one tool, a rule for when to call it, and a way to check what it says. This tutorial wires the Video API into Claude, Cursor or your own Python loop, via MCP and via REST, then gives you three real videos and three questions whose answers sit in the timeline with a timestamp, so you can hold the agent to the transcript.
$2 of free API usage per month · No card required · Failed reads are never billed
# "Understanding MCP From Scratch", 12:22 read_video({ url: "https://www.youtube.com/watch?v=CDjjaTALI68" }) → transcript: en (automatic captions), 25 chapters, 12 frames ## [4:00] Bridge to MCP: Connecting Tools to AI Applications [frame 5 · 3:50 · the speaker points at the screen] [3:50] here's the bridge to mCP what if I want … # 4,270 tokens · 7.3 s · the frames arrive as images
What the agent gets from one call
"Training" here does not mean fine-tuning a model. It means giving an agent a tool it did not have, a short rule about when and how to use it, and a test that tells you whether its answers hold up. The tool is read_video. One call with a YouTube URL returns one Markdown timeline: the description, every chapter as a heading, the transcript in the spoken language merged into 20-second blocks stamped [m:ss], and a [frame N · m:ss · why] marker wherever a small picture belongs. Over MCP the pictures arrive inline as images; over REST they are base64 JPEG strings in frames[].
This is what the agent read for the tutorial video in the terminal above, trimmed to the moment that matters for question three:
# Understanding MCP From Scratch Channel: LangChain · Duration: 12:22 Transcript: en (automatic captions), original language, timestamps [m:ss] Frames: 12 storyboard frames of 160×90 px, marked [frame N · m:ss · why] ## Timeline … [frame 5 · 3:50 · the speaker points at the screen] [3:50] here's the bridge to mCP what if I want … ## [4:00] Bridge to MCP: Connecting Tools to AI Applications …
Two details to notice, because the rule below depends on them. The automatic captions wrote "mCP": the response says automatic captions in its header and adds a note that proper names may be spelled as heard, so an agent that reads the header knows to trust the description and the frames for names. And the frame sits before the words said over it, so the model looks, then reads.
Part one
Via MCP: Claude, Cursor or the hosted endpoint
The QuanticData MCP server ships read_video with its other 28 tools. Add it once with your key; the tool appears in the client and the model decides when to call it. The web and research presets include it, so QUANTICDATA_TOOLS=web keeps the list short.
claude mcp add quanticdata \ -e QUANTICDATA_API_KEY=qd_live_your_key_here \ -e QUANTICDATA_TOOLS=web \ -- npx -y quanticdata-mcp # tools: scrape, search, search_and_read, read_video
Then ask: "Read https://www.youtube.com/watch?v=aircAruvnKk and tell me, with the minute, where the edge detection example starts and what is on screen." The client shows the tool call, the timeline and the frames, then the answer.
The rule that trains it
A tool the model does not know when to use is a tool it will misuse. These six lines go in the place your client keeps standing instructions: CLAUDE.md for Claude Code, the project rules in Cursor, the system prompt in your own loop. They encode what we learned from the three measured reads: use windows on long videos, quote with the stamp, trust the description for names, say when there is no transcript.
## Videos - When a question is about a YouTube video, call read_video with the URL before answering. - Videos over 20 minutes: read them in windows with start/end of about 10 minutes, or pass max_tokens; the response says when it was trimmed and where to resume. - Answer with the [m:ss] stamp and the exact words from the transcript, then what the frame at that moment shows. Never invent a timestamp. - The header says "automatic captions" when names may be spelled as heard: take names from the description or the chapters, not from the captions. - If transcript.source is none, say the video has no captions and answer from the chapters, the description and the frames only. - Frames are 160×90: describe scenes and objects, do not read small text from them.
The same text, saved as a SKILL.md, is what the Agent Skills QuanticData publishes already do for the whole MCP server; npx skills add https://quanticdata.io installs them in Claude Code, Cursor, Codex and any agent that reads the format.
Part two
Via the API: the same loop in Python
Without MCP you do two things the client did for you: fetch the timeline with one POST, and put each frame next to its marker as an image block. Forty lines, any model that accepts images; the example uses the Anthropic SDK.
import os, requests
QD_KEY = os.environ["QD_API_KEY"]
def read_video(url, **opts):
r = requests.post("https://api.quanticdata.io/v1/scraper/video",
headers={"Authorization": f"Bearer {QD_KEY}"},
json={"url": url, "max_frames": 8, "max_tokens": 6000, **opts},
timeout=120)
data = r.json()
if data["type"] != "response": # removed, gated, blocked: not billed
code = (data.get("payload") or {}).get("code")
raise SystemExit(f'{data["message"]} ({code})')
return data["payload"]
video = read_video("https://www.youtube.com/watch?v=aircAruvnKk")
print(video["transcript"]["source"], video["tokens"]["estimated"], "tokens",
len(video["frames"]), "frames")
The timeline of this video is 5,780 tokens with the defaults; with max_frames: 8 and max_tokens: 6000 the whole prompt, images included, stays under 10,000 tokens. Node users: the same three steps are a fetch and a loop over content.split("\n").
Check it on three videos
An agent is trained when you can measure it. On 20 October 2026 we read three public videos with the defaults and picked one question per video whose answer is in the timeline with a timestamp: the stamp of the transcript block, the quote the frame was taken for, or the chapter start. Ask your agent the same questions and compare with the column on the right; the words are the transcript's own.
| Video | Question | Where the answer is in the timeline |
|---|---|---|
| A product review in Italian, 8:23, automatic captions | What does the robot cost, and when is the price said? | [frame 1 · 0:10 · a price is said] over [0:00] … Partiamo subito dal prezzo, €499; said again at [frame 12 · 7:40], "ma costa sempre €499" |
| A maths lesson, 18:40, captions, 12 chapters | When does the edge detection example start, and what is on screen? | Chapter ## [8:38] Edge detection example; [frame 7 · 8:40 · chapter start] shows the slide the chapter opens with |
| A developer tutorial, 12:22, automatic captions, 25 chapters | Where is the bridge to MCP introduced? | [frame 5 · 3:50 · the speaker points at the screen] over "here's the bridge to mCP what if I want"; chapter ## [4:00] Bridge to MCP: Connecting Tools to AI Applications |
The check itself is a few lines: every expected answer is a timestamp the agent must mention, within a minute, and a phrase it must quote. Run it after every change to the rule or the model, the way you would run a unit test.
import re
CHECKS = [
("https://www.youtube.com/watch?v=qg7uHUHq9zk",
"What does the robot cost, and when is the price said?", "0:0", "499"),
("https://www.youtube.com/watch?v=aircAruvnKk",
"When does the edge detection example start, and what is on screen?", "8:3", "edge detection"),
("https://www.youtube.com/watch?v=CDjjaTALI68",
"Where is the bridge to MCP introduced?", "3:5", "bridge"),
]
def passes(answer, minute_prefix, phrase):
stamps = re.findall(r"\b\d{1,2}:\d{2}\b", answer)
return any(s.startswith(minute_prefix) for s in stamps) and phrase.lower() in answer.lower()
for url, question, minute_prefix, phrase in CHECKS:
answer = ask(read_video(url), question) # parts two and three, as a function
print("PASS" if passes(answer, minute_prefix, phrase) else "FAIL", "|", question)
A failure usually means one of three things, in this order: the agent answered without calling the tool (the rule's first line), it read a window that did not contain the moment (the rule's second line), or it paraphrased instead of quoting (the third). Fix the rule, not the test.
Context and cost
Each read is one price, whatever the length; what you control is how much of it reaches the model. These are the three videos of this tutorial, read with the defaults from outside our network.
| Video | Length | Timeline tokens | Frames | Fetched from the platform | Time |
|---|---|---|---|---|---|
| Product review, Italian | 8:23 | 2,342 | 12 | 442 KB | 1.7 s |
| Maths lesson, English | 18:40 | 5,780 | 12 | 503 KB | 2.6 s |
| Developer tutorial, English | 12:22 | 4,270 | 12 | 565 KB | 7.3 s |
- Windows, not whole lectures:
start: "20:00", end: "30:00"reads ten minutes, frames included, for the same price as the whole video. - A budget the response respects:
max_tokens: 6000trims the timeline at a block boundary and setstokens.truncated; the note says to continue with start and end. - Frames only when the question needs eyes:
max_frames: 0for summaries and quote hunting,frames: falseto keep the list of moments without the image data. - Agents probe for free: a removed, private or gated video answers a stable code and costs nothing, and $2 of usage is free every month.
The setting to start with
QUANTICDATA_TOOLS=web on the MCP server, or POST /v1/scraper/video with max_frames: 8 and max_tokens: 6000 from code. One price per successful read, failed reads never billed, and $2 of free API usage per month: this whole tutorial, three videos included, runs inside it.
Sources and standards
What this tutorial builds on, so you can check it yourself:
Does the agent download or watch the video?
No. The Video API reads the captions, the description and the storyboard tiles the platform already renders for its seek bar; no media byte is fetched. The agent receives a Markdown timeline and up to 30 small JPEG frames and reasons over those, which is why a read takes seconds, not minutes.
Which clients get the read_video tool?
Any MCP client connected to the QuanticData MCP server: Claude Desktop, Claude Code, Cursor, Windsurf, VS Code, Cline and the hosted endpoint from any client with MCP authorization. The tool is in the web and research presets, so QUANTICDATA_TOOLS=web keeps the tool list short and still includes it.
Can I use a model other than Claude?
Yes. The REST call returns Markdown text and base64 JPEGs; any model that accepts images takes them as image blocks, and a text-only model still reads the timeline with its [m:ss] stamps and the quotes that earned each frame. The Python example uses the Anthropic SDK because that is what we run, not because the API requires it.
How many frames should I ask for?
Eight is a good default for questions about what is on screen; twelve is the API default; thirty is the maximum. For summaries and quote hunting, max_frames: 0 returns the transcript alone and the prompt stays small. Each 160×90 frame is roughly 3 to 4 KB of base64, so even thirty frames add little to the request.
What if the video has no captions?
The read still succeeds with the metadata, the description, the chapters and the frames; transcript.source says none and the timeline carries only chapters and frame markers. Teach the agent to say so instead of guessing: the rule in part one does exactly that.
How do I keep a long video inside the context window?
Read it in windows. start and end accept seconds or m:ss, max_tokens trims the text to a budget and reports it in tokens.truncated, and the note tells the agent to continue with start and end. A 10-minute window of a lecture is a few thousand tokens, and each window is one read.
Give your agent eyes on YouTube
One tool, one rule, three checks. Start with $2 of free API usage per month, no card.
Get my free API key