Feature
Per-Key Budgets
Every API key can carry its own spend limit. Give a staging key $25 a month, a customer-facing key $500, and a demo key a one-time $5 cap — all funded from the same prepaid balance, all enforced with no code changes on your side.
How it works
Set a limit on the key
Attach a budget when you create a key, or add one later. Choose a recurring period or a fixed one-time amount.
Usage accrues per request
Every successful response debits that key's budget by the actual token cost, same as it debits the account balance.
Limit reached, key stops
The next request on that key returns 402 before it reaches a model. Every other key on the account keeps working.
const key = await aniron.keys.create({
name: 'staging-worker',
budget: {
limit_usd: 25,
period: 'monthly',
},
});
// Requests on this key are rejected with 402 once
// $25 of usage accrues in the current month.
// Other keys on the account are unaffected. Budget enforcement happens before a request is routed to a model, so a capped key never incurs provider cost.
When to use per-key budgets
Isolate dev from prod
Give a staging or CI key a small monthly cap so a runaway test loop can never touch the production balance.
Meter internal teams
Hand each team or project its own key with its own budget, and see exactly where spend is going without building your own metering layer.
Cap per-customer usage
Issue one key per customer on a usage-based plan, with a budget that matches what they paid for, and let Aniron enforce the ceiling.
Bound demo and trial keys
Give a sales demo or free trial a fixed one-time budget so it can never turn into an unbounded bill.
Frequently asked questions
What happens when a key hits its budget?
The next request on that key returns a 402 Payment Required error before it reaches any model. Keys with remaining budget on the same account continue to work normally.
Can I set a budget without a reset period?
Yes. Choose a one-time limit instead of a recurring period. The key is disabled once it spends that amount and stays disabled until you raise the limit manually.
Do budgets stack with the account-level prepaid balance?
Yes. A key budget is a ceiling within the account balance, not a separate wallet. If the account balance runs out first, requests stop even if the key still has budget left.
Can I change a budget after the key is created?
Yes. Budgets can be raised, lowered, or removed at any time from the dashboard or the API. Changes apply to the next request, not retroactively.
Do I get a warning before a key runs out?
Yes. You can set an alert threshold, such as 80% of the limit, and receive a webhook or email notification when a key crosses it.
Continue learning
Give every key its own ceiling
Create a key with a budget in under a minute. No contract change, no separate wallets to manage.