Skip to main content

Module cost

Module cost 

Source
Expand description

What a reasoner charges — the input to every cost claim the system makes.

§Why this is data and not a provider method

The headline claim is that a flow’s price can be bounded before it runs (ARCHITECTURE.md §10). That is only possible if per-token pricing and the context ceiling are knowable at build time, which means they cannot be something you learn by calling a model. So a CostModel is a value the compiler reads, and the provider that will eventually charge it is required to declare one (US-0601).

It lives here rather than beside the providers for the same reason Budget does: the compiler needs to reason about price long before there is a provider to ask, and a type in boundgraph-core is one both ends can see without either depending on the other.

§Why pricing is loaded, not compiled in

Model prices change on the vendor’s schedule, not on ours. A constant in a binary means every price change is a release; a Pricing catalogue read from a file means it is a config edit. The catalogue is also what makes staleness checkable — every entry carries the date it was correct on (AsOf), so “this flow was priced against nine-month-old numbers” is a question the compiler can answer instead of a thing nobody notices.

§Cached reads are a different price, not a discount

Prompt caching does not make input tokens cheaper — it makes some of them a different line item. A cached read is roughly a tenth of the uncached rate and a cache write is more than the uncached rate, so a model that collapsed them into one number would misprice both directions. Hence four rates rather than two.

Structs§

AsOf
The date a price was correct on.
CostModel
What one reasoner charges, and how much it can be given.
Pricing
Every model’s pricing, keyed by model id.
TokenUsage
What a call actually consumed, split by how each token was billed.

Enums§

AsOfParseError
A pricing date could not be read.
PricingError
A pricing catalogue could not be read.