Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
You can stream Claude output from Amazon Bedrock by consuming the AWS SDK’s ConverseStream event stream and forwarding text deltas from your Node.js server to the browser as Server-Sent Events (SSE). These are two separate streams: Bedrock sends structured events to your application; your application decides which events to send to the browser and how to frame them. AWS’s JavaScript example documents the Bedrock side, not a complete Node.js 22 SSE server.
How the two streaming layers fit together
The request path is: browser request → Node.js server → Amazon Bedrock ConverseStream → structured events returned to the server → selected text deltas framed as SSE → browser. Bedrock’s stream is not itself browser-facing SSE. Your server is responsible for translating between them.
| Layer | What it carries | What your application does |
|---|---|---|
| Bedrock upstream | Structured model events, including content deltas and lifecycle or metadata events. | Consume events and inspect their shape; do not assume every event is text. |
| Browser downstream | SSE messages produced by your HTTP server. | Choose which model events to expose and encode them according to SSE rules. |
AWS describes ConverseStream as a consistent message API for Bedrock models that support messages. Confirm that the specific model supports streaming in your target region by checking GetFoundationModel and its responseStreamingSupported value. The AWS CLI does not support streaming operations such as ConverseStream. Amazon Bedrock ConverseStream API
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Consume Claude events with the JavaScript SDK
The AWS SDK for JavaScript v3 pattern is to create a BedrockRuntimeClient, send a ConverseStreamCommand, then asynchronously iterate over response.stream. This example follows the documented AWS pattern and prints text deltas; it is not an HTTP server or SSE implementation. AWS SDK for JavaScript v3 Bedrock Runtime examples
#1 Best Overall
import {
BedrockRuntimeClient,
ConverseStreamCommand,
} from "@aws-sdk/client-bedrock-runtime";
const client = new BedrockRuntimeClient({ region: "us-east-1" });
const command = new ConverseStreamCommand({
modelId: "anthropic.claude-3-haiku-20240307-v1:0",
messages: [
{
role: "user",
content: [{ text: "Explain how SSE works in one paragraph." }],
},
],
inferenceConfig: {
maxTokens: 512,
temperature: 0.5,
topP: 0.9,
},
});
try {
const response = await client.send(command);
for await (const event of response.stream) {
const text = event.contentBlockDelta?.delta?.text;
if (text !== undefined) {
process.stdout.write(text);
}
}
} catch (error) {
console.error("Bedrock request or stream failed:", error);
}
The model ID and us-east-1 region above are AWS example values, not universal defaults. Check current model availability and streaming support in the region you intend to use. The sample’s token limit and sampling settings are illustrative request parameters, not required values or recommendations.
Handle structured events rather than treating the stream as tokens
Bedrock events describe message and content-block lifecycle as well as generated content. AWS documents a sequence that can include messageStart, content-block events, messageStop, and metadata. A content block may start, produce one or more deltas, and stop; tool-use blocks can include partial JSON, and deltas may carry text or reasoning. Amazon Bedrock: Inference using the Converse API
Rank #2
- Text delta: forward it if your interface is intended to display generated text incrementally.
- Tool-use or reasoning delta: handle according to your application’s tool workflow and disclosure policy; do not display it as ordinary user-facing prose by default.
- Lifecycle or metadata event: use it for control flow or observability as appropriate, rather than appending it to the displayed answer.
- Error event or thrown error: stop normal output and signal failure to the downstream client using the error behavior your application defines.
AWS also provides a Claude-specific ConverseStream example. Claude ConverseStream example
Translate text deltas into SSE in your Node.js server
After receiving a Bedrock text delta, a server can emit it as an SSE message. SSE is a downstream HTTP protocol; it is not created automatically by the SDK. Keep the mapping explicit: identify which upstream events are safe and useful to expose, encode those as SSE messages, and leave other Bedrock event types out of the user-facing text channel unless your design intentionally supports them.
Rank #3
The sources cited here document Bedrock’s JavaScript event consumption and event types, but do not establish Node.js 22-specific HTTP response framing, browser parsing, cancellation on disconnect, or proxy buffering behavior. Treat those as separate implementation details and verify them against current Node.js and browser documentation before deploying a complete SSE route. In particular, do not assume that writing a string to an HTTP response alone guarantees incremental delivery through every reverse proxy or hosting layer.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Plan for errors before and during streaming
A failure can occur while sending the command or after the stream has begun. Bedrock’s response-stream reference lists error variants including internal server errors, model stream errors, model timeouts, service unavailability, throttling, and validation errors; the API reference documents HTTP status information for several variants. Amazon Bedrock ResponseStream API
Quick Recap
Rank #4
- Wrap both
client.send(command)and the asynchronous event loop in error handling. - If the upstream request fails, return an appropriate failure response to the caller; if output has already started, send a downstream error signal if your SSE contract defines one, then close the response cleanly.
- Do not assume all errors are retryable or that a retry can safely resume an already-started generation. Decide retry behavior based on the error, request semantics, and your application’s requirements.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

