pricing

package
v0.16.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func MultiplierToUSDPerMillion(multiplier float64) float64

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL