pricing

package
v0.16.521 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pricing is the API price of tokens, per model, for Claude and OpenAI models: what a conversation would have cost at list prices. The tables and the way a model id finds its row are the previous runtime's, so a cost computed here is the number it showed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Anthropic added in v0.15.46

func Anthropic(model string) bool

Anthropic says whether a model id is one of Anthropic's: Claude Code's own ids and aliases, and the synthetic model of its notices. Another vendor's model (Kimi, GLM, Grok) that runs through Claude Code is not, and has no price here.

func ClaudeCost

func ClaudeCost(model string, input, output, cacheWrite5m, cacheWrite1h, cacheRead float64) (float64, bool)

ClaudeCost is the list price of a Claude model's tokens; false for a model the table does not know.

func ClaudeCostByFullID

func ClaudeCostByFullID(model string, input, output, cacheWrite5m, cacheWrite1h, cacheRead float64) float64

ClaudeCostByFullID is ClaudeCost, with a model the table does not know priced by the family its id mentions (Sonnet when none). A model that is not Anthropic's has no price: 0, never a Claude family's price.

func ClaudeKey

func ClaudeKey(model string) string

ClaudeKey is the price table key of a Claude model id ("opus-4-6"), "" when the id names none. Keys are remembered: a transcript names a handful of models a thousand times.

func OpenAICost

func OpenAICost(model string, input, cachedInput, output float64) (float64, bool)

OpenAICost is the list price of an OpenAI model's tokens, input counting the cached part too; false for a model the table does not know (or none).

func OpenAICostInWindow

func OpenAICostInWindow(model string, input, cachedInput, output, contextWindow float64) (float64, bool)

OpenAICostInWindow is OpenAICost for a session whose context window is known: a window past 200k tokens is billed at the model's long-context prices where it has them.

func OpenAIKey added in v0.16.86

func OpenAIKey(model string) (string, bool)

OpenAIKey is the table key an OpenAI model id finds, the way OpenAICost finds its row: its own key after the prefix, date and snapshot are cut, else the longest key it starts with; false for none.

func RegisterOpenAI added in v0.16.154

func RegisterOpenAI(model string, input, cachedInput, output float64)

RegisterOpenAI adds the price of a model that is not in the table (dollars per million tokens), for a model profile of the profiles file; the model id is matched whole, ahead of the table. A price of a model already registered is replaced.

Types

type Row added in v0.16.86

type Row struct {
	Provider                                             string
	Key                                                  string
	Input, Output, CacheWrite5m, CacheWrite1h, CacheRead float64
}

Row is one model's list price, USD per million tokens, for a price list kept elsewhere (the hub's prices table). Provider is "anthropic" or "openai"; Key is what ClaudeKey or OpenAIKey makes of a model id.

func Rows added in v0.16.86

func Rows() []Row

Rows is the whole table, sorted by provider and key. An OpenAI model without its own cached price has its cached input at the input price, as OpenAICost counts it; OpenAI has no cache writes.

Jump to

Keyboard shortcuts

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