cost

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package cost estimates per-model pricing for prompt tokens.

Prices are per 1M input tokens, in USD, approximate list prices as of this project's v1. The map is used for README-style "cost impact per 100k runs" projections; it is not a substitute for live billing data.

Index

Constants

View Source
const PricesAsOf = "2026-08-13"

PricesAsOf is the date the built-in price table was last updated. Bump it whenever prices map changes so `prompt-diff models --check` can warn when it goes stale.

Variables

This section is empty.

Functions

func EstimateBulk

func EstimateBulk(model string, count, invocations int64) float64

EstimateBulk computes the cost to run each model's tokens n times.

func IsKnown added in v1.4.0

func IsKnown(model string) bool

IsKnown reports whether model has an exact or override entry in the price table (as opposed to falling back to a prefix or family-default guess).

func Lookup

func Lookup(model string) float64

Lookup returns the USD per-1M-token price for a model. Unlisted models fall back to a neutral default so projections never crash.

func SetOverride added in v1.3.0

func SetOverride(model string, per1M float64)

SetOverride pins model's price, overriding the built-in list.

Types

type Estimated

type Estimated struct {
	Model  string  `json:"model"`
	Tokens int     `json:"tokens"`
	Per1M  float64 `json:"price_per_1m"`
	Cost   float64 `json:"cost_usd"`
}

Estimated is a per-model cost estimate for a given token count.

func Estimate

func Estimate(model string, count int) Estimated

Estimate computes the cost to run count tokens once, per model.

type Price

type Price struct {
	Per1M float64
}

Price is the USD cost per 1M input tokens.

Jump to

Keyboard shortcuts

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