File: streaming-text-response.md | Updated: 11/15/2025
Menu
v5 (Latest)
AI SDK 5.x
Model Context Protocol (MCP) Tools
AWSBedrockAnthropicMessagesStream
Copy markdown
==========================================================================================================================
StreamingTextResponse has been removed in AI SDK 4.0. Use streamText.toDataStreamResponse()
instead.
It is a utility class that simplifies the process of returning a ReadableStream of text in HTTP responses. It is a lightweight wrapper around the native Response class, automatically setting the status code to 200 and the Content-Type header to 'text/plain; charset=utf-8'.
import { StreamingTextResponse } from "ai"
ReadableStream
The stream of content which represents the HTTP response.
ResponseInit
It can be used to customize the properties of the HTTP response. It is an object that corresponds to the ResponseInit object used in the Response constructor.
ResponseInit
number
The status code for the response. StreamingTextResponse will overwrite this value with 200.
string
The status message associated with the status code.
HeadersInit
Any headers you want to add to your response. StreamingTextResponse will add 'Content-Type': 'text/plain; charset=utf-8' to these headers.
StreamData
StreamData object that you are using to generate additional data for the response.
An instance of Response with the provided ReadableStream as the body, the status set to 200, and the Content-Type header set to 'text/plain; charset=utf-8'. Additional headers and properties can be added using the init parameter
On this page
Deploy and Scale AI Apps with Vercel.
Vercel delivers the infrastructure and developer experience you need to ship reliable AI-powered applications at scale.
Trusted by industry leaders: