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

# Knowledge & RAG

> Build knowledge-augmented agents with vector databases, embedders, and document readers.

Build agents that search and retrieve information from your documents, databases, and APIs.

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

knowledge = Knowledge(
    vector_db=PgVector(table_name="documents", db_url="postgresql://..."),
)

# Add documents from any source
knowledge.insert(url="https://example.com/docs.pdf")
knowledge.insert(path="./local_docs/")

# Create an agent with knowledge
agent = Agent(knowledge=knowledge, search_knowledge=True)
agent.print_response("What does the documentation say about authentication?")
```

## Knowledge Categories

<CardGroup cols={2}>
  <Card title="Vector Databases" icon="database" href="/cookbook/knowledge/vector-databases">
    25+ vector databases including PgVector, Pinecone, Qdrant, Weaviate.
  </Card>

  <Card title="Embedders" icon="code" href="/cookbook/knowledge/embedders">
    29 embedder options from OpenAI, Cohere, HuggingFace, and more.
  </Card>

  <Card title="Document Readers" icon="file" href="/cookbook/knowledge/readers">
    PDF, CSV, JSON, Markdown, PowerPoint, and web content readers.
  </Card>

  <Card title="Chunking" icon="scissors" href="/cookbook/knowledge/chunking">
    Semantic, fixed-size, and custom chunking strategies.
  </Card>
</CardGroup>

## Quick Examples

### Basic Knowledge Base

```python cookbook/07_knowledge/vector_db/pgvector/pgvector_db.py theme={null}
from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.pgvector import PgVector

vector_db = PgVector(
    table_name="recipes",
    db_url="postgresql+psycopg://ai:ai@localhost:5532/ai",
)

knowledge = Knowledge(
    name="Recipe Knowledge",
    vector_db=vector_db,
)

# Add content from URL
knowledge.insert(
    name="Thai Recipes",
    url="https://example.com/recipes.pdf",
)

agent = Agent(
    knowledge=knowledge,
    search_knowledge=True,
)

agent.print_response("How do I make pad thai?", markdown=True)
```

### Multiple Sources

```python cookbook/07_knowledge/basic_operations/sync/04_from_multiple.py theme={null}
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.pgvector import PgVector

knowledge = Knowledge(
    vector_db=PgVector(table_name="docs", db_url="postgresql://..."),
)

# Add from multiple sources
knowledge.insert(path="./documentation/")
knowledge.insert(url="https://docs.example.com/api.pdf")
knowledge.insert(topic="Python best practices")
```

### Async Operations

```python cookbook/07_knowledge/basic_operations/async/01_from_path.py theme={null}
import asyncio
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.pgvector import PgVector

async def build_knowledge():
    knowledge = Knowledge(
        vector_db=PgVector(table_name="docs", db_url="postgresql://..."),
    )

    # Async content loading
    await knowledge.ainsert(path="./large_docs/")

    return knowledge

knowledge = asyncio.run(build_knowledge())
```

## Run Examples

```bash theme={null}
git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/07_knowledge

# PgVector example
python vector_db/pgvector/pgvector_db.py

# Multiple sources
python basic_operations/sync/04_from_multiple.py

# Embedders
python embedders/openai_embedder.py
```
