Help us shape the future of Go! Take the 2026 Go Developer Survey

pricing

package
v0.8.12 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package pricing converts normalized token counts into a per-model USD cost. It is the SOLE constructor of a derived agent cost: Total is always Input+Output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Stale

func Stale(t Table, asOf time.Time, maxAge time.Duration) []string

Stale returns a sorted list of model IDs whose UpdatedOn is empty, unparseable, or older than maxAge relative to asOf.

Types

type Breakdown

type Breakdown struct{ Input, Output, CacheRead, CacheWrite int }

Breakdown is NORMALIZED token counts: Input EXCLUDES cached.

type Cost

type Cost struct {
	Currency             string
	Input, Output, Total float64
}

type Rates

type Rates struct {
	Currency       string  `json:"currency"`
	InputPerM      float64 `json:"input_per_m"`
	OutputPerM     float64 `json:"output_per_m"`
	CacheReadPerM  float64 `json:"cache_read_per_m"`
	CacheWritePerM float64 `json:"cache_write_per_m"`
	UpdatedOn      string  `json:"updated_on,omitempty"`
	Source         string  `json:"source,omitempty"`
}

type Table

type Table map[string]Rates

func Default

func Default() Table

Default returns embedded rates ⊕ $AWF_PRICING_FILE (whole-entry replace), loaded once.

func (Table) Derive

func (t Table) Derive(model string, b Breakdown) (Cost, bool)

Derive prices a normalized Breakdown. ok=false on an unknown model. Total is set here as Input+Output, exactly once.

Jump to

Keyboard shortcuts

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