In short.
This page is the Pydantic AI documentation for its Vercel AI Data Stream Protocol adapter. It is for Python developers who want an agent backend to stream to an AI SDK UI frontend such as useChat. Its main catch is that it is a feature reference, not a full tutorial. It has no install steps, no minimum Python or Pydantic AI version, no full compatibility matrix, no pricing and no licence, and it gives code examples but no runtime test results. It does state which AI SDK versions apply: the adapter targets AI SDK v5 by default, setting sdk_version=6 turns on v6 features, and tool approval needs AI SDK UI v6 or later. The adapter (VercelAIAdapter) turns the frontend's request into arguments for Agent.run_stream_events(), runs the agent, and turns Pydantic AI events into Vercel AI events sent as server-sent events. The page is unusually explicit about security. Client-sent message history is treated as untrusted, system prompts from the client are stripped by default, and the page describes specific caveats for tool approval and cancellation in detail.
Researched and written by an AI model and checked by a second AI model. How it works
The scope is the complete Pydantic AI documentation page Vercel AI Data Stream Protocol at [https://pydantic.dev/docs/ai/integrations/ui/vercel-ai/index.md]. It covers usage with Starlette and FastAPI and with the lower-level adapter methods, cancellation, data chunks, files from client-side tools, message metadata, the trust model, keeping history on the server, compaction, structured content, citations, enqueued messages, MCP Apps, tool approval, tool input validation, and system prompts and instructions. Linked pages are separate references and are covered only as this page summarises them. These include the API reference, UI adapter overview, agent, message-history, compaction, MCP and deferred-tools pages, the AI SDK pages and GitHub issue #5174. The page names AI SDK versions: v5 by default, v6 through sdk_version=6, and AI SDK UI v6 or later for tool approval. It gives no minimum Python or Pydantic AI version, no full compatibility matrix, no licence, no pricing and no release or update date, so those remain unknown. The guide gives code examples but no runtime test results, so all behaviour described is the page's own account.
The overview
What this resource is
This is a single documentation page titled Vercel AI Data Stream Protocol, from the Pydantic AI docs at [https://pydantic.dev/docs/ai/integrations/ui/vercel-ai/index.md]. It documents the VercelAIAdapter class and the related VercelAIEventStream class in Pydantic AI's pydantic_ai.ui.vercel_ai module. Pydantic AI is a Python agent framework. The adapter lets it receive agent run input from, and stream events to, a frontend built with the Vercel AI SDK UI hooks (useChat is the example named), optionally with the AI Elements component set.
It is documentation, not a downloadable package, so the resource being assessed is the guide and the integration behaviour it describes. The page does not name an author or a version for itself.
Overall assessment
This is a detailed, specific reference for one integration. It is not a beginner tutorial. It assumes you already know what an agent, a tool call and a streaming endpoint are, and that you have a frontend or plan to build one with the AI SDK. It is strongest where integrations tend to go wrong: client-held message history, cancellation, tool approval, and what a browser is and is not allowed to send to the server. Each of these gets explicit warnings and recommended patterns.
Its weaknesses are typical of one page in a larger docs set. It has no installation command and no frontend project walkthrough. It explains which AI SDK versions apply (v5 by default, v6 through sdk_version=6, and AI SDK UI v6 or later for tool approval), but gives no minimum Python or Pydantic AI version and no full compatibility matrix. It provides no benchmarks or measured performance results. Its efficiency remarks are qualitative, for example that a file URL is often more efficient than inline bytes because only the reference crosses the wire. The guide gives code examples but no runtime test results, so every behaviour described is the documentation's own account.
Who it is for
The page fits Python developers who use Pydantic AI for the backend and want a chat UI built with the Vercel AI SDK on the frontend. It covers Starlette and FastAPI directly, and says that Django, Flask and other frameworks can use the lower-level methods.
It also suits teams that need human approval of tool calls, progress updates from long-running tools, source citations in the UI, or conversation storage on the server. It is a poor fit if your backend is not Python, if you do not use the Vercel AI SDK on the frontend, or if you want a first introduction to Pydantic AI itself. For core concepts the page links to separate Pydantic AI pages, such as the agent and message-history pages. Their contents are not described on this page.
What it lets you do
Per the page, the adapter supports the following.
Streaming an agent run to a frontend. VercelAIAdapter.dispatch_request() handles a Starlette or FastAPI request end to end and returns a streaming response. It accepts the agent, the same optional arguments as Agent.run_stream_events(), and optional on_complete and on_cancel callbacks.
Lower-level control. build_run_input(), from_request(), run_stream(), run_stream_native(), transform_stream(), encode_stream() and streaming_response() can be chained when you need custom input or output handling.
Cancellation. First-party cancellation (ctx.cancel(), AgentRun.cancel(), a CancellationToken, or a timeout) emits an abort chunk, and useChat keeps the partial message.
Custom data. Tools can send progress or other data to the client with CustomEvent and ctx.emit(), which arrive as data-{name} chunks. Tools can also attach DataChunk, SourceUrlChunk, SourceDocumentChunk and FileChunk items to a tool result through ToolReturn metadata.
Files from client-side tools. A client-side tool can return a file as inline bytes, a file URL or a provider-hosted uploaded file.
Message round-tripping. dump_messages and load_messages convert between Pydantic AI and Vercel AI message formats, including timestamps, message ids, retry feedback, compaction parts and structured content.
Citations. Cited web pages are sent as source-url parts, and full citations travel in providerMetadata.
Other features. The page also covers enqueued mid-run messages, MCP Apps rendering data, tool approval (with AI SDK v6), tool-input validation chunks, and a choice of who owns the system prompt.
Using it
What you need
The page implies the following requirements.
A Python backend with Pydantic AI. The page gives no install command and no minimum Python or Pydantic AI version, so those are unknown.
A web framework. FastAPI or Starlette for dispatch_request(), or any framework if you use the lower-level methods.
A Vercel AI SDK frontend. The examples use useChat from @ai-sdk/react and DefaultChatTransport from ai. By default the adapter targets AI SDK v5, and you set sdk_version=6 for v6 features. Tool approval requires AI SDK UI v6 or later.
A model and credentials. The examples create agents with the provider-prefixed model string 'openai:gpt-6.1-sol'. The page does not explain how to configure provider credentials or whether that identifier is meant as a placeholder. Treat it as an example string and substitute a model you have access to.
First-party cancellation, if your stop control needs it. Calling stop() on the client aborts the browser's request. The server sees a disconnect, and the run is torn down as an external asyncio.CancelledError with no abort chunk and no on_cancel call. If your stop control must keep the stream connected, emit an abort chunk and run on_cancel, you need a CancellationToken for the run and a separate cancel endpoint that calls token.cancel(). The page's example uses POST /chat/{chat_id}/cancel. The page says the in-memory token registry in that example needs a single server process or sticky routing. Multi-worker deployments need shared coordination such as a message broker.
How it works
The adapter sits between the browser and the agent. It takes the request body that the AI SDK sends (a RequestData object holding the messages array) and converts it into arguments for Agent.run_stream_events(). It then runs the agent and maps the resulting Pydantic AI events into Vercel AI data-stream chunks, which are encoded as server-sent events. The response content type defaults to SSE_CONTENT_TYPE, and the Accept header can override it in the page's longer example.
Tool calls are mapped to stream chunks. Normally, tool-input-available is emitted only after the call has passed the tool's schema and any args_validator, and its input field carries the raw arguments the model emitted. Failures produce tool-input-error with the raw arguments and an error_text. The page documents one exception. If a call is skipped because a final result was already processed (see end_strategy), it is not validated. It still gets tool-input-available with its unvalidated raw arguments, followed by tool-output-available carrying the 'not executed' return recorded in message history. With sdk_version=6, tools marked requires_approval=True produce tool-approval-request chunks, the adapter reads approval responses from follow-up requests, and it emits tool-output-denied for rejections.
History is the other half of the design. An AI SDK frontend normally holds the whole message list and sends it with each request, so the page explains how the adapter treats that list. By default it strips untrusted parts. With manage_message_history='server', it uses only the new turn from what useChat sends, so the server's stored history, not the browser's copy, stays authoritative.
Setup path
The page does not describe installation or project creation. In practice, its setup path is to define a Pydantic AI Agent, expose an HTTP POST endpoint, and point the frontend transport at it.
For FastAPI or Starlette, the endpoint calls VercelAIAdapter.dispatch_request(request, agent=agent). For other frameworks, you build the adapter from build_run_input(), call run_stream(), then encode_stream() and return the result as a streaming response.
The page has two frontend examples. The ordinary chat-transport setup example is a useChat call with a DefaultChatTransport whose api is '/api/chat'. It uses prepareSendMessagesRequest to send only the last message when history is kept on the server. The second is a TSX example that renders MCP Apps tool results with AI SDK UI's experimental_MCPAppRenderer. The page does not cover a complete frontend project or CORS and proxy settings. It does name AI SDK versions: the adapter targets AI SDK v5 by default, sdk_version=6 turns on v6 features, and tool approval requires AI SDK UI v6 or later. It gives no minimum Python or Pydantic AI version and no full compatibility matrix.
Example from the page
The smallest example on the page creates an agent with Agent('openai:gpt-6.1-sol') and a FastAPI app. It then defines a POST /chat route that returns await VercelAIAdapter.dispatch_request(request, agent=agent). According to the page, that is the whole backend for a basic streaming chat endpoint.
A fuller example adds cancellation. A POST /chat/{chat_id} route builds the run input, creates a CancellationToken, stores it by chat id, and streams the run with an on_cancel callback that can persist cancelled.all_messages(). A separate POST /chat/{chat_id}/cancel route calls token.cancel(). The page explains why a separate endpoint is needed to get an abort chunk and on_cancel from a stop gesture. Pressing stop in the browser only disconnects the request, which tears the run down as an external asyncio.CancelledError. In that case no abort chunk is emitted and on_cancel does not fire.
Another example shows a tool that emits FileUploadProgressEvent progress with ctx.emit() while it runs. According to the page, this reaches the client as a data-file_upload_progress chunk with data such as {'done': 1, 'total': 3}. The page provides these code examples but no runtime test results.
Assessment & evidence
Limitations and risks
Verification: the guide gives code examples but no runtime test results. Every behaviour is the documentation's own account, and the code samples may need adjusting for your Pydantic AI and AI SDK versions.
Version coupling: the adapter defaults to AI SDK v5, tool approval needs v6, and the page gives no full compatibility matrix. A mismatch between sdk_version and your frontend is a likely source of confusion.
Client-controlled history: the page says the request messages array is fully client-controlled, and the default stripping of untrusted parts does not make that history authentic. UIMessage.metadata is also fully client-controlled. Application metadata keys and the message timestamp round-trip through dump_messages and load_messages, but that does not authenticate the values a client sends back. The page says framework and provider state, such as usage, model_name and provider fields, is deliberately left out and belongs in trusted server-side storage. The one documented exception is a response's canonical_system, which round-trips beside provider_name. A compaction item from the client is ignored when you also pass server-side message_history.
Tool approval: approval responses are trusted from the request by design. The page recommends manage_message_history='server', where an approval must answer a pending call. If you need approval decisions tied to server-side state, you must intercept DeferredToolRequests, store approval ids server-side, and pass explicit deferred_tool_results.
System prompts: with the default manage_system_prompt='server', frontend system messages are stripped with a warning. The page advises setting 'client' only when the frontend is as trusted as the server.
Cancellation: a browser stop() does not produce the abort chunk or call on_cancel. The in-memory token registry in the example does not work across multiple workers without sticky routing or shared coordination.
Citations: Google and OpenAI Chat send citations at the end of the response, so when a tool call follows the text, those citations do not reach the frontend. Citation anchor positions count characters the way Python does, which can differ from JavaScript for characters such as emoji.
Client files: uploaded-file references work only if allow_uploaded_files is True. File URLs are limited by allowed_file_url_schemes (http and https by default). If the adapter cannot infer a media type from a URL shape, the result depends on media_type. An explicit media_type of null still produces a file with no media type. An absent or empty media_type leaves the shape as an ordinary mapping rather than a file.
Why this assessment
The page is long and specific. It names classes, methods, chunk types and parameters, and it gives code for the main flows. It also states where behaviour changes by SDK version and which options carry a security trade-off. Those details suggest it is written by maintainers for implementers.
The limits come from what is missing. There are no install steps, no minimum Python or Pydantic AI version, no full compatibility matrix, no licence, no pricing, no test results and no end-to-end frontend sample. The examples use the model string 'openai:gpt-6.1-sol' throughout without explaining it. Runtime behaviour is described only as the documentation states it.
Alternatives
The page does not compare the adapter with external options such as other frameworks or hand-written streaming endpoints, so how it stacks up against them is unknown.
Within the page, the main choice is between two ways of using the adapter. The convenience method VercelAIAdapter.dispatch_request() handles a Starlette or FastAPI request in one call. The lower-level methods (build_run_input(), from_request(), run_stream(), run_stream_native(), transform_stream(), encode_stream() and streaming_response()) are for frameworks not based on Starlette, such as Django or Flask, or when you need fine-grained control over input or output. The page also says the VercelAIEventStream class is typically used directly only when the agent's events reach you outside the request that serves the frontend.
The page refers to a separate UI adapter overview and a base UIAdapter class. It does not say whether that overview documents adapters for other protocols.
Evidence base
The source is the Pydantic AI documentation page Vercel AI Data Stream Protocol at [https://pydantic.dev/docs/ai/integrations/ui/vercel-ai/index.md]. Its own code examples support its claims. These include Python files named dispatch_request.py, run_stream.py, vercel_ai_custom_events.py, vercel_ai_custom_event_payload.py, vercel_ai_tool_chunks.py and vercel_ai_client_managed_system_prompt.py, a short tool-approval snippet, and TypeScript fragments for useChat transport setup and MCP Apps rendering. The guide gives code examples but no runtime test results, benchmarks or performance figures.
The page links to separate references: the Pydantic AI API reference, the UI adapter overview, the agent, message-history, compaction, MCP and deferred-tools pages, the AI SDK documentation, and GitHub issue #5174. Anything that depends on those references appears here only as the page itself summarises it.
Access & freshness
Costs
The page states no price for the adapter, for Pydantic AI, or for the AI SDK. Costs are therefore unknown from this evidence. Running an agent through this adapter sends requests to whichever model provider you configure, and that provider's usage charges are not covered here and cannot be estimated from this evidence. Hosting costs for your own server are likewise unstated.
Rights and licence
The page states no licence, copyright notice or reuse terms for the documentation or for the code it describes, so reuse rights are unknown. The page links to a public GitHub issue (#5174) in the pydantic/pydantic-ai repository but does not state that repository's licence. If you plan to copy the documentation text or depend on the library commercially, check the licence in the project's repository and package metadata yourself.
Freshness
As of 2026-11-15, the page shows no publication date, last-updated date or Pydantic AI release number. It does name AI SDK versions: the adapter targets AI SDK v5 by default, sdk_version=6 turns on v6 features, and tool approval requires AI SDK UI v6 or later. It gives no minimum Python or Pydantic AI version and no full compatibility matrix, so how current it is relative to the latest library release is unknown.
The page covers features such as compaction, MCP Apps, enqueued messages and AI SDK v6 support. It also says a planned broadening of message-metadata round-tripping is tracked in GitHub issue #5174. The page gives neither an update date nor the issue's current status, so how recently it was maintained is unknown. Check your installed Pydantic AI version against the API reference before relying on specific parameter names.
Suggested next steps
If you are evaluating the adapter, read the page's Trust model section and the linked UI adapter overview before writing any endpoint. Decide early whether history will live on the server (manage_message_history='server', which the page recommends for approval-gated tools) or in the browser.
Then build the minimal dispatch_request endpoint in a scratch project. Substitute a model you can actually use for the example model string, and confirm that your frontend's AI SDK version matches the adapter's sdk_version setting.
Calling stop() on the client already ends a request by disconnecting it, but that gives no abort chunk and does not run on_cancel. Add a CancellationToken and a separate cancel endpoint only if your stop control must keep the stream connected, emit an abort chunk and run on_cancel, and plan for shared coordination if you run more than one worker. If you need tool approval, use AI SDK v6 with sdk_version=6 and test that approvals for calls that are not pending are rejected. Finally, check the licence and minimum version details in the project's repository, because this page does not state them.
