Question 1 · choose 1
A chat feature calls ConverseStream from a Lambda function behind an existing Amazon API Gateway REST API that uses a Lambda authorizer. Users wait up to 90 seconds before they see any text, and some long answers fail at 29 seconds. The team wants tokens shown as they are generated, wants to keep the REST API and its authorizer, and does not want to manage persistent client connections. What should the team do?
- AMove the chat to an API Gateway WebSocket API and push each token to the client with the connections endpoint
- BRequest a higher integration timeout for the REST API and keep the default buffered transfer mode
- CSet the proxy integration's response transfer mode to STREAM and stream the model output
- DReplace the REST API with an HTTP API so that responses are sent with chunked transfer encoding
Show the answer and why
AMove the chat to an API Gateway WebSocket API and push each token to the client with the connections endpoint
Incorrect
WebSocket APIs can deliver tokens in real time, but they require the team to manage connections and client changes, which the team wants to avoid.
BRequest a higher integration timeout for the REST API and keep the default buffered transfer mode
Incorrect
A longer timeout stops the failures, but buffered mode still waits for the complete response, so users see nothing until the end.
CSet the proxy integration's response transfer mode to STREAM and stream the model output
Correct
Response streaming on REST API proxy integrations sends output as it is produced, lowers time to first byte, and can run up to 15 minutes without an integration timeout increase.
DReplace the REST API with an HTTP API so that responses are sent with chunked transfer encoding
Incorrect
Response streaming is supported only for REST APIs, and changing the API type would also drop the existing setup the team wants to keep.
For token-by-token delivery over an existing REST API, set the proxy integration's response transfer mode to STREAM. It lowers time to first byte, can exceed the 29-second integration timeout and the 10 MB payload limit, and keeps the authorizer in place. Endpoint caching is not available in streaming mode.
AWS documentation