Learning resourcesReviewed · Pydantic

Pydantic AI: Going to Production

Going to Production is a guide for Python developers deploying Pydantic AI agents, but its example still needs authentication, authorization and other production safeguards. It explains crash recovery, human approval, conversation storage, spending controls, tracing, evaluation and deployment.

Researched 14 Nov 2026

In short.

Going to Production is a practical guide for Python teams shipping Pydantic AI agents, with hosting, storage and application security left to the team. A FastAPI and DBOS example connects durable workflows, approval requests and tracing; subsequent sections explain persistence, budgets, provider failures, evaluations and frontend integration. Its most useful details concern failure boundaries: interrupted tools can run again, spending controls can overshoot, and approval endpoints still need authorization. No examples were executed, and compatibility, performance and operational reliability remain unassessed.

Researched and written by an AI model and checked by a second AI model. How it works

Covers the complete selected page at [https://pydantic.dev/docs/ai/production/index.md], including its examples, operational caveats and documentation-index and agent-query notices. All linked pages, the documentation index, repositories, service terms and pricing details are excluded. The captured source revision is sha256:1de836fe91e5dabc8e5946d17c6fbf4ce085b54f46c6c87d7b21818824766d48. No commands or examples were executed; runtime behavior, compatibility, security, performance and actual costs were not assessed.

The overview

identity

Going to Production is a Pydantic AI documentation guide at [https://pydantic.dev/docs/ai/production/index.md]. It teaches how to assemble and operate an agent service rather than offering a hosted agent application.

The page distinguishes Pydantic AI, Pydantic Evals and Pydantic AI Harness as Python packages running in your process. Logfire and Pydantic AI Gateway are optional hosted services; there is no Pydantic-hosted agent runtime.

assessment

The guide is useful for moving from a working agent to an application that must survive interruptions, manage approvals and expose an API. It connects these concerns through one service example and explains where each mechanism stops helping.

The example is a starting point rather than a complete public service: the page explicitly leaves out authentication, run ownership checks, request deduplication and usage limits. Its descriptions establish intended behavior, not measured reliability or deployment readiness.

users

The main audience is Python developers and platform teams building agents with tools, persistent conversations or actions requiring approval. Teams already using FastAPI, workflow engines or OpenTelemetry can connect the examples to familiar infrastructure.

Beginners receive explanations organized around practical questions, including what happens after a crash and where API keys belong. Implementing the service still requires familiarity with asynchronous Python, HTTP APIs, databases and credentials; it is not a no-code deployment tutorial.

capabilities

The page covers durable execution, deferred tool approval, stored conversations, request and spending limits, timeouts, concurrency controls, provider fallback, secret configuration and OpenTelemetry tracing. It also describes frontend streaming through AG-UI or Vercel AI adapters.

Testing guidance distinguishes simulated-model unit tests from evaluations of answer quality and tool trajectories. Additional Harness features include longer-term spending budgets, sandboxes, guardrails and model-assisted review of tool calls. These are separate components to configure, not features automatically enabled by the example.

Using it

requirements

The end-to-end example requires a Python environment, pydantic-ai with the DBOS extra, FastAPI, Uvicorn and a model provider API key. Its local workflow database is SQLite; the page recommends PostgreSQL for production. Exact supported Python and dependency versions are not supplied.

A real service also needs infrastructure, authorized access to conversations and tools, protected credentials and a strategy for concurrent state updates. Logfire credentials are optional, and another OpenTelemetry backend can receive traces. Some features described later require pydantic-ai-harness or a different durable engine.

mechanism

The guide separates three jobs. Durable execution journals model requests and covered tool calls for crash recovery. Deferred tools end an agent run with pending calls so approval can arrive later. A stored Conversation carries messages, accumulated usage, its identifier and pending deferred calls between runs.

Recovery replays completed journaled steps and retries the interrupted step. DBOS does not automatically wrap function tools, so the example marks its refund function with DBOS.step. An interrupted external action can still happen again; tools need repeat-safe behavior, such as an idempotency key that prevents duplicate effects.

setup

The documented installation command is pip install "pydantic-ai[dbos]" fastapi uvicorn. The alternative is uv add "pydantic-ai[dbos]" fastapi uvicorn. The page places its service in production_service.py and documents starting it with uvicorn production_service:app.

The example configures DBOS, launches it during FastAPI startup and instruments the agent with Logfire. Before exposing the endpoints, add authentication, ownership checks, deduplication and usage limits. Package versions and the example model identifiers require verification; no installation or startup was performed.

example

The support-agent example starts a workflow through POST /runs, returns a run identifier and exposes progress through GET /runs/{run_id}. When the model requests issue_refund, the workflow publishes pending approval details and waits for a decision sent to POST /runs/{run_id}/approvals. Unanswered requests are denied after a week.

The refund function only returns a message; it does not integrate with a payments API. The documented restart scenario illustrates DBOS recovery, but neither that scenario nor an actual refund was executed. The HTTP requests start, inspect and signal the workflow rather than remaining open throughout it.

Assessment & evidence

limitations

Approval decisions submitted by clients are trusted, so deferred approval does not replace endpoint authentication or authorization inside sensitive tools. Conversation identifiers are lookup keys, not credentials, and concurrent continuations need locking or version checks.

Telemetry includes prompts, completions and tool arguments by default. The include_content=False and include_binary_content=False settings do not affect run metadata, your own spans or captured HTTP request bodies, which must be configured separately. Filesystem path checks do not isolate shell commands, and streamed responses do not receive the custom response checks described for non-streamed model fallback.

Online evaluation runs inside the application process and needs concurrency limits and shutdown handling. Durable workflow changes can break in-flight runs that replay against new code. No security audit, load testing, crash testing or compatibility results are supplied.

reasoning

This guide fits teams willing to own a Python service and choose infrastructure for persistence, execution and observability. Its practical strength is making separate responsibilities explicit: storing a conversation does not itself provide durable execution, and model approval does not authorize the caller.

It is less suitable for someone seeking a managed deployment with security and operations already assembled. The evidence supports using it as implementation guidance; it does not establish superior answer quality, lower costs or better reliability than competing frameworks.

alternatives

The page describes several infrastructure choices: DBOS runs in-process against SQLite or PostgreSQL; Temporal and Restate use separate servers; Prefect and Airflow suit existing orchestration setups. Harness options Absurd and pgtask use PostgreSQL. Their linked implementation details were not assessed.

Logfire can be replaced by another OpenTelemetry backend, and direct provider access can replace Pydantic AI Gateway. Stored conversations and Harness snapshots address different persistence needs from durable execution. The page provides no head-to-head assessment of alternative agent frameworks.

evidence

The sole source is the complete Going to Production documentation page [https://pydantic.dev/docs/ai/production/index.md]. It supplies explanatory text, installation commands and Python examples, including explicit caveats about security, retries, persistence and spending controls.

Linked API references, repositories, pricing pages and production case studies are outside the evidence. No code was executed. Actual recovery behavior, authorization enforcement, evaluation quality, throughput and operating costs remain unverified.

Access & freshness

costs

Exact operating costs are unknown. The page mentions a Logfire free tier and commercial enterprise support without prices or quotas. Model calls, application hosting, storage and optional hosted services can contribute costs; MIT package licensing does not establish free operation.

UsageLimits checks token and cost totals after a response, so the request crossing the limit is already paid for. Cost tracking is best-effort: a model without genai-prices pricing data is not counted toward cost_limit, so the page advises keeping request_limit alongside it, and Harness SpendLimits treats an unpriced response as free unless on_unpriced='raise' is set. Harness SpendLimits can overshoot with concurrent requests and needs shared storage across processes or restarts. The example's USD 0.50 limit is an illustrative budget setting, not a service price.

rights

The page states that Pydantic AI, Pydantic Evals and Pydantic AI Harness are open source and MIT licensed. Full license texts and dependency notices are not included in the supplied evidence.

That package licensing statement does not establish the redistribution license for this documentation page or its examples. Documentation redistribution rights, hosted-service terms and model-provider terms remain unknown.

freshness

The page was captured at 2026-11-14T13:07:51.530Z. That timestamp establishes the documentation snapshot, not its publication date or the release date of any package.

The supplied page gives no publication or last-update date, and its installation commands do not pin versions. It links separate version policies for Pydantic AI and Harness. Current release numbers, model availability and compatibility among the illustrated APIs are unknown.

actions

Before adapting the service, confirm supported Python and package versions, provider model availability and expected pricing. Choose a durable engine and database, pin dependencies and plan how deployments will handle workflows started under older code.

Add authenticated routes, per-run ownership checks, tool authorization, request deduplication, concurrent-update protection and repeat-safe external actions. Configure spending controls and telemetry content handling. Then validate approval denial and resumption, crashes during side effects, provider failures, budget overshoot and shutdown behavior in your own environment.

Evidence for this report

selected-page.txtselected · checked 2026-11-14