Learn R Programming

rchroma

rchroma provides a clean interface to ChromaDB, a modern vector database for storing and querying embeddings.

Installation

You can isntall rchroma from CRAN:

install.packages("rchroma")

Or you can install the developer version from GitHub:

# install.packages("remotes")
remotes::install_github("cynkra/rchroma")

You also need a running ChromaDB instance. The easiest way to get started is using the provided Docker helper functions:

chroma_docker_run()
# use chroma_docker_stop() to stop the container

See the ChromaDB documentation for other installation methods.

Usage

library(rchroma)

# Connect to ChromaDB
client <- chroma_connect()

# Create a collection and add documents with embeddings
create_collection(client, "my_collection")
add_documents(
  client,
  "my_collection",
  documents = c("apple", "banana"),
  ids = c("doc1", "doc2"),
  embeddings = list(
    c(1.0, 0.0), # apple
    c(0.8, 0.2) # banana (similar to apple)
  )
)

# Query similar documents using embeddings
query(
  client,
  "my_collection",
  query_embeddings = list(c(1.0, 0.0)), # should match apple best
  n_results = 2
)

Copy Link

Version

Install

install.packages('rchroma')

Monthly Downloads

249

Version

0.2.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

David Schoch

Last Published

March 26th, 2025

Functions in rchroma (0.2.0)

get_database

Get a Database
get_collection

Get a Collection
reset

Reset ChromaDB
list_collections

List Collections in a Database
update_collection

Update a Collection
update_documents

Update Documents in a Collection
delete_documents

Delete Documents from a Collection
upsert_documents

Upsert Documents to a Collection
get_auth_identity

Get Authentication Identity
version

Get ChromaDB Server Version
pre_flight_checks

Get ChromaDB Server Information
add_documents

Add Documents to a Collection
create_collection

Create a Collection in ChromaDB
chroma_docker_stop

Stop ChromaDB Docker Container
chroma_docker_run

Start ChromaDB Docker Container
delete_collection

Delete a Collection
create_tenant

Create a Tenant
chroma_docker_running

Check ChromaDB Docker Container Status
chroma_connect

ChromaDB Client
count_collections

Count Collections in a Database
get_tenant

Get a Tenant
create_database

Create a Database
heartbeat

Check ChromaDB Server Heartbeat
query

Query Documents in a Collection