🔒 Auth

You can configure Chroma to use authentication when in server/client mode only.

Supported authentication methods:

Authentication MethodBasic Auth (Pre-emptive)Static API Token
DescriptionRFC 7617 Basic Auth with user:password base64-encoded Authorization header.Static auth token in Authorization: Bearer <token> or in X-Chroma-Token: <token> headers.
StatusAlphaAlpha
Server-Side SupportAlphaAlpha
Client/PythonAlphaAlpha
Client/JSAlphaAlpha

In this guide we will add authentication to a simple Chroma server running locally using our CLI:

shell

We also have dedicated auth guides for various deployments:

Encrypted User:Password Authentication#

Server Set-Up#

Generate Server-Side Credentials#

To generate the password hash, run the following command (you may need to install httpasswd):

Command Line

This creates the bcrypt password hash for the password admin, for the admin user, and puts it into server.htpasswd in your current working directory. It will look like admin:<password hash>.

Running the Server#

Set the following environment variables:

Command Line

And run the Chroma server:

Command Line

Client Set-Up#

We will use Chroma's Settings object to define the authentication method on the client.

python

We recommend setting the environment variable CHROMA_CLIENT_AUTH_CREDENTIALS instead of specifying the credentials in code.

Static API Token Authentication#

Server Set-Up#

If, for example, you want the static API token to be "test-token", set the following environment variables. This will set Authorization: Bearer test-token as your authentication header.

Command Line

To use X-Chroma-Token: test-token type of authentication header you can set the CHROMA_AUTH_TOKEN_TRANSPORT_HEADER environment variable:

Command Line

Then, run the Chroma server:

Command Line

To configure multiple tokens and use them for role-based access control (RBAC), use a file like this and the following environment variables:

Command Line

Client Set-Up#

We will use Chroma's Settings object to define the authentication method on the client.

python

If you are using a custom CHROMA_AUTH_TOKEN_TRANSPORT_HEADER (like X-Chroma-Token), add it to your Settings:

python

We recommend setting the environment variable CHROMA_CLIENT_AUTH_CREDENTIALS instead of specifying the token in code. Similarly, you can read the value of CHROMA_AUTH_TOKEN_TRANSPORT_HEADER in the client construction.