Documentation
¶
Overview ¶
Package pricing provides pure, database-free functions for normalizing upstream pricing signals into a canonical product model and converting pricing multipliers (ratios) into USD per million tokens. It is shared by the admin price-comparison surface so every consumer applies the same math and never invents an unlabeled price.
Index ¶
Constants ¶
const BaseUSDPerMillionInput = 2.0
BaseUSDPerMillionInput is the base USD per 1M input tokens at model ratio 1.0. It matches routing.CacheAwarePerMillionRates (input = modelRatio x 2 x groupMultiplier) so the canonical layer and the routing layer agree on the same effective rate.
Variables ¶
This section is empty.
Functions ¶
func MultiplierToUSDPerMillion ¶
MultiplierToUSDPerMillion converts a pricing multiplier into USD per 1M input tokens. Non-positive, NaN, or Inf multipliers yield 0 (no invented price).
Types ¶
type NormalizeInput ¶
type NormalizeInput struct {
ModelName string
InputPerMillion *float64 // explicit $/M input (already normalized)
OutputPerMillion *float64 // explicit $/M output
ModelRatio *float64
CompletionRatio *float64
GroupMultiplier *float64
}
NormalizeInput carries the raw pricing signals for one model. Pointer fields distinguish "missing" from an explicit zero.
type ProductCanonicalModel ¶
type ProductCanonicalModel struct {
ModelName string `json:"modelName"`
InputPerMillion float64 `json:"inputPerMillion"`
OutputPerMillion float64 `json:"outputPerMillion"`
}
ProductCanonicalModel is a normalized cross-site product model with effective USD-per-million input/output rates. It is the reusable shape consumed by price comparison rather than a wire type.
func NormalizeToProductCanonical ¶
func NormalizeToProductCanonical(in NormalizeInput) ProductCanonicalModel
NormalizeToProductCanonical resolves raw pricing signals into canonical USD-per-million rates. Explicit per-million values win when both sides are present; otherwise ratios are converted via MultiplierToUSDPerMillion.