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

# Async LanceDB Usage

> Insert knowledge and run an agent with Agno's async methods and a LanceDB backend.

```python async_lance_db.py theme={null}
import asyncio

from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.lancedb import LanceDb

knowledge = Knowledge(
    vector_db=LanceDb(
        table_name="async_recipes",
        uri="tmp/lancedb",
    )
)
agent = Agent(knowledge=knowledge, search_knowledge=True)


async def main() -> None:
    await knowledge.ainsert(
        name="Recipes",
        url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf",
        metadata={"doc_type": "recipe_book"},
    )
    await agent.aprint_response(
        "List the ingredients for Massaman Gai.",
        markdown=True,
    )


if __name__ == "__main__":
    asyncio.run(main())
```

`Knowledge.ainsert()` awaits reader and embedding work. In Agno v2.7.2, `LanceDb.async_upsert()` calls the synchronous upsert and table methods, and `LanceDb.async_search()` calls the synchronous search directly.

> [!WARNING]
>
> For LanceDB Cloud async calls, set `LANCEDB_API_KEY` in the environment. Passing only `api_key=` authenticates the synchronous connection, while the v2.7.2 adapter does not forward that value to `lancedb.connect_async()`.

## Run the Example

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

**1. Install dependencies**

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

**2. Export the API key**

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

**3. Run the example**

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

## Next Steps

| Task | Guide |
| - | - |
| Use the synchronous API | [LanceDB usage](https://agno-v2.mintlify.site/knowledge/vector-stores/lancedb/usage/lance-db.md) |
| Configure search behavior | [LanceDB overview](https://agno-v2.mintlify.site/knowledge/vector-stores/lancedb/overview.md) |


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