> ## 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

> Give a Cerebras agent knowledge from a PDF stored in PgVector.

## Code

```python knowledge.py theme={null}
from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.models.cerebras import Cerebras
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=Cerebras(id="gpt-oss-120b"), knowledge=knowledge)
agent.print_response("How to make Thai curry?", markdown=True)
```

## Usage

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

**1. Set your API key**

```bash theme={null}
export CEREBRAS_API_KEY=xxx
export OPENAI_API_KEY=xxx
```

**2. Install dependencies**

```bash theme={null}
uv pip install -U agno openai sqlalchemy psycopg pgvector pypdf cerebras-cloud-sdk
```

**3. Start your Postgres server**

Ensure your Postgres server is running and accessible at the connection string used in `db_url`.

**4. Run Agent (first time)**

The first run will load and index the PDF. This may take a while.
Save the code above as `knowledge.py`, then run:

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

**5. Subsequent Runs**

After the first run, comment out or remove the `knowledge.insert(...)` call to avoid reloading the PDF each time.


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