ProvenPin Install

Stacks

Pydantic recipes

16 tested Pydantic integration recipes with FastAPI, httpx, respx, hypothesis. Exact pinned versions and a last-passed receipt, last run 2026-10-15.

passed4/4python

FastAPI + Pydantic v2 validators, discriminated unions and serializers

Pydantic v2 patterns in FastAPI that agents often get wrong: field_validator, model_validator, discriminated unions, computed_field and response_model filtering.

fastapi@0.143.1pydantic@2.14.1httpx@0.28.1
last passed 2026-10-15 13:29 UTC
passed1/1python

FastAPI background tasks + dependency overrides

FastAPI BackgroundTasks for post-response work, with dependency_overrides to swap services in tests.

fastapi@0.143.1httpx@0.28.1pydantic@2.14.1
last passed 2026-10-15 13:29 UTC
passed5/5python

FastAPI endpoint with Pydantic v2 discriminated unions and Annotated validators

Accept a tagged union of payment methods with Field(discriminator), add Annotated validators, and test the exact 422 error shapes offline with TestClient.

fastapi@0.143.1pydantic@2.14.1httpx@0.28.1
last passed 2026-10-15 13:32 UTC
passed3/3python

httpx async API client + respx mocks

A typed async API client on httpx with retries on 5xx and Pydantic parsing, tested offline with respx route mocks.

httpx@0.28.1respx@0.23.1pydantic@2.14.1
last passed 2026-10-15 13:30 UTC
passed3/3python

Hypothesis property tests for Pydantic v2 models

Property-based tests with Hypothesis on Pydantic v2 models: JSON round trips, validator invariants, and a stateful RuleBasedStateMachine for a small inventory class.

hypothesis@6.169.4pydantic@2.14.1pytest@9.1.1
last passed 2026-10-15 13:32 UTC
passed5/5python

LangChain (Python) LCEL chain with structured parsing, tested with a fake chat model

Compose ChatPromptTemplate, a chat model and a Pydantic output parser with LCEL in langchain-core, tested offline using GenericFakeChatModel.

langchain-core@1.6.10pydantic@2.14.1pytest@9.1.1
last passed 2026-10-15 13:31 UTC
passed5/5python

Loading .env files with python-dotenv and pydantic-settings precedence rules

Typed app settings from .env files with pydantic-settings, covering source precedence, layered env files, extra-key rules and python-dotenv override behavior, tested offline with tmp_path files.

python-dotenv@1.2.4pydantic-settings@2.16.0pydantic@2.14.1
last passed 2026-10-15 13:33 UTC
passed5/5python

OpenAI chat.completions.parse with Pydantic output + respx mocks

Get typed output from OpenAI chat.completions.parse using a Pydantic response_format, handle refusals and schema mismatches, and test offline with respx returning canned JSON.

openai@3.31.0respx@0.23.1pydantic@2.14.1
last passed 2026-10-15 13:32 UTC
passed3/3python

OpenAI Python SDK structured outputs, tested with respx

Call the OpenAI Python SDK and validate JSON output with Pydantic, testing success, malformed output and API errors offline by mocking HTTP with respx.

openai@3.31.0pydantic@2.14.1respx@0.23.1
last passed 2026-10-15 13:32 UTC
passed3/3python

Pydantic Settings typed config from env and .env

Typed app configuration with pydantic-settings: env prefixes, nested settings, secrets and validation errors.

pydantic@2.14.1pydantic-settings@2.16.0pytest@9.1.1
last passed 2026-10-15 13:32 UTC
passed5/5python

Pydantic v2 email and phone validation with email-validator and phonenumbers

Validate emails with EmailStr and normalize phone numbers to E164 with phonenumbers inside a Pydantic model, tested offline with no network lookups.

pydantic@2.14.1email-validator@2.3.0phonenumbers@9.0.41
last passed 2026-10-15 13:32 UTC
passed4/4python

pydantic-ai Agent with typed output and deps-based tools, tested offline

A pydantic-ai agent with a typed Pydantic output and a tool that reads deps, tested fully offline with TestModel, FunctionModel and Agent.override.

pydantic-ai-slim@2.56.0pytest@9.1.1
last passed 2026-10-15 13:32 UTC
passed5/5python

pydantic-settings v2 config from env, YAML and defaults with SecretStr

Nested pydantic-settings models loaded with precedence init > env > YAML > defaults, with env_nested_delimiter, SecretStr masking, and offline tests using tmp_path and monkeypatch.

pydantic-settings@2.16.0pydantic@2.14.1python-dotenv@1.2.2
last passed 2026-10-15 13:32 UTC
passed4/4python

SQLAlchemy 2 ORM rows serialized with Pydantic v2 from_attributes

Map SQLAlchemy 2 models, expose nested relationships through Pydantic v2 schemas with from_attributes=True and a computed_field, and test them offline against in-memory SQLite.

sqlalchemy@2.1.4pydantic@2.14.1pytest@9.1.1
last passed 2026-10-15 13:33 UTC
passed6/6python

Typed httpx client parsing into pydantic v2 models, tested with respx

An async httpx client that retries 5xx and transport errors, validates responses into pydantic v2 models, and is tested offline with respx route mocks.

httpx@0.28.1pydantic@2.14.1respx@0.23.1
last passed 2026-10-15 13:30 UTC
passed5/5python

Validating polars DataFrame rows with pydantic v2 TypeAdapter and collecting errors

Validate each polars row against a strict pydantic v2 model with a shared TypeAdapter, collect per-row errors instead of failing the batch, and catch polars and pydantic gotchas such as nulls, NaN, numeric strings and extra columns.

polars@2.0.0pydantic@2.14.1pytest@9.1.1
last passed 2026-10-15 13:32 UTC

Used together with Pydantic

FastAPIhttpxrespxhypothesislangchain-corepython-dotenvPydantic Settingsopenaiemail-validatorphonenumberspydantic-aipyyamlSQLAlchemypolars