Documentation
¶
Overview ¶
Package pricing maps Claude model IDs to per-million-token USD rates and computes cost for a given token mix.
Rates are based on Anthropic's published pricing page. The table is deliberately small and easy to update: when Anthropic changes prices, edit baseRates, update docs/decisions.md with the date and reason, and adjust the arithmetic tests to match.
Cache semantics follow Anthropic's published multipliers applied to the model's input rate:
cache read = 0.1 × input rate cache write 5m = 1.25 × input rate cache write 1h = 2.0 × input rate
The multipliers are centralized in one place (below) so a future Anthropic change only needs a single edit.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownModel = errors.New("unknown model")
ErrUnknownModel is returned when RatesFor sees a model identifier not in the pricing table. Callers should log and skip the event rather than halting the watcher.
Functions ¶
func Cost ¶
Cost computes the total USD cost for a given (Rates, Usage) pair. Zero-cost calls are valid and return 0 without error.
func CostForModel ¶
CostForModel is the convenience one-shot: look up the model, then price the usage. Returns ErrUnknownModel if the model is unknown.
func KnownModels ¶
func KnownModels() []string
KnownModels returns a sorted list of model IDs in the pricing table. Useful for `budgetclaw pricing list` and for fuzzing tests.