Documentation
¶
Overview ¶
Package pricing embeds pricing.json and computes the USD cost of a message.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type History ¶
type History struct {
// contains filtered or unexported fields
}
History is the time-indexed set of pricing tables, sorted ascending by Version.
func HistoryForTest ¶
HistoryForTest builds a History from a caller-provided slice.
Test-only helper. Exported because Go does not let _test.go in one package be imported by tests in another. Do not call from production code — use Load() instead, which reads the embedded history/*.json.
func Load ¶
Load reads every embedded history/*.json file, validates each, and returns a History sorted by Version ascending. Duplicate versions are a build error.
func (History) CostFor ¶
CostFor resolves the applicable Table for m via fall-forward (see resolveTable) and returns cost, the stamped version string, and whether the model was missing from every snapshot at-or-after the date-resolved one. The stamped version is the snapshot whose rates produced the cost — the fall-forward source when the date-resolved snapshot predates the model.
func (History) TableAt ¶
TableAt resolves the historical Table that applies to ts. Picks the largest entry with Version <= ts.UTC() date string. Falls back to earliest entry if ts predates all entries.
func (History) VersionFor ¶ added in v0.4.0
VersionFor returns the pricing_version CostFor would stamp for a message with this timestamp and model, applying the same fall-forward resolution, without needing token counts. Used by staleness checks (PricingVersionStats).
type ModelRate ¶
type ModelRate struct {
InputPerMtok float64 `json:"input_per_mtok"`
OutputPerMtok float64 `json:"output_per_mtok"`
CacheReadPerMtok float64 `json:"cache_read_per_mtok"`
CacheWrite5mPerMtok float64 `json:"cache_write_5m_per_mtok"`
CacheWrite1hPerMtok float64 `json:"cache_write_1h_per_mtok"`
}
ModelRate holds the per-million-token billing rates for one model.