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

# Redis Async

> Load and query a Redis knowledge base asynchronously with ainsert() and aprint_response().

## Code

```python async_redis_db.py theme={null}
import asyncio
import os

from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.redis import RedisDB, SearchType

# Configure Redis connection
REDIS_URL = os.getenv("REDIS_URL", "redis://localhost:6379/0")
INDEX_NAME = os.getenv("REDIS_INDEX", "agno_cookbook_vectors")

# Initialize Redis Vector DB
vector_db = RedisDB(
    index_name=INDEX_NAME,
    redis_url=REDIS_URL,
    search_type=SearchType.vector,  # try SearchType.hybrid for hybrid search
)

knowledge = Knowledge(
    vector_db=vector_db,
)

agent = Agent(knowledge=knowledge)

if __name__ == "__main__":
    asyncio.run(
        knowledge.ainsert(
            url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"
        )
    )

    asyncio.run(agent.aprint_response("How to make Tom Kha Gai", markdown=True))
```

## Usage

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

**1. Install dependencies**

```bash theme={null}
uv pip install -U redis redisvl pypdf openai agno
```

**2. Run Redis**

```bash theme={null}
docker run -d --name my-redis -p 6379:6379 -p 8001:8001 redis/redis-stack:latest
```

**3. Set environment variables**

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

**4. Run Agent**

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


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