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
To stream Claude output to a browser, configure an API Gateway REST API Lambda proxy integration for response transfer mode STREAM, then have Lambda write client-facing Server-Sent Events (SSE) as Claude’s output arrives. The example below uses Claude on Amazon Bedrock’s newer Messages endpoint, /anthropic/v1/messages, which uses SSE. It does not use Bedrock’s legacy InvokeModel or Converse event-stream framing. You must configure the Claude call with the matching Bedrock credentials, model identifier, and current regional availability; those vary and should be checked before deployment.
How does streaming Claude through API Gateway and Lambda work?
The client opens an HTTP request to API Gateway. API Gateway invokes Lambda with response streaming enabled; Lambda calls the selected Claude endpoint and forwards incremental output as SSE. The browser reads each complete SSE event and updates the chat display. This reduces the wait for the first visible text, but it does not mean each network chunk is exactly one token or one complete event.
- Browser: Sends a request and reads the response incrementally.
- API Gateway REST API: Uses an
AWS_PROXYintegration with response transfer modeSTREAM. - Lambda: Calls Claude and writes SSE-formatted events to its response stream.
- Claude route: This example targets the Bedrock Messages endpoint at
/anthropic/v1/messages. Its authentication and model selection must match the Bedrock integration you deploy.
API Gateway response streaming is available for REST APIs, not every API Gateway API type. AWS describes generative AI chat as a streaming use case because it can lower time to first byte.
How do I configure API Gateway and Lambda for streaming?
Set up a streaming proxy integration
- Create or use an API Gateway REST API and a Lambda proxy integration for the route that will serve the chat request.
- Set the integration’s response transfer mode to
STREAM. The default buffered response mode does not deliver data incrementally. - Use a Lambda runtime and Region that support response streaming, and set a function timeout appropriate to the expected Claude response. Check the current regional capability and runtime guidance before deployment.
- Make the function return Lambda’s streaming proxy response format, rather than the ordinary buffered proxy response format.
- Set the response content type to
text/event-streamand have the client request a streaming response. Do not rely on API Gateway test invocation to prove incremental delivery; it buffers the stream.
Understand Lambda’s response framing
For the direct streaming format, Lambda expects valid JSON metadata followed by eight null bytes, then the payload. The delimiter must appear within the first 16 KB. Metadata can include headers, multiValueHeaders, cookies, and statusCode; do not add unsupported keys. AWS provides Node.js helpers, including awslambda.HttpResponseStream.from(), to frame the metadata, and recommends awslambda.streamifyResponse() with pipeline() for streaming handlers.
#1 Best Overall
- Upgrade your TV, instantly – Fire TV Stick HD is our fastest HD streaming stick ever, with a streamlined navigation that jumps straight to your movies, shows, and live TV. Take your entertainment on the go with the new ultra-portable profile. And watch it all come to life with crisp Full HD and Wi-Fi 6 support.
- The newest Fire TV experience (2026) – Our biggest update to Fire TV has a new, modern design that gets you to your entertainment fast. Browse dedicated content categories, pin more of your favorite apps, and get personalized recommendations from Alexa+. Spend less time scrolling, and more time watching.
- All your apps in one place – Prime Video, Netflix, YouTube, Disney+, Apple TV, HBO Max, Hulu, Peacock, Paramount+, and thousands more. It’s easy to find what to watch from hundreds of thousands of movies and TV episodes, including free, ad-supported content. Subscription fees may apply.
- Our most portable stick – Thin and light, without extra clutter. Connects directly to your TV's HDMI port without blocking other ports.
- Easier than ever to set up – Now with Direct Power, it's powered by your TV with the included USB-C cable and eliminates the need for a wall adapter.
The following is a transport scaffold for the Lambda-to-client side. Its claudeEvents() function is deliberately an adapter boundary: implement it with the Bedrock Messages endpoint’s current authentication, model identifier, request schema, and SSE event parsing. The handler expects that adapter to yield text fragments and a final completion signal; it is not a Bedrock SDK call by itself.
const { pipeline } = require('node:stream/promises');
exports.handler = awslambda.streamifyResponse(async (event, rawResponseStream) => {
const responseStream = awslambda.HttpResponseStream.from(rawResponseStream, {
statusCode: 200,
headers: {
'content-type': 'text/event-stream; charset=utf-8',
'cache-control': 'no-cache',
},
});
try {
for await (const item of claudeEvents(event)) {
if (item.type === 'text') {
responseStream.write(`event: deltandata: ${JSON.stringify({ text: item.text })}nn`);
} else if (item.type === 'done') {
responseStream.write('event: donendata: {}nn');
}
}
} catch (error) {
// Once the response has started, communicate failure in-band.
responseStream.write(`event: errorndata: ${JSON.stringify({ message: 'The response stopped unexpectedly.' })}nn`);
} finally {
responseStream.end();
}
});
The code frames each application event with a blank line, as SSE requires. Its JSON payload keeps arbitrary text—including newlines—from breaking the event framing. The browser should parse SSE events, append delta text, treat done as completion, and present error as an interrupted response. Since an HTTP status is not a useful way to report a failure after response streaming has begun, handle mid-stream errors as application events. Failures before the response starts can still use an appropriate HTTP error response.
Rank #2
- Advanced 4K streaming - Elevate your entertainment with the next generation of our best-selling 4K stick, with improved streaming performance optimized for 4K TVs.
- The newest Fire TV experience (2026) – Our biggest update to Fire TV has a new, modern design that gets you to your entertainment fast. Browse dedicated content categories, pin more of your favorite apps, and get personalized recommendations from Alexa+. Spend less time scrolling, and more time watching.
- Cloud gaming, no console required – Stream Call of Duty: Black Ops 7, Hogwarts Legacy, Outer Worlds 2, Ninja Gaiden 4, and hundreds of games on your Fire TV Stick 4K Select with Xbox Game Pass and Luna via cloud gaming. Xbox Game Pass subscription and compatible controller required. Each sold separately.
- Smarter picks with Alexa+ – Getting to what you love has never been easier. Press the voice remote button and talk naturally to find what to watch across your apps, manage your smart home, or dive into virtually any topic.
- Wi-Fi 6 support - Enjoy smooth 4K streaming, even when other devices are connected to your router.
How do I stream the events in a browser?
For a simple GET endpoint, the browser’s EventSource API can consume SSE. Chat requests commonly need a POST body, however, so use fetch() and read its response body as a stream. Network reads are arbitrary byte chunks, not guaranteed to align with SSE event boundaries. Buffer decoded text until the SSE blank-line delimiter, then parse complete events.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →const response = await fetch('/chat', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ message: 'Hello' }),
});
if (!response.ok || !response.body) {
throw new Error(`Chat request failed: ${response.status}`);
}
const reader = response.body.getReader();
const decoder = new TextDecoder();
let buffer = '';
while (true) {
const { value, done } = await reader.read();
buffer += decoder.decode(value, { stream: !done });
let boundary;
while ((boundary = buffer.indexOf('nn')) !== -1) {
const block = buffer.slice(0, boundary);
buffer = buffer.slice(boundary + 2);
// Parse the complete SSE block's event and data fields here.
// Append delta text; stop on done; surface error events.
handleSseBlock(block);
}
if (done) break;
}
This parsing sketch handles LF-delimited events. A production parser should also account for CRLF line endings and any event fields your server emits. Keep the server and client’s event names and data schema in agreement.
Rank #3
- The newest Fire TV experience (2026) – Our biggest update to Fire TV has a new, modern design that gets you to your entertainment fast. Browse dedicated content categories, pin more of your favorite apps, and get personalized recommendations from Alexa+. Spend less time scrolling, and more time watching.
- Elevate your entertainment experience with a powerful processor for lightning-fast app starts and fluid navigation.
- Smarter picks with Alexa+ – Getting to what you love has never been easier. Press the voice remote button and talk naturally to find what to watch across your apps, manage your smart home, or dive into virtually any topic.
- Enjoy the show in 4K Ultra HD, with support for Dolby Vision, HDR10+, and immersive Dolby Atmos audio.
- Fire TV Ambient Experience lets you display over 2,000 pieces of museum-quality art and photography.
Why is API Gateway buffering my response?
- The integration is still buffered. Confirm that the deployed REST API Lambda proxy integration uses response transfer mode
STREAM. - You tested with API Gateway’s test invocation. AWS says this test path buffers streaming responses and returns one response after completion, after 35 seconds, or after more than 1 MB has accumulated. It cannot establish that a real client receives incremental chunks.
- The client or an intermediary waits to accumulate data. Test the deployed route with an actual streaming client, and inspect the client-side read loop rather than assuming each read corresponds to a Claude event.
- A streaming constraint has been reached. Check endpoint idle timeout, maximum stream duration, and payload-rate limits before diagnosing an application-level stall.
For a deployed endpoint, AWS recommends testing with curl -i --no-buffer. The --no-buffer option makes arriving data visible without curl’s normal output buffering. API Gateway access logs can also include streaming-specific values such as response transfer mode, time to all headers, time to first content, and integration latency.
Which Claude streaming route should I use?
| Route | Streaming format | What to keep consistent |
|---|---|---|
| Anthropic’s own API | Anthropic Messages API SSE | Use the current Anthropic API endpoint, authentication instructions, and model identifier. This article’s Lambda adapter is not an implementation of that route. |
| Claude on Amazon Bedrock Messages endpoint | SSE at /anthropic/v1/messages |
Use the matching Bedrock authentication, model identifier, and regional availability. This is the route selected for the architecture in this article. |
| Legacy Claude on Bedrock through InvokeModel or Converse | AWS event-stream encoding | Do not parse or relay it as if it were the Messages endpoint’s Anthropic SSE format. |
Do not combine one route’s credentials or event parser with another route’s response framing. Model identifiers, availability, and lifecycle change; verify them against current provider documentation when deploying.
Rank #4
- Essential 4K streaming – Get everything you need to stream in brilliant 4K Ultra HD with High Dynamic Range 10+ (HDR10+).
- The newest Fire TV experience (2026) – Our biggest update to Fire TV has a new, modern design that gets you to your entertainment fast. Browse dedicated content categories, pin more of your favorite apps, and get personalized recommendations from Alexa+. Spend less time scrolling, and more time watching.
- Make your TV even smarter – Fire TV gives you instant access to a world of content, tailor-made recommendations, and Alexa, all backed by fast performance.
- All your favorite apps in one place – Experience endless entertainment with access to Prime Video, Netflix, YouTube, Disney+, Apple TV+, HBO Max, Hulu, Peacock, Paramount+, and thousands more. Easily discover what to watch from hundreds of thousands of movies and TV episodes (subscription fees may apply), including free, ad-supported content.
- Getting set up is easy – Plug in and connect to Wi-Fi for smooth streaming.
What limits and trade-offs affect a streamed response?
| Service | Limit | Operational meaning |
|---|---|---|
| API Gateway response streaming | Maximum stream duration: 15 minutes, per AWS documentation checked in 2026 | A response that exceeds the service duration cannot continue through this integration. |
| API Gateway Regional and private endpoints | Idle timeout: 5 minutes, per AWS documentation checked in 2026 | A quiet stream can time out even if the function has not completed. |
| API Gateway edge-optimized endpoints | Idle timeout: 30 seconds, per AWS documentation checked in 2026 | Long pauses between output may be more restrictive on this endpoint type. |
| API Gateway payload throughput | Payload beyond the first 10 MB is limited to 2 MB/s, per AWS documentation checked in 2026 | This is the API Gateway limit, separate from Lambda’s response limit. |
| Lambda streamed response | Up to 200 MB total; first 6 MB uncapped, then 2 MB/s, per AWS documentation checked in 2026 | Lambda’s cap and throughput phases are distinct from API Gateway’s. |
Streaming also removes features that rely on a complete buffered response: API Gateway endpoint caching, VTL response transformation, and API Gateway content encoding are unavailable for this mode. A client disconnect may not stop Lambda execution, so set a sensible function timeout and account for possible continued duration and cost after the caller has gone away.
Quick Recap
How should I validate the deployment?
- Deploy the REST API and Lambda integration with response transfer mode
STREAM. - Call the deployed endpoint with
curl -i --no-bufferand confirm that SSE data appears before the Claude response is complete. - Check that the response headers identify
text/event-streamand that events end with a blank line. - Exercise successful completion, a Claude-side failure before output, and an interruption after output begins. Confirm that the client distinguishes normal completion from an in-band stream error.
- Review API Gateway streaming access-log timing values alongside Lambda duration and timeout behavior.
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.

