Youtube

YouTubeTools let an agent fetch captions, metadata, and timestamps for a YouTube video from its URL.

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 and openai libraries.

uv pip install -U agno youtube_transcript_api openai

Example

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

cookbook/91_tools/youtube_tools.py
from agno.agent import Agent
from agno.tools.youtube import YouTubeTools

agent = Agent(
    tools=[YouTubeTools()],
    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
languagesOptional[List[str]]NoneSpecifies the list of languages for which data should be retrieved, if applicable.
proxiesOptional[Dict[str, Any]]NoneLegacy option; incompatible with the current transcript SDK fetch call. See compatibility below.
timeoutint30Timeout for the metadata/oEmbed request, in seconds; not applied to transcript fetching.
enable_get_video_captionsboolTrueEnable the get_youtube_video_captions functionality.
enable_get_video_databoolTrueEnable the get_youtube_video_data functionality.
enable_get_video_timestampsboolTrueEnable the get_video_timestamps functionality.
allboolFalseEnable all functionality.

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.
get_video_timestampsThis function retrieves the timestamps of a YouTube video.

Transcript availability and proxies

Captions must exist for the requested video and be accessible from the process running this tool. The current adapter passes proxies to the transcript SDK's fetch method, whose current signature does not accept it. Leave proxies=None for this example. When you need a proxy, configure a current YouTubeTranscriptApi client with its supported proxy configuration in a custom tool instead.

Developer Resources