What problem does it solve?
Pydantic eliminates runtime bugs caused by untrusted or loosely-typed data by turning Python type hints into strict(ish) validation, coercion rules, and predictable serialization.
Core Features & Use Cases
- Schema-backed runtime validation: Validate request/response bodies, settings, and structured tool arguments using BaseModel and TypeAdapter.
- Precise constraints and error reporting: Use Field constraints, discriminated unions, and strict mode to reject malformed inputs and produce actionable ValidationError.errors().
- Serialization and JSON Schema for integrations: Generate JSON Schema for OpenAPI/LLM tool definitions and control output with serializers and computed fields.
Quick Start
Use the pydantic skill to validate and serialize an HTTP request body by defining a BaseModel with Field constraints and then calling model_validate_json on the incoming JSON payload, ensuring ValidationError returns structured errors via errors() when inputs are invalid.