buckette®
Bounded, revocable spend limits for your agents and automated systems.
Your code asks buckette before it spends: each spend is applied atomically, on tokens, dollars or any unit you name, and refused if it would go over its limit. Limits split into child buckets, refill on a schedule, and can be frozen or revoked at any time.
Start in the Console Read the guide for agents
How it works
-
Create a budget.
POST /bucketswith a limit of 100,000 tokens, andPUT /buckets/:id/replenish-configto refill it on the 1st of each month. -
Ask before each call. Your code posts what the call will cost to
/buckets/:id/consume. Later in the month, with 20,000 tokens left:curl "$BUCKETTE_URL/buckets/$BUCKET_ID/consume" \ -H "Authorization: Bearer $BUCKETTE_KEY" \ -H "Content-Type: application/json" \ -d '{"crAmounts": {"tokens": 1200}, "crMode": {"tag": "Strict"}}'The tokens are taken, and the answer says what is left:
{ "coConsumed": {"tokens": 1200}, "coProtection": null, "coReceipt": null, "coRemaining": {"tokens": 18800}, "tag": "ConsumeSuccess" } -
Over the limit, it is refused. The same call for 25,000 tokens takes nothing. The answer says how much is missing and when the next refill covers it (
eaAtUnixis 1 December, 00:00 UTC):{ "coAvailable": {}, "coEta": { "seDimensions": { "tokens": {"eaAtUnix": 1796083200, "eaSeconds": 1339200, "tag": "EtaAt"} }, "seOverall": {"eaAtUnix": 1796083200, "eaSeconds": 1339200, "tag": "EtaAt"} }, "coProtection": null, "coShortfall": {"tokens": 6200}, "tag": "ConsumeShortfall" }
Both answers are 200 OK: read tag. Every route is in the guide for agents, and the first steps in Getting started.
Blog
- Wake your Cloud Run or Lambda function when the budget is back
A function on a schedule wakes up every few minutes to find that the budget it needs is still spent. Let the budget wake it instead: the function leaves a waiting request on its bucket and exits, and buckette calls it back when the amount it asked for is there. What that takes, and what buckette does not do for you.
- How buckette differs: on-chain metering and settlement
Blockchain networks meter usage and settle payments without a party everyone must trust. buckette does the opposite on purpose: it is the trusted party, and it signs a receipt instead of reaching consensus. What each is good at, where they differ, and when you should use a chain instead.
- Simplify your cron job schedules with buckette
Let cron fire often, on every host, and let a bucket decide which firing is the run: one run a day, never two at once, a failed run tried again, and a schedule you change with one call. Then, for the advanced case, start the job from a webhook instead of a poll.