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

# ChromaDB Vector Database

> Use ChromaDB as a vector database for your Knowledge Base.

## Setup

```shell theme={null}
uv pip install -U chromadb pypdf openai agno
```

## Example

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

from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.chroma import ChromaDb

# Create Knowledge Instance with ChromaDB
knowledge = Knowledge(
    name="Basic SDK Knowledge Base",
    description="Agno 2.0 Knowledge Implementation with ChromaDB",
    vector_db=ChromaDb(
        collection="vectors", path="tmp/chromadb", persistent_client=True
    ),
)

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

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

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

### For hosted ChromaDB (Chroma Cloud)

```python theme={null}
from chromadb.config import Settings

vector_db = ChromaDb(
    collection="vectors",
    tenant="your-tenant",
    database="your-database",
    settings=Settings(
        chroma_api_impl="chromadb.api.fastapi.FastAPI",
        chroma_server_host="api.trychroma.com",
        chroma_server_http_port=443,
        chroma_server_ssl_enabled=True,
        chroma_client_auth_provider="chromadb.auth.token_authn.TokenAuthClientProvider",
        chroma_client_auth_credentials="your-api-key",
        chroma_auth_token_transport_header="X-Chroma-Token",
    ),
)
```

The `tenant`, `database`, and `settings` arguments are forwarded to the ChromaDB client.

> **Async Support ⚡**
>
> ChromaDB also supports asynchronous operations, enabling concurrency and leading to better performance.
>
> ```python async_chroma_db.py theme={null}
> import asyncio
>
> from agno.agent import Agent
> from agno.knowledge.knowledge import Knowledge
> from agno.vectordb.chroma import ChromaDb
>
> # Initialize ChromaDB
> vector_db = ChromaDb(collection="recipes", path="tmp/chromadb", persistent_client=True)
>
> # Create knowledge base
> knowledge = Knowledge(
>     vector_db=vector_db,
> )
>
> # Create and use the agent
> agent = Agent(knowledge=knowledge)
>
> if __name__ == "__main__":
>     # Comment out after first run
>     asyncio.run(
>         knowledge.ainsert(url="https://docs.agno.com/agents/overview.md")
>     )
>
>     # Create and use the agent
>     asyncio.run(
>         agent.aprint_response("What is the purpose of an Agno Agent?", markdown=True)
>     )
> ```
>
> > [!TIP]
> >
> > Use `ainsert()` and `aprint_response()` methods with `asyncio.run()` for non-blocking operations in high-throughput applications.

> [!NOTE]
>
> ChromaDB has a batch size limit due to SQLite constraints.
> When inserting documents that exceed this limit, Agno automatically splits them into smaller batches.
> The batch size is auto-detected from ChromaDB's server configuration.
>
> You can also set `batch_size` to override the auto-detected value.

## ChromaDb Params

<Snippet file="vectordb_chromadb_params.mdx" />


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