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): TokenLimitErrorParameters
| Parameter | Type | Description |
|---|---|---|
context | TokenLimitErrorContext | Details describing the breached rule and usage metadata. |
Returns
Overrides
Error.constructorProperties
| Property | Modifier | Type | Description |
|---|---|---|---|
model | readonly | string | Model that exceeded the limit. |
rule | readonly | TokenLimitRule | Rule that caused the error to be thrown. |
usageKind? | readonly | string | Optional usage classification for context. |
window | readonly | TokenSummaryWindow | Window in which the error was triggered. |
windowKey | readonly | string | Window key describing the offending period. |
Accessors
displayMessage
Get Signature
get displayMessage(): stringMessage suitable for end-user display.
Returns
string
