Skip to content

AI Setup

This doc explains how to setup your AI providers, their APIs and credentials.

"Endpoints" refer to the AI provider, configuration or API to use, which determines what models and settings are available for the current chat request.

For example, OpenAI, Google, Plugins, Azure OpenAI, Anthropic, are all different "endpoints". Since OpenAI was the first supported endpoint, it's listed first by default.

Using the default environment values from /.env.example will enable several endpoints, with credentials to be provided on a per-user basis from the web app. Alternatively, you can provide credentials for all users of your instance.

This guide will walk you through setting up each Endpoint as needed.

For custom endpoint configuration, such as adding Mistral AI or Openrouter refer to the librechat.yaml configuration guide .

Reminder: If you use docker, you should rebuild the docker image (here's how) each time you update your credentials

Note: Configuring pre-made Endpoint/model/conversation settings as singular options for your users is a planned feature. See the related discussion here: System-wide custom model settings (lightweight GPTs) #1291


Free AI APIs

Setting a Default Endpoint

In the case where you have multiple endpoints setup, but want a specific one to be first in the order, you need to set the following environment variable.

# .env file
# No spaces between values

Note that LibreChat will use your last selected endpoint when creating a new conversation. So if Azure OpenAI is first in the order, but you used or view an OpenAI conversation last, when you hit "New Chat," OpenAI will be selected with its default conversation settings.

To override this behavior, you need a preset and you need to set that specific preset as the default one to use on every new chat.

Setting a Default Preset

See the Presets Guide for more details

A preset refers to a specific Endpoint/Model/Conversation Settings that you can save.

The default preset will always be used when creating a new conversation.

Here's a video to demonstrate: Setting a Default Preset


To get your OpenAI API key, you need to:

  • Go to
  • Create an account or log in with your existing one
  • Add a payment method to your account (this is not free, sorry ๐Ÿ˜ฌ)
  • Copy your secret key (sk-...) and save it in ./.env as OPENAI_API_KEY


  • Selecting a vision model for messages with attachments is not necessary as it will be switched behind the scenes for you. If you didn't outright select a vision model, it will only be used for the vision request and you should still see the non-vision model you had selected after the request is successful
  • OpenAI Vision models allow for messages without attachments


  • You can determine which models you would like to have available with ASSISTANTS_MODELS ; otherwise, the models list fetched from OpenAI will be used (only Assistants API compatible models will be shown).
# without spaces
  • If necessary, you can also set an alternate base URL instead of the official one with ASSISTANTS_BASE_URL , which is similar to the OpenAI counterpart OPENAI_REVERSE_PROXY
  • There is additional, optional configuration, depending on your needs, such as disabling the assistant builder UI, that are available via the librechat.yaml custom config file :
    • Control the visibility and use of the builder interface for assistants. More info
    • Specify the polling interval in milliseconds for checking run updates or changes in assistant run states. More info
    • Set the timeout period in milliseconds for assistant runs. Helps manage system load by limiting total run operation time. More info
    • Specify which assistant Ids are supported or excluded More info


  • At the time of writing, only the following models support the Retrieval capability:
    • gpt-3.5-turbo-0125
    • gpt-4-0125-preview
    • gpt-4-turbo-preview
    • gpt-4-1106-preview
    • gpt-3.5-turbo-1106
  • Vision capability is not yet supported.
  • If you have previously set the ENDPOINTS value in your .env file , you will need to add the value assistants



For the Google Endpoint, you can either use the Generative Language API (for Gemini models), or the Vertex AI API (for Gemini, PaLM2 & Codey models).

The Generative Language API uses an API key, which you can get from Google AI Studio .

For Vertex AI, you need a Service Account JSON key file, with appropriate access configured.

Instructions for both are given below.

Generative Language API (Gemini)

See here for Gemini API pricing and rate limits

โš ๏ธ While Google models are free, they are using your input/output to help improve the model, with data de-identified from your Google Account and API key. โš ๏ธ During this period, your messages โ€œmay be accessible to trained reviewers.โ€

To use Gemini models through Google AI Studio, you'll need an API key. If you don't already have one, create a key in Google AI Studio.

Get an API key here:

Once you have your key, provide the key in your .env file, which allows all users of your instance to use it.


Or, you can make users provide it from the frontend by setting the following:


Since fetching the models list isn't yet supported, you should set the models you want to use in the .env file.

For your convenience, these are the latest models as of 4/15/24 that can be used with the Generative Language API:


Notes: - A gemini-pro model or gemini-pro-vision are required in your list for attaching images. - Using LibreChat, PaLM2 and Codey models can only be accessed through Vertex AI, not the Generative Language API. - Only models that support the generateContent method can be used natively with LibreChat + the Gen AI API. - Selecting gemini-pro-vision for messages with attachments is not necessary as it will be switched behind the scenes for you - Since gemini-pro-vision does not accept non-attachment messages, messages without attachments are automatically switched to use gemini-pro (otherwise, Google responds with an error) - With the Google endpoint, you cannot use both Vertex AI and Generative Language API at the same time. You must choose one or the other. - Some PaLM/Codey models and gemini-pro-vision may fail when maxOutputTokens is set to a high value. If you encounter this issue, try reducing the value through the conversation parameters.

Setting GOOGLE_KEY=user_provided in your .env file sets both the Vertex AI Service Account JSON key file and the Generative Language API key to be provided from the frontend like so:


Vertex AI

See here for Vertex API pricing and rate limits

To setup Google LLMs (via Google Cloud Vertex AI), first, signup for Google Cloud:

You can usually get $300 starting credit , which makes this option free for 90 days.

1. Once signed up, Enable the Vertex AI API on Google Cloud:

2. Create a Service Account with Vertex AI role:

  • Click here to create a Service Account
  • Select or create a project
  • Enter a service account ID (required), name and description are optional

    • image
  • Click on "Create and Continue" to give at least the "Vertex AI User" role

    • image
  • Click on "Continue/Done"

3. Create a JSON key to Save in your Project Directory:

  • Go back to the Service Accounts page
  • Select your service account
  • Click on "Keys"

    • image
  • Click on "Add Key" and then "Create new key"

    • image
  • Choose JSON as the key type and click on "Create"
  • Download the key file and rename it as 'auth.json'
  • Save it within the project directory, in /api/data/
    • image

Saving your JSON key file in the project directory which allows all users of your LibreChat instance to use it.

Alternatively, you can make users provide it from the frontend by setting the following:

# Note: this configures both the Vertex AI Service Account JSON key file
# and the Generative Language API key to be provided from the frontend.

Since fetching the models list isn't yet supported, you should set the models you want to use in the .env file.

For your convenience, these are the latest models as of 4/15/24 that can be used with the Generative Language API:


Azure OpenAI

Please see the dedicated Azure OpenAI Setup Guide.

This was done to improve upon legacy configuration settings, to allow multiple deployments/model configurations setup with ease: #1390


OpenRouter is a legitimate proxy service to a multitude of LLMs, both closed and open source, including:

  • OpenAI models (great if you are barred from their API for whatever reason)
  • Anthropic Claude models (same as above)
  • Meta's Llama models
  • pygmalionai/mythalion-13b
  • and many more open source models. Newer integrations are usually discounted, too!

See their available models and pricing here: Supported Models

OpenRouter is integrated to the LibreChat by overriding the OpenAI endpoint.

Important : As of v0.6.6, you can use OpenRouter as its own standalone endpoint:

Review the Custom Config Guide (click here) to add an OpenRouter Endpoint


Setup (legacy):

Note: It is NOT recommended to setup OpenRouter this way with versions 0.6.6 or higher of LibreChat as it may be removed in future versions.

As noted earlier, review the Custom Config Guide (click here) to add an OpenRouter Endpoint instead.

  • Signup to OpenRouter and create a key. You should name it and set a limit as well.
  • Set the environment variable OPENROUTER_API_KEY in your .env file to the key you just created.
  • Set something in the OPENAI_API_KEY , it can be anyting, but do not leave it blank or set to user_provided
  • Restart your LibreChat server and use the OpenAI or Plugins endpoints.

Notes (legacy):

  • This will override the official OpenAI API or your reverse proxy settings for both Plugins and OpenAI.
  • On initial setup, you may need to refresh your page twice to see all their supported models populate automatically.
  • Plugins: Functions Agent works with OpenRouter when using OpenAI models.
  • Plugins: Turn functions off to try plugins with non-OpenAI models (ChatGPT plugins will not work and others may not work as expected).
  • Plugins: Make sure PLUGINS_USE_AZURE is not set in your .env file when wanting to use OpenRouter and you have Azure configured.

Unofficial APIs

Important: Stability for Unofficial APIs are not guaranteed. Access methods to these APIs are hacky, prone to errors, and patching, and are marked lowest in priority in LibreChat's development.


I recommend using Microsoft Edge for this:

  • Navigate to Bing Chat
  • Login if you haven't already
  • Initiate a conversation with Bing
  • Open Dev Tools , usually with F12 or Ctrl + Shift + C
  • Navigate to the Network tab
  • Look for lsp.asx (if it's not there look into the other entries for one with a very long cookie)
  • Copy the whole cookie value. (Yes it's very long ๐Ÿ˜‰)
  • Use this "full cookie string" for your "BingAI Token"


That's it! You're all set. ๐ŸŽ‰

โš ๏ธ Note: If you're having trouble, before creating a new issue, please search for similar ones on our #issues thread on our discord or our troubleshooting discussion on our Discussions page. If you don't find a relevant issue, feel free to create a new one and provide as much detail as possible.