> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langtrace.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# ChromaDB

> Chroma gives you the tools to store embeddings and their metadata.

Chroma is a AI-native open-source vector database focused on developer productivity and happiness. Chroma is licensed under Apache 2.0.

<iframe width="560" height="315" src="https://www.youtube.com/embed/DFgngVQ3hUM?si=Jr2LhsTAY7bR4Uh1" title="YouTube video player" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerPolicy="strict-origin-when-cross-origin" allowFullScreen />

## Setup

1. Install Langtrace's SDK and [initialize](/quickstart) the SDK in your code.

Install Chroma with:

<CodeGroup>
  ```bash Python theme={null}
  pip install chromadb
  ```

  ```bash Typescript theme={null}
  yarn install chromadb chromadb-default-embed
  ```
</CodeGroup>

## Usage

Here's a quick example of how to use Langtrace with LlamaIndex:

```typescript Typescript SDK theme={null}
import * as Langtrace from "@langtrase/typescript-sdk";
import { ChromaClient, OpenAIEmbeddingFunction } from "chromadb";

Langtrace.init({ write_spans_to_console: true });

export async function run(): Promise<void> {
	await Langtrace.withLangTraceRootSpan(async () => {
		const client = new ChromaClient();
		const embedder = new OpenAIEmbeddingFunction({
			openai_api_key: process.env.OPENAI_API_KEY as string,
		});
		console.info("Creating collection");
		const collection = await client.getOrCreateCollection({
			name: "test_collection",
			embeddingFunction: embedder,
		});

		console.info("Adding documents");
		await collection.add({
			ids: ["id1", "id2"],
			metadatas: [{ source: "my_source" }, { source: "my_source" }],
			documents: ["This is a document", "This is another document"],
		});
		console.info("Querying documents");
		const results = await collection.query({
			nResults: 2,
			queryTexts: ["This is a query document"],
		});

		console.info(results);
	});
}
void run().then(() => console.log("done"));
```

* [Python Notebook](https://github.com/Scale3-Labs/langtrace-docs/blob/main/langtrace-examples/chroma-example/chroma-starter.py.ipynb)

* [Google Collab](https://colab.research.google.com/github/Scale3-Labs/langtrace-docs/blob/main/langtrace-examples/chroma-example/chroma-starter.py.ipynb)

That's it! ✨ 🧙‍♂️ Enjoy debugging your Chroma applications using Langtrace.
