pydantic-settings

Configuration management library for Python using Pydantic models. pydantic-settings loads configuration from environment variables, .env files, AWS Secrets Manager, Azure Key Vault, and other sources — automatically parsing and validating values with Pydantic's type system. Define a Settings class once and get type-safe configuration with validation, documentation, and source priority out of the box. The standard for 12-factor Python applications.

Evaluated Mar 07, 2026 (0d ago) v2.x
Homepage ↗ Repo ↗ Developer Tools python settings configuration env pydantic dotenv validation open-source
⚙ Agent Friendliness
70
/ 100
Can an agent use this?
🔒 Security
89
/ 100
Is it safe for agents?
⚡ Reliability
88
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
92
Error Messages
90
Auth Simplicity
92
Rate Limits
98

🔒 Security

TLS Enforcement
90
Auth Strength
88
Scope Granularity
85
Dep. Hygiene
92
Secret Handling
90

SecretStr type prevents secret values from appearing in logs/repr. .env files should be in .gitignore — pydantic-settings doesn't enforce this. AWS/Azure integration uses cloud provider auth.

⚡ Reliability

Uptime/SLA
92
Version Stability
88
Breaking Changes
78
Error Recovery
92
AF Security Reliability

Best When

You're already using Pydantic and need 12-factor app configuration — pydantic-settings' BaseSettings provides type-validated, documented configuration with zero boilerplate.

Avoid When

You don't use Pydantic and don't want to add it as a dependency — python-decouple or dynaconf are lighter alternatives.

Use Cases

  • Load and validate agent service configuration from environment variables with automatic type coercion (DATABASE_URL, PORT, REDIS_URL)
  • Manage agent configuration across environments (dev/staging/prod) with .env file support and environment variable overrides
  • Validate required settings at startup — catch missing environment variables with descriptive errors before agents fail mid-execution
  • Load secrets from AWS Secrets Manager or Azure Key Vault into Pydantic settings models for agent secure configuration
  • Document agent configuration requirements as self-describing Pydantic models with field descriptions and validators

Not For

  • Non-Pydantic stacks — use dynaconf or python-decouple for configuration management without Pydantic dependency
  • Applications with very complex configuration hierarchy — Hydra or OmegaConf are better for deeply nested, composable config
  • Configuration that changes at runtime — pydantic-settings loads once at startup; use a dynamic config service for runtime-changing config

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

Library — no external auth. Optional: AWS/Azure integrations for Secrets Manager use cloud provider auth.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

MIT-licensed open source, part of the Pydantic ecosystem by Samuel Colvin.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • Environment variable names are case-insensitive by default on most systems but BaseSettings matches uppercase by default — set env_prefix or case_sensitive=True explicitly for deterministic behavior
  • Nested settings require model_config = ConfigDict(env_nested_delimiter='__') — without the delimiter, nested Pydantic models in BaseSettings are not populated from env vars
  • Secret fields (SecretStr type) are redacted in __repr__ and logs — accessing the actual value requires .get_secret_value() which is easy to forget in agent debugging
  • pydantic-settings v2 dropped Settings class in favor of BaseSettings with model_config — v1 to v2 migration requires updating all class Config inner classes to model_config
  • Loading from multiple .env files requires explicit env_file parameter with tuple of paths — later files override earlier files; ordering matters for environment-specific overrides
  • Field aliases don't affect environment variable name lookup by default — use validation_alias or set env_names explicitly for fields where the env var name differs from the field name

Full Evaluation Report

Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for pydantic-settings.

AI-powered analysis · PDF + markdown · Delivered within 30 minutes

$99

Package Brief

Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.

Delivered within 10 minutes

$3

Score Monitoring

Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.

Continuous monitoring

$3/mo

Scores are editorial opinions as of 2026-03-07.

6228
Packages Evaluated
26150
Need Evaluation
173
Need Re-evaluation
Community Powered