AI-103 Practice Question 54: Streaming Chat Completions
Microsoft Azure AI Apps and Agents Developer Associate (AI-103) · Test 6 · question 4 of 10
A support chat widget calls a chat completions endpoint and waits for the entire answer before showing anything. Longer answers leave the widget blank for several seconds, and users assume it has frozen. The team wants the widget to display words as the model produces them, without splitting the work into a separate background job.
What should they change on the request?
Show answer and explanation
Answer:
Setting stream: true switches the response to server-sent events: instead of one payload returned after the whole completion is generated, the service sends a series of chat.completion.chunk messages, each carrying a small piece of the answer in choices[0].delta.content, as soon as that piece exists. Microsoft's own description of this behavior is that customers "receive content from the API when it's generated, instead of waiting for" the full response, exactly the token-by-token rendering the widget needs, with finish_reason staying null until the final chunk.
- A is wrong because it trades away answer length to reduce total wait time; the widget still shows nothing until the (now shorter) full response is ready; it doesn't produce incremental rendering. - B is wrong because a longer client timeout only postpones when the client gives up on a slow request; it has no effect on when content becomes visible to the user. - C is wrong because that's the polling pattern for asynchronous batch-style jobs. Chat completions is a synchronous call; there's no separate job status to poll, and polling wouldn't produce a smooth per-token render even if there were.
Reference: Content streaming in Azure OpenAI