How it works
You describe data as a class with typed fields (name: str, age: int), and Pydantic validates incoming data against it: it converts '42' to 42 where that is safe and raises clear errors where it is not. Models can also produce JSON Schema and serialise back to JSON.
FastAPI is built on it, as are many AI libraries that need structured output, including the official OpenAI and Anthropic Python SDKs. Version 2 moved the core into Rust (pydantic-core), which made validation much faster. pydantic-settings loads configuration from environment variables the same way.
Pydantic pricing
Related terms
More in Backend and APIs
Frameworks