Documentation
¶
Overview ¶
Package usage provides model price tables and cost estimation for worker token usage.
Index ¶
Constants ¶
const DefaultLocalPath = ".config/djinn/prices.yaml"
DefaultLocalPath is the documented path where a user can place an override prices.yaml file.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ModelPrice ¶
type ModelPrice struct {
Input float64 `yaml:"input"`
Output float64 `yaml:"output"`
CacheRead float64 `yaml:"cache_read"`
CacheWrite float64 `yaml:"cache_write"`
Thinking float64 `yaml:"thinking"`
Source string `yaml:"source"`
Date string `yaml:"date"`
}
ModelPrice contains token pricing per million tokens in USD and its public citation.
type PriceTable ¶
type PriceTable struct {
Date string `yaml:"date"`
Currency string `yaml:"currency"`
Models map[string]ModelPrice `yaml:"models"`
}
PriceTable is the set of known model prices at a given date.
func DefaultTable ¶
func DefaultTable() (*PriceTable, error)
DefaultTable returns the embedded default price table.
func LoadTable ¶
func LoadTable(overridePath ...string) (*PriceTable, error)
LoadTable loads the price table. If an override path is provided and non-empty, and the file exists, it is loaded; otherwise the embedded default table is returned. This provides a clear seam for future local overrides.
func (*PriceTable) Estimate ¶
func (t *PriceTable) Estimate(u *planv1.Usage, model string, provider planv1.Provider) (cost float64, hasPrice bool, err error)
Estimate computes the estimated cost in USD for the given usage and model. Returns cost, whether a price exists for the model, and any error.
func (*PriceTable) ResolveModel ¶
func (t *PriceTable) ResolveModel(model string, provider planv1.Provider) string
ResolveModel maps a requested or stream-reported model and provider to a canonical entry in the table.