pydantic-settings

Type-safe application settings management for Python, built on Pydantic models.

Library
PyPI
v2.15.0
1,427stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
88/100Excellent
Development Activity96
Maintenance96
Community68
Maturity52
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
85/100Excellent
Architecture88
Code Quality90
Innovation85
Learning Curve78

Pydantic Settings extends Pydantic’s BaseModel into BaseSettings, a class that automatically reads and validates configuration values from environment variables, .env files, JSON, YAML, TOML, Docker/Kubernetes secrets files, cloud secret managers, and CLI arguments — in a configurable precedence order. Every setting is a typed, validated Pydantic field, so misconfigured environments fail fast at startup with clear error messages instead of surfacing as runtime bugs deep in application code.

Maintained by the Pydantic core team as an official companion package, it is the de facto standard for twelve-factor-app configuration in the Python ecosystem, used across FastAPI services, Django projects, CLI tools, and background workers to centralize environment-driven config into a single validated, IDE-autocompletable class.

What You Get

  • BaseSettings base class that behaves like a normal Pydantic model but auto-populates fields from environment variables and other sources on instantiation
  • Built-in source providers for .env files, JSON, YAML, TOML, pyproject.toml, Docker/Kubernetes-style secrets directories, and CLI argument parsing
  • First-party cloud secret manager integrations for AWS Secrets Manager, Azure Key Vault, and GCP Secret Manager via optional extras
  • Configurable source precedence (init kwargs > env vars > dotenv > file secrets > defaults, fully overridable) and nested-delimiter support for structured env vars like SUB__FIELD=value
  • A full CLI-parsing source (cli_parse_args) that turns any BaseSettings model into an argparse-style command-line interface with kebab-case flags, subcommands, and auto-generated help text
  • AliasChoices and env_prefix support for reading the same field from multiple differently-named environment variables

Common Use Cases

  • Centralizing FastAPI/Django/Flask app configuration (database URLs, API keys, feature flags) into one validated, autocompletable settings object
  • Twelve-factor-app deployments where config must be injected via environment variables in Docker/Kubernetes without code changes
  • Building typed CLI tools where flags, env vars, and config files all need to resolve into the same validated model
  • Pulling secrets from AWS Secrets Manager, Azure Key Vault, or GCP Secret Manager at startup without hand-rolled SDK calls
  • Multi-environment configuration (dev/staging/prod) where different .env files or config layers override a shared set of defaults

Under The Hood

Architecture Configuration resolution flows through a pipeline of PydanticBaseSettingsSource objects assembled in BaseSettings._settings_init_sources (pydantic_settings/main.py): init kwargs, CLI args, environment variables, dotenv files, file secrets, and any user-supplied sources are each wrapped as a source instance, called in a configurable precedence order, and their resulting dicts are deep-merged via Pydantic’s deep_update before being handed to the model constructor for validation — so every value, regardless of origin, passes through the same Pydantic validation path as a normal BaseModel field.

Tech Stack The package is pure Python (99.9% per GitHub’s language breakdown) targeting 3.10-3.14, built on pydantic>=2.7 for the validation core, python-dotenv for .env parsing, and typing-inspection for runtime generic/alias introspection; optional extras (pyyaml, tomli, azure-keyvault-secrets+azure-identity, boto3, google-cloud-secret-manager) are pulled in only when their respective source providers are used, keeping the base install lightweight. Packaging uses hatchling with hatch.version reading the version from pydantic_settings/version.py.

Code Quality Source logic is factored into one file per provider under pydantic_settings/sources/providers/ (env, dotenv, json, yaml, toml, pyproject, secrets, nested_secrets, cli, aws, azure, gcp), sharing common field-resolution and alias-handling helpers in sources/base.py and sources/utils.py — a clean separation that makes each source independently testable. The test suite spans 12,000+ lines across per-provider test files (test_source_cli.py, test_source_aws_secrets_manager.py, etc.) plus dedicated precedence/merging and docs-example tests, and the codebase is typed throughout with a py.typed marker, run under strict mypy and ruff via pre-commit hooks.

API Design The core API surface is a single subclassing pattern (class Settings(BaseSettings): ...) that developers already know from Pydantic’s BaseModel, so the learning curve for basic usage is close to zero for anyone using Pydantic elsewhere; configuration of behavior (env prefix, nested delimiter, secrets dir, CLI parsing) is done declaratively via SettingsConfigDict, keeping field declarations free of source-specific noise, though the surface grows large once CLI parsing and multiple file sources are combined — the docs run to 3,400+ lines covering the full option matrix.

Used by 25 apps in this directory

Python
66%
Apache 2.0

Agent Control

AI Agents

295

An open-source runtime control plane for AI agents — define safety guardrails once, apply them across agents built on LangChain, CrewAI, Google ADK, or AWS Strands, and update controls without redeploying code.

View details
79
Repo Health
71
Technical
70
Dependency
Built with
Python66%
TypeScript33%
Updated yesterday
Python
100%
Apache 2.0

Agno

Devops · AI Development · Automation

41,774

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
67
Dependency
Built with
Python100%
Updated today
Python
76%
MIT

ArchiveBox

Bookmarks Archiving

28,138

Self-hosted web archiving that saves HTML, PDFs, screenshots, media, and code in open formats you own forever

View details
88
Repo Health
84
Technical
70
Dependency
Built with
Python76%
HTML12%
Updated today
Python
59%
Apache 2.0

argilla

AI Development · Data Engineering

5,081

Collaborate on high-quality AI training data with a self-hosted annotation platform built for LLMs, NLP, and multimodal models.

View details
65
Repo Health
81
Technical
63
Dependency
Built with
Python59%
Jupyter Notebook21%
Updated 2 days ago
Python
62%
MIT

AutoGen

AI Development · Automation

60,518

Build autonomous and human-in-the-loop multi-agent AI systems with a layered, event-driven Python and .NET framework pioneered at Microsoft Research.

View details
57
Repo Health
78
Technical
75
Dependency
Built with
Python62%
C#25%
TypeScript12%
Updated 4 months ago
Python
68%
Other

AutoGPT

Automation · Productivity · AI Assistants

186,687

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
67
Dependency
Built with
Python68%
TypeScript31%
Updated today
Python
100%
GPL 3.0

ComfyUI

AI Design Tools · AI Development

128,363

The most powerful node-based AI workflow engine for creating images, video, 3D models, and audio with full control over every generation step.

View details
92
Repo Health
81
Technical
75
Dependency
Built with
Python100%
Updated today
Python
44%
MIT

/dev/push

Developer Tools · Devops

4,742

Self-hosted, open-source Vercel alternative that deploys Python, Node.js, PHP, and any Docker-compatible app from a Git push, with zero-downtime rollouts and real-time logs.

View details
44
Repo Health
68
Technical
73
Dependency
Built with
Python44%
HTML31%
CSS17%
Updated 5 months ago
TypeScript
50%
Other

Dify

No Code Platforms · AI Development · Developer Tools

152,883

Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.

View details
92
Repo Health
85
Technical
71
Dependency
Built with
TypeScript50%
Python47%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search