{
  "id": 11603193,
  "title": "Solving AWS re:Post's #1 GenAI Headache: Real-Time Token Streaming with Amazon Bedrock & AWS Lambda",
  "url": "https://urgent.news/2026/10/03/solving-aws-re-posts-1-genai-headache-real-time-token-streaming-with",
  "topic": "ai",
  "section": "AI",
  "published": "2026-10-03T04:50:32.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/sharmavarun/solving-aws-reposts-1-genai-headache-real-time-token-streaming-with-amazon-bedrock-aws-lambda-37kh"
  },
  "original_language": "en",
  "account": "If you have worked with Amazon Bedrock over the past year, you may have noticed a recurring question on AWS re:Post: How do I stream tokens as they are generated when integrating Bedrock with Lambda behind API Gateway? The underlying issue is that API Gateway buffers the entire response in memory, causing significant delays in displaying the chat app's first word. Additionally, API Gateway has a 29-second hard limit for integration timeouts, which can terminate the connection if the model takes longer than expected to generate a response. This often leads to a frustrating user experience with perceived latency of 8 to 15 seconds before any words appear. The architecture typically involves a web browser sending an HTTP request to Amazon API Gateway, which then forwards the request to an AWS Lambda function. The Lambda function interacts with Amazon Bedrock to generate responses, but the full buffering and timeout issues break the token streaming capability that Bedrock offers out of the box. The solution is to use Lambda Function URLs in RESPONSE_STREAM mode, which allows Lambda to send data back to the client using HTTP chunked transfer encoding. This means that bytes leave Lambda and hit the browser immediately as they are generated by Bedrock, providing real-time token streaming with sub-300ms Time-To-First-Token (TTFT).",
  "summary": "If you have spent any time working with Amazon Bedrock over the past year, you have probably noticed a recurring conversation on AWS re:Post under the #AmazonBedrock and #AWSLambda tags. Every couple of days, an engineer asks the exact same question: \"I hooked up Bedrock (Claude 3.5 Sonnet) to a Lambda function behind API Gateway, but my chat app takes 10 to 15 seconds before the first word shows…",
  "key_points": [
    "API Gateway buffers entire response, causing delays",
    "API Gateway 29-second timeout limit can terminate connection",
    "Lambda Function URLs in RESPONSESTREAM mode enable real-time token streaming"
  ],
  "editors_take": "Using Lambda Function URLs in RESPONSESTREAM mode resolves the token streaming issue, enabling real-time responses with sub-300ms Time-To-First-Token, and thereby significantly improving the user experience.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}