API Reference

pydantic-settings

Settings management for Pydantic apps, loading configuration from environment variables and secrets.

Official Documentation ↗
CompatibilityThis documentation covers version v2. Check the official docs for the latest API surface.

Installation

pippip install pydantic-settings

Methods

pydantic-settings extends Pydantic models with loaders for env vars, dotenv files, and secret files.

Key Features

  • Typed settings from environment variables
  • dotenv and secret file sources
  • Validation at load time

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

Errors

The following points are quoted verbatim from the official documentation. 来源:https://docs.pydantic.dev/latest/concepts/pydantic_settings/ · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:51:54.245Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.

Security notes

Quoted verbatim from the official documentation; this is not a complete threat model. 来源:https://docs.pydantic.dev/latest/concepts/pydantic_settings/ · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:51:54.245Z.

FAQ

How are env var names derived?
Field names are uppercased by default and can be prefixed or aliased through the model config.
Can I use nested models?
Yes. Nested settings read a JSON object from the variable or use a delimiter such as __ for nested keys.
Where should secrets go?
Use a secrets directory or your platform secret manager and point the settings model at it, never hardcode them.