> ## Documentation Index
> Fetch the complete documentation index at: https://docs.phidata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Youtube Timestamp Agent

Youtube Timestamp Agent is an agent that can extract the timestamp from a Youtube video.

Create a file `youtube_timestamp_agent.py` with the following code:

```python youtube_timestamp_agent.py theme={null}
from phi.agent import Agent
from phi.model.openai import OpenAIChat
from phi.tools.youtube_tools import YouTubeTools

agent = Agent(
    name="YouTube Timestamps Agent",
    model=OpenAIChat(id="gpt-4o"),
    tools=[YouTubeTools()],
    show_tool_calls=True,
    instructions=[
        "You are a YouTube agent. First check the length of the video. Then get the detailed timestamps for a YouTube video corresponding to correct timestamps.",
        "Don't hallucinate timestamps.",
        "Make sure to return the timestamps in the format of `[start_time, end_time, summary]`.",
    ],
)
agent.print_response(
    "Get the detailed timestamps for this video https://www.youtube.com/watch?v=M5tx7VI-LFA", markdown=True
)
```

## Usage

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install libraries">
    ```bash theme={null}
    pip install openai youtube_transcript_api
    ```
  </Step>

  <Step title="Run the agent">
    ```bash theme={null}
    python youtube_timestamp_agent.py
    ```
  </Step>
</Steps>
