
# `StreamingTextResponse`

<Note type="warning">
  `StreamingTextResponse` has been removed in AI SDK 4.0. Use
  [`streamText.toDataStreamResponse()`](/docs/reference/ai-sdk-core/stream-text)
  instead.
</Note>

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

<Snippet text={`import { StreamingTextResponse } from "ai"`} prompt={false} />

## API Signature

## Parameters

<PropertiesTable
  content={[
    {
      name: 'stream',
      type: 'ReadableStream',
      description: 'The stream of content which represents the HTTP response.',
    },
    {
      name: 'init',
      isOptional: true,
      type: 'ResponseInit',
      description:
        '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.',
      properties: [
        {
          type: 'ResponseInit',
          parameters: [
            {
              name: 'status',
              type: 'number',
              isOptional: true,
              description:
                'The status code for the response. StreamingTextResponse will overwrite this value with 200.',
            },
            {
              name: 'statusText',
              type: 'string',
              isOptional: true,
              description:
                'The status message associated with the status code.',
            },
            {
              name: 'headers',
              type: 'HeadersInit',
              isOptional: true,
              description:
                "Any headers you want to add to your response. StreamingTextResponse will add 'Content-Type': 'text/plain; charset=utf-8' to these headers.",
            },
          ],
        },
      ],
    },
    {
      name: 'data',
      isOptional: true,
      type: 'StreamData',
      description:
        'StreamData object that you are using to generate additional data for the response.',
    },
  ]}
/>

### 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


## Navigation

- [AIStream](/v5/docs/reference/stream-helpers/ai-stream)
- [StreamingTextResponse](/v5/docs/reference/stream-helpers/streaming-text-response)
- [streamToResponse](/v5/docs/reference/stream-helpers/stream-to-response)
- [OpenAIStream](/v5/docs/reference/stream-helpers/openai-stream)
- [AnthropicStream](/v5/docs/reference/stream-helpers/anthropic-stream)
- [AWSBedrockStream](/v5/docs/reference/stream-helpers/aws-bedrock-stream)
- [AWSBedrockAnthropicStream](/v5/docs/reference/stream-helpers/aws-bedrock-anthropic-stream)
- [AWSBedrockAnthropicMessagesStream](/v5/docs/reference/stream-helpers/aws-bedrock-messages-stream)
- [AWSBedrockCohereStream](/v5/docs/reference/stream-helpers/aws-bedrock-cohere-stream)
- [AWSBedrockLlama2Stream](/v5/docs/reference/stream-helpers/aws-bedrock-llama-2-stream)
- [CohereStream](/v5/docs/reference/stream-helpers/cohere-stream)
- [GoogleGenerativeAIStream](/v5/docs/reference/stream-helpers/google-generative-ai-stream)
- [HuggingFaceStream](/v5/docs/reference/stream-helpers/hugging-face-stream)
- [@ai-sdk/langchain Adapter](/v5/docs/reference/stream-helpers/langchain-adapter)
- [@ai-sdk/llamaindex Adapter](/v5/docs/reference/stream-helpers/llamaindex-adapter)
- [MistralStream](/v5/docs/reference/stream-helpers/mistral-stream)
- [ReplicateStream](/v5/docs/reference/stream-helpers/replicate-stream)
- [InkeepStream](/v5/docs/reference/stream-helpers/inkeep-stream)


[Full Sitemap](/sitemap.md)
