Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
catalogs learn the model, so spend from Grok 4.6 sessions shows
dollars instead of the unpriced ⚠ — including Cursor sessions, whose
usage export brands the model `cursor-grok-4.6-xhigh`.
- **DeepSeek V4 spend prices from day one** — AihubMix's rate cards for
`deepseek-v4-pro` ($0.464 in / $0.928 out / $0.004 cache read per
MTok) and `deepseek-v4-flash` ($0.154 / $0.308 / $0.003) are baked in
until public catalogs learn the family, dated snapshots like
`-0813` included, so Hermes sessions on these models show dollars
instead of the unpriced ⚠.

## 0.4.33 — 2026-08-12

Expand Down
47 changes: 46 additions & 1 deletion src-tauri/src/pricing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub fn generation() -> u64 {
/// fingerprinted below — an app update that reprices the same files would
/// otherwise leave history at the old dollars until upstream happens to
/// rewrite a catalog.
const CORRECTIONS_REV: u32 = 4; // 4: grok-4.6 builtin launch pricing
const CORRECTIONS_REV: u32 = 5; // 5: deepseek-v4 pro/flash builtin prices

/// Stable fingerprint of the effective pricing inputs: the on-disk catalog
/// files plus this binary's corrections revision. The persistent spend
Expand Down Expand Up @@ -669,8 +669,30 @@ fn builtin_price(canonical: &str) -> Option<Price> {
.strip_prefix("moonshot/")
.or_else(|| canonical.strip_prefix("moonshot-ai/"))
.or_else(|| canonical.strip_prefix("xai/"))
.or_else(|| canonical.strip_prefix("deepseek/"))
.unwrap_or(canonical);
// DeepSeek ships dated snapshots ("deepseek-v4-pro-0813"); price them as
// the base model so a new date doesn't silently go unpriced. Scoped to
// deepseek- slugs whose trailing dash-segment is all digits (≥4), so
// "deepseek-v4" or version-bearing names elsewhere never lose a tail.
let bare = match bare.strip_suffix(|c: char| c.is_ascii_digit()) {
Some(_) if bare.starts_with("deepseek-") => bare.rsplit_once('-').map_or(bare, |(h, t)| {
if t.chars().all(|c| c.is_ascii_digit()) && t.len() >= 4 { h } else { bare }
}),
_ => bare,
};

@devin-ai-integration devin-ai-integration Bot Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Trim placement relative to the 0/0 reconsideration and suffix peel is consistent

I walked the resolution order for dated slugs: the retry sits after every real-rate source and after builtin_price, but before the 0/0 reconsideration and the effort/mode suffix peel. That means (a) a catalog that learns the base slug with real rates outranks the baked table for dated spellings (as the new test asserts), and (b) a dated slug carrying a 0/0 placeholder in a catalog still resolves to the base's real rates rather than $0.00. Composed names like deepseek-v4-pro-0813-high still work because the suffix peel recurses and the trim runs on the peeled name. Recursion is bounded by the existing depth cap of 4, and each trim strictly shortens the slug, so no unbounded recursion is possible.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

match bare {
// AihubMix DeepSeek V4 family — the gateway's OWN rate cards
// (aihubmix.com/model/deepseek-v4-pro-0813 and /deepseek-v4-flash
// headline pricing, NOT the cheaper Baidu/Tencent provider rows on
// the same pages): pro $0.464/$0.928 with $0.004 cache read (yes,
// ~1/116 of input — the page really says $0.004), flash
// $0.154/$0.308 with $0.003 cache read. No cache-write rate is
// published, so writes bill at the input rate. Hermes logs these
// bare ("deepseek-v4-flash", "deepseek-v4-pro-0813" — verified
// against a real state.db); public catalogs don't carry them yet.
"deepseek-v4-pro" => Some(Price::flat(0.464, 0.928, 0.004, 0.464)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Pro cache-read rate is ~1/116 of input — worth an external re-verification

deepseek-v4-pro is baked at $0.004/MTok cache read against $0.464 input, an unusually large ratio (typical vendor cache reads are 1/4–1/10 of input). The PR explains this was verified against AihubMix's page and Devin previously flagged it, and the code/test comments pin it. Nothing in the repo can confirm the vendor number; if it is actually $0.04 or $0.046, cached-heavy DeepSeek V4 pro sessions would under-report spend by roughly 10x on the cache-read component until a catalog learns the slug. Worth one more look at the source page before merge.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

"deepseek-v4-flash" => Some(Price::flat(0.154, 0.308, 0.003, 0.154)),
"kimi-k3" | "kimi-k3-code" => Some(Price::flat(3.0, 15.0, 0.3, 3.0)),
// Alibaba Model Studio, GA'd 2026-08-03 (USD/MTok): input $2,
// output $6, implicit cache read $0.25, explicit cache write $2.50.
Expand Down Expand Up @@ -789,6 +811,29 @@ mod tests {
assert_eq!((terra.input, terra.output), (1.75, 11.0));
}

#[test]
fn deepseek_v4_builtins_price_including_dated_snapshots() {
let store = super::Store::default();
// Real Hermes slugs: bare flash, dated pro snapshot, and the
// deepseek/-prefixed catalog spelling.
for slug in ["deepseek-v4-pro", "deepseek-v4-pro-0813", "deepseek/deepseek-v4-pro-0813"] {
let p = super::resolve(&store, slug, 0).unwrap_or_else(|| panic!("{slug} unpriced"));
assert!((p.input - 0.464).abs() < 1e-9, "{slug}");
assert!((p.output - 0.928).abs() < 1e-9, "{slug}");
// AihubMix really does list $0.004/M cache read for pro —
// ~1/116 of input is the vendor's number, not a typo.
assert!((p.cache_read - 0.004).abs() < 1e-9, "{slug}");
}
for slug in ["deepseek-v4-flash", "deepseek-v4-flash-0731"] {
let p = super::resolve(&store, slug, 0).unwrap_or_else(|| panic!("{slug} unpriced"));
assert!((p.input - 0.154).abs() < 1e-9, "{slug}");
assert!((p.cache_read - 0.003).abs() < 1e-9, "{slug}");
}
// The trimmer never eats non-date tails or other families.
assert!(super::resolve(&store, "deepseek-v4", 0).is_none());
assert!(super::resolve(&store, "deepseek-v3.2", 0).is_none());
}

#[test]
fn grok_46_builtin_prices_with_long_context_tier() {
// Vendor rates (docs.x.ai/docs/pricing): $2/$0.50/$6, doubling for
Expand Down