Use this file to discover all available pages before exploring further.
YouTube holds a wealth of knowledge: conference talks, podcasts, tutorials. Finding specific insights means scrubbing through hours of video. This cookbook shows you how to ingest YouTube content and turn it into a searchable knowledge base.What you’ll build:
YouTube ingestion that extracts transcripts from playlists and individual videos
Smart Q&A that routes questions to the right source type automatically
Video recommendations that surface relevant videos instead of synthesized answers
We’ll use AI engineering content as our example dataset: conference talks from AI Engineer World’s Fair and podcast episodes. By the end, you’ll have a system that understands when to cite technical deep-dives vs. practitioner discussions.
We’ll ingest two types of YouTube content: a conference playlist (12 videos) and individual podcast episodes. Each will be tagged with metadata for smart routing later.
Conference Talks
Podcasts
Search & Retrieval track from AI Engineer World’s Fair 2025 — 12 talks covering RAG, vector search, agent memory, and production AI systems
Inside GitHub’s AI Revolution: Jared Palmer on Agent HQ & Coding Agents
AI prompt engineering in 2025: What works and what doesn’t
Pass a playlist URL and the ingestion automatically extracts each video’s transcript, chunks it, and creates embeddings. We’ll tag this content as conference for routing later.We will ingest this YouTube playlist
Each video in the playlist becomes a separate document with its own metadata (title, URL, duration). Transcripts are extracted and chunked automatically.
You can also ingest individual video URLs. Here we’ll add some podcast episodes and tag them as podcast to distinguish them from the conference playlist.We will ingest these YouTube videos
Not all questions need both sources. Technical “how do I implement X” questions benefit from conference talks. Questions about real-world experiences and opinions benefit from podcasts. Let’s build a router that classifies questions and searches the right source.
// "What's the state of RAG in 2025?" → BOTH → conferences + podcastsconst results = await routedSearch("What's the state of RAG in 2025?");console.log(results.map((r) => r.text).join("\n\n"));
Combine the router with LLM generation to answer questions from the right sources.
import { Agentset } from "agentset";import { generateText, generateObject } from "ai";import { openai } from "@ai-sdk/openai";import { z } from "zod";const agentset = new Agentset({ apiKey: process.env.AGENTSET_API_KEY,});const ns = agentset.namespace("ns_xxxx");const SYSTEM_PROMPT = `You are an AI Engineering Assistant. Answer questions using only the provided context.Rules:1. Cite sources using [1], [2], etc.2. If the context doesn't contain the answer, say so.3. Be direct and practical.`;async function answerQuestion(question: string) { // Route to the right source(s) const results = await routedSearch(question); // Build numbered context const context = results .map((r, i) => `[${i + 1}] ${r.text}`) .join("\n\n"); // Generate answer const { text } = await generateText({ model: openai("gpt-5.2"), system: SYSTEM_PROMPT + `\n\nContext:\n${context}`, prompt: question, }); return text;}const answer = await answerQuestion( "How should I layer techniques in a RAG pipeline?");console.log(answer);
Sometimes you don’t want an AI-generated answer. You want to know which video to watch. Let’s build a recommender that returns video suggestions instead of synthesized text.
interface VideoRecommendation { title: string; url: string; snippet: string;}async function recommendVideos(topic: string): Promise<VideoRecommendation[]> { const results = await ns.search(topic, { topK: 10 }); // Group results by video (using title from metadata) const videoMap = new Map<string, VideoRecommendation>(); for (const result of results) { const title = result.metadata?.title as string; const url = result.metadata?.url as string; if (title && !videoMap.has(title)) { videoMap.set(title, { title, url, snippet: result.text.slice(0, 200) + "...", }); } } return Array.from(videoMap.values()).slice(0, 5);}const recommendations = await recommendVideos("building AI agents for sales");for (const video of recommendations) { console.log(`📺 ${video.title}`); console.log(` ${video.snippet}`); console.log(` Watch: ${video.url}\n`);}
You’ve turned YouTube content into a searchable knowledge base. Here’s what you learned:
YouTube ingestion: Extract transcripts from playlists and individual videos with a single API call — no manual downloading or processing
Metadata tagging: Label content by type (conference, podcast) during ingestion for downstream filtering
Smart routing: Use an LLM to classify questions and automatically search the right source
Q&A generation: Generate answers with citations from routed results
Video recommendations: Return video suggestions instead of synthesized answers
The YouTube ingestion handles transcript extraction, chunking, and embedding automatically. You can apply the same routing and recommendation patterns to any content type you ingest.