Build a Serverless Streaming LLM Chat App on AWS with Bedrock, WebSockets & Lambda A developer published a step-by-step guide for building a serverless streaming LLM chat app on AWS using API Gateway WebSocket APIs, Lambda functions written in Python 3.12, DynamoDB for connection tracking, and Amazon Bedrock's ConverseStream API with the amazon.nova-micro-v1:0 model. The architecture pushes token-by-token responses from Bedrock through Lambda and API Gateway to a static S3/CloudFront frontend, avoiding managed servers and scaling to zero when idle. The guide includes CLI commands for provisioning the DynamoDB connections table with TTL, IAM permissions for bedrock:InvokeModelWithResponseStream and execute-api:ManageConnections, and notes the stack fits largely within AWS Free Tier limits. Most tutorials for building an AI chat app start by spinning up a Node.js or Python backend server, configuring Docker, and babysitting an EC2 instance or container service. You don't need any of that. Combining a static HTML frontend with an Amazon API Gateway WebSocket API and AWS Lambda gives you real-time, bidirectional user interaction and token-by-token LLM streaming—with zero servers to manage , automatic scaling to zero when idle, and near-\$0 running costs. In this step-by-step guide, you'll build and deploy a complete serverless streaming AI chat app on AWS using: wss:// connections Before writing a single line of code, let's clear up a common misconception about AWS AI pricing: amazon.nova-micro-v1:0 , AWS's fastest and most economical text model, even uncredited testing costs Best of all, we'll use Bedrock's unified ConverseStream API—so if you ever want to switch to Meta Llama or Anthropic Claude, it's a one-line environment variable change. Standard REST APIs force users to stare at a loading spinner until the LLM finishes generating its entire answer—and long responses easily hit gateway timeouts. With API Gateway WebSockets , the browser keeps a persistent connection open. As Amazon Bedrock streams tokens to AWS Lambda, Lambda immediately pushes each chunk back through API Gateway to the browser in real time. index.html from Amazon S3 fronted by CloudFront . $connect Lambda saves the user's connectionId to DynamoDB. "action": "sendMessage" . API Gateway routes it to the ws-send-message Lambda. bedrock-runtime.converse stream using contentBlockDelta event from Bedrock, Lambda calls apigatewaymanagementapi.post to connection to push the text chunk straight to the browser, finishing with a {"type": "done"} event. $disconnect deletes the | Service | Purpose | Cost Profile | |---|---|---| | Amazon S3 + CloudFront | Hosts static index.html over HTTPS | AWS Free Tier eligible | | API Gateway WebSocket | Manages persistent wss:// connections | 1M messages & 750K connection-mins/mo Free Tier | | AWS Lambda Python 3.12 | Runs $connect , $disconnect , and streaming logic | 1M requests/mo always free | | Amazon DynamoDB | Stores active connectionId records + TTL | 25 GB storage + generous on-demand Free Tier | | Amazon Bedrock | Serverless LLM inference amazon.nova-micro-v1:0 | Pay-per-token covered by new-account AWS credits | | IAM & CloudWatch Logs | Least-privilege security & execution logs | Free IAM / 5 GB CloudWatch Free Tier | aws configure us-east-1 Create a working folder on your machine so everything stays organized: mkdir aws-serverless-llm-chat cd aws-serverless-llm-chat You can quickly verify access from your terminal: aws bedrock list-foundation-models \ --region us-east-1 \ --by-provider Amazon \ --query "modelSummaries ?contains modelId, 'nova-micro' .modelId" You should see "amazon.nova-micro-v1:0" in the output. Create an on-demand DynamoDB table called WebSocketConnections to store each client's connectionId : aws dynamodb create-table \ --table-name WebSocketConnections \ --attribute-definitions AttributeName=connectionId,AttributeType=S \ --key-schema AttributeName=connectionId,KeyType=HASH \ --billing-mode PAY PER REQUEST \ --region us-east-1 Enable TTL Time to Live on the ttl attribute so abandoned connections clean themselves up automatically: aws dynamodb update-time-to-live \ --table-name WebSocketConnections \ --time-to-live-specification "Enabled=true, AttributeName=ttl" \ --region us-east-1 Our Lambda functions need permission to: bedrock:InvokeModelWithResponseStream execute-api:ManageConnections First, grab your 12-digit AWS Account ID: ACCOUNT ID=$ aws sts get-caller-identity --query Account --output text echo $ACCOUNT ID Create trust-policy.json : { "Version": "2012-10-17", "Statement": { "Effect": "Allow", "Principal": { "Service": "lambda.amazonaws.com" }, "Action": "sts:AssumeRole" } } Create the role and attach the basic CloudWatch logging policy: aws iam create-role \ --role-name ServerlessLLMWebSocketRole \ --assume-role-policy-document file://trust-policy.json aws iam attach-role-policy \ --role-name ServerlessLLMWebSocketRole \ --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole Now create lambda-permissions.json replace