Documentation
¶
Overview ¶
Package costs provides token cost tracking and pricing for LLM models.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ModelPricing = map[string]ModelCost{
"gpt-4.1": {Input: 2.50, Output: 15.00},
"gpt-4.1-mini": {Input: 0.75, Output: 4.50},
"gpt-4.1-nano": {Input: 0.20, Output: 1.25},
"gpt-5.3-codex": {Input: 2.50, Output: 15.00},
"gpt-5.4": {Input: 2.50, Output: 15.00},
"gpt-5.4-mini": {Input: 0.75, Output: 4.50},
"gpt-5.4-nano": {Input: 0.20, Output: 1.25},
"gpt-5.4-pro": {Input: 15.00, Output: 60.00},
"o3": {Input: 2.50, Output: 15.00},
"o4-mini": {Input: 0.75, Output: 4.50},
"grok-build-0.1": {Input: 1.00, Output: 2.00},
"grok-4-1-fast": {Input: 0.20, Output: 0.50},
"grok-4-1-fast-reasoning": {Input: 0.20, Output: 0.50},
"grok-4-1-fast-non-reasoning": {Input: 0.20, Output: 0.50},
"grok-4.3": {Input: 1.25, Output: 2.50},
"grok-4.20-0309-reasoning": {Input: 1.25, Output: 2.50},
"grok-4.20-0309-non-reasoning": {Input: 1.25, Output: 2.50},
"grok-4.20-multi-agent-0309": {Input: 1.25, Output: 2.50},
"grok-code-fast-1": {Input: 0.20, Output: 0.50},
"gemini-2.0-flash": {Input: 0.10, Output: 0.40},
"claude-opus-4-6": {Input: 5.00, Output: 25.00},
"claude-sonnet-4-6": {Input: 3.00, Output: 15.00},
"claude-haiku-4-5": {Input: 1.00, Output: 5.00},
"venice-uncensored": {Input: 0.20, Output: 0.90},
"venice-uncensored-role-play": {Input: 0.50, Output: 2.00},
"deepseek-v3.2": {Input: 0.33, Output: 0.48},
"qwen3-coder-480b-a35b-instruct": {Input: 0.75, Output: 3.00},
"qwen3-coder-480b-a35b-instruct-turbo": {Input: 0.35, Output: 1.50},
"qwen3-235b-a22b-thinking-2507": {Input: 0.45, Output: 3.50},
"kimi-k2-5": {Input: 0.56, Output: 3.50},
"zai-org-glm-4.7": {Input: 0.55, Output: 2.65},
"mistral-small-3-2-24b-instruct": {Input: 0.09, Output: 0.25},
"llama-3.3-70b": {Input: 0.70, Output: 2.80},
"minimax-m25": {Input: 0.34, Output: 1.19},
}
ModelPricing maps model identifiers to their costs.
Functions ¶
Types ¶
type CostSummary ¶
type CostSummary struct {
Model string `json:"model"`
TotalInput int `json:"total_input_tokens"`
TotalOutput int `json:"total_output_tokens"`
TotalCostUSD float64 `json:"total_cost_usd"`
Turns int `json:"turns"`
}
CostSummary is a snapshot of cumulative session costs.
type ModelCost ¶
type ModelCost struct {
Input float64 // USD per 1M input tokens
Output float64 // USD per 1M output tokens
}
ModelCost holds the per-1M-token pricing for a model.
type SessionTracker ¶
type SessionTracker struct {
Model string `json:"model"`
TotalInput int `json:"total_input"`
TotalOutput int `json:"total_output"`
TotalCostUSD float64 `json:"total_cost_usd"`
Turns int `json:"turns"`
// contains filtered or unexported fields
}
SessionTracker accumulates token usage and cost across a session.
func NewSessionTracker ¶
func NewSessionTracker() *SessionTracker
NewSessionTracker creates a new empty tracker.
func (*SessionTracker) GetSummary ¶
func (t *SessionTracker) GetSummary() CostSummary
GetSummary returns a snapshot of the current session cost state.
func (*SessionTracker) Load ¶
func (t *SessionTracker) Load(path string) error
Load deserialises tracker state from a JSON file.
func (*SessionTracker) RecordUsage ¶
func (t *SessionTracker) RecordUsage(model string, inputTokens, outputTokens int)
RecordUsage adds a turn's token usage and computes the incremental cost.
func (*SessionTracker) Save ¶
func (t *SessionTracker) Save(path string) error
Save serialises the tracker state to a JSON file.
Click to show internal directories.
Click to hide internal directories.