The four stop reasons
Every response includes a stop_reason telling you why generation halted. The four you will see in production: end_turn (model finished naturally), max_tokens (you ran out of budget), stop_sequence (your custom stop string fired), tool_use (the model wants to call a tool — handle separately). A response with stop_reason='max_tokens' is truncated; treat it differently from end_turn.
Stop sequences for structured output
You can pass stop_sequences=["</answer>", "END"] and the API halts as soon as any of those strings appears. Combined with prompt design, this is a lightweight way to extract structured fragments. Heavier structure should use tool use or schema-prompted JSON, not stop sequences.
JSON output without tool use
For pure JSON output, the most reliable pattern is: tell the system prompt the exact JSON schema, prefill the assistant turn with {, and parse defensively. Prefilling the assistant message biases the model into the shape you want without any tool overhead.