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 ¶
- func Anthropic(model string) bool
- func ClaudeCost(model string, input, output, cacheWrite5m, cacheWrite1h, cacheRead float64) (float64, bool)
- func ClaudeCostByFullID(model string, input, output, cacheWrite5m, cacheWrite1h, cacheRead float64) float64
- func ClaudeKey(model string) string
- func OpenAICost(model string, input, cachedInput, output float64) (float64, bool)
- func OpenAICostInWindow(model string, input, cachedInput, output, contextWindow float64) (float64, bool)
- func OpenAIKey(model string) (string, bool)
- func RegisterOpenAI(model string, input, cachedInput, output float64)
- type Row
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Anthropic ¶ added in v0.15.46
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 ¶
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 ¶
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
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
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.