Documentation
¶
Overview ¶
Package usage holds the cost-observability pricing table (design 003).
Cost is computed in micro-USD (µUSD). A convenient identity keeps the table readable: because 1 USD = 1e6 µUSD and prices are quoted per 1e6 tokens, the µUSD cost of one token equals the model's USD-per-1M-tokens price. So a price of $3 / 1M input tokens is exactly 3 µUSD per input token.
The table ships as an editable default. Prices drift; unknown models return (0, false) so the UI shows tokens only, flagged with a tilde, rather than inventing a dollar figure. Overrides are applied via SetOverrides.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CostMicroUSD ¶
CostMicroUSD computes the µUSD cost of a call. The bool is false when the model is unpriced (unknown), in which case cost is 0 and the caller should flag the figure rather than treat 0 as free.
func KnownModels ¶
func KnownModels() []string
KnownModels returns the sorted list of priced model prefixes (for docs/tests).
func SetOverrides ¶
SetOverrides installs config-supplied pricing entries (keyed by lowercased model prefix). They take precedence over the default table. Passing nil clears overrides.
Types ¶
type Price ¶
type Price struct {
In float64 // uncached input
Out float64 // generated output
CacheRead float64 // input served from prompt cache
CacheWrite float64 // input written to prompt cache
}
Price is the per-1M-token price (USD) for each token class, which is also the per-token cost in µUSD (see package doc).