Documentation
¶
Index ¶
- type Agent
- type Config
- func (c *Config) Convert(amount, from, to string) (string, error)
- func (c *Config) Delete(kind, id string) error
- func (c *Config) ImportModels(prices map[string]Price, overwrite bool) (added, updated, skipped int, err error)
- func (c *Config) Save(path string) error
- func (c *Config) SetAgent(id string, a Agent) error
- func (c *Config) SetModel(id string, p Price) error
- func (c *Config) SetRate(code, rate string) error
- func (c *Config) SetUsage(id string, u Usage) error
- func (c *Config) Total(agent, currency string) (Report, error)
- func (c *Config) Validate() error
- type Price
- type Report
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
BaseCurrency string `json:"base_currency"`
Rates map[string]string `json:"rates"`
Agents map[string]Agent `json:"agents"`
Models map[string]Price `json:"models"`
Usages map[string]Usage `json:"usages"`
}
Config is the entire portable ledger. Rates are units of each currency per one base unit.
func (*Config) ImportModels ¶
func (c *Config) ImportModels(prices map[string]Price, overwrite bool) (added, updated, skipped int, err error)
ImportModels merges a batch atomically in memory. Existing prices are retained unless overwrite is true.
func (*Config) Save ¶
Save replaces the file only after validation and a complete write in the same directory. Callers must serialize read-modify-write transactions across processes.
func (*Config) SetUsage ¶
SetUsage creates or replaces a record and snapshots the model's current price.
type Price ¶
type Price struct {
Currency string `json:"currency"`
Input string `json:"input_per_million"`
Output string `json:"output_per_million"`
}
Price specifies the charge per one million tokens.
type Usage ¶
type Usage struct {
Agent string `json:"agent"`
Model string `json:"model"`
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
Time string `json:"time"`
Price Price `json:"price"`
}
Usage stores a price snapshot, so later model price edits never change past charges.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package catalog imports base text token prices from models.dev.
|
Package catalog imports base text token prices from models.dev. |
|
cmd
|
|
|
aiprice
command
|
|
|
cataloggen
command
|
Click to show internal directories.
Click to hide internal directories.