Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

LLMBUDGET.SET

Last updated
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. 0 means 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). 0 means no cost cap.
  • window_seconds: the window length. A new window starts when the budget is created, and once window_seconds have passed the usage goes back to zero and the next window starts. 0 means a single window that never resets.
Case RESP2 RESP3
Budget created or updated Simple string OK Same

Errors:

  • ERR invalid argument if a limit or the window is negative or not in the format above.
  • ERR budget limit reached if the budget is new and the server already holds its maximum number of budgets (max_budgets under [llmbudget]).
  • ERR wrong number of arguments for 'llmbudget.set' command if the argument count is wrong.
  • NOLICENSE llm-budget requires a HotKV license. Contact sales@hotkv.com if your license does not include the llm-budget feature.
127.0.0.1:6379> LLMBUDGET.SET tenant_acme 0 5.00 3600
OK
127.0.0.1:6379> LLMBUDGET.SET tenant_beta 1000000 0 86400
OK

The first budget allows $5 per hour with no token cap; the second allows a million tokens per day with no cost cap.

HotKV-only command. Redis and Valkey have no equivalent.

LLMBUDGET.CONSUME, LLMBUDGET.STATUS, LLMBUDGET.RESET, LLMBUDGET.DROP, LLMBUDGET.LIST, AI features guide