Documentation
¶
Overview ¶
Package accounting contains pure usage and cost accounting helpers.
Package accounting Usage accounting price catalog and cost estimation.
Index ¶
Constants ¶
View Source
const ( CostSourceProviderReported = "provider_reported" CostSourceEstimated = "estimated" )
Variables ¶
This section is empty.
Functions ¶
func SubMoneyChecked ¶
SubMoneyChecked subtracts non-negative money (nano) amounts without underflow. Also used for non-negative token residuals in DeriveTokenBreakdown.
Types ¶
type CostInput ¶
type CostInput struct {
Backend string
Model string
Usage TokenUsage
ProviderCost ProviderCost
}
type CostResult ¶
func EstimateCost ¶
func EstimateCost(in CostInput, catalog PriceCatalog) CostResult
type ModelPrice ¶
type ModelPrice struct {
InputPer1M int64
CachedInputPer1M OptionalNanoRate
CacheWriteInputPer1M OptionalNanoRate
OutputPer1M int64
ReasoningOutputPer1M OptionalNanoRate
}
type ModelPriceConfig ¶
type OptionalNanoRate ¶
OptionalNanoRate is a catalog rate that may be unspecified (absent) or explicitly present, including an authoritative zero. It aliases the public economics NanoRate contract so OSS catalog and injected raters share one shape.
type PriceCatalog ¶
type PriceCatalog struct {
// contains filtered or unexported fields
}
func NewPriceCatalog ¶
func NewPriceCatalog(cfg PriceCatalogConfig) (PriceCatalog, error)
type PriceCatalogConfig ¶
type PriceCatalogConfig struct {
Version string
Currency string
Models []ModelPriceConfig
}
type ProviderCost ¶
ProviderCost is an optional authoritative provider-reported cost. Present distinguishes authoritative zero from an absent cost.
type TokenBreakdown ¶
type TokenBreakdown struct {
TokenUsage
NonCachedInputTokens int64
NonReasoningOutputTokens int64
}
func DeriveTokenBreakdown ¶
func DeriveTokenBreakdown(usage TokenUsage) TokenBreakdown
Click to show internal directories.
Click to hide internal directories.