Versions in this module Expand all Collapse all v0 v0.40.0 Apr 19, 2026 Changes in this version + type Budget struct + MaxCostUSD float64 + MaxInputTokens int + MaxOutputTokens int + MaxTotalTokens int + func (b Budget) Exceeded(agg Record) bool + type Cost struct + CacheRead float64 + CacheWrite float64 + Input float64 + Output float64 + Reasoning float64 + Source string + Total float64 + func CalcCost(items TokenItems, p Pricing) Cost + func (c Cost) IsZero() bool + type CostCalculator interface + Calculate func(provider, model string, tokens TokenItems) (Cost, bool) + func Compose(calculators ...CostCalculator) CostCalculator + func Default() CostCalculator + type CostCalculatorFunc func(provider, model string, tokens TokenItems) (Cost, bool) + func (f CostCalculatorFunc) Calculate(p, m string, t TokenItems) (Cost, bool) + type Dims struct + Labels map[string]string + Model string + Provider string + RequestID string + SessionID string + TurnID string + type Drift struct + Actual Record + ActualInput int + Dims Dims + Estimate Record + EstimatedInput int + InputDelta int + InputPct float64 + func ComputeDrift(estimate, actual *Record) *Drift + type DriftStats struct + MaxPct float64 + MeanPct float64 + MinPct float64 + N int + P50Pct float64 + P95Pct float64 + type FilterFunc func(Record) bool + func ByLabel(key, value string) FilterFunc + func ByModel(model string) FilterFunc + func ByProvider(name string) FilterFunc + func BySessionID(id string) FilterFunc + func ByTurnID(id string) FilterFunc + func EstimatesOnly() FilterFunc + func ExcludeEstimates() FilterFunc + func Since(t time.Time) FilterFunc + type Pricing struct + CacheWrite float64 + CachedInput float64 + Input float64 + Output float64 + Reasoning float64 + type Record struct + Cost Cost + Dims Dims + Encoder string + Extras map[string]any + IsEstimate bool + RecordedAt time.Time + Source string + Tokens TokenItems + type TokenItem struct + Count int + Kind TokenKind + type TokenItems []TokenItem + func (t TokenItems) Count(kind TokenKind) int + func (t TokenItems) NonZero() TokenItems + func (t TokenItems) Total() int + func (t TokenItems) TotalInput() int + func (t TokenItems) TotalOutput() int + type TokenKind string + const KindCacheRead + const KindCacheWrite + const KindInput + const KindOutput + const KindReasoning + type Tracker struct + func NewTracker(opts ...TrackerOption) *Tracker + func (t *Tracker) Aggregate() Record + func (t *Tracker) Drift(requestID string) (*Drift, bool) + func (t *Tracker) DriftStats() DriftStats + func (t *Tracker) Drifts() []Drift + func (t *Tracker) Filter(fs ...FilterFunc) []Record + func (t *Tracker) Record(r Record) + func (t *Tracker) Records() []Record + func (t *Tracker) Reset() + func (t *Tracker) WithinBudget() bool + type TrackerOption func(*Tracker) + func WithBudget(b Budget) TrackerOption + func WithCostCalculator(c CostCalculator) TrackerOption + func WithSessionID(id string) TrackerOption