pydantic-ai

pydantic-ai is a skill for Claude Code, Codex from davila7/claude-code-templates. It costs 32 tokens per session (2,870 once invoked), scanned A, original, MIT.

A Python framework for building AI agents that use tools and return validated, structured results. It supports multiple language-model providers and allows agent logic to be unit tested without calling a live model.

In plain words
What is it for?
Use it to build Python agents, chatbots, and language-model pipelines with tool calls, typed outputs, dependency injection, streaming, and multi-turn conversations.
Why use it?
It helps catch invalid model output and makes agent code easier to test, maintain, and move between supported model providers.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to build Python agents, chatbots, and language-model pipelines with tool calls, typed outputs, dependency injection, streaming, and multi-turn conversations.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/davila7/claude-code-templates/pydantic-ai
About the project

Claude Code Templates is a command-line tool and catalogue for configuring Anthropic’s Claude Code with agents, commands, settings, hooks, integrations, skills, and project templates. Developers use it to browse and install reusable components for their coding workflows. The catalogue includes many of these Claude Code components.

davila7/claude-code-templates · 30,566 stars · on GitHub · aitmpl.com

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 davila7/claude-code-templates --skill pydantic-ai
Clone the repo
git clone --depth 1 https://github.com/davila7/claude-code-templates

Made for: Claude Code, Codex.

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/davila7/claude-code-templates/pydantic-ai/github.svg)](https://agentmods.dev/skills/davila7/claude-code-templates/pydantic-ai)
Your own site
<a href="https://agentmods.dev/skills/davila7/claude-code-templates/pydantic-ai"><img src="https://agentmods.dev/badge/skills/davila7/claude-code-templates/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/davila7/claude-code-templates/pydantic-ai"><img src="https://agentmods.dev/badge/skills/davila7/claude-code-templates/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,870 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. Third-party audits
  • Snyk pass 7 Sept 2026
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found 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.02870
Opus 5 $0.00016 $0.01435
Sonnet 5 $0.00006 $0.00574
Haiku 4.5 $0.00003 $0.00287

Measured 5d ago against content hash 5b7395198d1e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, 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 5d 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.

cli-tool/components/skills/ai-research/pydantic-ai/SKILL.md · 351 lines

How it starts

The opening of the file, as written. The whole thing — 351 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 · 351 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. 5d ago First seen · 351 lines · 32 tokens per session scan A 5b7395198d1e

Subscribe to this mod's changes

pydantic-ai is a skill published in the GitHub repository davila7/claude-code-templates (30,566 stars, last pushed today), licensed MIT. It adds 32 tokens to every session and 2,870 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

accelerate

Run PyTorch training across GPUs with minimal changes.

NousResearch/hermes-agent · 13 tokens

free-llm-apis

Guide users through obtaining and configuring free API keys for LLM providers. Use when the user wants to set up a free LLM API, get a free API key, connect to a free model provider, configure an OpenAI-compatible endpoint at no cost, or asks about free tiers for AI models. Triggers on "free API key", "free LLM", "set…

mnfst/awesome-free-llm-apis · 116 tokens

ax-python-llm

Use when writing Python code with axllm for using the generated Ax package, factory functions, package docs, examples, and API reference.

ax-llm/ax · 36 tokens

liter-llm

Universal LLM API client for 165 providers with native bindings for 14 languages. Use when writing code that calls LLM APIs via liter-llm in Python, TypeScript, Rust, Go, Java, C#, Ruby, PHP, Elixir, WASM, or C, when running the OpenAI-compatible proxy, or when calling LLMs through the MCP server. Covers chat…

xberg-io/liter-llm · 117 tokens

calling-llms

Use when sending chat completions through liter-llm and routing to a specific provider via the provider/model prefix. Covers the chat call shape, provider routing, modelhint, message roles, and error categories.

xberg-io/liter-llm · 49 tokens

embeddings-and-search

Use when generating embeddings, calling the 12 web-search providers, or running OCR over documents with the 4 OCR providers through liter-llm. Covers embed, search, and ocr methods plus reranking.

xberg-io/liter-llm · 48 tokens