StreamingTextResponse

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

import { StreamingTextResponse } from "ai"

API Signature

Parameters

stream:

ReadableStream

init?:

ResponseInit
ResponseInit

status?:

number

statusText?:

string

headers?:

HeadersInit

data?:

StreamData

Returns

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