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.

LLMSTATS.GET

Last updated
LLMSTATS.GET name
Group
LLM usage and budgets
Complexity
O(1)
Arity
2 (exactly, counting the command name)
Flags
read-only, fast
Keys
first 1, last 1, step 1
HotKV Cloud
Performance and Scale
On-Premise
requires the llm-stats license feature

LLM usage stats keep running totals of the requests, tokens, cost and latency of your model calls in named buckets, for example one per tenant or per model. LLMSTATS.GET returns a bucket’s totals since it was created or last reset, plus the requests, tokens and cost of the last minute. For a bucket that does not exist, every field is zero.

The reply is a flat array of alternating field names and values in both RESP2 and RESP3 (it is not sent as a RESP3 map). The fields, in order:

Field Type Meaning
requests Integer Requests recorded.
errors Integer Requests recorded with ERROR 1.
input_tokens Integer Uncached input tokens.
output_tokens Integer Output tokens.
cached_tokens Integer Cache-read tokens.
cost_usd Bulk string Total cost in US dollars.
avg_latency_ms Bulk string Mean latency in milliseconds.
requests_1m Integer Requests in the last minute.
tokens_1m Integer All tokens (input, output, cache read and cache write) in the last minute.
cost_usd_1m Bulk string Cost in the last minute, in US dollars.
cache_write_5m_tokens Integer Tokens written to 5-minute provider caches.
cache_write_1h_tokens Integer Tokens written to 1-hour provider caches.
unpriced_requests Integer Requests recorded with a MODEL that has no price.

Errors:

  • ERR wrong number of arguments for 'llmstats.get' command if the argument count is wrong.
  • NOLICENSE llm-stats requires a HotKV license. Contact sales@hotkv.com if your license does not include the llm-stats feature.
127.0.0.1:6379> LLMSTATS.RECORD model_sonnet5 100000 2000 50000 0 420 MODEL claude-sonnet-5 CACHEWRITE5M 10000
OK
127.0.0.1:6379> LLMSTATS.GET model_sonnet5
1) "requests"
2) (integer) 1
3) "errors"
4) (integer) 0
5) "input_tokens"
6) (integer) 100000
7) "output_tokens"
8) (integer) 2000
9) "cached_tokens"
10) (integer) 50000
11) "cost_usd"
12) "0.255"
13) "avg_latency_ms"
14) "420"
15) "requests_1m"
16) (integer) 1
17) "tokens_1m"
18) (integer) 162000
19) "cost_usd_1m"
20) "0.255"
21) "cache_write_5m_tokens"
22) (integer) 10000
23) "cache_write_1h_tokens"
24) (integer) 0
25) "unpriced_requests"
26) (integer) 0

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

LLMSTATS.BUCKET, LLMSTATS.RECORD, LLMSTATS.RESET, LLMSTATS.DROP, LLMSTATS.LIST, LLMSTATS.PRICE, AI features guide