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

# YouTube Reader

> Fetch a YouTube transcript and convert it into knowledge documents.

`YouTubeReader` fetches the transcript for a YouTube watch URL and applies recursive chunking by default.

```python youtube_reader.py theme={null}
from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.knowledge.reader.youtube_reader import YouTubeReader
from agno.models.openai import OpenAIResponses
from agno.vectordb.pgvector import PgVector

db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"

knowledge = Knowledge(
    name="YouTube Knowledge Base",
    description="Knowledge base from YouTube video transcripts",
    vector_db=PgVector(
        table_name="youtube_vectors",
        db_url=db_url,
    ),
)

agent = Agent(
    model=OpenAIResponses(id="gpt-5.2"),
    knowledge=knowledge,
    search_knowledge=True,
)

if __name__ == "__main__":
    knowledge.insert(
        url="https://www.youtube.com/watch?v=nLkBNnnA8Ac",
        metadata={"source": "youtube", "type": "educational"},
        reader=YouTubeReader(),
    )
    agent.print_response(
        "What are the main topics discussed in the video?",
        markdown=True,
    )
```

## Run the Agent

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

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U "agno[youtube]" openai pgvector psycopg sqlalchemy
    ```
  </Step>

  <Step title="Export the API key">
    ```bash theme={null}
    export OPENAI_API_KEY=your_openai_api_key_here
    ```
  </Step>

  <Snippet file="run-pgvector-step.mdx" />

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

## Reader Parameters

<Snippet file="youtube-reader-reference.mdx" />

<Warning>
  Use `Knowledge.insert()` with `YouTubeReader` in v2.7.2. `Knowledge.ainsert()` passes a document name to `YouTubeReader.async_read()`, which accepts only the URL, so asynchronous knowledge ingestion fails.
</Warning>

## Next Steps

| Task                         | Guide                                                                 |
| ---------------------------- | --------------------------------------------------------------------- |
| Configure recursive chunking | [Recursive Chunking](/knowledge/concepts/chunking/recursive-chunking) |
| Inspect the complete API     | [YouTube Reader Reference](/reference/knowledge/reader/youtube)       |
| Compare available readers    | [Readers Overview](/knowledge/concepts/readers/overview)              |
