YouTubeTools enable an Agent to access captions and metadata of YouTube videos, when provided with a video URL.

Prerequisites

The following example requires the youtube_transcript_api library.

pip install -U youtube_transcript_api

Example

The following agent will provide a summary of a YouTube video.

cookbook/tools/youtube_tools.py
from phi.agent import Agent
from phi.tools.youtube_tools import YouTubeTools

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

agent.print_response("Summarize this video https://www.youtube.com/watch?v=Iv9dewmcFbs&t", markdown=True)

Toolkit Params

ParamTypeDefaultDescription
get_video_captionsboolTrueEnables the functionality to retrieve video captions.
get_video_databoolTrueEnables the functionality to retrieve video metadata and other related data.
languagesList[str]-Specifies the list of languages for which data should be retrieved, if applicable.

Toolkit Functions

FunctionDescription
get_youtube_video_captionsThis function retrieves the captions of a YouTube video.
get_youtube_video_dataThis function retrieves the metadata of a YouTube video.

Information