> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-studio-tools-doc.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 chromadb
```

## 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({"user_tag": "Recipes from website"})
```

### For hosted ChromaDB (Chroma Cloud)

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

vector_db = ChromaDb(
    collection="vectors",
    settings=Settings(
        chroma_api_impl="chromadb.api.fastapi.FastAPI",
        chroma_server_host="your-tenant-id.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"
    )
)
```

<Card title="Async Support ⚡">
  <div className="mt-2">
    <p>
      ChromaDB also supports asynchronous operations, enabling concurrency and leading to better performance.
    </p>

    ```python async_chroma_db.py theme={null}
    # install chromadb - `pip install chromadb`

    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/introduction/agents.md")
        )

        # Create and use the agent
        asyncio.run(
            agent.aprint_response("What is the purpose of an Agno Agent?", markdown=True)
        )
    ```

    <Tip className="mt-4">
      Use <code>ainsert()</code> and <code>aprint\_response()</code> methods with <code>asyncio.run()</code> for non-blocking operations in high-throughput applications.
    </Tip>
  </div>
</Card>

<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.
</Note>

## ChromaDb Params

<Snippet file="vectordb_chromadb_params.mdx" />
