max_tokens

API

Definition

API parameter that sets the maximum number of tokens Claude will generate in its response. If the response would exceed this limit, it is truncated and stop_reason is set to 'max_tokens'. Always check stop_reason to detect truncation.

Example Usage

Set max_tokens high enough for complete responses but low enough to control costs. Always check stop_reason for 'max_tokens' to detect truncation.

Related Terms