Arcjet · Concept
Capacity
Use an Arcjet token bucket to limit AI tokens per user. Estimate each request's token cost, charge it to the user's bucket, and deny requests when the bucket is empty.
Last updated
Syntax
arcjet.TokenBucket(arcjet.TokenBucketOptions{Mode, Characteristics, RefillRate, Interval, Capacity})
aj.Protect(ctx, request, arcjet.WithRequested(tokens), arcjet.WithCharacteristics(values))In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
TokenBucketTokenBucketOptionsWithRequestedWithCharacteristicsProtectModeLivefixed windowsliding window