LLMBUDGET.SET
LLMBUDGET.SET name token_limit cost_limit_usd window_seconds
- Group
- LLM usage and budgets
- Complexity
- O(1)
- Arity
- 5 (exactly, counting the command name)
- Flags
- write, fast
- Keys
- first 1, last 1, step 1
- HotKV Cloud
- Performance and Scale
- On-Premise
- requires the llm-budget license feature
LLM budgets put a hard cap on the tokens and dollars a named budget (for example one per tenant) can spend in a time window, so you can refuse a request before you pay the model provider for it. LLMBUDGET.SET creates budget name, or changes the limits of an
existing one without clearing what it has already used.
All three arguments are positional:
token_limit: the most tokens allowed per window.0means no token cap.cost_limit_usd: the most dollars allowed per window, as a decimal with at most six digits after the point and a leading digit (5,5.00,0.25).0means no cost cap.window_seconds: the window length. A new window starts when the budget is created, and oncewindow_secondshave passed the usage goes back to zero and the next window starts.0means a single window that never resets.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Budget created or updated | Simple string OK |
Same |
Errors:
ERR invalid argumentif a limit or the window is negative or not in the format above.ERR budget limit reachedif the budget is new and the server already holds its maximum number of budgets (max_budgetsunder[llmbudget]).ERR wrong number of arguments for 'llmbudget.set' commandif the argument count is wrong.NOLICENSE llm-budget requires a HotKV license. Contact sales@hotkv.comif your license does not include thellm-budgetfeature.
Examples
Section titled “Examples”127.0.0.1:6379> LLMBUDGET.SET tenant_acme 0 5.00 3600OK127.0.0.1:6379> LLMBUDGET.SET tenant_beta 1000000 0 86400OKThe first budget allows $5 per hour with no token cap; the second allows a million tokens per day with no cost cap.
Compatibility
Section titled “Compatibility”HotKV-only command. Redis and Valkey have no equivalent.
See also
Section titled “See also”LLMBUDGET.CONSUME, LLMBUDGET.STATUS, LLMBUDGET.RESET, LLMBUDGET.DROP, LLMBUDGET.LIST, AI features guide
Was this page helpful?
Thanks for the feedback.