Map environment variables into typed settings
Environment-based application configuration
Pydantic · Class
SettingsConfigDict configures Pydantic settings models through named options such as environment-variable prefixes and dotenv-file loading. It is used as model_config data on a settings class.
SettingsConfigDict is the settings-specific configuration dictionary used with Pydantic Settings models. It supplies options such as environment-variable naming and dotenv-file loading while retaining the typed configuration model used by Pydantic.
model_config = SettingsConfigDict(**options)from pydantic_settings import BaseSettings, SettingsConfigDict
class AppSettings(BaseSettings):
model_config = SettingsConfigDict(env_prefix="APP_", env_file=".env")
debug: bool = False
settings = AppSettings()The settings model reads configuration using the declared environment prefix and optional dotenv file.
Environment-based application configuration
Local development configuration
Consistent model behavior
SettingsConfigDict is a typed configuration dictionary for settings models. It is assigned to model_config to control how configuration values are sourced and interpreted.
Follow-up: How would you make environment variables use a common prefix? Set env_prefix in SettingsConfigDict and name variables with that prefix.
It lets a settings model declare options such as an environment-variable prefix and a dotenv file. The settings model then applies those options when it is instantiated.
Follow-up: What is the practical effect of env_file=".env"? Values from that dotenv file become one of the configured sources for settings loading.
The configuration is expressed as a dictionary-shaped object because the underlying configuration type is ConfigDict, documented as a TypedDict. This provides a structured set of named configuration fields rather than an untyped mapping.
Follow-up: Why prefer the documented configuration type over arbitrary keys? The typed fields communicate supported behavior and help catch misspelled or unsupported options.
ConfigDictwith_configBaseSettings