Skip to content

Vector Database Connectors

To persist agent conversation histories, perform similarity searches, and manage long-term contexts, Elsai provides a unified vector store interface under elsai.integrations.elsai_vectordb.

The database clients can be registered directly onto your MemoryConfig similarity search setup.


Installation

Ensure you have the elsai-vectordb extra or the standalone elsai-model package installed:

bash
pip install --extra-index-url https://core-packages.elsai.ai/root/elsai-model/ elsai-model

Vector Clients Factory

You can initialize a vector store using explicit configurations or system environment variables:

1. build_vectordb_client(config: VectorBackendConfig)

Initializes a client explicitly using configuration parameters.

python
from elsai.integrations.elsai_vectordb import VectorBackendConfig, build_vectordb_client

config = VectorBackendConfig(
    provider="chroma",
    collection_name="chat_logs",
    persist_directory="./chroma_data",
)
db_client = build_vectordb_client(config)

2. build_vectordb_client_from_env(provider=None)

Loads database credentials and index configuration directly from environment variables.

python
import os
from elsai.integrations.elsai_vectordb import build_vectordb_client_from_env

# Configure environment
os.environ["VECTORDB_PROVIDER"] = "chroma"
os.environ["CHROMA_PERSIST_DIRECTORY"] = "./chroma_data"

db_client = build_vectordb_client_from_env()

Supported Vector Databases

Chroma DB

Chroma is a lightweight, local vector database ideal for development, testing, and embedded setups.

  • Client configuration attributes (VectorBackendConfig):
    • provider: "chroma"
    • collection_name: Name of the Chroma collection.
    • persist_directory: Local filesystem directory path to save vector indexes. Defaults to CHROMA_PERSIST_DIRECTORY env var.

Example

python
from elsai.integrations.elsai_vectordb import VectorBackendConfig, build_vectordb_client

chroma_client = build_vectordb_client(
    VectorBackendConfig(
        provider="chroma",
        collection_name="agent_history",
        persist_directory="./chroma_db",
    )
)

Pinecone

Pinecone is a fully managed cloud vector database suitable for large-scale production setups.

  • Client configuration attributes (VectorBackendConfig):
    • provider: "pinecone"
    • pinecone_api_key: Your Pinecone API key. Defaults to PINECONE_API_KEY env var.
    • index_name: Pinecone index name. Defaults to PINECONE_INDEX_NAME env var.
    • namespace: Optional Pinecone query namespace. Defaults to PINECONE_NAMESPACE env var.
    • dimension: Vector dimensions size (e.g. 1536 for OpenAI). Defaults to PINECONE_DIMENSION env var.

Example

python
import os
from elsai.integrations.elsai_vectordb import VectorBackendConfig, build_vectordb_client

pinecone_client = build_vectordb_client(
    VectorBackendConfig(
        provider="pinecone",
        pinecone_api_key=os.environ.get("PINECONE_API_KEY"),
        index_name="my-global-index",
        dimension=1536,
    )
)

Weaviate

Weaviate is an open-source vector database supporting both self-hosted local hosts and cloud-hosted instances.

  • Client configuration attributes (VectorBackendConfig):
    • provider: "weaviate"
    • collection_name: Collection (or Class) name.
    • connection_type: "local" (for self-hosted hosts) or "cloud" (for cloud instances).
    • host / port: Host and port details (local connection).
    • cluster_url: Cloud endpoint URL (cloud connection).
    • auth_credentials: Authentication keys (cloud connection).
    • use_default_vectorizer: Set to True if using Weaviate's native embedding module. Default: False.

Example (Local Weaviate)

python
from elsai.integrations.elsai_vectordb import VectorBackendConfig, build_vectordb_client

weaviate_client = build_vectordb_client(
    VectorBackendConfig(
        provider="weaviate",
        collection_name="AgentMemory",
        connection_type="local",
        host="localhost",
        port=8080,
    )
)

Copyright © 2026 Elsai Foundry.