Course menuAIP-C01

Exams / AIP-C01 / Streaming responses (ConverseStream, WebSockets, response streaming) / Question 1

AIP-C01 practice question: Streaming responses (ConverseStream, WebSockets, response streaming)

Implementation and Integration A free question from our original AIP-C01 practice exam. Try it, then open the answer to see why each option is right or wrong.

Last verified against current AWS documentation ·How we write our questions

A telehealth company runs a symptom-checker chat app. A web front end calls a backend Lambda function in the same Region as the model, and the backend calls a foundation model on Amazon Bedrock. Full answers take about 25 seconds, and users are abandoning the chat before the answer appears.

The team wants the first words visible within about one second, with the same model and no increase in total cost per conversation. The answers must still be generated with the same model settings.

The team's developers are comfortable changing the backend and the front end.

Which change meets these requirements?

Choose one answer.

  1. A. Call ConverseStream instead of Converse, and forward each text chunk from the backend to the browser over a streaming connection as soon as it arrives.
  2. B. Keep the Converse call, but split each question into five smaller prompts and send them one after another, so that each shorter answer returns quickly.
  3. C. Switch to batch inference, have the backend write each request to Amazon S3, and have the front end poll the bucket every second for the result file.
  4. D. Call InvokeModel with the largest allowed output length, so that the model returns the full answer in one response with fewer round trips.
Show the answer and explanation

Answer: A

  • A. Right: ConverseStream returns output as the model generates it, so the first words reach the user in about a second. The model, its settings and the token count stay the same, so the cost per conversation does not change. Learn more: ConverseStream API reference (opens in a new tab)
  • B. Wrong: Sequential calls add their latencies together, so the full answer takes at least as long. The first visible text would also come only after the first call finishes, and the answers would change.
  • C. Wrong: Batch inference runs offline and produces results after the job completes, so it cannot show text during a chat. Polling a bucket every second adds delay and request cost.
  • D. Wrong: A single full response still waits for the model to finish, so the user sees nothing for about 25 seconds. Fewer round trips does not change the time to the first word.

Explanation

ConverseStream returns the model's output as it is generated, so the backend can forward each chunk to the browser and the first words appear within about a second. Keeping the same model and settings leaves cost unchanged. Sequential prompts, batch jobs and a single full response each keep the user waiting for the complete answer.

Study

Keep practicing

Answer questions with a score at the end, or practice just this topic with the explanation after each one. No sign-up needed.

Want more on Streaming responses (ConverseStream, WebSockets, response streaming)? The 5 full-length practice sets have 5 more Streaming responses (ConverseStream, WebSockets, response streaming) questions, 375 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets