Registry / vector-search / chromadb-client

chromadb-client

JSON →
library1.5.9pypypi✓ verified 22d ago

ChromaDB Client is a lightweight Python HTTP client for interacting with a running ChromaDB server. It provides a programmatic interface to store, query, and manage vector embeddings, enabling integration with AI applications for tasks like semantic search and Retrieval-Augmented Generation (RAG). The library is actively maintained with frequent releases, typically on a weekly or bi-weekly cadence.

pip install chromadb-client
INSTALL
IMPORT
SIG · CHROMADB-CLIENT
C
chromadb-client
vector-searchpythonv1.5.9
Install
10.3s avg
Import
2499ms
Disk
145MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.5.9 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 2.770s · 144.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 10.3s · import 2.228s · 138MB
145MB installed
● package 145MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

HttpClient
from chromadb import HttpClient
from chromadb import Client
The `chromadb-client` package provides `HttpClient` for connecting to a server. `Client`, `PersistentClient`, and `EphemeralClient` are part of the full `chromadb` package, not `chromadb-client`.
Collection
collection = client.create_collection(...)
Collection objects are returned by client methods after client initialization.

This quickstart demonstrates how to connect to a ChromaDB server using `chromadb.HttpClient`, create a collection, add documents with metadata, and perform a similarity search. It includes an example of filtering results by metadata and ensuring embeddings are returned.

import chromadb import os # Connect to a running ChromaDB server (replace with your server's host and port) # For local testing, ensure a ChromaDB server is running (e.g., `chroma run --path /path/to/db`) # Or connect to a Chroma Cloud instance. client = chromadb.HttpClient(host=os.environ.get('CHROMADB_HOST', 'localhost'), port=int(os.environ.get('CHROMADB_PORT', 8000))) # Create a collection collection_name = "my_documents" try: collection = client.create_collection(name=collection_name) print(f"Collection '{collection_name}' created.") except Exception as e: print(f"Collection '{collection_name}' might already exist or error: {e}. Attempting to get it.") collection = client.get_or_create_collection(name=collection_name) # Add documents to the collection collection.add( documents=["This is document1 about cats", "This is document2 about dogs", "A third document on artificial intelligence"], metadatas=[ {"source": "blog", "category": "pets"}, {"source": "website", "category": "pets"}, {"source": "article", "category": "tech"} ], ids=["doc1", "doc2", "doc3"] ) print(f"Added {collection.count()} documents.") # Query the collection results = collection.query( query_texts=["tell me about animals"], n_results=2, where={"category": "pets"}, include=["documents", "metadatas", "distances"] ) print("\nQuery Results:") for i, doc in enumerate(results['documents'][0]): print(f" Document: {doc}") print(f" Metadata: {results['metadatas'][0][i]}") print(f" Distance: {results['distances'][0][i]}") # Clean up (optional, for demonstration) # client.delete_collection(name=collection_name) # print(f"Collection '{collection_name}' deleted.")
Debug
Known issues
breakingMajor breaking changes occurred around ChromaDB v1.0.0 (March 2025), which involved a rewrite in Rust and significant API restructuring. This affects method names, return types, and how clients interact with the server's various functionalities (e.g., `client.health.*`, `client.collections.*`). Ensure your client code is updated if upgrading from pre-1.0.0 versions.
fix
Refer to the official ChromaDB migration guides for v1.0.0 for specific API changes and update your client code accordingly. This may involve changes in import patterns, client instantiation, and method calls (e.g., `client.heartbeat()` might become `client.health.heartbeat()`).
affects: <1.0.0
gotchaBy default, `collection.query()` and `collection.get()` methods do not return embeddings to reduce payload size. If you need the embeddings, you must explicitly include them in the `include` parameter.
fix
When calling `query()` or `get()`, add `include=['embeddings', 'documents', 'metadatas', 'distances']` to retrieve the desired information, e.g., `results = collection.query(..., include=['documents', 'embeddings'])`.
affects: All versions
gotchaRunning ChromaDB in 'library mode' (e.g., using `chromadb.PersistentClient` embedded directly within an application) with multiple worker processes (like Gunicorn) can lead to stale data. Each worker might maintain its own in-memory index, unaware of changes made by other workers.
fix
For production deployments with multiple workers, always run ChromaDB in 'server mode' as a separate process (e.g., `chroma run --path /path/to/db`). Your `chromadb-client` instances should then connect to this central server via HTTP.
affects: All versions when using library mode for the server
gotchaThere can be cross-version incompatibilities between the `chromadb-client` and the ChromaDB server, especially with older server versions and newer clients (e.g., clients v0.5.1+ might not communicate with servers v0.5.0 or lower).
fix
Always ensure your `chromadb-client` version is compatible with your ChromaDB server version. It's generally recommended to keep both client and server updated to the latest stable release or to match versions explicitly to avoid unexpected behavior.
affects: All versions, specifically across major/minor version boundaries
Errors
Common errors & fixes
ConnectionRefusedError: [Errno 111] Connection refused
The ChromaDB server is not running or is not accessible at the specified host and port, preventing the client from establishing a connection.
fix
Ensure the ChromaDB server is running and accessible from your client. If running locally, start the server; if remote, verify the host, port, and network connectivity (e.g., firewalls). 

Example (running a local server via Docker for HTTP client):
```python
import chromadb

# Ensure ChromaDB server is running, e.g., via Docker:
# docker run -p 8000:8000 chromadb/chroma

client = chromadb.HttpClient(host='localhost', port=8000)
print(client.heartbeat())
```
ValueError: You must provide an embedding function to compute embeddings.
The `chromadb-client` package is a lightweight HTTP client and does not include a default embedding function to reduce its size. You need to explicitly provide one when creating or getting a collection.
fix
Instantiate and pass an embedding function (e.g., from `chromadb.utils.embedding_functions` or a custom one) when creating or getting a collection.
```python
import chromadb
from chromadb.utils import embedding_functions

client = chromadb.HttpClient(host='localhost', port=8000) # Or PersistentClient if using the full chromadb package

# Using a Sentence Transformer embedding function
sentence_transformer_ef = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="all-MiniLM-L6-v2")

collection = client.get_or_create_collection(
    name="my_collection", 
    embedding_function=sentence_transformer_ef
)

collection.add(documents=["This is a test document"], metadatas=[{"source": "my_doc"}], ids=["doc1"])
```
ModuleNotFoundError: No module named 'chromadb'
This error typically occurs when the `chromadb-client` package is installed, but the code attempts to import modules or classes (like `chromadb` or `chromadb.config`) that are part of the full `chromadb` server package, or when `chromadb` is expected as a dependency but not installed.
fix
If you intend to use the full ChromaDB server functionalities (including local persistence), ensure you install the complete `chromadb` package, not just `chromadb-client`. If you only need the HTTP client, import `chromadb.HttpClient` directly or ensure that `chromadb` (the full package) is installed if other libraries implicitly require it.

To install the full `chromadb` package:
`pip install chromadb`

Then, for an HTTP client:
```python
import chromadb # This would now refer to the full package which includes HttpClient
client = chromadb.HttpClient(host='localhost', port=8000)
```

If you only have `chromadb-client` installed and specifically want the client, ensure you import correctly:
```python
import chromadb.api.segment # Example of a valid import within chromadb-client
from chromadb.api.segment import API # Or chromadb.HttpClient

# Note: chromadb-client does not expose chromadb.Client() directly for a local client.
# You would typically use chromadb.HttpClient.
```
AttributeError: module 'chromadb' has no attribute 'PersistentClient'
This error arises when the `chromadb-client` package is installed, which only provides an HTTP client interface, but the code attempts to use `chromadb.PersistentClient`, which is a feature of the full `chromadb` server package for local, persistent storage.
fix
To use `PersistentClient`, you must install the full `chromadb` package instead of `chromadb-client`. The `chromadb-client` is designed for remote interactions with a running ChromaDB server.

Install the full `chromadb` package:
`pip install chromadb`

Then, use `PersistentClient`:
```python
import chromadb

client = chromadb.PersistentClient(path="./my_chroma_db")
collection = client.get_or_create_collection(name="my_persistent_collection")
```

If you intended to use an HTTP client with `chromadb-client`, use `chromadb.HttpClient`:
```python
import chromadb

client = chromadb.HttpClient(host='localhost', port=8000) # Assumes a ChromaDB server is running
collection = client.get_or_create_collection(name="my_http_collection")
```
Upgrade
Version history
1.5.9latest on PyPI · released May 5, 2026
Audit
Dependencies
pydantic-settingsrequiredUsed for managing client configuration settings.
Agent activity
60 hits · last 30 days
node
52
OpenAI (training)
1
Resources
chromadb-client — pip install chromadb-client · libregistry