
# `AWSBedrockLlama2Stream`

<Note type="warning">
  AWSBedrockLlama2Stream has been removed in AI SDK 4.0.
</Note>

<Note type="warning">
  AWSBedrockLlama2Stream is part of the legacy AWS Bedrock integration. It is
  not compatible with the AI SDK 3.1 functions.
</Note>

The AWS Bedrock stream functions are utilties that transform the outputs from the AWS Bedrock API into a ReadableStream. It uses AIStream under the hood and handle parsing Bedrock's response.

## Import

### React

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

## API Signature

### Parameters

<PropertiesTable
  content={[
    {
      name: 'response',
      type: 'AWSBedrockResponse',
      description: 'The response object returned from AWS Bedrock.',
      properties: [
        {
          type: 'AWSBedrockResponse',
          parameters: [
            {
              name: 'body',
              isOptional: true,
              type: 'AsyncIterable<{ chunk?: { bytes?: Uint8Array } }>',
              description:
                'An optional async iterable of objects containing optional binary data chunks.',
            },
          ],
        },
      ],
    },
    {
      name: 'callbacks',
      type: 'AIStreamCallbacksAndOptions',
      isOptional: true,
      description:
        'An object containing callback functions to handle the start, each token, and completion of the AI response. In the absence of this parameter, default behavior is implemented.',
      properties: [
        {
          type: 'AIStreamCallbacksAndOptions',
          parameters: [
            {
              name: 'onStart',
              type: '() => Promise<void>',
              description:
                'An optional function that is called at the start of the stream processing.',
            },
            {
              name: 'onCompletion',
              type: '(completion: string) => Promise<void>',
              description:
                "An optional function that is called for every completion. It's passed the completion as a string.",
            },
            {
              name: 'onFinal',
              type: '(completion: string) => Promise<void>',
              description:
                'An optional function that is called once when the stream is closed with the final completion message.',
            },
            {
              name: 'onToken',
              type: '(token: string) => Promise<void>',
              description:
                "An optional function that is called for each token in the stream. It's passed the token as a string.",
            },
          ],
        },
      ],
    },
  ]}
/>

### Returns

A `ReadableStream`.


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