Data streams
Match the decoder to your server’s stream format.
Read a current UI-message stream
Use DefaultChatTransport in the Vercel recipe for a current UI-message stream. The SDK assembles messages and tool parts as they arrive and handles cancellation. Server bridge examples are available for OpenAI Agents, Mastra, and Pydantic AI.
AI SDK v7 is the checked hook path. Older v6/v5 wire compatibility does not establish that every older hook API matches; use the matching upstream migration guide. Plain text uses TextStreamChatTransport.
Legacy v4 data stream
If your server still uses the v4 line-based protocol, install the maintained decoder and accumulator.
The application supplies a stable assistant message ID for this response, preserves user history and replaces that same assistant record as snapshots arrive. Initiate fetch with the owner's AbortSignal; cancellation, network errors and incomplete streams must reach the host state. Render the canonical message through plain-data views. Preliminary tool results remain data rather than completed execution.
Limits and troubleshooting
Keep authentication, storage, replay, and tool execution in your app. The helper rejects a stream with no known terminal result. The accumulator can report “complete” with an unknown outcome at EOF, so check the actual finish status. Strict mode validates decoded messages and order. The decoder can still log and skip malformed lines. Check the bytes and headers when a stream fails, and set size limits that fit your app.
For arbitrary agent state carried alongside messages, use Assistant Transport. See assistant-stream source and protocol codecs for exhaustive formats; Ghost adds projection into canonical views, not a competing wire format.