> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upsonic.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Chroma

> Using ChromaDB as a vector database provider

## Overview

ChromaDB is an open-source vector database designed for embedding search and similarity matching. It supports embedded, local, and cloud deployments with HNSW and FLAT index types.

**Provider Class:** `ChromaProvider`\
**Config Class:** `ChromaConfig`

## Install

<Note>
  Install the Chroma optional dependency group:

  ```bash theme={null}
    uv pip install "upsonic[chroma]"
  ```
</Note>

## Examples

```python theme={null}
from upsonic import Agent, Task, KnowledgeBase
from upsonic.embeddings import OpenAIEmbedding, OpenAIEmbeddingConfig
from upsonic.vectordb import ChromaProvider, ChromaConfig, ConnectionConfig, Mode, HNSWIndexConfig

# Setup embedding provider
embedding = OpenAIEmbedding(OpenAIEmbeddingConfig())

# Embedded mode (local file storage)
config = ChromaConfig(
    collection_name="my_collection",
    vector_size=1536,
    connection=ConnectionConfig(mode=Mode.EMBEDDED, db_path="./chroma_db"),
    index=HNSWIndexConfig(m=16, ef_construction=200)
)
vectordb = ChromaProvider(config)

# Create knowledge base
kb = KnowledgeBase(
    sources="document.pdf",
    embedding_provider=embedding,
    vectordb=vectordb
)

# Use with Agent
agent = Agent("anthropic/claude-sonnet-4-5")
task = Task(
    description="What is this document about?",
    context=[kb]
)
result = agent.do(task)
```

## Parameters

### Base Parameters (from BaseVectorDBConfig)

| Parameter | Type | Description | Default | Required |
| - | - | - | - | - |
| `collection_name` | `str` | Name of the collection | `"default_collection"` | No |
| `vector_size` | `int` | Dimension of vectors | - | **Yes** |
| `distance_metric` | `DistanceMetric` | Similarity metric (`COSINE`, `EUCLIDEAN`, `DOT_PRODUCT`) | `COSINE` | No |
| `recreate_if_exists` | `bool` | Recreate collection if it exists | `False` | No |
| `default_top_k` | `int` | Default number of results | `10` | No |
| `default_similarity_threshold` | `Optional[float]` | Minimum similarity score (0.0-1.0) | `None` | No |
| `dense_search_enabled` | `bool` | Enable dense vector search | `True` | No |
| `full_text_search_enabled` | `bool` | Enable full-text search | `True` | No |
| `hybrid_search_enabled` | `bool` | Enable hybrid search | `True` | No |
| `default_hybrid_alpha` | `float` | Default alpha for hybrid search (0.0-1.0) | `0.5` | No |
| `default_fusion_method` | `Literal['rrf', 'weighted']` | Default fusion method for hybrid search | `'weighted'` | No |
| `provider_name` | `Optional[str]` | Provider name | `None` | No |
| `provider_description` | `Optional[str]` | Provider description | `None` | No |
| `provider_id` | `Optional[str]` | Provider ID | `None` | No |
| `default_metadata` | `Optional[Dict[str, Any]]` | Default metadata for all records | `None` | No |
| `indexed_fields` | `Optional[List[Union[str, Dict[str, Any]]]]` | Fields to index for filtering | `None` | No |

### Chroma-Specific Parameters

| Parameter | Type | Description | Default | Required |
| - | - | - | - | - |
| `connection` | `ConnectionConfig` | Connection configuration (mode, db\_path, etc.) | - | **Yes** |
| `index` | `Union[HNSWIndexConfig, FlatIndexConfig]` | Index type configuration | `HNSWIndexConfig()` | No |
| `tenant` | `Optional[str]` | Tenant name for multi-tenancy | `None` | No |
| `database` | `Optional[str]` | Database name | `None` | No |

### ConnectionConfig Parameters

| Parameter | Type | Description | Default | Required |
| - | - | - | - | - |
| `mode` | `Mode` | Connection mode (`EMBEDDED`, `LOCAL`, `CLOUD`, `IN_MEMORY`) | - | **Yes** |
| `db_path` | `Optional[str]` | Path for embedded/local storage | `None` | Required for `EMBEDDED` |
| `host` | `Optional[str]` | Host address | `None` | Required for `LOCAL` |
| `port` | `Optional[int]` | Port number | `None` | Required for `LOCAL` |
| `api_key` | `Optional[SecretStr]` | API key for cloud/local | `None` | Required for `CLOUD` |
| `url` | `Optional[str]` | Full connection URL | `None` | No |
| `use_tls` | `bool` | Use TLS encryption | `True` | No |
| `grpc_port` | `Optional[int]` | gRPC port | `None` | No |
| `prefer_grpc` | `bool` | Prefer gRPC over HTTP | `False` | No |
| `https` | `Optional[bool]` | Use HTTPS | `None` | No |
| `prefix` | `Optional[str]` | URL path prefix | `None` | No |
| `timeout` | `Optional[float]` | Request timeout in seconds | `None` | No |
| `location` | `Optional[str]` | Special location string | `None` | No |


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