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

# Agent with Knowledge

> Load a PDF into PgVector and query it with a Llama agent.

## Code

```python knowledge.py theme={null}
from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.models.meta import Llama
from agno.vectordb.pgvector import PgVector

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

knowledge = Knowledge(
    vector_db=PgVector(table_name="recipes", db_url=db_url),
)
# Add content to the knowledge
knowledge.insert(
    url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"
)

agent = Agent(
    model=Llama(id="Llama-4-Maverick-17B-128E-Instruct-FP8"), knowledge=knowledge
)
agent.print_response("How to make Thai curry?", markdown=True)

```

## Usage

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

**1. Set your API keys**

```bash theme={null}
export LLAMA_API_KEY=YOUR_API_KEY
export OPENAI_API_KEY=YOUR_API_KEY
```

**2. Install dependencies**

```bash theme={null}
uv pip install llama-api-client sqlalchemy psycopg pgvector pypdf openai agno
```

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

**3. Run Agent**

Save the code above as `knowledge.py`, then run:

```bash theme={null}
python knowledge.py
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.