> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agno.com/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

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

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

  <Step title="Export environment variables">
    <CodeGroup>
      ```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"
      ```
    </CodeGroup>
  </Step>

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

  <Step title="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).
  </Step>

  <Step title="Run the example">
    Save the code above as `knowledge.py`, then run:

    ```bash theme={null}
    python knowledge.py
    ```
  </Step>
</Steps>

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