Vercel AI SDK in production: when DefaultChatTransport needs a session layer
Blog post from Ably
The Vercel AI SDK's DefaultChatTransport, designed for stateless serverless platforms, uses HTTP POST and Server-Sent Events (SSE) to facilitate chat functionalities. While effective for single-user scenarios with stable connections, this setup reveals limitations in production environments. These constraints include an inability to reliably cancel server-side operations, lack of multi-device support, and the need for custom infrastructure, such as Redis, to resume streams. The transport is not inherently flawed but is bounded by HTTP's structural properties, which do not support persistent connections or multi-user scenarios. Vercel's architecture does not accommodate persistent WebSocket connections, prompting the design of a pluggable ChatTransport interface. Transitioning to a WebSocket-based transport layer, like Ably AI Transport, allows for durable sessions that mitigate these limitations by enabling persistent connections, reliable cancellation signals, and multi-device delivery without altering the existing application logic. This shift addresses the shortcomings of DefaultChatTransport by decoupling sessions from connections, thus resolving issues related to session persistence and multi-user engagement.
| Trend | Post Mentions | Total Month Mentions | Posts | Companies | MoM |
|---|---|---|---|---|---|
| Serverless | 8 | 1,011 | 235 | 82 | -44% |