pricing

package
v0.27.3 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: CC0-1.0 Imports: 5 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) (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) (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