stop_reason
field that indicates why the model stopped generating its response. Understanding these values is crucial for building robust applications that handle different response types appropriately.
For details about stop_reason
in the API response, see the Messages API reference.
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 successfully completed its response generation.
max_tokens
limit specified in your request.
stop_reason
in your response handling logic:
stop_reason
values and actual errors:
stop_reason
is:
null
in the initial message_start
eventmessage_delta
eventstop_reason
values, you can build more robust applications that gracefully handle different response scenarios and provide better user experiences.