building-pydantic-ai-agents
Build AI agents with Pydantic AI — tools, capabilities, structured output, streaming, testing, and multi-agent patterns.
Skill by pydantic
Chalk Labs
Need help deploying building-pydantic-ai-agents?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/dushyantkhosla-building-pydantic-ai-agents
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: testing, agent-building
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions: not checked yet.
What's inside
- Skill name
building-pydantic-ai-agents- Description
- Build AI agents with Pydantic AI — tools, capabilities, structured output, streaming, testing, and multi-agent patterns. Use when the user mentions Pydantic AI, imports pydantic_ai, or asks to build an AI agent, add tools/capabilities, stream output, define agents from YAML, or test agent behavior.
- License
- MIT
- Compatibility
- Requires Python 3.10+
- Metadata
- author: pydantic · version: 1.1.0 · opencode/autoinvoke: false
- Instructions
- 289 lines in SKILL.md · view on GitHub
Files (11)
- SKILL.md
- AGENTS-CORE.md · references/
- ARCHITECTURE.md · references/
- BUILTIN-TOOLS.md · references/
- CAPABILITIES-AND-HOOKS.md · references/
- COMMON-TASKS.md · references/
- INPUT-AND-HISTORY.md · references/
- ORCHESTRATION-AND-INTEGRATIONS.md · references/
- TESTING-AND-DEBUGGING.md · references/
- TOOLS-ADVANCED.md · references/
- TOOLS-CORE.md · references/
SKILL.md (first lines)
# 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_ai` or references Pydantic AI classes (`Agent`, `RunContext`, `Tool`)
- User asks about hooks, lifecycle interception, or agent observability with Logfire
Do **not** use this skill for:
- The Pydantic validation library alone (`pydantic`/`BaseModel` without agents)
- Other AI frameworks (LangChain, LlamaIndex, CrewAI, AutoGen)
- General Python development unrelated to AI agents
## Quick-Start Patterns
### Create a Basic Agent
```python
from pydantic_ai import Agent
agent = Agent(
'anthropic:claude-sonnet-4-6',
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.
"""
```
### Create a basic Agent with local provider
This example uses the model `qwen3.5-9b-mlx` running on LMStudio
```python
from pydantic_ai import Agent, ModelSettings
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.openai import OpenAIProvider
from src import my_prompt, my_pydantic_model
agent = Agent(
model=OpenAIChatModel(
'qwen3.5-9b-mlx',
provider=OpenAIProvider(base_url="http://localhost:1234/v1", api_key="x"),
),
model_settings=ModelSettings(thinking=False),
output_type=my_pydantic_model,
output_retries=2,
instructions=my_prompt,
)
```
### Add Tools to an Agent
```python
import random
from pydantic_ai import Agent, RunContext
agent = Agent(
'google-gla:gemini-3-flash-preview',
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!
```
### Structured Output with Pydantic Models
```python
from pydantic import BaseModel
from pydantic_ai import Agent
class CityLocation(BaseModel):
city: str
country: str
agent = Agent('google-gla:gemini-3-flash-preview', output_type=CityLocation)
result = agent.run_sync('Where were the olympics held in 2012?')
print(result.output)
#> city='London' country='United Kingdom'
print(result.usage())
#> RunUsage(input_tokens=57, output_tokens=8, requests=1)
```
### Dependency InjectionFrom dushyantkhosla/agent-skills, MIT.
More from dushyantkhosla/agent-skills
- 0.570score
dk-wikibot
dushyantkhosla
Fetch, search, and extract information from Wikipedia, Wikidata, or any MediaWiki-based wiki using pywikibot.
SkillAFreshness: AClaude Code +9 - 0.570score
dk-wiki-article-writing
dushyantkhosla
Use when writing a Wikipedia-style article or comprehensive research-backed document on a technical topic.
SkillAFreshness: AClaude Code +9 - 0.570score
dk-lm-studio-pydantic-ai
opencode
Use LM Studio as a local LLM backend with Pydantic AI for structured output extraction.
SkillAFreshness: AClaude Code +9 - 0.566score
dk-transcribe-summarize
dushyantkhosla
Transcribe audio files or YouTube videos via subtitles or OpenRouter's multimodal API, generate 100-word and 400-word summaries using cloud models…
SkillAFreshness: AClaude Code +9 - 0.565score
here-now
dushyantkhosla
here.now lets agents publish websites and files to live URLs in seconds.
SkillAFreshness: AClaude Code +9 - 0.559score
browser-tools
dushyantkhosla
Browser automation over Chrome DevTools Protocol on port 9222 — navigate, evaluate JavaScript, take screenshots, and extract readable article content as…
SkillAFreshness: AClaude Code +9 - 0.553score
caveman
dushyantkhosla
Ultra-compressed communication mode that cuts output tokens while keeping technical accuracy.
SkillAFreshness: AClaude Code +9 - 0.531score
improve-codebase-architecture
dushyantkhosla
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
SkillAFreshness: AClaude Code +9 - 0.531score
sdd-brainstorming
dushyantkhosla
You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior.
SkillAFreshness: AClaude Code +9 - 0.523score
handoff
dushyantkhosla
Compact the current conversation into a handoff document for another agent to pick up.
SkillAFreshness: AClaude Code +9
Signals
- Stars
- 0
- Forks
- 1
- Open issues
- 0
- Last commit (this folder)
- Oct 7, 2026 (26 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- Version
- 1.1.0
- License
- MIT
- Repository
- github.com/dushyantkhosla/agent-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
More from pydantic
- 0.691score
AGENTS.md · pydantic/pydantic-ai
pydantic
AGENTS.md from pydantic/pydantic-ai: 171 lines covering Choosing an agent model, Pushing changes, Repository structure, Development workflow and more.
TemplateAFreshness: A★ 20.8KCodex +5 - 0.570score
building-pydantic-ai-agents
pydantic
Build AI agents with Pydantic AI — tools, capabilities, structured output, streaming, testing, and multi-agent patterns.
SkillAFreshness: AClaude Code +9
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get building-pydantic-ai-agents running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
building-pydantic-ai-agents skill. Agent Mart. https://agentmart.dev/skills/dushyantkhosla-building-pydantic-ai-agents (last updated 2026-10-24)