# LLMSTATS.PRICE

> Set, read, list or remove model prices in the price table shared by usage stats, budgets and cache savings.

URL: https://docs.hotkv.com/commands/llmstats-price/

```
LLMSTATS.PRICE SET model INPUT usd OUTPUT usd [CACHEREAD usd] [CACHEWRITE5M usd] [CACHEWRITE1H usd]
LLMSTATS.PRICE GET model
LLMSTATS.PRICE LIST
LLMSTATS.PRICE DEL model
```

- Group: LLM usage and budgets
- Complexity: O(1) for SET, GET and DEL; O(N) for LIST where N is the number of known models
- HotKV Cloud: Performance and Scale plans
- On-Premise: requires the llm-stats license feature

HotKV keeps one price table for LLM models, in US dollars per million
tokens. [LLMSTATS.RECORD](https://docs.hotkv.com/commands/llmstats-record/index.md), [LLMBUDGET.CONSUME](https://docs.hotkv.com/commands/llmbudget-consume/index.md) and the
`usage_saved_cost_usd` field of every cache family use it whenever you pass a
`MODEL`. HotKV ships list prices for current Anthropic and OpenAI models
(source `default`). `LLMSTATS.PRICE` lets you add your own models or
override a built-in price (source `custom`).

In a cluster, the price table is the same on every node: a change made on one
node reaches all the others.

You can also seed custom prices at startup with `price_overrides` under
`[llmstats]`, one `"model:input:output"` entry per model, optionally
followed by `:cacheread:cachewrite5m:cachewrite1h`.

## Subcommands

| Subcommand | Effect |
| --- | --- |
| `SET model INPUT usd OUTPUT usd ...` | Set a custom price. `INPUT` and `OUTPUT` are required. If you leave them out, `CACHEREAD` defaults to 0.1 times the input price, `CACHEWRITE5M` to 1.25 times and `CACHEWRITE1H` to 2 times. |
| `GET model` | Show the price HotKV uses for a model. |
| `LIST` | Show every model the table knows, built-in and custom. |
| `DEL model` | Remove a custom price. A built-in price for the same model applies again. |

Prices are decimal numbers with at most six digits after the point, written
with a leading digit and no sign (`0.80`, not `.80` or `+0.80`).
Subcommand and option names are case-insensitive.

## Return value

| Subcommand | RESP2 | RESP3 |
| --- | --- | --- |
| `SET` | Simple string `OK` | Same |
| `GET` | A price entry (below) | Same |
| `LIST` | Array of price entries | Same |
| `DEL` | Integer `1` if a custom price was removed, `0` if the model had none | Same |

A price entry is a flat array of alternating field names and values in both
protocols, with these fields in order:

| Field | Type | Meaning |
| --- | --- | --- |
| `model` | Bulk string | The model id. |
| `source` | Bulk string | `custom`, `default` (built in), or `unpriced` (unknown model). |
| `priced` | Integer | `1` if HotKV has a price for the model, else `0`. |
| `retired` | Integer | `1` for a retired model that HotKV recognises but has no current price for. |
| `input_usd_per_mtok` | Bulk string | Input price. |
| `output_usd_per_mtok` | Bulk string | Output price. |
| `cache_read_usd_per_mtok` | Bulk string | Cache-read price. |
| `cache_write_5m_usd_per_mtok` | Bulk string | 5-minute cache-write price. |
| `cache_write_1h_usd_per_mtok` | Bulk string | 1-hour cache-write price. |

Prices are shown with six decimals. A model with no price shows `0.000000`
for each and contributes `$0` wherever it is used.

Errors:

- `ERR INPUT and OUTPUT are required` if `SET` lacks either.
- `ERR invalid INPUT price` (or `OUTPUT`, `CACHEREAD`, `CACHEWRITE5M`, `CACHEWRITE1H`) if a price is not in the format above.
- `ERR model must not be empty` if `SET` gets an empty model id.
- `ERR syntax error` if a `SET` option has no value.
- `ERR unknown option` for any other `SET` option.
- `ERR unknown LLMSTATS.PRICE subcommand, use SET|GET|LIST|DEL` for any other subcommand.
- `ERR wrong number of arguments for 'llmstats.price set' command` (or `get`, `list`, `del`) if a subcommand has the wrong argument count.
- `NOLICENSE llm-stats requires a HotKV license. Contact sales@hotkv.com` if your license does not include the `llm-stats` feature.

## Examples

```
127.0.0.1:6379> LLMSTATS.PRICE GET claude-sonnet-5
 1) "model"
 2) "claude-sonnet-5"
 3) "source"
 4) "default"
 5) "priced"
 6) (integer) 1
 7) "retired"
 8) (integer) 0
 9) "input_usd_per_mtok"
10) "2.000000"
11) "output_usd_per_mtok"
12) "10.000000"
13) "cache_read_usd_per_mtok"
14) "0.200000"
15) "cache_write_5m_usd_per_mtok"
16) "2.500000"
17) "cache_write_1h_usd_per_mtok"
18) "4.000000"
127.0.0.1:6379> LLMSTATS.PRICE SET my-finetuned-model INPUT 0.80 OUTPUT 2.40
OK
127.0.0.1:6379> LLMSTATS.PRICE GET my-finetuned-model
 1) "model"
 2) "my-finetuned-model"
 3) "source"
 4) "custom"
 5) "priced"
 6) (integer) 1
 7) "retired"
 8) (integer) 0
 9) "input_usd_per_mtok"
10) "0.800000"
11) "output_usd_per_mtok"
12) "2.400000"
13) "cache_read_usd_per_mtok"
14) "0.080000"
15) "cache_write_5m_usd_per_mtok"
16) "1.000000"
17) "cache_write_1h_usd_per_mtok"
18) "1.600000"
127.0.0.1:6379> LLMSTATS.PRICE DEL my-finetuned-model
(integer) 1
127.0.0.1:6379> LLMSTATS.PRICE DEL my-finetuned-model
(integer) 0
```

## Compatibility

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

## See also

[LLMSTATS.BUCKET](https://docs.hotkv.com/commands/llmstats-bucket/index.md), [LLMSTATS.RECORD](https://docs.hotkv.com/commands/llmstats-record/index.md), [LLMSTATS.GET](https://docs.hotkv.com/commands/llmstats-get/index.md), [LLMSTATS.RESET](https://docs.hotkv.com/commands/llmstats-reset/index.md), [LLMSTATS.DROP](https://docs.hotkv.com/commands/llmstats-drop/index.md), [LLMSTATS.LIST](https://docs.hotkv.com/commands/llmstats-list/index.md), [LLMBUDGET.CONSUME](https://docs.hotkv.com/commands/llmbudget-consume/index.md), [PCACHE.STATS](https://docs.hotkv.com/commands/pcache-stats/index.md), [AI features guide](https://docs.hotkv.com/ai-features/index.md)