Pydantic AI is a typed Python SDK for building AI agents that can use different language models and interfaces, including voice, image generation, and embeddings. Developers use it for applications ranging from structured data extraction to long-running multi-agent work. The catalogue entries provide workflows and configuration for its coding-agent and harness features.
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.
npx skills add pydantic/pydantic-ai --skill building-pydantic-ai-agentsgit clone --depth 1 https://github.com/pydantic/pydantic-aiWrote 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.
[](https://agentmods.dev/skills/pydantic/pydantic-ai/building-pydantic-ai-agents)<a href="https://agentmods.dev/skills/pydantic/pydantic-ai/building-pydantic-ai-agents"><img src="https://agentmods.dev/badge/skills/pydantic/pydantic-ai/building-pydantic-ai-agents/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.
<a href="https://agentmods.dev/skills/pydantic/pydantic-ai/building-pydantic-ai-agents"><img src="https://agentmods.dev/badge/skills/pydantic/pydantic-ai/building-pydantic-ai-agents.svg" alt="Reviewed on agentmods" width="80" height="20"></a>- Snyk pass
- NVIDIA SkillSpector pass
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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00085 | $0.05015 |
| Opus 5 | $0.00043 | $0.02508 |
| Sonnet 5 | $0.00017 | $0.01003 |
| Haiku 4.5 | $0.00009 | $0.00502 |
Grade A, and why
building-pydantic-ai-agents 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 today.
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.
How it starts
The opening of the file, as written. The whole thing — 402 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Building AI Agents with Pydantic AI
Pydantic AI is a Python agent framework for building production-grade Generative AI applications. This skill provides patterns, architecture guidance, and tested code examples for building applications with Pydantic AI.
When to Use This Skill
Invoke this skill when:
- User asks to build an AI agent, create an LLM-powered app, or mentions Pydantic AI
- User wants to add tools, capabilities (thinking, web search), or structured output to an agent
- User asks to define agents from YAML/JSON specs or use template strings
- User wants to stream agent events, delegate between agents, or test agent behavior
- Code imports
pydantic_aior references Pydantic AI classes (Agent,RunContext,Tool) - User asks about hooks, lifecycle interception, or agent observability with Logfire
- The agent design includes optional instructions, specialist workflows, long-tail tools, or any context the model does not need on most turns
Do not use this skill for:
- The Pydantic validation library alone (
pydantic/BaseModelwithout agents) - Other AI frameworks (LangChain, LlamaIndex, CrewAI, AutoGen)
- General Python development unrelated to AI agents
Quick-Start Patterns
Create a Basic Agent
from pydantic_ai import Agent
agent = Agent(
'anthropic:claude-sonnet-4-6',
name='hello_world_agent',
instructions='Be concise, reply with one sentence.',
)
result = agent.run_sync('Where does "hello world" come from?')
print(result.output)
"""
The first known use of "hello, world" was in a 1974 textbook about the C programming language.
"""
Add Tools to an Agent
import random
from pydantic_ai import Agent, RunContext
agent = Agent(
'google:gemini-3-flash-preview',
name='dice_game_agent',
deps_type=str,
instructions=(
"You're a dice game, you should roll the die and see if the number "
"you get back matches the user's guess. If so, tell them they're a winner. "
"Use the player's name in the response."
),
)
@agent.tool_plain
def roll_dice() -> str:
"""Roll a six-sided die and return the result."""
return str(random.randint(1, 6))
@agent.tool
def get_player_name(ctx: RunContext[str]) -> str:
"""Get the player's name."""
return ctx.deps
dice_result = agent.run_sync('My guess is 4', deps='Anne')
print(dice_result.output)
#> Congratulations Anne, you guessed correctly! You're a winner!
What ships with it
11 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
- references/AGENTS-CORE.md 7.2 KB
- references/ARCHITECTURE.md 13 KB
- references/CAPABILITIES-AND-HOOKS.md 14 KB
- references/COMMON-TASKS.md 4.8 KB
- references/INPUT-AND-HISTORY.md 12 KB
- references/NATIVE-TOOLS.md 3.4 KB
- references/ON-DEMAND-CAPABILITIES.md 14 KB
- references/ORCHESTRATION-AND-INTEGRATIONS.md 7.7 KB
- references/TESTING-AND-DEBUGGING.md 2.9 KB
- references/TOOLS-ADVANCED.md 13 KB
- references/TOOLS-CORE.md 4.5 KB
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.
- today Changed · +5 lines 1f9231f777a7
- 3d ago Changed 86b33a5dcf44
- 7d ago Changed · +17 lines 59086d713f3c
- 8d ago Changed · +4 lines fc373a55e4e7
- 12d ago First seen · 376 lines · 85 tokens per session scan A 006594854cef
building-pydantic-ai-agents is a skill published in the GitHub repository pydantic/pydantic-ai (19,869 stars, last pushed today), licensed MIT. It adds 85 tokens to every session and 5,015 once invoked, about $0.0004 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-08-30.
Other skills, from other repositories
test-generator
Generate pytest test cases for Python functions and classes.
browser-use
Direct browser control via CDP for web interaction: automation, scraping, testing, screenshots, and site/app work.
review-prs
Review a GitHub pull request in the googleapis/mcp-toolbox repo against the team's reviewer checklist: PR title/description conventions, linked issue, logic errors and unhandled edge cases, breaking changes, test coverage, docs updates, security (input handling), and new dependencies. Use whenever a maintainer asks…
reproduce-bug
Reproduce a reported bug in googleapis/mcp-toolbox and decide whether it is real, delivering an evidence-backed verdict: confirmed, already fixed, misconfiguration, client-side, works as intended, not reproducible, or blocked. Use whenever a maintainer asks you to reproduce, verify, confirm, or investigate a bug…
fix-failing-tests
Diagnose a failing test in the googleapis/mcp-toolbox repo and land a fix by reasoning from the actual error: read the failure, reproduce it, shrink it until the cause is forced into the open, then fix the cause. Use this whenever a test or CI job is red, a build breaks after a change, many packages fail at once, or a…
python-testing
Guidelines for writing and running tests in the Agent Framework Python codebase. Use this when creating, modifying, or running tests.