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

# Weaviate

> Insert a PDF, search it with an agent, and delete Weaviate records by name or metadata.

## Code

```python weaviate_db.py theme={null}
from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.search import SearchType
from agno.vectordb.weaviate import Distance, VectorIndex, Weaviate

vector_db = Weaviate(
    collection="vectors",
    search_type=SearchType.vector,
    vector_index=VectorIndex.HNSW,
    distance=Distance.COSINE,
    local=False,  # Set to True if using Weaviate locally
)

# Create Knowledge Instance with Weaviate
knowledge = Knowledge(
    name="Basic SDK Knowledge Base",
    description="Agno 2.0 Knowledge Implementation with Weaviate",
    vector_db=vector_db,
)

knowledge.insert(
    name="Recipes",
    url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf",
    metadata={"doc_type": "recipe_book"},
    skip_if_exists=True,
)

# Create and use the agent
agent = Agent(knowledge=knowledge)
agent.print_response("List down the ingredients to make Massaman Gai", markdown=True)

# Delete operations
vector_db.delete_by_name("Recipes")
# or
vector_db.delete_by_metadata({"doc_type": "recipe_book"})
```

## Usage

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

**1. Install dependencies**

```bash theme={null}
uv pip install -U weaviate-client pypdf openai agno
```

**2. Setup Weaviate**

```bash Weaviate Cloud theme={null}
# 1. Create account at https://console.weaviate.cloud/
# 2. Create a cluster and copy the "REST endpoint" and "Admin" API Key
# 3. Set environment variables:
export WCD_URL="your-cluster-url"
export WCD_API_KEY="your-api-key"
# 4. Set local=False in the code
```

```bash Local Development theme={null}
# 1. Install Docker from https://docs.docker.com/get-docker/
# 2. Run Weaviate locally:
docker run -d \
    -p 8080:8080 \
    -p 50051:50051 \
    --name weaviate \
    cr.weaviate.io/semitechnologies/weaviate:1.28.4
# 3. Set local=True in the code
```

**3. Set environment variables**

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

**4. Run Agent**

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


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