review: update default model prices to current Anthropic list pricing

Per operator request on the PR: the built-in/default prices were the old
Claude 3 numbers (opus 15/75, etc.). Update opus + haiku to the current
Claude 4.x family list pricing (cache_write = the default 5-minute cache
TTL); sonnet was already correct:

- opus:   input 5, output 25, cache_read 0.5,  cache_write 6.25
- sonnet: input 3, output 15, cache_read 0.3,  cache_write 3.75  (unchanged)
- haiku:  input 1, output 5,  cache_read 0.1,  cache_write 1.25

Updated in both builtin_prices (hive_stats.rs) and the nix modelPrices
default (hive-c0re.nix), with cross-reference "keep in sync" notes on
both sides. Also addresses the earlier reviewer note: dropped the
over-strong "single source of truth" wording in the --model-prices arg
doc (the nix default does mirror the numbers in production).
This commit is contained in:
iris 2026-06-08 19:34:56 +02:00
commit a9560ebb51
3 changed files with 30 additions and 21 deletions

View file

@ -98,23 +98,27 @@ pub struct Prices {
/// every model uses [`builtin_prices`]. /// every model uses [`builtin_prices`].
pub type PriceTable = HashMap<String, Prices>; pub type PriceTable = HashMap<String, Prices>;
/// Built-in fallback pricing — the historical hard-coded table. Used /// Built-in fallback pricing, per **million** tokens. Used when the
/// when the operator's [`PriceTable`] has no key matching the model. /// operator's [`PriceTable`] has no key matching the model. Figures are
/// current Anthropic list prices for the Claude 4.x family (Opus 4.x,
/// Sonnet 4.x, Haiku 4.5); `cache_write` uses the default 5-minute
/// cache-TTL price. Keep in sync with the `services.hyperhive.modelPrices`
/// nix default (`nix/modules/hive-c0re.nix`).
fn builtin_prices(model: &str) -> Prices { fn builtin_prices(model: &str) -> Prices {
let m = model.to_ascii_lowercase(); let m = model.to_ascii_lowercase();
if m.contains("opus") { if m.contains("opus") {
Prices { Prices {
input: 15.0, input: 5.0,
output: 75.0, output: 25.0,
cache_read: 1.5, cache_read: 0.5,
cache_write: 18.75, cache_write: 6.25,
} }
} else if m.contains("haiku") { } else if m.contains("haiku") {
Prices { Prices {
input: 0.8, input: 1.0,
output: 4.0, output: 5.0,
cache_read: 0.08, cache_read: 0.1,
cache_write: 1.0, cache_write: 1.25,
} }
} else { } else {
// sonnet + unknown fallback // sonnet + unknown fallback

View file

@ -89,9 +89,10 @@ enum Cmd {
/// model id; models not covered fall back to the built-in /// model id; models not covered fall back to the built-in
/// estimate. Set via the `services.hyperhive.modelPrices` NixOS /// estimate. Set via the `services.hyperhive.modelPrices` NixOS
/// option (whose default carries the full opus/sonnet/haiku /// option (whose default carries the full opus/sonnet/haiku
/// table). Defaults to `{}` here so a bare `hive-c0re serve` /// table — kept in sync with the in-code `builtin_prices`).
/// leans entirely on the in-code `builtin_prices` fallback — /// Defaults to `{}` here so a bare `hive-c0re serve` leans
/// keeping a single source of truth for the numbers. /// entirely on `builtin_prices`; the NixOS default (every real
/// deployment) shadows it with the same operator-tunable table.
#[arg(long, default_value = "{}")] #[arg(long, default_value = "{}")]
model_prices: String, model_prices: String,
}, },

View file

@ -446,12 +446,16 @@ in
}; };
} }
); );
# Current Anthropic list prices for the Claude 4.x family (Opus
# 4.x, Sonnet 4.x, Haiku 4.5); cache_write is the default 5-minute
# cache-TTL price. Keep in sync with `builtin_prices` in
# hive-c0re/src/hive_stats.rs.
default = { default = {
opus = { opus = {
input = 15.0; input = 5.0;
output = 75.0; output = 25.0;
cache_read = 1.5; cache_read = 0.5;
cache_write = 18.75; cache_write = 6.25;
}; };
sonnet = { sonnet = {
input = 3.0; input = 3.0;
@ -460,10 +464,10 @@ in
cache_write = 3.75; cache_write = 3.75;
}; };
haiku = { haiku = {
input = 0.8; input = 1.0;
output = 4.0; output = 5.0;
cache_read = 0.08; cache_read = 0.1;
cache_write = 1.0; cache_write = 1.25;
}; };
}; };
example = { example = {