Claude Certified Architect – Foundations Practice Question 70: Streaming Long Requests
Claude Certified Architect, Foundations · Test 7 · question 10 of 10
A report-generation service calls the Messages API without streaming and sets a very large max_tokens so Claude can write a long document. Requests intermittently fail or time out behind a corporate network that drops idle connections, and the SDK warns about the expected duration. The user is waiting in the UI for the finished document, so the work cannot be deferred. What is the best fix?
Show answer and explanation
Answer:
C is correct. The API docs advise using streaming for long-running requests and warn against a large max_tokens value without streaming, because networks may drop idle connections. The SDKs validate that non-streaming requests are not expected to exceed a 10-minute timeout, so for large max_tokens streaming is required. If you do not need incremental events, the SDK's stream helpers consume the stream and return the complete Message object, such as get_final_message() in Python.
A is wrong because a longer client timeout does not stop an intermediate network device from dropping the idle connection, and the SDK still refuses non-streaming calls expected to run too long. B is wrong because caching reduces cost and latency on repeated prefixes, not generation time for a long output. D is wrong because the Batches API is asynchronous and suited to jobs that can wait; the stem says the user is waiting, so it does not fit.
Reference: Claude API errors - Long requests and Streaming Messages