UiMessageStreamBackend
Talks to an agent server speaking a Vercel AI SDK streaming protocol — e.g. the bundled Pydantic AI server (server/main.py), or any AI SDK route:
v5/v6 UI Message Stream: SSE
data: {"type": "text-delta", ...}chunks (toUIMessageStreamResponse()), ending in[DONE];v4 Data Stream:
0:"text",g:"reasoning",9:{toolCall}… lines (toDataStreamResponse()). Detected automatically per line.
Request: POST endpoint with {trigger, id, messages: UIMessage[]} — the whole history, including tool parts, as useChat sends it.
Like useChat, the turn continues automatically when the server hands work back to the client:
tool approval (AI SDK 6): a
tool-approval-requestasks approver; the answer is sent back as anapproval-respondedtool part (approval.reasoncarries the user's reason; the protocol has no edited arguments);client-side tools: a
tool-input-availablefor one of tools with no server output runs the tool here and sends itsoutput-availablepart (sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls).
A tool output that is itself a UIMessage (a subagent streaming through preliminary tool results) is shown as that tool's nested run.
Parameters
optional model override, sent as ?model= (server-specific).