Settings management using Pydantic. Provides BaseSettings for loading config from environment variables, .env files, and secrets files with full type validation. Extracted from pydantic core into a separate package in V2. Current version is 2.13.1 (Feb 2026).
pip install pydantic-settingsVerified import paths — ran on the pinned version, not inferred.
Minimal BaseSettings loading from .env file with pydantic-settings 2.x.
pip install pydantic-settings; from pydantic_settings import BaseSettings
Verify .env file exists before startup or use extra='forbid' to catch missing required fields early.
Expected behavior — documented priority order: init args > env vars > .env file > defaults.
Pass _env_file='.env' directly to CliApp.run(Settings, _env_file='.env') as workaround, or pin to 2.12.0.
class SubModel(BaseModel): ... — not BaseSettings.
model_config = SettingsConfigDict(env_file='.env')
model_config = SettingsConfigDict(env_file='.env', env_prefix='APP_')