pricing

package
v0.27.6 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: CC0-1.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CostUSD

func CostUSD(model string, usage session.TokenUsage, at time.Time) (float64, bool)

CostUSD estimates one session's usage cost. cached_tokens is treated as cache-read input when the provider does not expose the read/create split.

func NormalizeModel

func NormalizeModel(model string) string

NormalizeModel strips provider prefixes, vendor-tag suffixes, and dated snapshot suffixes so a family stays priced after the snapshot date rotates.

Types

type Rates

type Rates struct {
	Input         float64
	Output        float64
	CacheRead     float64
	CacheCreation float64
}

Rates are USD-per-token prices. The table is intentionally embedded and conservative; unknown models return priced=false instead of guessing.

func Lookup

func Lookup(model string, at time.Time) (Rates, bool)

Lookup resolves rates for a raw model string. Falls back to a longest-prefix match so versioned variants (e.g. claude-opus-4-7) don't collapse onto a shorter key (claude-opus-4) with a different price tier.

Jump to

Keyboard shortcuts

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