Skip to content

Publish the rate card as a feed, and diff it against DeepSeek daily - #4

Merged
lroolle merged 1 commit into
mainfrom
feat/pricing-feed
Aug 20, 2026
Merged

Publish the rate card as a feed, and diff it against DeepSeek daily#4
lroolle merged 1 commit into
mainfrom
feat/pricing-feed

Conversation

@lroolle

@lroolle lroolle commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

lib/core.js was already the single source of the plugin, the bundle and the site. Two things were still missing: nobody outside this repo could read the card, and its "verbatim from the published table" claim was re-established by a human remembering to look.

docs/pricing.json

Served at https://dsh.works/dsh-meter/pricing.json (Pages = main + /docs, and the host already answers access-control-allow-origin: *).

Both currencies, both live tariffs, the 24-hour UTC schedule, the retired flat card with the date it stopped applying, and the definition of each billed bucket — which is the half of a cost estimate a price list cannot give you. Generated from lib/core.js by scripts/build-pricing.mjs, checked by pnpm test. It is a pure function of the card (no timestamp, no fetch), so the file changes exactly when the price does.

JS consumers can skip the fetch entirely: import { costOf, tariffAt } from '@dshworks/dsh-meter/core'core.js imports nothing.

Why publish it at all

Because no external source is right. Checked 2026-08-20, four days after the switchover:

Source v4-pro cache-miss input Verdict
models.dev $0.435 the retired flat card, last_updated: 2026-08-12
LiteLLM $0.435 the same retired card
OpenRouter /api/v1/models $1.60 accurate, different question — what OpenRouter charges to resell
this feed $0.66 off-peak / $1.32 peak matches both published tables

Both aggregators understate a v4-pro bill by 1.5x off-peak, 3x at peak, and 12x on cached input at peak. Neither can fix it by refreshing: both schemas hold one flat price per model per bucket, with nowhere to put a tariff. A rate that doubles for seven hours of every UTC day cannot be represented in either.

Keeping it honest

scripts/verify-pricing.mjs scrapes DeepSeek's own two pricing pages — English and Chinese — and diffs every rate, the peak windows, and the model list (a model priced upstream and missing here would meter at zero). A page it can no longer parse exits non-zero too: the alarm should fire when the source changes shape, not only when a number moves.

.github/workflows/pricing-watch.yml runs it daily and opens or comments on a pricing-drift issue. Deliberately outside pnpm test: a unit suite must not fail because a documentation site is slow, and a price alarm must not stay silent because nobody opened a PR this week. The last price change arrived with no announcement in any channel we watch.

Verification

  • The card matches both published tables as of 2026-08-20 (npm run verify:pricing, exit 0).
  • The verifier catches an injected 0.66 → 0.60 rate and a widened peak window (exit 1, both named in the report).
  • 56 tests green, including 6 new ones pinning the feed's published shape and the rule that a retired price never appears as a live one.
  • Site re-rendered and checked in a browser: the rates fine print and the footer link.

Not in this PR

No version bump — the CHANGELOG entry sits under Unreleased. This merge makes the feed live on the site; the npm release is a separate step.

…aily

The card in lib/core.js was already the single source of the plugin, the
bundle and the site. Two things were still missing: nobody outside this
repo could read it, and its "verbatim from the published table" claim was
re-established by a human remembering to look.

docs/pricing.json is the card as machine-readable JSON, served at
dsh.works/dsh-meter/pricing.json — both currencies, both live tariffs,
the 24-hour UTC schedule, the retired flat card with the date it stopped
applying, and the definition of each billed bucket, which is the half of
a cost estimate a price list cannot give you. Generated from core.js and
checked by `pnpm test`; a pure function of the card, so the file changes
exactly when the price does.

It exists because no external source is right. Checked 2026-08-20, four
days after the switchover, models.dev and LiteLLM both still published
DeepSeek's retired flat card as current — understating a v4-pro bill by
1.5x off-peak, 3x at peak, 12x on cached input at peak. Neither can fix
it by refreshing: both schemas hold one flat price per model per bucket,
with nowhere to put a tariff.

scripts/verify-pricing.mjs scrapes DeepSeek's own two pricing pages and
diffs every rate, the peak windows and the model list against the card. A
page it can no longer parse fails too — the alarm should fire when the
source changes shape, not only when a number moves. A daily workflow runs
it and opens a pricing-drift issue. Deliberately outside `pnpm test`: a
unit suite must not fail because a docs site is slow, and a price alarm
must not stay silent because nobody opened a PR this week.

Verified: the card matches both published tables today, and the verifier
catches an injected 0.66 -> 0.60 and a widened peak window.
@lroolle
lroolle merged commit 4eb8a69 into main Aug 20, 2026
1 check passed
@lroolle
lroolle deleted the feat/pricing-feed branch August 20, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant