existential-birds avatar

Pydantic Ai Agent Creation

This walks you through spinning up PydanticAI agents with proper type safety and structured outputs. You get model selection across OpenAI, Anthropic, Google, and others using a simple provider:model-name format, plus Pydantic models for validated responses instead of raw strings. The dependency injection pattern is clean (deps_type lets you thread API keys or database connections through without globals), and the three verification gates at the end are genuinely useful for catching issues before production. If you're building anything beyond one-off LLM calls, the structured output alone justifies the setup cost. The instructions versus system prompts distinction trips people up initially, but the examples make it clear.

skills.sh installs
219
GitHub stars
87
last updated
Aug 21, 2026

Install

$ npx -y skills add existential-birds/beagle --skill pydantic-ai-agent-creation --agent claude-code

Installs into .claude/skills of the current project.

Files

Creating PydanticAI Agents

Quick Start

from pydantic_ai import Agent

# Minimal agent (text output)
agent = Agent('openai:gpt-4o')
result = agent.run_sync('Hello!')
print(result.output)  # str

Model Selection

Model strings follow provider:model-name format:

# OpenAI
agent = Agent('openai:gpt-4o')
agent = Agent('openai:gpt-4o-mini')

# Anthropic
agent = Agent('anthropic:claude-sonnet-4-5')
agent = Agent('anthropic:claude-haiku-4-5')

# Google
agent = Agent('google-gla:gemini-2.0-flash')
agent = Agent('google-vertex:gemini-2.0-flash')

# Others: groq:, mistral:, cohere:, bedrock:, etc.

Structured Outputs

Use Pydantic models for validated, typed responses:

from pydantic import BaseModel
from pydantic_ai import Agent

class CityInfo(BaseModel):
    city: str
    country: str
    population: int

agent = Agent('openai:gpt-4o', output_type=CityInfo)
result = agent.run_sync('Tell me about Paris')
print(result.output.city)  # "Paris"
print(result.output.population)  # int, validated

Agent Configuration

from pydantic_ai import Agent
from pydantic_ai.settings import ModelSettings

Sponsors

Details

Repository
github.com/existential-birds/beagle
Categories
AI & Agent Building, Python
First seen
Jun 3, 2026

More from existential-birds/beagle

All 40
1absolutelyskilled avatarai-agent-designabsolutelyskilled/absolutelyskilledai agent design140skills.sh installs
2neondatabase avatarneon-ai-gatewayneondatabase/agent-skillsOne API and one credential for frontier and open-source LLMs and embedding models, built into your Neon branch and powered by Databricks. Use when a user wants 39.8Kskills.sh installs
3github avataragentic-evalgithub/awesome-copilotPatterns and techniques for evaluating and improving AI agent outputs. Use this skill when: - Implementing self-critique and reflection loops - Building evaluat10.3Kskills.sh installs
4github avataragent-governancegithub/awesome-copilotPatterns and techniques for adding governance, safety, and trust controls to AI agent systems. Use this skill when: - Building AI agents that call external tool9.7Kskills.sh installs
5emblemcompany avataremblem-ai-agent-walletemblemcompany/agent-skillsConnect to EmblemVault and manage wallet-aware workflows via EmblemAI with review-first, operator-controlled actions. Supports Solana, Ethereum, Base, BSC, Poly8.8Kskills.sh installs
6inferen-sh avatarai-rag-pipelineinferen-sh/skills6.3Kskills.sh installs