!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}return t}()||function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}(),document.documentElement.setAttribute("data-announcement-bar-initially-dismissed",function(){try{return"true"===localStorage.getItem("docusaurus.announcement.dismiss")}catch(t){}return!1}())

[Skip to main content](#__docusaurus_skipToContent_fallback)

LangChain v0.2 is coming soon! Preview the new docs [here](/v0.2/docs/introduction/).

[

![🦜️🔗 Langchain](/v0.1/img/brand/wordmark.png)![🦜️🔗 Langchain](/v0.1/img/brand/wordmark-dark.png)

](/v0.1/)[Docs](/v0.1/docs/get_started/introduction/)[Use cases](/v0.1/docs/use_cases/)[Integrations](/v0.1/docs/integrations/platforms/)[API Reference](https://api.js.langchain.com)

[More](#)

*   [People](/v0.1/docs/people/)
*   [Community](/v0.1/docs/community/)
*   [Tutorials](/v0.1/docs/additional_resources/tutorials/)
*   [Contributing](/v0.1/docs/contributing/)

[v0.1](#)

*   [v0.2](https://js.langchain.com/v0.2/docs/introduction)
*   [v0.1](/v0.1/docs/get_started/introduction/)

[🦜🔗](#)

*   [LangSmith](https://smith.langchain.com)
*   [LangSmith Docs](https://docs.smith.langchain.com)
*   [LangChain Hub](https://smith.langchain.com/hub)
*   [LangServe](https://github.com/langchain-ai/langserve)
*   [Python Docs](https://python.langchain.com/)

[Chat](https://chatjs.langchain.com)[](https://github.com/langchain-ai/langchainjs)

Search

*   [Providers](/v0.1/docs/integrations/platforms/)
    
    *   [Providers](/v0.1/docs/integrations/platforms/)
    *   [Anthropic](/v0.1/docs/integrations/platforms/anthropic/)
    *   [AWS](/v0.1/docs/integrations/platforms/aws/)
    *   [Google](/v0.1/docs/integrations/platforms/google/)
    *   [Microsoft](/v0.1/docs/integrations/platforms/microsoft/)
    *   [OpenAI](/v0.1/docs/integrations/platforms/openai/)
*   [Components](/v0.1/docs/integrations/components/)
    
    *   [LLMs](/v0.1/docs/integrations/llms/)
        
    *   [Chat models](/v0.1/docs/integrations/chat/)
        
    *   [Document loaders](/v0.1/docs/integrations/document_loaders/)
        
    *   [Document transformers](/v0.1/docs/integrations/document_transformers/)
        
    *   [Document compressors](/v0.1/docs/integrations/document_compressors/)
        
    *   [Text embedding models](/v0.1/docs/integrations/text_embedding/)
        
    *   [Vector stores](/v0.1/docs/integrations/vectorstores/)
        
        *   [Memory](/v0.1/docs/integrations/vectorstores/memory/)
        *   [AnalyticDB](/v0.1/docs/integrations/vectorstores/analyticdb/)
        *   [Astra DB](/v0.1/docs/integrations/vectorstores/astradb/)
        *   [Azure AI Search](/v0.1/docs/integrations/vectorstores/azure_aisearch/)
        *   [Azure Cosmos DB](/v0.1/docs/integrations/vectorstores/azure_cosmosdb/)
        *   [Cassandra](/v0.1/docs/integrations/vectorstores/cassandra/)
        *   [Chroma](/v0.1/docs/integrations/vectorstores/chroma/)
        *   [ClickHouse](/v0.1/docs/integrations/vectorstores/clickhouse/)
        *   [CloseVector](/v0.1/docs/integrations/vectorstores/closevector/)
        *   [Cloudflare Vectorize](/v0.1/docs/integrations/vectorstores/cloudflare_vectorize/)
        *   [Convex](/v0.1/docs/integrations/vectorstores/convex/)
        *   [Couchbase](/v0.1/docs/integrations/vectorstores/couchbase/)
        *   [Elasticsearch](/v0.1/docs/integrations/vectorstores/elasticsearch/)
        *   [Faiss](/v0.1/docs/integrations/vectorstores/faiss/)
        *   [Google Vertex AI Matching Engine](/v0.1/docs/integrations/vectorstores/googlevertexai/)
        *   [SAP HANA Cloud Vector Engine](/v0.1/docs/integrations/vectorstores/hanavector/)
        *   [HNSWLib](/v0.1/docs/integrations/vectorstores/hnswlib/)
        *   [LanceDB](/v0.1/docs/integrations/vectorstores/lancedb/)
        *   [Milvus](/v0.1/docs/integrations/vectorstores/milvus/)
        *   [Momento Vector Index (MVI)](/v0.1/docs/integrations/vectorstores/momento_vector_index/)
        *   [MongoDB Atlas](/v0.1/docs/integrations/vectorstores/mongodb_atlas/)
        *   [MyScale](/v0.1/docs/integrations/vectorstores/myscale/)
        *   [Neo4j Vector Index](/v0.1/docs/integrations/vectorstores/neo4jvector/)
        *   [Neon Postgres](/v0.1/docs/integrations/vectorstores/neon/)
        *   [OpenSearch](/v0.1/docs/integrations/vectorstores/opensearch/)
        *   [PGVector](/v0.1/docs/integrations/vectorstores/pgvector/)
        *   [Pinecone](/v0.1/docs/integrations/vectorstores/pinecone/)
        *   [Prisma](/v0.1/docs/integrations/vectorstores/prisma/)
        *   [Qdrant](/v0.1/docs/integrations/vectorstores/qdrant/)
        *   [Redis](/v0.1/docs/integrations/vectorstores/redis/)
        *   [Rockset](/v0.1/docs/integrations/vectorstores/rockset/)
        *   [SingleStore](/v0.1/docs/integrations/vectorstores/singlestore/)
        *   [Supabase](/v0.1/docs/integrations/vectorstores/supabase/)
        *   [Tigris](/v0.1/docs/integrations/vectorstores/tigris/)
        *   [Turbopuffer](/v0.1/docs/integrations/vectorstores/turbopuffer/)
        *   [TypeORM](/v0.1/docs/integrations/vectorstores/typeorm/)
        *   [Typesense](/v0.1/docs/integrations/vectorstores/typesense/)
        *   [Upstash Vector](/v0.1/docs/integrations/vectorstores/upstash/)
        *   [USearch](/v0.1/docs/integrations/vectorstores/usearch/)
        *   [Vectara](/v0.1/docs/integrations/vectorstores/vectara/)
        *   [Vercel Postgres](/v0.1/docs/integrations/vectorstores/vercel_postgres/)
        *   [Voy](/v0.1/docs/integrations/vectorstores/voy/)
        *   [Weaviate](/v0.1/docs/integrations/vectorstores/weaviate/)
        *   [Xata](/v0.1/docs/integrations/vectorstores/xata/)
        *   [Zep](/v0.1/docs/integrations/vectorstores/zep/)
    *   [Retrievers](/v0.1/docs/integrations/retrievers/)
        
    *   [Tools](/v0.1/docs/integrations/tools/)
        
    *   [Agents and toolkits](/v0.1/docs/integrations/toolkits/)
        
    *   [Chat Memory](/v0.1/docs/integrations/chat_memory/)
        
    *   [Stores](/v0.1/docs/integrations/stores/)
        

*   [](/v0.1/)
*   [Components](/v0.1/docs/integrations/components/)
*   [Vector stores](/v0.1/docs/integrations/vectorstores/)
*   Chroma

On this page

Chroma
======

> [Chroma](https://docs.trychroma.com/getting-started) is a AI-native open-source vector database focused on developer productivity and happiness. Chroma is licensed under Apache 2.0.

[![Discord](https://img.shields.io/discord/1073293645303795742)](https://discord.gg/MMeYNTmh3x)  [![License](https://img.shields.io/static/v1?label=license&message=Apache 2.0&color=white)](https://github.com/chroma-core/chroma/blob/master/LICENSE)  ![Integration Tests](https://github.com/chroma-core/chroma/actions/workflows/chroma-integration-test.yml/badge.svg?branch=main)

*   [Website](https://www.trychroma.com/)
*   [Documentation](https://docs.trychroma.com/)
*   [Twitter](https://twitter.com/trychroma)
*   [Discord](https://discord.gg/MMeYNTmh3x)

Setup[​](#setup "Direct link to Setup")
---------------------------------------

1.  Run Chroma with Docker on your computer

    git clone git@github.com:chroma-core/chroma.gitcd chromadocker-compose up -d --build

2.  Install the Chroma JS SDK.

*   npm
*   Yarn
*   pnpm

    npm install -S chromadb

    yarn add chromadb

    pnpm add chromadb

Chroma is fully-typed, fully-tested and fully-documented.

Like any other database, you can:

*   `.add`
*   `.get`
*   `.update`
*   `.upsert`
*   `.delete`
*   `.peek`
*   and `.query` runs the similarity search.

View full docs at [docs](https://docs.trychroma.com/js_reference/Collection).

Usage, Index and query Documents[​](#usage-index-and-query-documents "Direct link to Usage, Index and query Documents")
-----------------------------------------------------------------------------------------------------------------------

tip

See [this section for general instructions on installing integration packages](/v0.1/docs/get_started/installation/#installing-integration-packages).

*   npm
*   Yarn
*   pnpm

    npm install @langchain/openai @langchain/community

    yarn add @langchain/openai @langchain/community

    pnpm add @langchain/openai @langchain/community

    import { Chroma } from "@langchain/community/vectorstores/chroma";import { OpenAIEmbeddings } from "@langchain/openai";import { TextLoader } from "langchain/document_loaders/fs/text";// Create docs with a loaderconst loader = new TextLoader("src/document_loaders/example_data/example.txt");const docs = await loader.load();// Create vector store and index the docsconst vectorStore = await Chroma.fromDocuments(docs, new OpenAIEmbeddings(), {  collectionName: "a-test-collection",  url: "http://localhost:8000", // Optional, will default to this value  collectionMetadata: {    "hnsw:space": "cosine",  }, // Optional, can be used to specify the distance method of the embedding space https://docs.trychroma.com/usage-guide#changing-the-distance-function});// Search for the most similar documentconst response = await vectorStore.similaritySearch("hello", 1);console.log(response);/*[  Document {    pageContent: 'Foo\nBar\nBaz\n\n',    metadata: { source: 'src/document_loaders/example_data/example.txt' }  }]*/

#### API Reference:

*   [Chroma](https://api.js.langchain.com/classes/langchain_community_vectorstores_chroma.Chroma.html) from `@langchain/community/vectorstores/chroma`
*   [OpenAIEmbeddings](https://api.js.langchain.com/classes/langchain_openai.OpenAIEmbeddings.html) from `@langchain/openai`
*   [TextLoader](https://api.js.langchain.com/classes/langchain_document_loaders_fs_text.TextLoader.html) from `langchain/document_loaders/fs/text`

Usage, Index and query texts[​](#usage-index-and-query-texts "Direct link to Usage, Index and query texts")
-----------------------------------------------------------------------------------------------------------

    import { Chroma } from "@langchain/community/vectorstores/chroma";import { OpenAIEmbeddings } from "@langchain/openai";// text sample from Godel, Escher, Bachconst vectorStore = await Chroma.fromTexts(  [    `Tortoise: Labyrinth? Labyrinth? Could it Are we in the notorious Little        Harmonic Labyrinth of the dreaded Majotaur?`,    "Achilles: Yiikes! What is that?",    `Tortoise: They say-although I person never believed it myself-that an I        Majotaur has created a tiny labyrinth sits in a pit in the middle of        it, waiting innocent victims to get lost in its fears complexity.        Then, when they wander and dazed into the center, he laughs and        laughs at them-so hard, that he laughs them to death!`,    "Achilles: Oh, no!",    "Tortoise: But it's only a myth. Courage, Achilles.",  ],  [{ id: 2 }, { id: 1 }, { id: 3 }],  new OpenAIEmbeddings(),  {    collectionName: "godel-escher-bach",  });const response = await vectorStore.similaritySearch("scared", 2);console.log(response);/*[  Document { pageContent: 'Achilles: Oh, no!', metadata: {} },  Document {    pageContent: 'Achilles: Yiikes! What is that?',    metadata: { id: 1 }  }]*/// You can also filter by metadataconst filteredResponse = await vectorStore.similaritySearch("scared", 2, {  id: 1,});console.log(filteredResponse);/*[  Document {    pageContent: 'Achilles: Yiikes! What is that?',    metadata: { id: 1 }  }]*/

#### API Reference:

*   [Chroma](https://api.js.langchain.com/classes/langchain_community_vectorstores_chroma.Chroma.html) from `@langchain/community/vectorstores/chroma`
*   [OpenAIEmbeddings](https://api.js.langchain.com/classes/langchain_openai.OpenAIEmbeddings.html) from `@langchain/openai`

Usage, Query docs from existing collection[​](#usage-query-docs-from-existing-collection "Direct link to Usage, Query docs from existing collection")
-----------------------------------------------------------------------------------------------------------------------------------------------------

    import { Chroma } from "@langchain/community/vectorstores/chroma";import { OpenAIEmbeddings } from "@langchain/openai";const vectorStore = await Chroma.fromExistingCollection(  new OpenAIEmbeddings(),  { collectionName: "godel-escher-bach" });const response = await vectorStore.similaritySearch("scared", 2);console.log(response);/*[  Document { pageContent: 'Achilles: Oh, no!', metadata: {} },  Document {    pageContent: 'Achilles: Yiikes! What is that?',    metadata: { id: 1 }  }]*/

#### API Reference:

*   [Chroma](https://api.js.langchain.com/classes/langchain_community_vectorstores_chroma.Chroma.html) from `@langchain/community/vectorstores/chroma`
*   [OpenAIEmbeddings](https://api.js.langchain.com/classes/langchain_openai.OpenAIEmbeddings.html) from `@langchain/openai`

Usage, delete docs[​](#usage-delete-docs "Direct link to Usage, delete docs")
-----------------------------------------------------------------------------

    import { Chroma } from "@langchain/community/vectorstores/chroma";import { OpenAIEmbeddings } from "@langchain/openai";const embeddings = new OpenAIEmbeddings();const vectorStore = new Chroma(embeddings, {  collectionName: "test-deletion",});const documents = [  {    pageContent: `Tortoise: Labyrinth? Labyrinth? Could it Are we in the notorious Little    Harmonic Labyrinth of the dreaded Majotaur?`,    metadata: {      speaker: "Tortoise",    },  },  {    pageContent: "Achilles: Yiikes! What is that?",    metadata: {      speaker: "Achilles",    },  },  {    pageContent: `Tortoise: They say-although I person never believed it myself-that an I    Majotaur has created a tiny labyrinth sits in a pit in the middle of    it, waiting innocent victims to get lost in its fears complexity.    Then, when they wander and dazed into the center, he laughs and    laughs at them-so hard, that he laughs them to death!`,    metadata: {      speaker: "Tortoise",    },  },  {    pageContent: "Achilles: Oh, no!",    metadata: {      speaker: "Achilles",    },  },  {    pageContent: "Tortoise: But it's only a myth. Courage, Achilles.",    metadata: {      speaker: "Tortoise",    },  },];// Also supports an additional {ids: []} parameter for upsertionconst ids = await vectorStore.addDocuments(documents);const response = await vectorStore.similaritySearch("scared", 2);console.log(response);/*[  Document { pageContent: 'Achilles: Oh, no!', metadata: {} },  Document {    pageContent: 'Achilles: Yiikes! What is that?',    metadata: { id: 1 }  }]*/// You can also pass a "filter" parameter insteadawait vectorStore.delete({ ids });const response2 = await vectorStore.similaritySearch("scared", 2);console.log(response2);/*  []*/

#### API Reference:

*   [Chroma](https://api.js.langchain.com/classes/langchain_community_vectorstores_chroma.Chroma.html) from `@langchain/community/vectorstores/chroma`
*   [OpenAIEmbeddings](https://api.js.langchain.com/classes/langchain_openai.OpenAIEmbeddings.html) from `@langchain/openai`

* * *

#### Help us out by providing feedback on this documentation page:

[

Previous

Cassandra

](/v0.1/docs/integrations/vectorstores/cassandra/)[

Next

ClickHouse

](/v0.1/docs/integrations/vectorstores/clickhouse/)

*   [Setup](#setup)
*   [Usage, Index and query Documents](#usage-index-and-query-documents)
*   [Usage, Index and query texts](#usage-index-and-query-texts)
*   [Usage, Query docs from existing collection](#usage-query-docs-from-existing-collection)
*   [Usage, delete docs](#usage-delete-docs)

Community

*   [Discord](https://discord.gg/cU2adEyC7w)
*   [Twitter](https://twitter.com/LangChainAI)

GitHub

*   [Python](https://github.com/langchain-ai/langchain)
*   [JS/TS](https://github.com/langchain-ai/langchainjs)

More

*   [Homepage](https://langchain.com)
*   [Blog](https://blog.langchain.dev)

Copyright © 2024 LangChain, Inc.