Hey Ajika,
Just wanted to reply so you’re not left hanging, and also so this can serve as a reference for anyone else running into issues with YoutubeChannelSearchTool
or YoutubeVideoSearchTool
. Heads up – they’re broken right now!
Since it looks like from your example you were interested in testing out the YoutubeChannelSearchTool
to search the @CircleCI-Videos
YouTube channel using Google models, here’s a full example to really nail down how you’d typically set up the tool correctly (even though it won’t work at the moment):
import os
from crewai import Agent, Crew, LLM, Process, Task
from crewai_tools import YoutubeChannelSearchTool
# Set your Gemini API key (used by LiteLLM for the LLM)
os.environ["GEMINI_API_KEY"] = "YOUR_KEY"
# Set your Google API key (used by Embedchain for embeddings)
os.environ["GOOGLE_API_KEY"] = os.environ["GEMINI_API_KEY"]
embedchain_config = {
"embedder": {
"provider": "google",
"config": {
"model": "models/text-embedding-004",
"task_type": "RETRIEVAL_DOCUMENT"
}
}
}
youtube_search_tool = YoutubeChannelSearchTool(
youtube_channel_handle="@CircleCI-Videos",
config=embedchain_config
)
gemini_llm = LLM(
model="gemini/gemini-2.5-flash-preview-04-17",
temperature=0.3
)
blog_researcher_agent = Agent(
role="Blog Creator from Youtube Videos",
goal=(
"Get the relevant video content for the given topic "
"from youtube channel"
),
backstory=(
"Expert in understanding videos in crime, fun and entertainment "
"and providing suggestion"
),
tools=[youtube_search_tool],
allow_delegation=False,
verbose=False,
llm=gemini_llm
)
blog_writer_agent = Agent(
role="Blog Writer from Youtube Videos",
goal=(
"Narrate compelling blog content from the video content for "
"the given topic"
),
backstory=(
"With a flair for simplifying complex topics, you craft engaging "
"narratives that captivate and educate, bringing new discoveries "
"to light in an accessible manner."
),
tools=[youtube_search_tool],
allow_delegation=False,
verbose=False,
llm=gemini_llm
)
research_task = Task(
description=(
"Identify the video '{topic}'. "
"Get detailed information about the video from the channel"
),
expected_output=(
"A comprehensive 3 paragraphs long report based on "
"'{topic}' of video content"
),
agent=blog_researcher_agent
)
writing_task = Task(
description=(
"Get the info from the youtube channel on topic '{topic}'."
),
expected_output=(
"Summarize the info from youtube channel video on the topic "
"'{topic}' and create the content for the blog"
),
agent=blog_writer_agent
)
blog_crew = Crew(
agents=[blog_researcher_agent, blog_writer_agent],
tasks=[research_task, writing_task],
process=Process.sequential,
verbose=True
)
result = blog_crew.kickoff(
inputs={"topic": "7 tips for effective system prompting"}
)
print(f"\n🤖 Final Report:\n\n{result.raw}")
Like I mentioned, this code isn’t actually going to run because the RAG tool itself is busted. As you probably know, CrewAI’s RAG tools use the Embedchain library under the hood by default. And Embedchain itself is having trouble adding YouTube channels (or even single videos) as a data source right now. The issue seems to stem from the pytube
library, which Embedchain relies on for YouTube scraping.
Here’s some simpler code using just Embedchain that shows even trying to add a single video throws an error:
from embedchain import App
import os
os.environ["GOOGLE_API_KEY"] = "YOUR_KEY"
embedchain_config = {
"embedder": {
"provider": "google",
"config": {
"model": "models/text-embedding-004",
"task_type": "RETRIEVAL_DOCUMENT"
}
}
}
app = App.from_config(config=embedchain_config)
app.add("https://www.youtube.com/watch?v=MvzmUdMg7wg", data_type="youtube_video")
result = app.search("7 tips for effective system prompting")
print(result)
Finally, just a heads-up: even if the code worked, that @CircleCI-Videos
channel has over 400 videos. When Embedchain tries to scrape all of them to build its index, you’d probably get your IP blocked by YouTube pretty quickly for excessive requests (happened to me!). So, keep that potential issue in mind for when the tools are fixed.