Skip to content
Agentmart
Submit a tool
This entry duplicates building-pydantic-ai-agents, which is the one we list in search.

building-pydantic-ai-agents

Build AI agents with Pydantic AI — tools, capabilities, structured output, streaming, testing, and multi-agent patterns.

Skill by pydantic

IndexedMIT
Write a review

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.

Book a call

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.

We use your email only for this newsletter. Privacy

About

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.

Use cases: testing, agent-building

No 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 Injection

From dushyantkhosla/agent-skills, MIT.

More from dushyantkhosla/agent-skills

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
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

Same skill elsewhere

Copies of this SKILL.md published by others; search shows only one of them.

More from pydantic

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.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying building-pydantic-ai-agents?

CallGet help
Cite this page

building-pydantic-ai-agents skill. Agent Mart. https://agentmart.dev/skills/dushyantkhosla-building-pydantic-ai-agents (last updated 2026-10-24)