YouTube Tools

Fetch YouTube video captions and answer questions about the video with YouTubeTools.

youtube_tools.py
"""
Youtube Tools
=============================

Demonstrates youtube tools.
"""

from agno.agent import Agent
from agno.tools.youtube import YouTubeTools

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------


agent = Agent(
    tools=[YouTubeTools()],
    description="You are a YouTube agent. Obtain the captions of a YouTube video and answer questions.",
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    agent.print_response(
        "Summarize this video https://www.youtube.com/watch?v=Iv9dewmcFbs&t",
        markdown=True,
    )

The answer is based on available captions and video metadata. This toolkit does not inspect video frames or transcribe audio when captions are unavailable. Use a video with accessible captions, and set languages=["en"] or another available language list when needed.

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno openai youtube-transcript-api

Export your OpenAI API key

export OPENAI_API_KEY="your_openai_api_key_here"

Run the example

Save the code above as youtube_tools.py, then run:

python youtube_tools.py

Full source: cookbook/91_tools/youtube_tools.py