Documentation
¶
Index ¶
- func HasPricing(model string) bool
- type ModelPricing
- type Tracker
- func (t *Tracker) AddUsage(inputTokens, outputTokens, cacheCreation, cacheRead int)
- func (t *Tracker) CacheCreationTokens() int
- func (t *Tracker) CacheReadTokens() int
- func (t *Tracker) CostString() string
- func (t *Tracker) Currency() string
- func (t *Tracker) InputTokens() int
- func (t *Tracker) Model() string
- func (t *Tracker) OutputTokens() int
- func (t *Tracker) Reset()
- func (t *Tracker) SetCurrency(currency string)
- func (t *Tracker) SetModel(model string)
- func (t *Tracker) TotalCost() float64
- func (t *Tracker) TotalCostUSD() float64
- func (t *Tracker) TotalTokens() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ModelPricing ¶
type ModelPricing struct {
InputPerMillion float64 // 输入 token 单价($/M tokens)
OutputPerMillion float64 // 输出 token 单价($/M tokens)
CacheWritePerMillion float64 // Cache 写入单价($/M tokens)
CacheReadPerMillion float64 // Cache 读取单价($/M tokens)
}
ModelPricing 单个模型的价格信息
func GetPricing ¶
func GetPricing(model string) ModelPricing
GetPricing 获取模型价格,先精确匹配,再尝试子串匹配,未知模型返回零值
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker 实时费用追踪器
func (*Tracker) CacheCreationTokens ¶
CacheCreationTokens 返回缓存写入 token 数
func (*Tracker) CacheReadTokens ¶
CacheReadTokens 返回缓存读取 token 数
Click to show internal directories.
Click to hide internal directories.