← ClaudeAtlas

pydantic-ai-agent-creationlisted

Create PydanticAI agents with type-safe dependencies, structured outputs, and proper configuration. Use when building AI agents, creating chat systems, or integrating LLMs with Pydantic validation.
existential-birds/beagle · ★ 61 · AI & Automation · score 84
Install: claude install-skill existential-birds/beagle
# Creating PydanticAI Agents ## Quick Start ```python 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: ```python # 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: ```python 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 ```python from pydantic_ai import Agent from pydantic_ai.settings import ModelSettings agent = Agent( 'openai:gpt-4o', output_type=MyOutput, # Structured output type deps_type=MyDeps, # Dependency injection type instructions='You are helpful.', # Static instructions retries=2, # Retry attempts for validation name='my-agent', # For log