pydantic-ai

pydantic-ai is a skill for Claude Code from skillmds/skillmd. It costs 32 tokens per session (2,931 once invoked), scanned A, a copy of pydantic-ai, MIT.

A Python framework for building AI agents that use tools and return validated, structured data instead of only plain text. It supports dependency injection, testing without a live model, streamed responses, and multiple model providers.

In plain words
What is it for?
Use it to build typed agents, validate model results, connect tools, inject application data, and test agent logic.
Why use it?
It reduces errors caused by unpredictable model output and makes agent code easier to test and change between providers.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the build-multi-agent-system-with-crewai plugin — 11 skills shipped together

Good fit Use it to build typed agents, validate model results, connect tools, inject application data, and test agent logic.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/skillmds/skillmd/pydantic-ai
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add skillmds/skillmd --skill pydantic-ai
Clone the repo
git clone --depth 1 https://github.com/skillmds/skillmd

Made for: Claude Code.

Or install build-multi-agent-system-with-crewai, the plugin that ships this one along with the rest of its 11 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pydantic-ai

README.md
[![agentmods](https://agentmods.dev/badge/skills/skillmds/skillmd/pydantic-ai/github.svg)](https://agentmods.dev/skills/skillmds/skillmd/pydantic-ai)
Your own site
<a href="https://agentmods.dev/skills/skillmds/skillmd/pydantic-ai"><img src="https://agentmods.dev/badge/skills/skillmds/skillmd/pydantic-ai/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pydantic-ai

Your own site · 80×15
<a href="https://agentmods.dev/skills/skillmds/skillmd/pydantic-ai"><img src="https://agentmods.dev/badge/skills/skillmds/skillmd/pydantic-ai.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,931 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 92% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00032 $0.02931
Opus 5.5 $0.00013 $0.01172
Sonnet 5 $0.00006 $0.00586
Haiku 4.5 $0.00003 $0.00293

Measured 4d ago against content hash 7b0a5038d380, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-23, from the pricing page.

Security

Grade A, and why

pydantic-ai scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

92% identical to pydantic-ai — 5 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

plugins/build-multi-agent-system-with-crewai/skills/pydantic-ai/SKILL.md · 356 lines

How it starts

The opening of the file, as written. The whole thing — 356 lines — stays where its author put it; the contents beside it link to each section on GitHub.

PydanticAI — Typed AI Agents in Python

Overview

PydanticAI is a Python agent framework from the Pydantic team that brings the same type-safety and validation guarantees as Pydantic to LLM-based applications. It supports structured outputs (validated with Pydantic models), dependency injection for testability, streamed responses, multi-turn conversations, and tool use — across OpenAI, Anthropic, Google Gemini, Groq, Mistral, and Ollama. Use this skill when building production AI agents, chatbots, or LLM pipelines where correctness and testability matter.

When to Use This Skill

  • Use when building Python AI agents that call tools and return structured data
  • Use when you need validated, typed LLM outputs (not raw strings)
  • Use when you want to write unit tests for agent logic without hitting a real LLM
  • Use when switching between LLM providers without rewriting agent code
  • Use when the user asks about Agent, @agent.tool, RunContext, ModelRetry, or result_type

How It Works

Step 1: Installation

pip install pydantic-ai

# Install extras for specific providers
pip install 'pydantic-ai[openai]'       # OpenAI / Azure OpenAI
pip install 'pydantic-ai[anthropic]'    # Anthropic Claude
pip install 'pydantic-ai[gemini]'       # Google Gemini
pip install 'pydantic-ai[groq]'         # Groq
pip install 'pydantic-ai[vertexai]'     # Google Vertex AI

Step 2: A Minimal Agent

from pydantic_ai import Agent

# Simple agent — returns a plain string
agent = Agent(
    'anthropic:claude-sonnet-4-6',
    system_prompt='You are a helpful assistant. Be concise.',
)

result = agent.run_sync('What is the capital of Japan?')
print(result.data)  # "Tokyo"
print(result.usage())  # Usage(requests=1, request_tokens=..., response_tokens=...)

Step 3: Structured Output with Pydantic Models

from pydantic import BaseModel
from pydantic_ai import Agent

class MovieReview(BaseModel):
    title: str
    year: int
    rating: float  # 0.0 to 10.0
    summary: str
    recommended: bool

agent = Agent(
    'openai:gpt-4o',
    result_type=MovieReview,
    system_prompt='You are a film critic. Return structured reviews.',
)

result = agent.run_sync('Review Inception (2010)')
review = result.data  # Fully typed MovieReview instance
print(f"{review.title} ({review.year}): {review.rating}/10")
print(f"Recommended: {review.recommended}")

Read the full file on GitHub · 356 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 356 lines · 32 tokens per session scan A 7b0a5038d380

Subscribe to this mod's changes

pydantic-ai is a skill published in the GitHub repository skillmds/skillmd (1 stars, last pushed yesterday), licensed MIT. It adds 32 tokens to every session and 2,931 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 92% identical to pydantic-ai, differing in 5 lines, and is treated as a copy.