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

# Qdrant

> Using Qdrant as a vector database provider

## Overview

Qdrant is a vector similarity search engine and database. It supports embedded, local, and cloud deployments with HNSW and FLAT indexes, plus advanced features like quantization and payload indexing.

**Provider Class:** `QdrantProvider`\
**Config Class:** `QdrantConfig`

## Install

<Note>
  Install the Qdrant optional dependency group:

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

## Examples

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

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

# Embedded mode
config = QdrantConfig(
    collection_name="my_collection",
    vector_size=1536,
    connection=ConnectionConfig(mode=Mode.EMBEDDED, db_path="./qdrant_db"),
    index=HNSWIndexConfig(m=16, ef_construction=200),
    on_disk_payload=False
)
vectordb = QdrantProvider(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="Find relevant information",
    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       |

### Qdrant-Specific Parameters

| Parameter                  | Type                                      | Description                                                          | Default             | Required |
| -------------------------- | ----------------------------------------- | -------------------------------------------------------------------- | ------------------- | -------- |
| `connection`               | `ConnectionConfig`                        | Connection configuration (mode, db\_path, etc.)                      | -                   | **Yes**  |
| `index`                    | `Union[HNSWIndexConfig, FlatIndexConfig]` | Index type configuration (IVF not supported)                         | `HNSWIndexConfig()` | No       |
| `quantization_config`      | `Optional[Dict[str, Any]]`                | Quantization settings                                                | `None`              | No       |
| `on_disk_payload`          | `bool`                                    | Store payloads on disk                                               | `False`             | No       |
| `write_consistency_factor` | `int`                                     | Write consistency factor                                             | `1`                 | No       |
| `shard_number`             | `Optional[int]`                           | Number of shards                                                     | `None`              | No       |
| `replication_factor`       | `Optional[int]`                           | Replication factor                                                   | `None`              | No       |
| `payload_field_configs`    | `Optional[List[PayloadFieldConfig]]`      | Advanced payload field configurations with types                     | `None`              | No       |
| `dense_vector_name`        | `str`                                     | Dense vector field name                                              | `"dense"`           | No       |
| `sparse_vector_name`       | `str`                                     | Sparse vector field name                                             | `"sparse"`          | No       |
| `use_sparse_vectors`       | `bool`                                    | Enable sparse vector support (requires `hybrid_search_enabled=True`) | `False`             | 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                      |
