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
| Parameter | Type | Description |
|---|---|---|
context | TokenLimitErrorContext | Details describing the breached rule and usage metadata. |
Returns
Overrides
Error.constructor
Properties
| Property | Modifier | Type | Description | Inherited from |
|---|---|---|---|---|
message | public | string | - | Error.message |
model | readonly | string | Model that exceeded the limit. | - |
name | public | string | - | Error.name |
rule | readonly | TokenLimitRule | Rule that caused the error to be thrown. | - |
stack? | public | string | - | Error.stack |
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(): string
Message suitable for end-user display.
Returns
string