Global variables
Global variables let you store and reuse generic input values and credentials across your projects. -You can use a global variable in any text input field that displays the Globe icon.
+You can use a global variable in any text input field that displays the icon.Langflow stores global variables in its internal database, and encrypts the values using a secret key.
-Create a global variable
+Create a global variable
+To create a new global variable, follow these steps.
-
In the Langflow UI, click your profile icon, and then select Settings.
@@ -60,21 +61,22 @@ You can use a global variable in any text input field that displays the
You can now select your global variable from any text input field that displays the 🌐 icon.
-Because values are encrypted, you can't view the actual values of your global variables. -In Settings > Global Variables, the Value column shows the encrypted hash for Generic type variables, and shows nothing for Credential type variables.
You can now select your global variable from any text input field that displays the icon.
Edit a global variable
- @@ -110,18 +112,21 @@ In Settings > Global Variables, the Value c
The global variable, and any existing references to it, are deleted.
-Add global variables from the environment
-Custom environment variables
-You can use the LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT environment variable to source global variables from your runtime environment.
Add custom global variables from the environment
+You can use the LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT environment variable to source custom global variables from your runtime environment.
+All global variables sourced from the environment are automatically set as Credential type global variables.
Langflow's default global variables are already included in this list and are automatically sourced when detected.
+You can extend this list by setting LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT with your additional variables.
- Local
- Docker
If you installed Langflow locally, you must define the LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT environment variable in a .env file.
-
Create a
.envfile and open it in your preferred editor. -
Add the
-LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENTenvironment variable as follows:-_10LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT=VARIABLE1,VARIABLE2Replace
+VARIABLE1,VARIABLE2with a comma-separated list (no spaces) of variables that you want Langflow to source from the environment. -For example,my_key,some_string.You can specify the variables either as a comma-separated string with no spaces, or as a JSON list:
++_10# Option 1: Comma-separated string (no spaces)_10LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT=VARIABLE1,VARIABLE2_10_10# Option 2: JSON list format_10LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT=["VARIABLE1", "VARIABLE2"]Replace
VARIABLE1,VARIABLE2with your additional variables that you want Langflow to source from the environment, such asmy_key,some_stringor["my_key", "some_string"]. +These are added to the default list of variables that Langflow already monitors. -
Save and close the file.
@@ -155,8 +160,11 @@ To add additional parameters, such as the Apply To Fields paramGlobal variables that you add from the environment always have the Credential type.
If you want to explicitly prevent Langflow from sourcing global variables from the environment, set LANGFLOW_STORE_ENVIRONMENT_VARIABLES to false in your .env file:
_10LANGFLOW_STORE_ENVIRONMENT_VARIABLES=false
Default environment variables
+If you want to explicitly prevent Langflow from sourcing global variables from the environment, set LANGFLOW_STORE_ENVIRONMENT_VARIABLES to false in your .env file:
_10LANGFLOW_STORE_ENVIRONMENT_VARIABLES=false
If you want to automatically set fallback values for your global variables from environment variables, set the LANGFLOW_FALLBACK_FROM_ENV_VAR environment variable to true in your .env file. When this feature is enabled, if a global variable is not found, Langflow attempts to use an environment variable with the same name as a fallback.
_10LANGFLOW_FALLBACK_FROM_ENV_VAR=true
Default environment variables
Langflow automatically detects and converts some environment variables into global variables of the type Credential, which are applied to the specific fields in components that require them. Currently, the following variables are supported:
ANTHROPIC_API_KEY
@@ -187,8 +195,6 @@ To add additional parameters, such as the Apply To Fields param
VECTARA_CORPUS_IDVECTARA_CUSTOMER_ID
For information about other environment variables and their usage, see Environment Variables.
-Security best practices
-For information about securing your global variables and other sensitive data, see Security best practices.