A court clerk's office calls Claude to produce a single tagged block of case metadata and wants generation to halt as soon as the closing tag is emitted, so no trailing commentary is billed or returned. Which API parameter is designed for this?
Select an answer to reveal the explanation.
Short Explanation
A stop sequence is a tripwire. Hand the API your closing tag, and the moment Claude generates it the turn ends, with no trailing commentary to pay for or strip out.
Full Explanation
Choosing a termination control means asking what actually defines the end of a valid response. For a single tagged block of case metadata the boundary is a known string, the closing tag, rather than a token count or a matter of sampling breadth, so the parameter that watches content is the one that fits the clerk's office requirement.
Stop_sequences carries a list of strings, and when the model generates any of them the API ends the turn at that point, returns a stop_reason of stop_sequence, and reports which sequence matched. Generation halts exactly at the structural boundary of the record, so the office is neither billed for trailing prose nor forced to strip it downstream.
Max_tokens is a content-blind length ceiling that either truncates the block mid-record or leaves room for the very commentary being avoided; top_p shapes which tokens are considered at each step and never terminates a turn; the system parameter carries standing instructions that can request brevity but cannot mechanically stop generation.
Exam caveat: the matched stop sequence is not included in the returned text, so code that needs a well-formed block has to append the closing tag itself before parsing. Operational check: issue a request with the closing tag as the stop sequence, assert that stop_reason comes back as stop_sequence, and confirm the returned text ends immediately before the tag rather than containing it.