# Pydantic AI — Production AI Agent Framework > Build production-ready AI agents in Python with type-safe structured outputs, dependency injection, and multi-model support. By the creators of Pydantic. ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: ## Quick Use ```bash pip install pydantic-ai ``` ```python from pydantic_ai import Agent agent = Agent('claude-sonnet-4-20250514', system_prompt='Be concise.') result = agent.run_sync('What is the capital of France?') print(result.output) # "Paris" ``` ## What is Pydantic AI? Pydantic AI is a Python agent framework built by the Pydantic team. It brings type safety, structured outputs, and dependency injection to AI agent development — making agents as reliable and testable as regular Python code. **Answer-Ready**: Pydantic AI is a production-grade AI agent framework by the Pydantic team that provides type-safe structured outputs, dependency injection, streaming, and multi-model support for building reliable AI agents in Python. **Best for**: Python developers building production AI agents who need type safety and testability. **Works with**: Claude, GPT, Gemini, Groq, Mistral, Ollama. **Setup time**: Under 2 minutes. ## Core Features ### 1. Structured Outputs with Pydantic Models ```python from pydantic import BaseModel from pydantic_ai import Agent class CityInfo(BaseModel): name: str country: str population: int agent = Agent('claude-sonnet-4-20250514', result_type=CityInfo) result = agent.run_sync('Tell me about Tokyo') print(result.output) # CityInfo(name='Tokyo', country='Japan', population=13960000) ``` ### 2. Tool Definitions ```python from pydantic_ai import Agent, RunContext agent = Agent('claude-sonnet-4-20250514') @agent.tool async def get_weather(ctx: RunContext[str], city: str) -> str: # Fetch weather data return f"Sunny, 22C in {city}" result = agent.run_sync('Weather in London?') ``` ### 3. Dependency Injection ```python from dataclasses import dataclass @dataclass class Deps: db: Database user_id: str agent = Agent('claude-sonnet-4-20250514', deps_type=Deps) @agent.tool async def get_orders(ctx: RunContext[Deps]) -> list: return await ctx.deps.db.get_orders(ctx.deps.user_id) result = agent.run_sync('Show my orders', deps=Deps(db=db, user_id='123')) ``` ### 4. Streaming ```python async with agent.run_stream('Write a poem') as response: async for text in response.stream_text(): print(text, end='', flush=True) ``` ### 5. Multi-Model Support ```python from pydantic_ai.models import OpenAIModel, AnthropicModel agent = Agent(OpenAIModel('gpt-4o')) # OpenAI agent = Agent(AnthropicModel('claude-sonnet-4-20250514')) # Anthropic agent = Agent('gemini-1.5-pro') # Google agent = Agent(OpenAIModel('llama3', base_url='http://localhost:11434/v1')) # Ollama ``` ## FAQ **Q: How does it compare to LangChain?** A: Pydantic AI is more opinionated and type-safe. LangChain is broader but more complex. Pydantic AI focuses on making agents testable and production-ready. **Q: Can I use it with Claude?** A: Yes, Anthropic Claude is a first-class supported provider. **Q: Is it production ready?** A: Yes, built by the Pydantic team (whose validation library is used by 80% of Python AI projects). ## Source & Thanks > Created by [Pydantic Team](https://github.com/pydantic). Licensed under MIT. > > [pydantic/pydantic-ai](https://github.com/pydantic/pydantic-ai) — 10k+ stars ## Quick Start ```bash pip install pydantic-ai ``` Create a type-safe AI agent in three lines of code. ## What is Pydantic AI? Pydantic AI is a Python agent framework from the Pydantic team that brings type safety, structured output, and dependency injection to AI agent development. **In one sentence**: Pydantic AI is a production-grade AI agent framework with type-safe structured output, dependency injection, streaming, and multi-model support. **For**: Python developers who need type safety and testability. **Supported models**: Claude, GPT, Gemini, Groq, Ollama. ## Core Features ### 1. Pydantic Structured Output Define outputs with Pydantic models — automatically validated. ### 2. Tool Definitions Define tool functions with decorators — the agent calls them automatically. ### 3. Dependency Injection Inject databases, user context, and other dependencies for easy testing. ### 4. Streaming Output Async streaming of text or structured data. ## FAQ **Q: How does it compare to LangChain?** A: Pydantic AI focuses more on type safety and testability; LangChain is broader but more complex. **Q: Production ready?** A: Yes — built by the Pydantic team (whose validation library is used by 80% of Python AI projects). ## Source & Thanks > [pydantic/pydantic-ai](https://github.com/pydantic/pydantic-ai) — 10k+ stars, MIT --- Source: https://tokrepo.com/en/workflows/pydantic-ai-production-ai-agent-framework-97ebc107 Author: Pydantic