Expand description
What a model call costs, so a cost budget can be charged.
Runtime 0.1 §8 says a backend that can
price a request should enforce budget.cost, and one that cannot must not
pretend to. This module is the first half; the interpreter is the second.
§Why the operator supplies the prices
A price table is provider- and time-dependent, so it cannot live in an artifact: an artifact carrying one would be stale the moment it was published, and a reproducible artifact whose meaning changed with the vendor’s price list would not be reproducible at all. It cannot live in this binary either, for the same reason with a slower clock.
So it lives where the API keys and the tool servers already live: in the project manifest, which is deployment configuration the operator owns and updates. A run with no prices configured charges nothing and says so.
§Why integers
Money is decimal and binary floats are not, which is why
ingot_ir::Cost stores an amount as a decimal string with six fractional
digits. Accumulation here uses the same unit as an integer — millionths of
one currency unit — so a total is exact and identical on every platform.
Nothing in a cost calculation touches an f64.
Structs§
- Model
Price - What one model costs, as the operator wrote it in the manifest.
- Pricing
- Every price a run was given.
- Spend
- What a run spent, and what it could not price.
Enums§
- Charge
- What a priced call cost, or why it could not be priced.
Constants§
- MICROS
- Millionths per whole unit.
- TOKENS_
PER_ QUOTE - Prices are quoted per this many tokens, which is how every vendor quotes them.
Functions§
- parse_
micros - A decimal string as millionths, or
Nonewhen it is not one. - render_
micros - Millionths as the decimal string the IR uses.
Type Aliases§
- Micros
- One millionth of a currency unit, which is the precision
ingot_ir::format_amountalready renders.