* feat: assistant name/icon in Landing & Header * feat: assistname in textarea placeholder, and use `Assistant` as default name * feat: display non-image files in user messages * fix: only render files if files.length is > 0 * refactor(config -> file-config): move file related configuration values to separate module, add excel types * chore: spreadsheet file rendering * fix(Landing): dark mode style for Assistant Name * refactor: move progress incrementing to own hook, start smaller, cap near limit \(1\) * refactor(useContentHandler): add empty Text part if last part was completed tool or image * chore: add accordion trigger border styling for dark mode * feat: Assistant Builder model selection * chore: use Spinner when Assistant is mutating * fix(get/assistants): return correct response object `AssistantListResponse` * refactor(Spinner): pass size as prop * refactor: make assistant crud mutations optimistic, add types for options * chore: remove assistants route and view * chore: move assistant builder components to separate directory * feat(ContextButton): delete Assistant via context button/dialog, add localization * refactor: conditionally show use and context menu buttons, add localization for create assistant * feat: save side panel states to localStorage * style(SidePanel): improve avatar menu and assistant select styling for dark mode * refactor: make NavToggle reusable for either side (left or right), add SidePanel Toggle with ability to close it completely * fix: resize handle and navToggle behavior * fix(/avatar/:assistant_id): await `deleteFile` and assign unique name to uploaded image * WIP: file UI components from PR #576 * refactor(OpenAIMinimalIcon): pass className * feat: formatDate helper fn * feat: DataTableColumnHeader * feat: add row selection, formatted row values, number of rows selected * WIP: add files to Side panel temporarily * feat: `LB_QueueAsyncCall`: Leaky Bucket queue for external APIs, use in `processDeleteRequest` * fix(TFile): correct `source` type with `FileSources` * fix(useFileHandling): use `continue` instead of return when iterating multiple files, add file type to extendedFile * chore: add generic setter type * refactor(processDeleteRequest): settle promises to prevent rejections from processing deletions, log errors * feat: `useFileDeletion` to reuse file deletion logic * refactor(useFileDeletion): make `setFiles` an optional param and use object as param * feat: useDeleteFilesFromTable * feat: use real `files` data and add deletion action to data table * fix(Table): make headers sticky * feat: add dynamic filtering for columns; only show to user Host or OpenAI storage type * style(DropdownMenu): replace `slate` with `gray` * style(DataTable): apply dark mode themes and other misc styling * style(Columns): add color to OpenAI Storage option * refactor(FileContainer): make file preview reusable * refactor(Images): make image preview reusable * refactor(FilePreview): make file prop optional for FileIcon and FilePreview, fix relative style * feat(Columns): add file/image previews, set a minimum size to show for file size in bytes * WIP: File Panel with real files and formatted * feat: open files dialog from panel * style: file data table mobile and general column styling fixes * refactor(api/files): return files sorted by the most recently updated * refactor: provide fileMap through context to prevent re-selecting files to map in different areas; remove unused imports commented out in PanelColumns * refactor(ExtendFile): make File type optional, add `attached` to prevent attached files from being deleted on remove, make Message.files a partial TFile type * feat: attach files through file panel * refactor(useFileHandling): move files to the start of cache list when uploaded * refactor(useDeleteFilesMutation): delete files from cache when successfully deleted from server * fix(FileRow): handle possible edge case of duplication due to attaching recently uploaded file * style(SidePanel): make resize grip border transparent, remove unnecessary styling on close sidepanel button * feat: action utilities and tests * refactor(actions): add `ValidationResult` type and change wording for no server URL found * refactor(actions): check for empty server URL * fix(data-provider): revert tsconfig to fix type issue resolution * feat(client): first pass of actions input for assistants * refactor(FunctionSignature): change method to output object instead of string * refactor(models/Assistant): add actions field to schema, use searchParams object for methods, and add `getAssistant` * feat: post actions input first pass - create new Action document - add actions to Assistant DB document - create /action/:assistant_id POST route - pass more props down from PanelSwitcher, derive assistant_id from switcher - move privacy policy to ActionInput - reset data on input change/validation - add `useUpdateAction` - conform FunctionSignature type to FunctionTool - add action, assistant doc, update hook related types * refactor: optimize assistant/actions relationship - past domain in metadata as hostname and not a URL - include domain in tool name - add `getActions` for actions retrieval by user - add `getAssistants` for assistant docs retrieval by user - add `assistant_id` to Action schema - move actions to own module as a subroute to `api/assistants` - add `useGetActionsQuery` and `useGetAssistantDocsQuery` hooks - fix Action type def * feat: show assistant actions in assistant builder * feat: switch to actions on action click, editing action styling * fix: add Assistant state for builder panel to allow immediate selection of newly created assistants as well as retaining the current assistant when switching to a different panel within the builder * refactor(SidePanel/NavToggle): offset less from right when SidePanel is completely collapsed * chore: rename `processActions` -> `processRequiredActions` * chore: rename Assistant API Action to RequiredAction * refactor(actions): avoid nesting actual API params under generic `requestBody` to optimize LLM token usage * fix(handleTools): avoid calling `validTool` if not defined, add optional param to skip the loading of specs, which throws an error in the context of assistants * WIP: working first pass of toolCalls generated from openapi specs * WIP: first pass ToolCall styling * feat: programmatic iv encryption/decryption helpers * fix: correct ActionAuth types/enums, and define type for AuthForm * feat: encryption/decryption helpers for Action AuthMetadata * refactor(getActions): remove sensitive fields from query response * refactor(POST/actions): encrypt and remove sensitive fields from mutation response * fix(ActionService): change ESM import to CJS * feat: frontend auth handling for actions + optimistic update on action update/creation * refactor(actions): use the correct variables and types for setAuth method * refactor: POST /:assistant_id action can now handle updating an existing action, add `saved_auth_fields` to determine when user explicitly saves new auth creds. only send auth metadata if user explicitly saved fields * refactor(createActionTool): catch errors and send back meaningful error message, add flag to `getActions` to determine whether to retrieve sensitive values or not * refactor(ToolService): add `action` property to ToolCall PartMetadata to determine if the tool call was an action, fix parsing function name issue with actionDelimiter * fix(ActionRequest): use URL class to correctly join endpoint parts for `execute` call * feat: delete assistant actions * refactor: conditionally show Available actions * refactor: show `retrieval` and `code_interpreter` as Capabilities, swap `Switch` for `Checkbox` * chore: remove shadow-stroke from messages * WIP: first pass of Assistants Knowledge attachments * refactor: remove AssistantsProvider in favor of FormProvider, fix selectedAssistant re-render bug, map Assistant file_ids to files via fileMap, initialize Knowledge component with mapped files if any exist * fix: prevent deleting files on assistant file upload * chore: remove console.log * refactor(useUploadFileMutation): update files and assistants cache on upload * chore: disable oauth option as not supported yet * feat: cancel assistant runs * refactor: initialize OpenAI client with helper function, resolve all related circular dependencies * fix(DALL-E): initialization * fix(process): openai client initialization * fix: select an existing Assistant when the active one is deleted * chore: allow attaching files for assistant endpoint, send back relevant OpenAI error message when uploading, deconstruct openAI initialization correctly, add `message_file` to formData when a file is attached to the message but not the assistant * fix: add assistant_id on newConvo * fix(initializeClient): import fix * chore: swap setAssistant for setOption in useEffect * fix(DALL-E): add processFileURL to loadTools call * chore: add customConfig to debug logs * feat: delete threads on convo delete * chore: replace Assistants icon * chore: remove console.dir() in `abortRun` * feat(AssistantService): accumulate text values from run in openai.responseText * feat: titling for assistants endpoint * chore: move panel file components to appropriate directory, add file checks for attaching files, change icon for Attach Files * refactor: add localizations to tools, plugins, add condition for adding/remove user plugins so tool selections don't affect this value * chore: disable `import from url` action for now * chore: remove textMimeTypes from default fileConfig for now * fix: catch tool errors and send as outputs with error messages * fix: React warning about button as descendant of button * style: retrieval and cancelled icon * WIP: pass isSubmitting to Parts, use InProgressCall to display cancelled tool calls correctly, show domain/function name * fix(meilisearch): fix `postSaveHook` issue where indexing expects a mongo document, and join all text content parts for meili indexing * ci: fix dall-e tests * ci: fix client tests * fix: button types in actions panel * fix: plugin auth form persisting across tool selections * fix(ci): update AppService spec with `loadAndFormatTools` * fix(clearConvos): add id check earlier on * refactor(AssistantAvatar): set previewURL dynamically when emtadata.avatar changes * feat(assistants): addTitle cache setting * fix(useSSE): resolve rebase conflicts * fix: delete mutation * style(SidePanel): make grip visible on active and hover, invisible otherwise * ci: add data-provider tests to workflow, also update eslint/tsconfig to recognize specs, and add `text/csv` to fileConfig * fix: handle edge case where auth object is undefined, and log errors * refactor(actions): resolve schemas, add tests for resolving refs, import specs from separate file for tests * chore: remove comment * fix(ActionsInput): re-render bug when initializing states with action fields * fix(patch/assistant): filter undefined tools * chore: add logging for errors in assistants routes * fix(updateAssistant): map actions to functions to avoid overwriting * fix(actions): properly handle GET paths * fix(convos): unhandled delete thread exception * refactor(AssistantService): pass both thread_id and conversationId when sending intermediate assistant messages, remove `mapMessagesToSteps` from AssistantService * refactor(useSSE): replace all messages with runMessages and pass latestMessageId to abortRun; fix(checkMessageGaps): include tool calls when syncing messages * refactor(assistants/chat): invoke `createOnTextProgress` after thread creation * chore: add typing * style: sidepanel styling * style: action tool call domain styling * feat(assistants): default models, limit retrieval to certain models, add env variables to to env.example * feat: assistants api key in EndpointService * refactor: set assistant model to conversation on assistant switch * refactor: set assistant model to conversation on assistant select from panel * fix(retrieveAndProcessFile): catch attempt to download file with `assistant` purpose which is not allowed; add logging * feat: retrieval styling, handling, and logging * chore: rename ASSISTANTS_REVERSE_PROXY to ASSISTANTS_BASE_URL * feat: FileContext for file metadata * feat: context file mgmt and filtering * style(Select): hover/rounded changes * refactor: explicit conversation switch, endpoint dependent, through `useSelectAssistant`, which does not create new chat if current endpoint is assistant endpoint * fix(AssistantAvatar): make empty previewURL if no avatar present * refactor: side panel mobile styling * style: merge tool and action section, optimize mobile styling for action/tool buttons * fix: localStorage issues * fix(useSelectAssistant): invoke react query hook directly in select hook as Map was not being updated in time * style: light mode fixes * fix: prevent sidepanel nav styling from shifting layout up * refactor: change default layout (collapsed by default) * style: mobile optimization of DataTable * style: datatable * feat: client-side hide right-side panel * chore(useNewConvo): add partial typing for preset * fix(useSelectAssistant): pass correct model name by using template as preset * WIP: assistant presets * refactor(ToolService): add native solution for `TavilySearchResults` and log tool output errors * refactor: organize imports and use native TavilySearchResults * fix(TavilySearchResults): stringify result * fix(ToolCall): show tool call outputs when not an action * chore: rename Prompt Prefix to custom instructions (in user facing text only) * refactor(EditPresetDialog): Optimize setting title by debouncing, reset preset on dialog close to avoid state mixture * feat: add `presetOverride` to overwrite active conversation settings when saving a Preset (relevant for client side updates only) * feat: Assistant preset settings (client-side) * fix(Switcher): only set assistant_id and model if current endpoint is Assistants * feat: use `useDebouncedInput` for updating conversation settings, starting with EditPresetDialog title setting and Assistant instructions setting * feat(Assistants): add instructions field to settings * feat(chat/assistants): pass conversation settings to run body * wip: begin localization and only allow actions if the assistant is created * refactor(AssistantsPanel): knowledge localization, allow tools on creation * feat: experimental: allow 'priming' values before assistant is created, that would normally require an assistant_id to be defined * chore: trim console logs and make more meaningful * chore: toast messages * fix(ci): date test * feat: create file when uploading Assistant Avatar * feat: file upload rate limiting from custom config with dynamic file route initialization * refactor: use file upload limiters on post routes only * refactor(fileConfig): add endpoints field for endpoint specific fileconfigs, add mergeConfig function, add tests * refactor: fileConfig route, dynamic multer instances used on all '/' and '/images' POST routes, data service and query hook * feat: supportedMimeTypesSchema, test for array of regex * feat: configurable file config limits * chore: clarify assistants file knowledge prereq. * chore(useTextarea): default to localized 'Assistant' if assistant name is empty * feat: configurable file limits and toggle file upload per endpoint * fix(useUploadFileMutation): prevent updating assistant.files cache if file upload is a message_file attachment * fix(AssistantSelect): set last selected assistant only when timeout successfully runs * refactor(queries): disable assistant queries if assistants endpoint is not enabled * chore(Switcher): add localization * chore: pluralize `assistant` for `EModelEndpoint key and value * feat: show/hide assistant UI components based on endpoint availability; librechat.yaml config for disabling builder section and setting polling/timeout intervals * fix(compactEndpointSchemas): use EModelEndpoint for schema access * feat(runAssistant): use configured values from `librechat.yaml` for `pollIntervalMs` and `timeout` * fix: naming issue * wip: revert landing * 🎉 happy birthday LibreChat (#1768) * happy birthday LibreChat * Refactor endpoint condition in Landing component * Update birthday message in Eng.tsx * fix(/config): avoid nesting ternaries * refactor(/config): check birthday --------- Co-authored-by: Danny Avila <messagedaniel@protonmail.com> * fix: landing * fix: landing * fix(useMessageHelpers): hardcoded check to use EModelEndpoint instead * fix(ci): convo test revert to main * fix(assistants/chat): fix issue where assistant_id was being saved as model for convo * chore: added logging, promises racing to prevent longer timeouts, explicit setting of maxRetries and timeouts, robust catching of invalid abortRun params * refactor: use recoil state for `showStopButton` and only show for assistants endpoint after syncing conversation data * refactor: optimize abortRun strategy using localStorage, refactor `abortConversation` to use async/await and await the result, refactor how the abortKey cache is set for runs * fix(checkMessageGaps): assign `assistant_id` to synced messages if defined; prevents UI from showing blank assistant for cancelled messages * refactor: re-order sequence of chat route, only allow aborting messages after run is created, cancel abortRun if there was a cancelling error (likely due already cancelled in chat route), and add extra logging * chore(typedefs): add httpAgent type to OpenAIClient * refactor: use custom implementation of retrieving run with axios to allow for timing out run query * fix(waitForRun): handle timed out run retrieval query * refactor: update preset conditions: - presets will retain settings when a different endpoint is selected; for existing convos, either when modular or is assistant switch - no longer use `navigateToConvo` on preset select * fix: temporary calculator hack as expects string input when invoked * fix: cancel abortRun only when cancelling error is a result of the run already being cancelled * chore: remove use of `fileMaxSizeMB` and total counterpart (redundant) * docs: custom config documentation update * docs: assistants api setup and dotenv, new custom config fields * refactor(Switcher): make Assistant switcher sticky in SidePanel * chore(useSSE): remove console log of data and message index * refactor(AssistantPanel): button styling and add secondary select button to bottom of panel * refactor(OpenAIClient): allow passing conversationId to RunManager through titleConvo and initializeLLM to properly record title context tokens used in cases where conversationId was not defined by the client * feat(assistants): token tracking for assistant runs * chore(spendTokens): improve logging * feat: support/exclude specific assistant Ids * chore: add update `librechat.example.yaml`, optimize `AppService` handling, new tests for `AppService`, optimize missing/outdate config logging * chore: mount docker logs to root of project * chore: condense axios errors * chore: bump vite * chore: vite hot reload fix using latest version * chore(getOpenAIModels): sort instruct models to the end of models list * fix(assistants): user provided key * fix(assistants): user provided key, invalidate more queries on revoke --------- Co-authored-by: Marco Beretta <81851188+Berry-13@users.noreply.github.com>
34 KiB
| title | description | weight |
|---|---|---|
| ⚙️ Environment Variables | Comprehensive guide for configuring your application's environment with the `.env` file. This document is your one-stop resource for understanding and customizing the environment variables that will shape your application's behavior in different contexts. | -11 |
.env File Configuration
Welcome to the comprehensive guide for configuring your application's environment with the .env file. This document is your one-stop resource for understanding and customizing the environment variables that will shape your application's behavior in different contexts.
While the default settings provide a solid foundation for a standard docker installation, delving into this guide will unveil the full potential of LibreChat. This guide empowers you to tailor LibreChat to your precise needs. Discover how to adjust language model availability, integrate social logins, manage the automatic moderation system, and much more. It's all about giving you the control to fine-tune LibreChat for an optimal user experience.
Reminder: Please restart LibreChat for the configuration changes to take effect
Alternatively, you can create a new file named docker-compose.override.yml in the same directory as your main docker-compose.yml file for LibreChat, where you can set your .env variables as needed under environment, or modify the default configuration provided by the main docker-compose.yml, without the need to directly edit or duplicate the whole file.
For more info see:
-
Our quick guide:
-
The official docker documentation:
-
You can also view an example of an override file for LibreChat in your LibreChat folder and on GitHub:
Server Configuration
Customization
- Here you can change the app title and footer
- Uncomment to add a custom footer.
- Uncomment and make empty "" to remove the footer.
APP_TITLE=LibreChat
CUSTOM_FOOTER="My custom footer"
Port
- The server will listen to localhost:3080 by default. You can change the target IP as you want. If you want to make this server available externally, for example to share the server with others or expose this from a Docker container, set host to 0.0.0.0 or your external IP interface.
Tips: Setting host to 0.0.0.0 means listening on all interfaces. It's not a real IP.
- Use localhost:port rather than 0.0.0.0:port to access the server.
HOST=localhost
PORT=3080
MongoDB Database
- Change this to your MongoDB URI if different. You should also add
LibreChator your ownAPP_TITLEas the database name in the URI. For example:- if you are using docker, the URI format is
mongodb://<ip>:<port>/<database>. YourMONGO_URIshould look like this:mongodb://127.0.0.1:27018/LibreChat - if you are using an online db, the URI format is
mongodb+srv://<username>:<password>@<host>/<database>?<options>. YourMONGO_URIshould look like this:mongodb+srv://username:password@host.mongodb.net/LibreChat?retryWrites=true(retryWrites=trueis the only option you need when using the online db)
- if you are using docker, the URI format is
- Instruction on how to create an online MongoDB database (useful for use without docker):
- Securely access your docker MongoDB database:
MONGO_URI=mongodb://127.0.0.1:27018/LibreChat
Application Domains
- To use LibreChat locally, set
DOMAIN_CLIENTandDOMAIN_SERVERtohttp://localhost:3080(3080 being the port previously configured) - When deploying LibreChat to a custom domain, set
DOMAIN_CLIENTandDOMAIN_SERVERto your deployed URL, e.g.https://librechat.example.com
DOMAIN_CLIENT=http://localhost:3080
DOMAIN_SERVER=http://localhost:3080
Prevent Public Search Engines Indexing
By default, your website will not be indexed by public search engines (e.g. Google, Bing, …). This means that people will not be able to find your website through these search engines. If you want to make your website more visible and searchable, you can change the following setting to false
NO_INDEX=true
❗Note: This method is not guaranteed to work for all search engines, and some search engines may still index your website or web page for other purposes, such as caching or archiving. Therefore, you should not rely solely on this method to protect sensitive or confidential information on your website or web page.
Logging
LibreChat has built-in central logging, see Logging System for more info.
- Debug logging is enabled by default and crucial for development.
- To report issues, reproduce the error and submit logs from
./api/logs/debug-%DATE%.logat: LibreChat GitHub Issues - Error logs are stored in the same location.
- Keep debug logs active by default or disable them by setting
DEBUG_LOGGING=falsein the environment variable. - For more information about this feature, read our docs: Logging System
DEBUG_LOGGING=true
- Enable verbose server output in the console with
DEBUG_CONSOLE=TRUE, though it's not recommended due to high verbosity.
DEBUG_CONSOLE=false
This is not recommend, however, as the outputs can be quite verbose, and so it's disabled by default.
Permission
UID and GID are numbers assigned by Linux to each user and group on the system. If you have permission problems, set here the UID and GID of the user running the docker compose command. The applications in the container will run with these uid/gid.
UID=1000
GID=1000
Endpoints
In this section you can configure the endpoints and models selection, their API keys, and the proxy and reverse proxy settings for the endpoints that support it.
General Config
- Uncomment
ENDPOINTSto customize the available endpoints in LibreChat PROXYis to be used by all endpoints (leave blank by default)
ENDPOINTS=openAI,azureOpenAI,bingAI,chatGPTBrowser,google,gptPlugins,anthropic
PROXY=
Anthropic
see: Anthropic Endpoint
- You can request an access key from https://console.anthropic.com/
- Leave
ANTHROPIC_API_KEY=blank to disable this endpoint - Set
ANTHROPIC_API_KEY=to "user_provided" to allow users to provide their own API key from the WebUI - If you have access to a reverse proxy for
Anthropic, you can set it withANTHROPIC_REVERSE_PROXY=- leave blank or comment it out to use default base url
ANTHROPIC_API_KEY=user_provided
ANTHROPIC_MODELS=claude-1,claude-instant-1,claude-2
ANTHROPIC_REVERSE_PROXY=
Azure
Important: See the complete Azure OpenAI setup guide for thorough instructions on enabling Azure OpenAI
- To use Azure with this project, set the following variables. These will be used to build the API URL.
AZURE_API_KEY=
AZURE_OPENAI_API_INSTANCE_NAME=
AZURE_OPENAI_API_DEPLOYMENT_NAME=
AZURE_OPENAI_API_VERSION=
AZURE_OPENAI_API_COMPLETIONS_DEPLOYMENT_NAME=
AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME=
Note: As of 2023-11-10, the Azure API only allows one model per deployment,
- Chat completion:
https://{AZURE_OPENAI_API_INSTANCE_NAME}.openai.azure.com/openai/deployments/{AZURE_OPENAI_API_DEPLOYMENT_NAME}/chat/completions?api-version={AZURE_OPENAI_API_VERSION} - You should also consider changing the
OPENAI_MODELSvariable to the models available in your instance/deployment.
Note:
AZURE_OPENAI_API_COMPLETIONS_DEPLOYMENT_NAMEandAZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAMEare optional but might be used in the future
-
It's recommended to name your deployments after the model name, e.g.
gpt-35-turbo,which allows for fast deployment switching andAZURE_USE_MODEL_AS_DEPLOYMENT_NAMEenabled. However, you can use non-model deployment names and setting theAZURE_OPENAI_DEFAULT_MODELto ensure it works as expected. -
Identify the available models, separated by commas without spaces. The first will be default. Leave it blank or as is to use internal settings.
-
The base URL for Azure OpenAI API requests can be dynamically configured.
# .env file
AZURE_OPENAI_BASEURL=https://${INSTANCE_NAME}.openai.azure.com/openai/deployments/${DEPLOYMENT_NAME}
# Cloudflare example
AZURE_OPENAI_BASEURL=https://gateway.ai.cloudflare.com/v1/ACCOUNT_TAG/GATEWAY/azure-openai/${INSTANCE_NAME}/${DEPLOYMENT_NAME}
- Sets the base URL for Azure OpenAI API requests.
- Can include
${INSTANCE_NAME}and${DEPLOYMENT_NAME}placeholders or specific credentials. - Example: "https://gateway.ai.cloudflare.com/v1/ACCOUNT_TAG/GATEWAY/azure-openai/${INSTANCE_NAME}/${DEPLOYMENT_NAME}"
- More info about
AZURE_OPENAI_BASEURLhere
Note: as deployment names can't have periods, they will be removed when the endpoint is generated.
AZURE_OPENAI_MODELS=gpt-3.5-turbo,gpt-4
- This enables the use of the model name as the deployment name, e.g. "gpt-3.5-turbo" as the deployment name (Advanced)
AZURE_USE_MODEL_AS_DEPLOYMENT_NAME=TRUE
- To use Azure with the Plugins endpoint, you need the variables above, and uncomment the following variable:
Note: This may not work as expected and Azure OpenAI may not support OpenAI Functions yet Omit/leave it commented to use the default OpenAI API
PLUGINS_USE_AZURE="true"
** Generate images with Azure OpenAI Service**
- For DALL-E-3:
DALLE3_AZURE_API_VERSION=the-api-version # e.g.: 2023-12-01-preview
DALLE3_BASEURL=https://<AZURE_OPENAI_API_INSTANCE_NAME>.openai.azure.com/openai/deployments/<DALLE3_DEPLOYMENT_NAME>/
DALLE3_API_KEY=your-azure-api-key-for-dall-e-3
- For DALL-E-2:
DALLE2_AZURE_API_VERSION=the-api-version # e.g.: 2023-12-01-preview
DALLE2_BASEURL=https://<AZURE_OPENAI_API_INSTANCE_NAME>.openai.azure.com/openai/deployments/<DALLE2_DEPLOYMENT_NAME>/
DALLE2_API_KEY=your-azure-api-key-for-dall-e-2
BingAI
Bing, also used for Sydney, jailbreak, and Bing Image Creator, see: Bing Access token and Bing Jailbreak
- Follow these instructions to get your bing access token (it's best to use the full cookie string for that purpose): Bing Access Token
- Leave
BINGAI_TOKEN=blank to disable this endpoint - Set
BINGAI_TOKEN=to "user_provided" to allow users to provide their own API key from the WebUI
Note: It is recommended to leave it as "user_provided" and provide the token from the WebUI.
BINGAI_HOSTcan be necessary for some people in different countries, e.g. China (https://cn.bing.com). Leave it blank or commented out to use default server.
BINGAI_TOKEN=user_provided
BINGAI_HOST=
ChatGPT
see: ChatGPT Free Access token
Warning
: To use this endpoint you'll have to set up your own reverse proxy. Here is the installation guide to deploy your own (based on Ninja): Ninja Deployment Guide
CHATGPT_REVERSE_PROXY=<YOUR-REVERSE-PROXY>
Note: If you're a GPT plus user you can try adding
gpt-4,gpt-4-plugins,gpt-4-code-interpreter, andgpt-4-browsingto the list above and use the models for these features; however, the view/display portion of these features are not supported, but you can use the underlying models, which have higher token context
This method might only works with
text-davinci-002-render-shaand might stop working at any moment.
- Leave
CHATGPT_TOKEN=blank to disable this endpoint - Set
CHATGPT_TOKEN=to "user_provided" to allow users to provide their own API key from the WebUI- It is not recommended to provide your token in the
.envfile since it expires often and sharing it could get you banned.
- It is not recommended to provide your token in the
CHATGPT_TOKEN=
CHATGPT_MODELS=text-davinci-002-render-sha
Follow these instructions to setup the Google Endpoint
GOOGLE_KEY=user_provided
GOOGLE_REVERSE_PROXY=
- Customize the available models, separated by commas, without spaces.
- The first will be default.
- Leave it blank or commented out to use internal settings (default: all listed below).
# all available models as of 12/16/23
GOOGLE_MODELS=gemini-pro,gemini-pro-vision,chat-bison,chat-bison-32k,codechat-bison,codechat-bison-32k,text-bison,text-bison-32k,text-unicorn,code-gecko,code-bison,code-bison-32k
OpenAI
-
To get your OpenAI API key, you need to:
- Go to https://platform.openai.com/account/api-keys
- 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-...) to
OPENAI_API_KEY
-
Leave
OPENAI_API_KEY=blank to disable this endpoint -
Set
OPENAI_API_KEY=to "user_provided" to allow users to provide their own API key from the WebUI
OPENAI_API_KEY=user_provided
- You can specify which organization to use for each API request to OpenAI. However, it is not required if you are only part of a single organization or intend to use your default organization. You can check your default organization here. This can also help you limit your LibreChat instance from allowing API keys outside of your organization to be used, as a mismatch between key and organization will throw an API error.
# Optional
OPENAI_ORGANIZATION=org-Y6rfake63IhVorgqfPQmGmgtId
- Set to true to enable debug mode for the OpenAI endpoint
DEBUG_OPENAI=false
- Customize the available models, separated by commas, without spaces.
- The first will be default.
- Leave it blank or commented out to use internal settings.
OPENAI_MODELS=gpt-3.5-turbo-0125,gpt-3.5-turbo-0301,gpt-3.5-turbo,gpt-4,gpt-4-0613,gpt-4-vision-preview,gpt-3.5-turbo-0613,gpt-3.5-turbo-16k-0613,gpt-4-0125-preview,gpt-4-turbo-preview,gpt-4-1106-preview,gpt-3.5-turbo-1106,gpt-3.5-turbo-instruct,gpt-3.5-turbo-instruct-0914,gpt-3.5-turbo-16k
- Titling is enabled by default when initiating a conversation.
- Set to false to disable this feature.
TITLE_CONVO=true
- The default model used for titling by is gpt-3.5-turbo. You can change it by uncommenting the following and setting the desired model. (Optional)
Note: Must be compatible with the OpenAI Endpoint.
OPENAI_TITLE_MODEL=gpt-3.5-turbo
- Enable message summarization by uncommenting the following (Optional/Experimental)
Note: this may affect response time when a summary is being generated.
OPENAI_SUMMARIZE=true
Experimental: We are using the ConversationSummaryBufferMemory method to summarize messages. To learn more about this, see this article: https://www.pinecone.io/learn/series/langchain/langchain-conversational-memory/
- Reverse proxy settings for OpenAI:
- see: LiteLLM
- see also: Free AI APIs
Important: As of v0.6.6, it's recommend you use the librechat.yaml Configuration file (guide here) to add Reverse Proxies as separate endpoints.
OPENAI_REVERSE_PROXY=
- Sometimes when using Local LLM APIs, you may need to force the API to be called with a
promptpayload instead of amessagespayload; to mimic the/v1/completionsrequest instead of/v1/chat/completions. This may be the case for LocalAI with some models. To do so, uncomment the following (Advanced)
OPENAI_FORCE_PROMPT=true
Assistants
-
The Assistants API by OpenAI has a dedicated endpoint.
-
To get your OpenAI API key, you need to:
- Go to https://platform.openai.com/account/api-keys
- 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-...) to
ASSISTANTS_API_KEY
-
Leave
ASSISTANTS_API_KEY=blank to disable this endpoint -
Set
ASSISTANTS_API_KEY=touser_providedto allow users to provide their own API key from the WebUI -
Customize the available models, separated by commas, without spaces.
- The first will be default.
- Leave it blank or commented out to use internal settings:
- The models list will be fetched from OpenAI but only Assistants-API-compatible models will be shown; at the time of writing, they are as shown in the example below.
ASSISTANTS_MODELS=gpt-3.5-turbo-0125,gpt-3.5-turbo-16k-0613,gpt-3.5-turbo-16k,gpt-3.5-turbo,gpt-4,gpt-4-0314,gpt-4-32k-0314,gpt-4-0613,gpt-3.5-turbo-0613,gpt-3.5-turbo-1106,gpt-4-0125-preview,gpt-4-turbo-preview,gpt-4-1106-preview
- 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 counterpartOPENAI_REVERSE_PROXY
ASSISTANTS_BASE_URL=http://your-alt-baseURL:3080/
- There is additional, optional configuration, depending on your needs, such as disabling the assistant builder UI, and determining which assistants can be used, that are available via the
librechat.yamlcustom config file.
OpenRouter
See OpenRouter for more info.
- OpenRouter is a legitimate proxy service to a multitude of LLMs, both closed and open source, including: OpenAI models, Anthropic models, Meta's Llama models, pygmalionai/mythalion-13b and many more open source models. Newer integrations are usually discounted, too!
Note: this overrides the OpenAI and Plugins Endpoints.
OPENROUTER_API_KEY=
Plugins
Here are some useful documentation about plugins:
General Configuration:
- Identify the available models, separated by commas without spaces. The first model in the list will be set as default. Leave it blank or commented out to use internal settings.
PLUGIN_MODELS=gpt-4,gpt-4-turbo-preview,gpt-4-0125-preview,gpt-4-1106-preview,gpt-4-0613,gpt-3.5-turbo,gpt-3.5-turbo-0125,gpt-3.5-turbo-1106,gpt-3.5-turbo-0613
- Set to false or comment out to disable debug mode for plugins
DEBUG_PLUGINS=true
- For securely storing credentials, you need a fixed key and IV. You can set them here for prod and dev environments.
- You need a 32-byte key (64 characters in hex) and 16-byte IV (32 characters in hex) You can use this replit to generate some quickly: Key Generator
Warning: If you don't set them, the app will crash on startup.
CREDS_KEY=f34be427ebb29de8d88c107a71546019685ed8b241d8f2ed00c3df97ad2566f0
CREDS_IV=e2341419ec3dd3d19b13a1a87fafcbfb
Azure AI Search
This plugin supports searching Azure AI Search for answers to your questions. See: Azure AI Search
AZURE_AI_SEARCH_SERVICE_ENDPOINT=
AZURE_AI_SEARCH_INDEX_NAME=
AZURE_AI_SEARCH_API_KEY=
AZURE_AI_SEARCH_API_VERSION=
AZURE_AI_SEARCH_SEARCH_OPTION_QUERY_TYPE=
AZURE_AI_SEARCH_SEARCH_OPTION_TOP=
AZURE_AI_SEARCH_SEARCH_OPTION_SELECT=
DALL-E:
Note: Make sure the gptPlugins endpoint is set in the ENDPOINTS environment variable if it was configured before.
API Keys:
DALLE_API_KEY: This environment variable is intended for storing the OpenAI API key that grants access to both DALL-E 2 and DALL-E 3 services. Typically, this key should be kept private. If you are distributing a plugin or software that integrates with DALL-E, you may choose to leave this commented out, requiring the end user to input their own API key. If you have a shared API key you want to distribute with your software (not recommended for security reasons), you can uncomment this and provide the key.
DALLE_API_KEY=
DALLE3_API_KEYandDALLE2_API_KEY: These are similar to the above but are specific to each version of DALL-E. They allow for separate keys for DALL-E 2 and DALL-E 3, providing flexibility if you have different access credentials or subscription levels for each service.
DALLE3_API_KEY=
DALLE2_API_KEY=
System Prompts:
DALLE3_SYSTEM_PROMPTandDALLE2_SYSTEM_PROMPT: These variables allow users to set system prompts that can preconfigure or guide the image generation process for DALL-E 3 and DALL-E 2, respectively. Use these to set default prompts or special instructions that affect how the AI interprets the user's input prompts.
DALLE3_SYSTEM_PROMPT="Your DALL-E-3 System Prompt here"
DALLE2_SYSTEM_PROMPT="Your DALL-E-2 System Prompt here"
Reverse Proxy Settings:
DALLE_REVERSE_PROXY: This setting enables the specification of a reverse proxy for DALL-E API requests. This can be useful for routing traffic through a specific server, potentially for purposes like caching, logging, or adding additional layers of security. Ensure that the URL follows the required pattern and is appropriately configured to handle DALL-E requests.
DALLE_REVERSE_PROXY=
Base URLs:
DALLE3_BASEURLandDALLE2_BASEURL: These variables define the base URLs for DALL-E 3 and DALL-E 2 API endpoints, respectively. These might need to be set if you are using a custom proxy or a specific regional endpoint provided by OpenAI.
DALLE3_BASEURL=
DALLE2_BASEURL=
Azure OpenAI Integration (Optional):
DALLE3_AZURE_API_VERSIONandDALLE2_AZURE_API_VERSION: If you are using Azure's OpenAI service to access DALL-E, these environment variables specify the API version for DALL-E 3 and DALL-E 2, respectively. Azure may have specific API version strings that need to be set to ensure compatibility with their services.
DALLE3_AZURE_API_VERSION=
DALLE2_AZURE_API_VERSION=
Remember to replace placeholder text such as "Your DALL-E-3 System Prompt here" with actual prompts or instructions and provide your actual API keys if you choose to include them directly in the file (though managing sensitive keys outside of the codebase is a best practice). Always review and respect OpenAI's usage policies when embedding API keys in software.
Note: if you have PROXY set, it will be used for DALL-E calls also, which is universal for the app
Google Search
See detailed instructions here: Google Search
GOOGLE_API_KEY=
GOOGLE_CSE_ID=
SerpAPI
SerpApi is a real-time API to access Google search results (not as performant)
SERPAPI_API_KEY=
Stable Diffusion (Automatic1111)
See detailed instructions here: Stable Diffusion
- Use
http://127.0.0.1:7860with local install andhttp://host.docker.internal:7860for docker
SD_WEBUI_URL=http://host.docker.internal:7860
WolframAlpha
See detailed instructions here: Wolfram Alpha
WOLFRAM_APP_ID=
Zapier
- You need a Zapier account. Get your API key from here: Zapier
- Create allowed actions - Follow step 3 in this getting start guide from Zapier
Note: zapier is known to be finicky with certain actions. Writing email drafts is probably the best use of it.
ZAPIER_NLA_API_KEY=
Search (Meilisearch)
Enables search in messages and conversations:
SEARCH=true
Note: If you're not using docker, it requires the installation of the free self-hosted Meilisearch or a paid remote plan
To disable anonymized telemetry analytics for MeiliSearch for absolute privacy, set to true:
MEILI_NO_ANALYTICS=true
For the API server to connect to the search server. Replace '0.0.0.0' with 'meilisearch' if serving MeiliSearch with docker-compose.
MEILI_HOST=http://0.0.0.0:7700
This master key must be at least 16 bytes, composed of valid UTF-8 characters. MeiliSearch will throw an error and refuse to launch if no master key is provided or if it is under 16 bytes. MeiliSearch will suggest a secure autogenerated master key. This is a ready made secure key for docker-compose, you can replace it with your own.
MEILI_MASTER_KEY=DrhYf7zENyR6AlUCKmnz0eYASOQdl6zxH7s7MKFSfFCt
User System
This section contains the configuration for:
Moderation
The Automated Moderation System uses a scoring mechanism to track user violations. As users commit actions like excessive logins, registrations, or messaging, they accumulate violation scores. Upon reaching a set threshold, the user and their IP are temporarily banned. This system ensures platform security by monitoring and penalizing rapid or suspicious activities.
see: Automated Moderation
Basic Moderation Settings
OPENAI_MODERATION: Set to true or false, Whether or not to enable OpenAI moderation on the OpenAI and Plugins endpointsOPENAI_MODERATION_API_KEY: Your OpenAI API keyOPENAI_MODERATION_REVERSE_PROXY: Note: Commented out by default, this is not working with all reverse proxys
OPENAI_MODERATION=false
OPENAI_MODERATION_API_KEY=
OPENAI_MODERATION_REVERSE_PROXY=
BAN_VIOLATIONS: Whether or not to enable banning users for violations (they will still be logged)BAN_DURATION: How long the user and associated IP are banned for (in milliseconds)BAN_INTERVAL: The user will be banned everytime their score reaches/crosses over the interval threshold
BAN_VIOLATIONS=true
BAN_DURATION=1000 * 60 * 60 * 2
BAN_INTERVAL=20
Score for each violation
LOGIN_VIOLATION_SCORE=1
REGISTRATION_VIOLATION_SCORE=1
CONCURRENT_VIOLATION_SCORE=1
MESSAGE_VIOLATION_SCORE=1
NON_BROWSER_VIOLATION_SCORE=20
Login and registration rate limiting.
LOGIN_MAX: The max amount of logins allowed per IP perLOGIN_WINDOWLOGIN_WINDOW: In minutes, determines the window of time forLOGIN_MAXloginsREGISTER_MAX: The max amount of registrations allowed per IP perREGISTER_WINDOWREGISTER_WINDOW: In minutes, determines the window of time forREGISTER_MAXregistrations
LOGIN_MAX=7
LOGIN_WINDOW=5
REGISTER_MAX=5
REGISTER_WINDOW=60
Message rate limiting (per user & IP)
LIMIT_CONCURRENT_MESSAGES: Whether to limit the amount of messages a user can send per requestCONCURRENT_MESSAGE_MAX: The max amount of messages a user can send per request
LIMIT_CONCURRENT_MESSAGES=true
CONCURRENT_MESSAGE_MAX=2
Limiters
Note: You can utilize both limiters, but default is to limit by IP only.
- IP Limiter:
LIMIT_MESSAGE_IP: Whether to limit the amount of messages an IP can send perMESSAGE_IP_WINDOWMESSAGE_IP_MAX: The max amount of messages an IP can send perMESSAGE_IP_WINDOWMESSAGE_IP_WINDOW: In minutes, determines the window of time forMESSAGE_IP_MAXmessages
LIMIT_MESSAGE_IP=true
MESSAGE_IP_MAX=40
MESSAGE_IP_WINDOW=1
- User Limiter:
LIMIT_MESSAGE_USER: Whether to limit the amount of messages an IP can send perMESSAGE_USER_WINDOWMESSAGE_USER_MAX: The max amount of messages an IP can send perMESSAGE_USER_WINDOWMESSAGE_USER_WINDOW: In minutes, determines the window of time forMESSAGE_USER_MAXmessages
LIMIT_MESSAGE_USER=false
MESSAGE_USER_MAX=40
MESSAGE_USER_WINDOW=1
Balance
The following enables user balances for the OpenAI/Plugins endpoints, which you can add manually or you will need to build out a balance accruing system for users.
see: Token Usage
- To manually add balances, run the following command:
npm run add-balance- You can also specify the email and token credit amount to add, e.g.:
npm run add-balance example@example.com 1000 - To list the balance of every user:
npm run list-balances
- You can also specify the email and token credit amount to add, e.g.:
Note: 1000 credits = $0.001 (1 mill USD)
- Set to
trueto enable token credit balances for the OpenAI/Plugins endpoints
CHECK_BALANCE=false
Registration and Login
see: User/Auth System
- General Settings:
ALLOW_EMAIL_LOGIN: Email login. Set totrueorfalseto enable or disable ONLY email login.ALLOW_REGISTRATION: Email registration of new users. Set totrueorfalseto enable or disable Email registration.ALLOW_SOCIAL_LOGIN: Allow users to connect to LibreChat with various social networks, see below. Set totrueorfalseto enable or disable.ALLOW_SOCIAL_REGISTRATION: Enable or disable registration of new user using various social network. Set totrueorfalseto enable or disable.
Quick Tip: Even with registration disabled, add users directly to the database using
npm run create-user. Quick Tip: With registration disabled, you can delete a user withnpm run delete-user email@domain.com.
ALLOW_EMAIL_LOGIN=true
ALLOW_REGISTRATION=true
ALLOW_SOCIAL_LOGIN=false
ALLOW_SOCIAL_REGISTRATION=false
- Default values: session expiry: 15 minutes, refresh token expiry: 7 days
- For more information: Refresh Token
SESSION_EXPIRY=1000 * 60 * 15
REFRESH_TOKEN_EXPIRY=(1000 * 60 * 60 * 24) * 7
- You should use new secure values. The examples given are 32-byte keys (64 characters in hex).
- Use this replit to generate some quickly: JWT Keys
JWT_SECRET=16f8c0ef4a5d391b26034086c628469d3f9f497f08163ab9b40137092f2909ef
JWT_REFRESH_SECRET=eaa5191f2914e30b9387fd84e254e4ba6fc51b4654968a9b0803b456a54b8418
Social Logins
Discord Authentication
for more information: Discord
# Discord
DISCORD_CLIENT_ID=your_client_id
DISCORD_CLIENT_SECRET=your_client_secret
DISCORD_CALLBACK_URL=/oauth/discord/callback
Facebook Authentication
for more information: Facebook Authentication
# Facebook
FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=
FACEBOOK_CALLBACK_URL=/oauth/facebook/callback
GitHub Authentication
for more information: GitHub Authentication
# GitHub
GITHUB_CLIENT_ID=your_client_id
GITHUB_CLIENT_SECRET=your_client_secret
GITHUB_CALLBACK_URL=/oauth/github/callback
Google Authentication
for more information: Google Authentication
# Google
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_CALLBACK_URL=/oauth/google/callback
OpenID Authentication
for more information: Azure OpenID Authentication or AWS Cognito OpenID Authentication
# OpenID
OPENID_CLIENT_ID=
OPENID_CLIENT_SECRET=
OPENID_ISSUER=
OPENID_SESSION_SECRET=
OPENID_SCOPE="openid profile email"
OPENID_CALLBACK_URL=/oauth/openid/callback
OPENID_BUTTON_LABEL=
OPENID_IMAGE_URL=
Email Password Reset
Email is used for password reset. See: Email Password Reset
- Note that all either service or host, username and password and the From address must be set for email to work.
If using
EMAIL_SERVICE, do NOT set the extended connection parameters:
HOST,PORT,ENCRYPTION,ENCRYPTION_HOSTNAME,ALLOW_SELFSIGNEDFailing to set valid values here will result in LibreChat using the unsecured password reset!
See: nodemailer well-known-services
EMAIL_SERVICE=
If EMAIL_SERVICE is not set, connect to this server:
EMAIL_HOST=
Mail server port to connect to with EMAIL_HOST (usually 25, 465, 587, 2525):
EMAIL_PORT=25
Encryption valid values: starttls (force STARTTLS), tls (obligatory TLS), anything else (use STARTTLS if available):
EMAIL_ENCRYPTION=
Check the name in the certificate against this instead of EMAIL_HOST:
EMAIL_ENCRYPTION_HOSTNAME=
Set to true to allow self-signed, anything else will disallow self-signed:
EMAIL_ALLOW_SELFSIGNED=
Username used for authentication. For consumer services, this MUST usually match EMAIL_FROM:
EMAIL_USERNAME=
Password used for authentication:
EMAIL_PASSWORD=
The human-readable address in the From is constructed as EMAIL_FROM_NAME <EMAIL_FROM>. Defaults to APP_TITLE:
EMAIL_FROM_NAME=
Mail address for from field. It is REQUIRED to set a value here (even if it's not porperly working):
EMAIL_FROM=noreply@librechat.ai