This page describes the backend Settings Service: the Settings and AuthSettings Pydantic models, how configuration values are loaded from environment variables and config files, the SettingsService wrapper, the initialization sequence, and runtime access patterns.
For a catalog of all supported environment variable names and their purposes, see 7.1 For how the frontend reads backend-provided configuration at startup, see 7.3
The Settings Service is the first subsystem initialized when the Langflow backend starts. All other services — database, cache, auth, tracing — receive a SettingsService reference at construction time and read their parameters from it.
The implementation lives in the lfx package and is re-exported by langflow-base:
| Module | Role |
|---|---|
src/lfx/src/lfx/services/settings/base.py | Defines Settings, CustomSource, load_settings_from_yaml, save_settings_to_yaml |
src/lfx/src/lfx/services/settings/constants.py | Defines DEFAULT_SUPERUSER, DEFAULT_SUPERUSER_PASSWORD, VARIABLES_TO_GET_FROM_ENVIRONMENT, AGENTIC_VARIABLES |
src/backend/base/langflow/services/settings/base.py | Re-export shim forwarding all symbols from lfx.services.settings.base |
lfx.services.settings.manager / lfx.services.settings.service | SettingsService service wrapper |
Sources: src/lfx/src/lfx/services/settings/base.py src/backend/base/langflow/services/settings/base.py
Diagram: Settings Service — Code Entity Map
Sources: src/lfx/src/lfx/services/settings/base.py src/backend/base/langflow/services/settings/base.py src/backend/base/langflow/main.py42-51 src/backend/base/langflow/services/utils.py19 src/backend/base/langflow/services/database/service.py39-90
Settings ModelSettings is a pydantic_settings.BaseSettings subclass. All fields are populated by the custom source stack described in the Loading Mechanism section below.
| Category | Fields | Notes |
|---|---|---|
| Database | database_url, database_connection_retry, db_connection_settings, alembic_log_file, alembic_log_to_stdout | pool_size and max_overflow are deprecated; use db_connection_settings dict instead |
| Components | components_path (list) | Defaults to BASE_COMPONENTS_PATH from lfx.constants; extended at startup by bundle loading |
| Server | host, port, workers, worker_timeout, backend_only, frontend_path | CLI flags in __main__.py override these |
| CORS | cors_origins, cors_allow_credentials | Defaults to permissive "*" / True; a startup warning urges production tightening |
| Caching | cache_type, redis_host, redis_port, redis_password, redis_url | Determines which CacheService backend is initialized |
| Files | max_file_size_upload | Expressed in MB; exposed to the frontend via /api/v1/config |
| Frontend | frontend_timeout, auto_saving, auto_saving_interval, open_browser | frontend_timeout exposed to frontend |
| Logging | log_level, alembic_log_to_stdout | Controls backend log verbosity and Alembic output destination |
| Features | agentic_experience, store_environment_variables, mcp_server_enabled | Boolean feature toggles |
| Telemetry | do_not_track | Opt-out of telemetry |
The model uses pydantic.field_validator decorators. is_valid_database_url (from lfx.utils.util_strings) is used for database URL validation. The SettingsConfigDict sets the environment variable prefix used for all fields.
Sources: src/lfx/src/lfx/services/settings/base.py1-30 src/backend/base/langflow/services/database/service.py46-148 src/backend/base/langflow/main.py135-145
AuthSettings ModelAuthentication-related settings are held in a separate model (accessible at settings_service.auth_settings). Default superuser credentials are stored in lfx.services.settings.constants as DEFAULT_SUPERUSER and DEFAULT_SUPERUSER_PASSWORD.
| Field | Env Variable | Purpose |
|---|---|---|
AUTO_LOGIN | LANGFLOW_AUTO_LOGIN | Skip login; auto-create default superuser on startup |
SECRET_KEY | LANGFLOW_SECRET_KEY | JWT signing key |
ACCESS_TOKEN_EXPIRE_MINUTES | LANGFLOW_ACCESS_TOKEN_EXPIRE_MINUTES | JWT access token TTL |
REFRESH_TOKEN_EXPIRE_MINUTES | LANGFLOW_REFRESH_TOKEN_EXPIRE_MINUTES | JWT refresh token TTL |
Sources: src/backend/base/langflow/__main__.py22 src/backend/base/langflow/main.py184 src/backend/base/langflow/services/utils.py7
__main__.py are applied after SettingsService construction by writing directly to the Settings instance or via update_settings().CustomSource (overrides EnvSettingsSource)..env file — loaded with python-dotenv's load_dotenv(env_file) in the run command before the app starts.load_settings_from_yaml() if a --config path is supplied.default and default_factory values.Diagram: Settings Resolution Flow
Sources: src/lfx/src/lfx/services/settings/base.py1-80 src/backend/base/langflow/__main__.py183-260 src/backend/base/langflow/main.py147-160 src/backend/base/langflow/services/utils.py
CustomSource: Comma-Separated List ParsingCustomSource extends pydantic_settings.EnvSettingsSource and overrides prepare_field_value to support comma-separated strings for list-typed fields. The check is performed by is_list_of_any(field), which inspects the field annotation for list[...] or Optional[list[...]] types.
For example, LANGFLOW_COMPONENTS_PATH=/path/one,/path/two is split into ["/path/one", "/path/two"] before Pydantic processes the value.
Sources: src/lfx/src/lfx/services/settings/base.py24-55
load_settings_from_yaml(path) reads a YAML file using aiofile.async_open and returns a dict merged into the Settings model. save_settings_to_yaml(settings, path) serializes the current settings back to YAML using orjson and yaml. These functions are re-exported through src/backend/base/langflow/services/settings/base.py.
Sources: src/lfx/src/lfx/services/settings/base.py src/backend/base/langflow/services/settings/base.py1-16
SettingsServiceSettingsService is a thin service wrapper that:
Settings instance (.settings) and AuthSettings instance (.auth_settings)ServiceType.SETTINGS_SERVICEinitialize method that may perform synchronous file I/O (reading config files, setting up log paths)DatabaseService.__init__It is not instantiated directly by application code. Always retrieve it via:
Sources: src/backend/base/langflow/services/database/service.py42-50 src/backend/base/langflow/services/utils.py19 src/backend/tests/conftest.py60
Settings initialization is split into two calls during application startup:
Diagram: Startup Initialization Order
The call initialize_settings_service() occurs at the top of get_lifespan() — before the lifespan context manager body runs — ensuring that all subsequent service constructors can read from a fully-resolved settings object.
After initialize_services() completes, main.py extends settings.components_path with any paths discovered by load_bundles_with_error_handling():
Sources: src/backend/base/langflow/main.py147-210 src/backend/base/langflow/services/utils.py1-30
A subset of settings is serialized and returned from the /api/v1/config endpoint. The TypeScript interface is defined in src/frontend/src/controllers/API/queries/config/use-get-config.ts.
Two response shapes are defined:
PublicConfigResponse — returned to unauthenticated users; contains only base fields.ConfigResponse extends BaseConfig — returned to authenticated users; includes additional fields.| Response Field | Source Setting | Auth Required |
|---|---|---|
frontend_timeout | settings.frontend_timeout | No |
max_file_size_upload | settings.max_file_size_upload | No |
event_delivery | settings.event_delivery | No |
voice_mode_available | detected at startup | No |
auto_saving | settings.auto_saving | Yes |
auto_saving_interval | settings.auto_saving_interval | Yes |
health_check_max_retries | settings.health_check_max_retries | Yes |
langflow_version | package metadata | Yes |
feature_flags | feature flag dict | Yes |
mcp_server_enabled | settings.mcp_server_enabled | Yes |
Sources: src/frontend/src/controllers/API/queries/config/use-get-config.ts1-80
Refresh this wiki
This wiki was recently refreshed. Please wait 3 days to refresh again.