
Pydantic Ai Model Integration
This walks you through wiring up different LLM providers in PydanticAI using simple string formats like `openai:gpt-4o` or `anthropic:claude-sonnet-4-5`. The fallback model setup is the standout feature: chain multiple providers so if one hits rate limits or goes down, it automatically tries the next. You also get streaming for both plain text and structured Pydantic output, per-run model settings overrides, and usage tracking that shows token counts across requests. Useful when you're building something that needs to stay up despite API hiccups or when you want to route cheaper requests to mini models and save the expensive ones for complex work.
- skills.sh installs
- 120
- GitHub stars
- 87
- last updated
- Aug 21, 2026
Install
$ npx -y skills add existential-birds/beagle --skill pydantic-ai-model-integration --agent claude-codeInstalls into .claude/skills of the current project.
Files
PydanticAI Model Integration
Provider Model Strings
Format: provider:model-name
from pydantic_ai import Agent
# OpenAI
Agent('openai:gpt-4o')
Agent('openai:gpt-4o-mini')
Agent('openai:o1-preview')
# Anthropic
Agent('anthropic:claude-sonnet-4-5')
Agent('anthropic:claude-haiku-4-5')
# Google (API Key)
Agent('google-gla:gemini-2.0-flash')
Agent('google-gla:gemini-2.0-pro')
# Google (Vertex AI)
Agent('google-vertex:gemini-2.0-flash')
# Groq
Agent('groq:llama-3.3-70b-versatile')
Agent('groq:mixtral-8x7b-32768')
# Mistral
Agent('mistral:mistral-large-latest')
# Other providers
Agent('cohere:command-r-plus')
Agent('bedrock:anthropic.claude-3-sonnet')
Model Settings
from pydantic_ai import Agent
from pydantic_ai.settings import ModelSettings
agent = Agent(
'openai:gpt-4o',
model_settings=ModelSettings(
temperature=0.7,
max_tokens=1000,
top_p=0.9,
timeout=30.0, # Request timeout
)
)
# Override per-run
result = await agent.run(
'Generate creative text',
model_settings=ModelSettings(temperature=1.0)
)
Fallback Models
Chain models for resilience:
Sponsors
Details
- Repository
- github.com/existential-birds/beagle
- Categories
- Backend & APIs, AI & Agent Building, Python
- First seen
- Jun 3, 2026
More from existential-birds/beagle
All 40- React Flow1.3K
- Python Code Review928
- Langgraph Code Review887
- Tailwind V4817
- React Flow Advanced643
- React Router V7577
- React Flow Architecture536
- Vitest Testing471
- Docling431
- Fastapi Code Review387
- React Flow Implementation374
- Shadcn Ui356
- React Flow Code Review324
- Langgraph Architecture282
- Swiftui Code Review273
- Tutorial Docs271
- Bubbletea Code Review265
- Zustand State258
- Adr Writing250
- Dagre React Flow247
- Swift Code Review247
- Pytest Code Review232
- Sqlalchemy Code Review225
- Pydantic Ai Common Pitfalls221