Skip to content

MaxTokensError

Defined in: src/errors.ts:58

Error thrown when the model reaches its maximum token limit during generation.

This error indicates that the model stopped generating content because it reached the maximum number of tokens allowed for the response. This is an unrecoverable state that requires intervention, such as reducing the input size or adjusting the max tokens parameter.

new MaxTokensError(message, partialMessage): MaxTokensError;

Defined in: src/errors.ts:71

Creates a new MaxTokensError.

ParameterTypeDescription
messagestringError message describing the max tokens condition
partialMessageMessageThe partial assistant message generated before the limit

MaxTokensError

ModelError.constructor

readonly partialMessage: Message;

Defined in: src/errors.ts:63

The partial assistant message that was generated before hitting the token limit. This can be useful for understanding what the model was trying to generate.