In short.
The Pydantic AI Web Chat UI guide is a setup reference for Python developers who want browser access to their agents, but its interface is intended for local development and debugging. Agent.to_web() creates an app served through an ASGI server, with configurable models, supported native tools and approval prompts. Those prompts trust decisions sent by the client and do not provide authorization. The guide also explains hostname validation, root-path routing and a self-contained offline frontend. Costs, licensing, minimum package versions and runtime reliability are not established by this page; nothing was executed.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage is the complete selected page at [https://pydantic.dev/docs/ai/guides/web/index.md], including its introductory documentation-index and request-parameter notices, examples, security cautions, routing constraints and offline-build notes. Linked pages, the documentation index, linked image contents, package code and CDN files are excluded. Described behavior is supported by documentation only; installation, execution, security protections and offline operation remain untested.
The overview
identity
This is the Pydantic AI documentation guide titled Web Chat UI, available at [https://pydantic.dev/docs/ai/guides/web/index.md]. It teaches developers to expose a Pydantic AI agent through the framework’s built-in browser interface using Agent.to_web().
The resource is a feature guide rather than a standalone hosted chat service. Its stated purpose is local agent development and debugging.
assessment
The documented interface suits developers who already have a Pydantic AI agent and want to interact with it without first building a frontend. The guide supplies concrete installation and serving instructions, followed by configuration and deployment constraints.
Its security cautions materially affect suitability: tool approvals are developer conveniences, and exposing the endpoint to untrusted clients requires authentication in front of it. Production frontend needs are directed toward separate UI Event Stream integrations.
users
Python developers learning agent development can use the short examples to understand how an agent, a tool and a browser interface connect. The examples assume familiarity with Python functions, package installation and starting a server.
Experienced developers get additional guidance for model configuration, reverse proxies, tunnels, health probes and offline frontend delivery. Teams needing a production application should account for the guide’s local-development scope and its recommendation to use a custom frontend.
capabilities
Agent.to_web() exposes browser chat for an agent. Its models argument accepts model names or instances, either as a list or as a dictionary with display labels. Extra instructions can be included in each agent run.
Configured native tools appear as UI options only for models that support them. Tools requiring approval produce pending-call prompts with approve and reject choices. The guide also supports replacing the default HTML source with a local file or custom URL.
The native memory tool has a specific exception: the page says it is not supported through to_web() or clai web and directs agents needing memory to configure MemoryTool at agent construction.
Using it
requirements
The documented installation uses the web extra of pydantic-ai-slim, which installs Starlette and Uvicorn. Serving the interface requires a Python agent, an ASGI server and a browser. Minimum Python and Pydantic AI versions, hardware requirements and provider credential setup are not stated.
The default frontend is fetched from a CDN and cached locally. The self-contained offline build is described as approximately 16 MB. Removing frontend CDN requests does not establish that the configured model or agent tools can operate without network access.
mechanism
Agent.to_web() creates an ASGI application that serves the chat interface and exposes chat, configuration and health endpoints. The documented routes are /, /{id}, /api/chat, /api/configure and /api/health.
The chat endpoint requires Content-Type: application/json and rejects other content types with HTTP 415. The guide explains that cross-origin browser requests using this content type require a preflight that the server refuses. Host validation provides an additional defense against DNS rebinding.
Approval decisions arrive from the client, and the server trusts them. Any client able to reach the endpoint can approve a pending call, including calls to tools marked requires_approval=True.
setup
The page gives pip install 'pydantic-ai-slim[web]' and uv add 'pydantic-ai-slim[web]' as installation options. Create an Agent, assign app = agent.to_web(), and serve the module with uvicorn my_module:app --host 127.0.0.1 --port 7932. The corresponding browser address is [http://127.0.0.1:7932].
If a reverse proxy or tunnel serves the app under a hostname, configure allowed_hosts for that hostname. Host validation applies to health checks too, so probes using an unlisted DNS hostname receive HTTP 421.
For an offline frontend, obtain the self-contained build identified by OFFLINE_HTML_URL and set html_source to its local file. Downloading only the default index.html is insufficient because that build loads additional CDN assets.
example
The basic example creates an Agent using the model identifier openai:gpt-6.1-sol, registers get_weather(city: str) with agent.tool_plain, and exposes the agent with app = agent.to_web(). The weather function always returns a sentence saying the city is sunny; it does not retrieve a real forecast.
A separate example supplies OpenAI and Anthropic models through the models argument, optionally with friendly display labels. These are documentation examples, not evidence of current provider availability, successful tool calls or working model switching. None of the examples was executed.
Assessment & evidence
limitations
The app cannot currently be mounted under a subpath such as /chat because the frontend expects its routes at the root. Additional routes must avoid the reserved paths.
Default Host acceptance includes IP addresses, including LAN addresses, localhost and names beneath localhost. Other hostnames require configuration. Wildcards should cover only subdomains the operator controls; allowed_hosts=['*'] is advised only when an upstream component already authenticates requests.
Binding to localhost alone is not an authorization boundary, and approval prompts do not authenticate the person approving a tool call. The page does not establish conversation retention, data-handling terms, browser compatibility, performance or production reliability.
reasoning
The central trade-off is quick browser access versus application control. A developer can expose an existing agent with a short method call, while the documented root-route assumptions and client-trusted approvals constrain how the interface should be deployed.
The offline build addresses frontend asset delivery, not the agent’s entire execution environment. Likewise, host filtering addresses particular browser attack paths without identifying users. These distinctions matter when deciding whether the built-in UI fits a local debugging task or requires additional application infrastructure.
alternatives
The page points to clai web for launching the browser interface through the CLI. For production, it points to UI Event Stream integrations that connect an agent to a custom frontend.
For frontend delivery, html_source allows a local self-contained file or a custom URL instead of the default CDN source. The linked CLI and integration guides are outside the selected scope, so their detailed requirements and comparative capabilities are not assessed.
evidence
The source is the complete Web Chat UI documentation page at [https://pydantic.dev/docs/ai/guides/web/index.md]. It supplies installation commands, API examples, endpoint behavior, security cautions and frontend delivery guidance.
The evidence establishes documented behavior rather than measured results. Installation success, browser rendering, model access, approval handling, endpoint protections and offline operation were not tested. Linked documentation, image contents, package code and CDN assets are not included.
Access & freshness
costs
The page states no software price, model-call rates, subscription terms or operating-cost estimate. Total cost is unknown from this evidence. Local serving and the offline frontend option do not establish that model use or deployment is free.
rights
The selected page does not state the documentation licence, software licence or redistribution terms for the downloadable HTML assets. Commercial-use permissions and attribution obligations are unknown from this page. Download instructions alone do not establish redistribution rights.
freshness
The page was captured on 24 November 2026 at 19:32:46.523 UTC. That is a capture time, not an established publication or release date.
The default and offline HTML URL examples reference @pydantic/ai-chat-ui version 2.1.0. This identifies the frontend build illustrated in the page; it does not establish the installed Pydantic AI version, current package compatibility or later changes.
actions
For local debugging, follow the documented installation, expose an agent with Agent.to_web(), and serve it on the loopback address. Verify the chosen model’s access requirements and tool support before relying on the examples.
Before exposing the endpoint to other clients, provide authentication and configure allowed_hosts for controlled hostnames. Keep the app at the root path and check health-probe Host headers.
For offline frontend delivery, use the self-contained build and separately establish whether the model and tools require network access. Confirm licensing, compatibility and costs from additional authoritative sources before making deployment commitments.
