Loading...
Loading...
Use this skill whenever the user is working with the Pydantic AI framework — including building AI agents, defining structured outputs with Pydantic models, wiring up tools/function calling, configuring model providers (OpenAI, Anthropic, Gemini, etc.), managing dependencies via agent context, handling streaming responses, or debugging agent runs. Trigger this skill even for adjacent tasks like "how do I make my agent return JSON", "set up a multi-step agent", "add a tool to my agent", or "validate LLM output with Pydantic" — any time Pydantic AI is mentioned or implied as the target framework.
npx skill4agent add arthrod/conejo-skills pydanticai-docsfrom pydantic_ai import Agent
agent = Agent(
'openai:gpt-4o', # model string: provider:model-name
system_prompt='Be helpful.',
)
result = agent.run_sync('What is the capital of France?')
print(result.output)references/AGENT.md@agent.toolfrom pydantic_ai import Agent, RunContext
agent = Agent('openai:gpt-4o', deps_type=str)
@agent.tool
def get_user_name(ctx: RunContext[str]) -> str:
"""Return the current user's name."""
return ctx.deps
result = agent.run_sync('What is my name?', deps='Alice')@agent.tool_plainRunContextreferences/FUNCTION_TOOLS.mdRunContextfrom dataclasses import dataclass
from pydantic_ai import Agent, RunContext
@dataclass
class MyDeps:
api_key: str
user_id: int
agent = Agent('openai:gpt-4o', deps_type=MyDeps)
@agent.tool
async def fetch_data(ctx: RunContext[MyDeps]) -> str:
return f'User {ctx.deps.user_id}'RunContextreferences/DEPENDENCIES.mdfrom pydantic import BaseModel
from pydantic_ai import Agent
class CityInfo(BaseModel):
city: str
country: str
agent = Agent('openai:gpt-4o', output_type=CityInfo)
result = agent.run_sync('Where were the 2012 Olympics held?')
print(result.output) # CityInfo(city='London', country='United Kingdom')output_validatorreferences/OUTPUT.mdFor these topics, load the named reference file or follow the doc link — no implementation code is provided here.
references/<CONCEPT>.mdmodels/anthropic/index.mddougtrajano/pydantic-ai-skills./scripts/update-vendored.sh pydanticai-docspydantic-ai-agent-builderpydantic-ai-common-pitfallspydantic-ai-dependency-injectionpydantic-ai-model-integrationpydantic-ai-testingpydantic-ai-tool-system