pricing

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package pricing prices token usage deterministically. It is the basis of the dollar budget the governor enforces and the cost ledger records. Prices are static, defensible list prices (USD per 1M tokens) and are overridable via config — RiskKernel never asks an LLM what something costs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rate

type Rate struct {
	InputPerM  float64
	OutputPerM float64
}

Rate is a model's price in USD per 1,000,000 tokens.

type Table

type Table struct {
	// contains filtered or unexported fields
}

Table prices models. The zero value is usable (built-in rates only); use NewTable to layer config overrides on top.

func NewTable

func NewTable(overrides map[string]Rate) *Table

NewTable returns a Table seeded with the built-in rates, with overrides applied on top (override keys are matched by the same prefix rule).

func (*Table) Cost

func (t *Table) Cost(model string, promptTokens, completionTokens int64) (usd float64, ok bool)

Cost returns the USD cost of the given token counts for a model, and whether the model was priced. When ok is false the cost is 0 — the caller decides whether to treat an unpriced model as a dollar-budget enforcement gap.

func (*Table) Rate

func (t *Table) Rate(model string) (Rate, bool)

Rate returns the rate for a model and whether it was found. Matching is by longest case-insensitive prefix so dated snapshots resolve to their family.

Jump to

Keyboard shortcuts

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