LogoRobo.js
Packages@robojs/ai

TokenLimitError

Class: TokenLimitError

Error thrown when a block mode limit has been exceeded.

Examples

try {
  await AI.chat(options)
} catch (error) {
  if (error instanceof TokenLimitError) {
    console.warn(error.displayMessage)
  }
}
tokenLedger.configure({
  limits: { perModel: { 'gpt-4o': { window: 'day', maxTokens: 10_000, mode: 'block' } } }
})

See

tokenLedger.configure

Extends

  • Error

Constructors

new TokenLimitError()

new TokenLimitError(context): TokenLimitError

Parameters

ParameterTypeDescription
contextTokenLimitErrorContextDetails describing the breached rule and usage metadata.

Returns

TokenLimitError

Overrides

Error.constructor

Properties

PropertyModifierTypeDescription
modelreadonlystringModel that exceeded the limit.
rulereadonlyTokenLimitRuleRule that caused the error to be thrown.
usageKind?readonlystringOptional usage classification for context.
windowreadonlyTokenSummaryWindowWindow in which the error was triggered.
windowKeyreadonlystringWindow key describing the offending period.

Accessors

displayMessage

Get Signature

get displayMessage(): string

Message suitable for end-user display.

Returns

string

On this page