Typed Python agent framework
How to use
Pydantic AI.
Building Python agents with strongly typed inputs, dependencies, tools, and outputs, then evaluating and running them with explicit token, request, tool, concurrency, and durability controls.
Pydantic AI is a Python agent framework for typed dependencies, validated tools and outputs, model portability, evaluation, observability, and durable execution. Building Python agents with strongly typed inputs, dependencies, tools, and outputs, then evaluating and running them with explicit token, request, tool, concurrency, and durability controls. This guide covers the whole path in one place: official access, a first session that produces something reviewable, the checks that make output trustworthy, and the permissions worth limiting before you connect real work.
AI should make the work easier to inspect. If the workflow removes the source, the owner, or the review step, redesign the workflow.
Access & setup
Find, install, and sign in to Pydantic AI
Get into the official Pydantic AI experience with the right account and a setup you understand.
- 01
Start at https://pydantic.dev/ai/ and confirm the domain before entering account or payment information.
- 02
Availability: Pydantic AI is installed as a Python package and used in code, tests, services, and supported durable-execution systems rather than through a standalone desktop app.
- 03
A supported Python environment, model-provider credentials, typed application dependencies, secure tools and secrets, usage and concurrency limits, representative eval datasets, and production telemetry and recovery ownership.
- 04
Sign in with the account you intend to keep using, then review plan, data, notification, and permission settings.
- 05
Run one low-risk test task before connecting sensitive files, repositories, or workspace data.
- Use official download pages.
- Review permissions during setup.
- Keep installers and applications updated.
First session
Your first useful Pydantic AI session
Learn the interaction loop using a small task with a clear outcome.
- 01
Define the task, users, dependency and output types, data classification, model, tools, authorization, limits, retries, quality, safety, durability, observability, and rollback criteria.
- 02
Create one agent with narrow instructions, typed runtime dependencies, an explicit output model, and the smallest toolset, keeping provider keys and user authorization outside prompts.
- 03
Run representative and adversarial cases with token, request, tool-call, timeout, retry, and concurrency limits, validating both outputs and the tool-call trajectory.
- 04
Inspect evals and traces for correctness, unsafe actions, schema retries, loops, failures, privacy, latency, and cost, then pin versions and canary behind independent authorization and fallback.
- State the outcome before the background.
- Provide the real source material.
- Review the result before expanding the task.
Quality control
Check the quality of Pydantic AI output
Establish that an autonomous run did the right thing, not merely that it finished.
- 01
Define what the run should achieve and what it must never touch before granting it a single tool.
- 02
Read the full execution trace: which tools were called, with what arguments, and in what order.
- 03
Verify the side effects directly in the target system rather than trusting the agent's own report of success.
- 04
Confirm failures surfaced as failures — a silent retry loop or a swallowed error is more dangerous than a crash.
- 05
Re-run the same task and compare: an agent that behaves differently across identical runs is not yet production-ready.
- Verify side effects in the system of record, not in the agent's summary.
- Require human approval for any irreversible or outward-facing action.
- Log every tool call so a run can be reconstructed afterwards.
Privacy & permissions
Use Pydantic AI safely
Bound what an autonomous system can reach before you let it run unattended.
- 01
Enumerate every tool, credential, and system the agent can reach, and remove the ones it does not need.
- 02
Require explicit human approval for irreversible actions: sending, publishing, paying, deleting, or deploying.
- 03
Run against non-production data until behaviour is predictable across repeated runs.
- 04
Set hard limits on spend, iterations, and runtime so a failure loop cannot run unbounded.
- 05
Treat anything the agent reads from the web or a document as data, never as instructions it may follow.
- Pydantic validation confirms declared types and constraints, not factual correctness, permission, provenance, or harmless side effects. Model-generated tool calls remain untrusted. Enforce current user and tenant authorization inside tools, cap requests, tokens and calls, set timeouts and concurrency, use idempotency for writes, redact telemetry, test replay semantics, and account for integration-specific durability and retry limitations.
- Follow your organisation's approved-use policy.
- Never treat fluent output as authorization to act.
Core workflows
Step-by-step ways to use Pydantic AI for the work it does best.
Each workflow is a separate guide with its own steps and review checkpoints.
Use types to constrain interfaces while treating model output and tool intent as untrusted until independently authorized and verified.
↗ 02 WorkflowMake a Pydantic AI agent durable and testableChoose a supported durability engine, define replay-safe boundaries, and couple recovery tests with code-first output and trajectory evals.
↗Official references
Check the current product documentation.
Features, plan limits, availability, and data controls change. These official pages are the starting points used for this guide.