Skip to content

PydanticAI Examples

A comprehensive collection of examples demonstrating PydanticAI framework capabilities — from basic model requests to advanced document processing with schema validation.

  • Direct Model Requests


    Make LLM calls without agents using the direct API.

    View example

  • Temperature


    Control output randomness and creativity with temperature.

    View example

  • Reasoning Effort


    Tune internal reasoning depth for speed vs accuracy.

    View example

  • Basic Sentiment


    Fixed 3-class sentiment analysis with structured outputs.

    View example

  • Dynamic Classification


    Runtime-adaptable classification with dynamic Literal types.

    View example

  • Bielik (Local Models)


    Run a Polish LLM locally with Ollama and PydanticAI.

    View example

  • History Processor


    Manage conversation history, filtering, and persistence.

    View example

  • OCR Parsing


    Extract structured data from PDFs with schema validation.

    View example

Why PydanticAI?

PydanticAI brings type safety and structured outputs to LLM interactions. Instead of parsing free-form text, you define Pydantic models and let the framework handle validation, retries, and schema enforcement.

These examples show real patterns you can adapt for your own projects — each one is self-contained and runnable.

Getting Started

New here? Head to the Getting Started guide for setup instructions, then follow the learning path through the examples.