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

# OpenAI Knowledge

> Load a recipe PDF into PgVector with AzureOpenAIEmbedder and query it from an agent.

```python knowledge.py theme={null}
"""Run `uv pip install ddgs sqlalchemy pgvector pypdf openai` to install dependencies."""

import asyncio

from agno.agent import Agent
from agno.knowledge.embedder.azure_openai import AzureOpenAIEmbedder
from agno.knowledge.knowledge import Knowledge
from agno.models.azure import AzureOpenAI
from agno.vectordb.pgvector import PgVector

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

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

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

agent = Agent(
    model=AzureOpenAI(id="gpt-5.2"),
    knowledge=knowledge,
)
agent.print_response("How to make Thai curry?", markdown=True)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    pass
```

## Run the Example

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

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno "psycopg[binary]" beautifulsoup4 openai pgvector pypdf sqlalchemy
```

**2. Export environment variables**

```bash Mac/Linux theme={null}
export AZURE_EMBEDDER_DEPLOYMENT="your_azure_embedder_deployment_here"
export AZURE_EMBEDDER_OPENAI_API_KEY="your_azure_embedder_openai_api_key_here"
export AZURE_EMBEDDER_OPENAI_ENDPOINT="your_azure_embedder_openai_endpoint_here"
export AZURE_OPENAI_API_KEY="your_azure_openai_api_key_here"
export AZURE_OPENAI_DEPLOYMENT="your_azure_openai_deployment_here"
export AZURE_OPENAI_ENDPOINT="your_azure_openai_endpoint_here"
```

```bash Windows theme={null}
$Env:AZURE_EMBEDDER_DEPLOYMENT="your_azure_embedder_deployment_here"
$Env:AZURE_EMBEDDER_OPENAI_API_KEY="your_azure_embedder_openai_api_key_here"
$Env:AZURE_EMBEDDER_OPENAI_ENDPOINT="your_azure_embedder_openai_endpoint_here"
$Env:AZURE_OPENAI_API_KEY="your_azure_openai_api_key_here"
$Env:AZURE_OPENAI_DEPLOYMENT="your_azure_openai_deployment_here"
$Env:AZURE_OPENAI_ENDPOINT="your_azure_openai_endpoint_here"
```

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

**3. Configure Azure deployments**

Confirm that `AZURE_OPENAI_DEPLOYMENT` and `AZURE_EMBEDDER_DEPLOYMENT` refer to deployed `gpt-5.2` and `text-embedding-3-small` resources. Azure API calls use deployment names rather than model names. See [Azure OpenAI deployment setup](https://learn.microsoft.com/en-us/azure/foundry-classic/openai/how-to/create-resource?view=foundry-classic#deploy-a-model).

**4. Run the example**

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

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

Full source: [cookbook/90\_models/azure/openai/knowledge.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/90_models/azure/openai/knowledge.py)


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