Pydantic v2.5 Documentation

website·Indexed Jun 3, 2026

https://pydantic.dev/docs/

Official documentation for Pydantic v2.5, a data validation and settings management library. Includes API references for BaseModel, FieldInfo, and pydantic-core, as well as guides on JSON schema generation, custom types, strict mode, and migrations from V1 to V2. Covers integrations with PyCharm, VS Code, Mypy, and Hypothesis.

Tokens
1.5M
Snippets
5.8K
Records
8.1K
Agent score
50%

What's inside Pydantic

  1. Overview of Logfire MCP capabilities

    The Logfire Model Context Protocol (MCP) server provides AI assistants with tools to interact with your existing telemetry. Instead of summarizing logs or guessing, it exposes actual telemetry data to the model, allowing it to use sharp tools to anchor debugging in trace IDs, spans, and hard facts. This is particularly useful for debugging flaky integrations, production-only bugs, and performance regressions.
  2. Overview of Pydantic TypeAdapter

    A TypeAdapter provides a flexible interface for validating and serializing Python types that do not inherit from BaseModel, such as primitive types, dataclasses, or complex generic types.

    Note: TypeAdapter instances are not types themselves and cannot be used as type annotations for fields.

  3. Overview of Pydantic V2 Architecture and Improvements

    Pydantic V2 is a major rewrite of the library designed for significant performance gains and improved safety. The core validation logic has been moved to pydantic-core, a separate package written in Rust using pyo3.

    Key improvements include:

    • Performance: V2 is significantly faster than V1, with benchmarks showing improvements between 4x and 50x depending on the use case (averaging ~17x faster for common models).
    • Strict Mode: A new mode that prevents automatic data coercion. In strict mode, the input must match the exact expected type (e.g., an int field will reject the string `
  4. Overview of Pydantic Data Platform Components

    Pydantic is developing a data platform consisting of five key components designed to improve developer experience when working with data outside of Python:

    1. Python Analytics/Observability: A logging and metrics platform with tight Pydantic integration for engineering and business analytics.
    2. Data Gateway for object stores: A service providing validation, transformation, and cataloging for object stores (e.g., S3) using Pydantic models.
    3. Data Gateway for data warehouses: Similar to the object store gateway, but integrated with existing data warehouses.
    4. Schema Catalog: A single source of truth for organization-wide Pydantic schemas, tracking changes and integrating with other tools.
    5. Dashboards and UI: A managed platform where UI components (forms, tables) and database schemas are defined using Pydantic models in Python.
  5. Overview of Pydantic BaseModel

    In Pydantic, models are created by inheriting from the BaseModel class and defining fields as annotated attributes. BaseModel provides the core functionality for data validation, serialization, and model management.
  6. Overview of Logfire TypeScript SDK packages

    The Logfire TypeScript SDK provides observability support (tracing, logs, metrics, and error reporting) for JavaScript and TypeScript applications. The SDK is split into several packages depending on your runtime environment:

    • logfire: The core, runtime-agnostic manual tracing API. Includes spans, logs, levels, error reporting, sampling helpers, evaluations, and managed variables.
    • @pydantic/logfire-node: For Node.js environments. Configures the OpenTelemetry Node SDK, exporters, automatic instrumentation, logs, and metrics, and re-exports the logfire manual API.
    • @pydantic/logfire-browser: For client-side browser applications. Configures browser tracing and re-exports the logfire manual API.
    • @pydantic/logfire-cf-workers: For Cloudflare Workers. Instruments workers and forwards spans to Logfire.
  7. Overview of the Pydantic Open Source Fund

    Pydantic operates an Open Source Fund as part of its commitment to the Open Source Pledge. The fund commits to investing at least $2,000 per developer per year into open source projects and maintainers. This is separate from the direct costs Pydantic incurs for maintaining its own libraries (such as Pydantic, pydantic-core, Jiter, and FastUI).
  8. Overview of Pydantic Experimental Pipeline API

    The _Pipeline class provides an experimental, abstract representation of a chain of validation, transformation, and parsing steps. It is a generic class _Pipeline[_InT, _OutT] used to build sequential data processing logic.

    Warning: This API is experimental and subject to change.

  9. Overview of Pydantic AI Native Tools

    Native tools are capabilities provided directly by LLM providers and executed on the provider's infrastructure, rather than being custom implementations executed by Pydantic AI. These tools are passed to an agent's capabilities list, wrapped in a NativeTool object.

    Supported native tools include:

    • WebSearchTool: Allows agents to search the web.
    • XSearchTool: Allows agents to search X/Twitter (supported by xAI only).
    • CodeExecutionTool: Enables secure code execution.
    • ImageGenerationTool: Enables image generation.
    • WebFetchTool: Enables fetching web pages.
    • MemoryTool: Enables agent memory usage.
    • MCPServerTool: Enables use of remote MCP servers via the model provider.
    • FileSearchTool: Enables RAG-based searching through uploaded files via vector search.
  10. Overview of Pydantic AI agent framework

    Pydantic AI is an AI agent framework released by the Pydantic team. It is designed to work within the Pydantic ecosystem for building agentic systems. It is intended to be used alongside tools like Monty (a Rust-based Python implementation for LLM code execution) to enable faster and safer code execution by LLMs.
  11. Introduction to Pydantic AI

    Pydantic AI is a Python agent framework designed for building production-grade Generative AI applications. It is built by the Pydantic team and focuses on type safety, model agnosticism, and seamless observability via Pydantic Logfire. Key features include:

    • Model-agnostic: Supports OpenAI, Anthropic, Gemini, DeepSeek, Grok, Ollama, and many others.
    • Type-safe: Leverages Python type hints for IDE auto-completion and static type checking.
    • Extensible: Uses 'capabilities' to bundle tools, hooks, and instructions.
    • Observability: Native integration with Pydantic Logfire (OpenTelemetry) for tracing and cost tracking.
    • Advanced Patterns: Supports Human-in-the-loop tool approval, durable execution, streamed structured outputs, and graph-based control flows.
  12. Overview of pydantic.json_schema module

    The pydantic.json_schema module provides tools to customize and generate JSON Schemas. While this module contains low-level classes like GenerateJsonSchema, most users should instead use the high-level methods provided by Pydantic models or type adapters:

    • BaseModel.model_json_schema()
    • TypeAdapter.json_schema()