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

# Pinecone Async

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

## Code

```python async_pinecone_db.py theme={null}
import asyncio
from os import getenv

from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.pineconedb import PineconeDb

api_key = getenv("PINECONE_API_KEY")
index_name = "thai-recipe-index"

vector_db = PineconeDb(
    name=index_name,
    dimension=1536,
    metric="cosine",
    spec={"serverless": {"cloud": "aws", "region": "us-east-1"}},
    api_key=api_key,
)

knowledge = Knowledge(
    name="My Pinecone Knowledge Base",
    description="This is a knowledge base that uses a Pinecone Vector DB",
    vector_db=vector_db,
)

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

if __name__ == "__main__":
    asyncio.run(
        knowledge.ainsert(
            name="Recipes",
            url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf",
            metadata={"doc_type": "recipe_book"},
        )
    )

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

## Usage

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

**1. Install dependencies**

```bash theme={null}
uv pip install -U pinecone==5.4.2 pypdf openai agno
```

**2. Set environment variables**

```bash theme={null}
export PINECONE_API_KEY="your-pinecone-api-key"
export OPENAI_API_KEY=xxx
```

**3. Run Agent**

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


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