ChromaDB Quickstart
First insert two documents and retrieve a relevant result. A local client is enough to understand that loop before adding server infrastructure or external providers.
#Install and run a minimal example
bashpip install chromadb
pythonimport chromadb client = chromadb.PersistentClient(path="./my_db") collection = client.get_or_create_collection(name="my_documents") collection.add( documents=["Apple makes the iPhone.", "Microsoft develops Windows."], metadatas=[{"source": "wiki"}, {"source": "wiki"}], ids=["id1", "id2"], ) results = collection.query(query_texts=["Who develops Windows?"], n_results=1) print(results)
The configured/default embedding function may download a local model. Confirm the environment and version requirements before running the example.
#Establish a baseline
Start with documents and metadata, confirm correct retrieval, then evaluate around twenty representative queries before selecting a custom embedding model.
#Storage modes
| Mode | Client | Use |
|---|---|---|
| Temporary | chromadb.Client() | Tests or disposable scripts |
| Persistent | chromadb.PersistentClient(path="./db") | Local persisted data |
| Server | chromadb.HttpClient(host="localhost", port=8000) | A separately operated service |
The source shows a basic Docker server:
bashdocker pull chromadb/chroma docker run -p 8000:8000 chromadb/chroma
This is an illustrative start command, not a complete secure production deployment. Plan persistence, access and versioning for an actual service.