Docs
☁️ Remote Hosting
Hugging Face

Hugging Face Deployment

Create and Configure your Database (Required)

The first thing you need is to create a MongoDB Atlas Database and get your connection string.

Follow the instructions in this document: MongoDB Atlas

Getting Started

1. Login or Create an account on Hugging Face

2. Visit https://huggingface.co/spaces/LibreChat/template and click on Duplicate this Space to copy the LibreChat template into your profile.

Note: It is normal for this template to have a runtime error, you will have to configure it using the following guide to make it functional.

image

3. Name your Space and Fill the Secrets and Variables

You can also decide here to make it public or private

image

You will need to fill these values:

SecretsValues
MONGO_URI* use these instruction to get the string: https://librechat.ai/docs/configuration/mongodb/mongodb_atlas
OPENAI_API_KEYuser_provided
BINGAI_TOKENuser_provided
CHATGPT_TOKENuser_provided
ANTHROPIC_API_KEYuser_provided
GOOGLE_KEYuser_provided
CREDS_KEY* see bellow
CREDS_IV* see bellow
JWT_SECRET* see bellow
JWT_REFRESH_SECRET* see bellow

⬆️ Leave the value field blank for any endpoints that you wish to disable.

⚠️ setting the API keys and token to user_provided allows you to provide them safely from the webUI

  • For CREDS_KEY, CREDS_IV and JWT_SECRET use this tool: Credentials Generator
  • Run the tool a second time and use the new JWT_SECRET value for the JWT_REFRESH_SECRET
VariablesValues
APP_TITLELibreChat
ALLOW_REGISTRATIONtrue

Deployment

1. When you’re done filling the secrets and variables, click Duplicate Space in the bottom of that window

image

2. The project will now build, this will take a couple of minutes

image

3. When ready, Building will change to Running

image

And you will be able to access LibreChat!

image

Update

To update LibreChat, simply select Factory Reboot from the ⚙️Settings menu

image

Conclusion

You can now access it with from the current URL. If you want to access it without the Hugging Face overlay, you can modify this URL template with your info:

https://username-projectname.hf.space/

e.g. https://cooluser-librechat.hf.space/

🎉 Congratulation, you’ve sucessfully deployed LibreChat on Hugging Face! 🤗

Meilisearch Setup (Optional)

To enable the search functionality in LibreChat, you’ll need to deploy and configure a Meilisearch instance. Here’s how:

1. Duplicate the Meilisearch Space:

Visit this link: https://huggingface.co/spaces/LibreChat/meilisearch and click “Duplicate this Space”.

2. Configure the Meilisearch Space:

  • Visibility: Set the visibility to “public”.

  • MEILI_MASTER_KEY: Generate a secure 16-character master key. You can use a tool like https://randomkeygen.com/ to generate a random key. Set this key as the value for the MEILI_MASTER_KEY environment variable in the Meilisearch space. Important: Keep this key secure!

  • MEILI_ENV: Set the MEILI_ENV environment variable to production.

3. Duplicate the Space:

Click the “Duplicate Space” button.

4. Configure LibreChat to use Meilisearch:

  • Edit the Dockerfile: Go to your LibreChat space (the one you duplicated from the main LibreChat template). Navigate to “Files” -> “Dockerfile” and click “Edit”.

  • Uncomment and Modify Lines: Uncomment/edit the following lines in the Dockerfile. These lines will contain ENV SEARCH and ENV MEILI_*. Make sure to replace <YOUR_MEILISEARCH_SPACE_URL> with the actual URL of your Meilisearch deployment on Hugging Face Spaces. It should look something like https://username-meilisearch.hf.space/. Update the username to match your username!

    ENV SEARCH=true
    ENV MEILI_NO_ANALYTICS=true
    ENV MEILI_HOST=<YOUR_MEILISEARCH_SPACE_URL>
  • Commit Changes: Commit your changes to the main branch.

5. Add the MEILI_MASTER_KEY Secret to LibreChat:

  • Go to your LibreChat space’s settings (the LibreChat deployment, not the Meilisearch one).

  • Click “New secret”.

  • Name: Enter MEILI_MASTER_KEY.

  • Value: Enter the same master key you used when setting up the Meilisearch space.

6. Verify the Setup:

After LibreChat rebuilds and starts running, you should see a search option in the top left of the LibreChat interface. If you don’t see it, double-check that you’ve followed all the steps correctly.