Skip to content

MaxTokensError

Defined in: src/errors.ts:59

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:72

Creates a new MaxTokensError.

| Parameter | Type | Description | | ---------------- | ------------------------ | -------------------------------------------------------- | | message | string | Error message describing the max tokens condition | | partialMessage | Message | The partial assistant message generated before the limit |

MaxTokensError

ModelError.constructor

readonly partialMessage: Message;

Defined in: src/errors.ts:64

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.