Stream the response, the first token is the loading indicator
A ten second wait for a complete answer feels broken. The same ten seconds with words appearing from the first second feels fast.
for await (const chunk of stream) res.write(chunk);Render the partial text as it arrives and keep the "stop" button visible. For structured output, stream the fields you can show and validate the whole object at the end.
ai-engineeringfrontend