Skill 2.4.2

Develop real-time AI interaction systems to provide immediate feedback from FM (for example, by using Amazon Bedrock streaming APIs for incremental response delivery, WebSockets or server-sent events to generate text in real time, API Gateway to implement chunked transfer encoding)

Key Concepts

ConverseStream and InvokeModelWithResponseStream return an event stream with message start, content block deltas containing text, message stop with the stop reason, and metadata with token usage. Total generation time is unchanged, but perceived latency drops to the time to first token.

To deliver tokens to clients, an API Gateway WebSocket API keeps a two-way connection and a backend pushes each chunk with the @connections API; server-sent events or chunked transfer encoding over HTTP stream one-way text from a Lambda function with response streaming or from a container. API Gateway REST APIs support response streaming for HTTP proxy and Lambda integrations, and AWS AppSync subscriptions can push updates to web and mobile clients.