Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Every Messages API response includes a stop_reason field that tells you why Claude stopped generating. Check this field to decide whether to use the response as-is, continue the conversation, retry, or fall back to another model.
For the full response schema, see the Messages API reference.
| Value | When it occurs | What to do |
|---|---|---|
end_turn | Claude finished its response naturally. | Use the response. |
max_tokens | The response reached your max_tokens limit. | Raise max_tokens or continue the response. |
stop_sequence | Claude emitted one of your stop_sequences. | Read stop_sequence to see which one fired. |
tool_use | Claude is calling a tool. | Run the tool and return the result. A server tool call still missing its result block completes in a later response. |
pause_turn | A server-tool loop reached its iteration limit. | Send the assistant content back to continue. |
refusal | Claude declined to respond. | Read stop_details and retry on a fallback model. |
model_context_window_exceeded | The response filled the model's context window. | Treat the response as truncated. |
The stop_reason field is part of every successful Messages API response. Unlike errors, which indicate failures in processing your request, stop_reason tells you why Claude completed its response generation.
{
"id": "msg_01234",
"type": "message",
"role": "assistant",
"content"