Expand description
Rust client library for the Chroma AI-native database.
This crate provides a comprehensive, production-ready client for interacting with Chroma, an AI-native open-source embedding database. Chroma transforms embeddings into queryable databases, enabling similarity search, filtering, and retrieval operations over high-dimensional vector data.
§Features
- Automatic retries - Configurable exponential backoff with jitter for resilient network operations
- OpenTelemetry support - Optional metrics collection for observability (enable
opentelemetryfeature) - TLS flexibility - Support for both native-tls and rustls backends
§Core Types
ChromaHttpClient- Main client for database-level operations (create/list/delete collections)collection::ChromaCollection- Collection handle for CRUD operations on records (add/get/query/update/delete)ChromaHttpClientOptions- Configuration for client initialization including auth and retry behavior
§Quick Start
§Connecting to Chroma Cloud
use chroma::{ChromaHttpClient, client::ChromaHttpClientOptions, client::ChromaAuthMethod};
let client = ChromaHttpClient::cloud()?;
let heartbeat = client.heartbeat().await?;
println!("Connected! Heartbeat: {}", heartbeat.nanosecond_heartbeat);§Managing Databases
client.create_database("my_database".to_string()).await?;
let databases = client.list_databases().await?;
for db in databases {
println!("Found database: {}", db.name);
}
client.delete_database("my_database".to_string()).await?;§Working with Collections
let collections = client
.list_collections(100, None)
.await?;
for collection in collections {
println!("Collection: {}", collection.name());
}§Authentication
The client supports multiple authentication methods:
- Cloud API Key - For Chroma Cloud deployments using
ChromaAuthMethod::cloud_api_key - Custom Headers - For self-hosted instances with custom auth via
ChromaAuthMethod::HeaderAuth - No Auth - For local development with
ChromaAuthMethod::None
§Error Handling
All operations return Result<T, ChromaHttpClientError> where ChromaHttpClientError
captures network errors, serialization failures, and validation errors.
match client.heartbeat().await {
Ok(response) => println!("Heartbeat: {}", response.nanosecond_heartbeat),
Err(ChromaHttpClientError::RequestError(e)) => eprintln!("Network error: {}", e),
Err(e) => eprintln!("Other error: {}", e),
}§Feature Flags
default- Enablesnative-tlsfor TLS supportnative-tls- Use native system TLS (OpenSSL on Linux, Secure Transport on macOS)rustls- Use pure-Rust TLS implementationopentelemetry- Enable metrics collection for request latency and retry counts
Re-exports§
pub use client::ChromaHttpClient;pub use client::ChromaHttpClientOptions;
Modules§
- client
- Client configuration and connection management for Chroma.
- embed
- Embedding function abstractions for converting text to vector representations.
- types
- Type definitions and re-exports for client requests and responses.
Structs§
- Chroma
Collection - A handle to a specific collection within a Chroma database.