Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendUsage ¶ added in v0.14.0
AppendUsage adds u as one JSON line to path (created 0600, folders 0700). A zero At becomes now. A nil CostUSD is filled from the pricing table, or, for a model the table does not price, left out with CostUnknown set: an unknown cost is never recorded as 0.
func Calculate ¶
func Calculate(model string, inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens int64) float64
Calculate returns the estimated cost in USD for the given token usage. Returns 0 if the model is unknown.
func DefaultUsagePath ¶ added in v0.14.0
func DefaultUsagePath() string
DefaultUsagePath is where aimux's own model usage is recorded.
Types ¶
type ModelPricing ¶
ModelPricing holds per-million-token pricing in USD.
type Usage ¶ added in v0.14.0
type Usage struct {
At time.Time `json:"at"`
Label string `json:"label"`
Model string `json:"model"`
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
CostUSD *float64 `json:"cost_usd,omitempty"` // nil when the price is unknown
CostUnknown bool `json:"cost_unknown,omitempty"` // the model is not in the pricing table: only tokens are known
Estimated bool `json:"estimated,omitempty"` // token counts guessed from text length
}
Usage is one model call aimux itself made (not an agent session's), kept so its cost is visible. Label names the feature, e.g. "naming".
Click to show internal directories.
Click to hide internal directories.