Documentation
¶
Overview ¶
Package pricing is core-agent's name for core-models' shared price catalog, github.com/go-steer/core-models/pricing. It used to carry its own LiteLLM-generated table, regenerator and layered catalog; mast carried another, and the two drifted. Both products now price from the one catalog core-models ships and regenerates weekly, and this package re-exports it so existing callers (pkg/usage, pkg/compose, embedders driving Refresh or building a *Catalog per tenant) keep compiling.
Every type here is an alias, so a value from this package IS the core-models value: nothing is copied or converted at the boundary.
Lookup chain (first exact match wins, then longest prefix):
- cfg.Model.Pricing[name] — operator override in .agents/config.json.
- .agents/pricing.json — project-local additions.
- ~/.core-agent/pricing.json — `manual` (/pricing set) and `external` (the daily LiteLLM refresh).
- builtin — core-models' compiled-in table.
- declared — rates provider profiles declare (models[].rates), for models no catalog covers.
Catalog.LookupFor(backend, model) consults "<backend>/<model>" before the bare id in each layer, so a model billed differently on two backends (Claude first-party vs on Vertex AI, OpenAI's and xAI's models, which have no bare rows) gets its own rate. Catalog.Lookup is LookupFor with no backend. See the core-models package docs for the exact order.
Index ¶
- Constants
- func Builtin() map[string]Rates
- func BuiltinByBackend() map[string]Rates
- func BuiltinContextWindow(modelID string) (int, bool)
- func BuiltinContextWindows() map[string]int
- func DeclaredFromProfiles(ps []profile.Profile) map[string]ModelRates
- func SaveUserFile(userHome string, uf *UserFile) error
- type Catalog
- type CountByLayer
- type ExternalSource
- type IntroductoryRate
- type LongContext
- type ManualSection
- type ModelRates
- type Options
- type ProjectFile
- type Rates
- type RefreshOptions
- type RefreshOutcome
- type UserFile
- type Verdict
Constants ¶
const ( SourceCfgOverride = cm.SourceCfgOverride SourceProjectFile = cm.SourceProjectFile SourceUserManual = cm.SourceUserManual SourceUserExternal = cm.SourceUserExternal SourceBuiltin = cm.SourceBuiltin SourceDeclared = cm.SourceDeclared )
Source names LookupWithSource reports.
const ( SchemaVersion = cm.SchemaVersion ProjectFileName = cm.ProjectFileName UserFileName = cm.UserFileName DefaultRefreshSource = cm.DefaultRefreshSource DefaultRefreshInterval = cm.DefaultRefreshInterval DefaultMaxRefreshBodyBytes = cm.DefaultMaxRefreshBodyBytes // ExternalFormat is the ExternalSource.Format a refresh writes. A // cache in an older format (written by core-models v0.13.2 or // earlier) is re-qualified on load and refetched in full on the next // refresh. ExternalFormat = cm.ExternalFormat )
File and refresh constants.
Variables ¶
This section is empty.
Functions ¶
func BuiltinByBackend ¶
BuiltinByBackend returns a copy of the compiled-in (backend, model) table, keyed "<backend>/<model>".
func BuiltinContextWindow ¶
BuiltinContextWindow returns the compiled-in max input window for a lowercase model id.
func BuiltinContextWindows ¶
BuiltinContextWindows returns a copy of the whole window table.
func DeclaredFromProfiles ¶
func DeclaredFromProfiles(ps []profile.Profile) map[string]ModelRates
DeclaredFromProfiles collects the rates provider profiles declare into Options.Declared, keyed "<backend>/<model>".
func SaveUserFile ¶
SaveUserFile writes <userHome>/pricing.json atomically.
Types ¶
type Catalog ¶
Rate and catalog types.
func NewCatalog ¶
NewCatalog reads every configured source and returns the merged catalog.
type IntroductoryRate ¶
type IntroductoryRate = cm.IntroductoryRate
Rate and catalog types.
func IntroductoryRates ¶
func IntroductoryRates() []IntroductoryRate
IntroductoryRates lists the built-in rates known to be introductory, with the date each is due to end.
type ProjectFile ¶
type ProjectFile = cm.ProjectFile
Rate and catalog types.
func LoadProjectFile ¶
func LoadProjectFile(agentsDir string) (*ProjectFile, error)
LoadProjectFile reads <agentsDir>/pricing.json; a missing file is not an error.
type RefreshOutcome ¶
type RefreshOutcome = cm.RefreshOutcome
Rate and catalog types.
func Refresh ¶
func Refresh(ctx context.Context, userHome string, opts RefreshOptions) (RefreshOutcome, error)
Refresh fetches LiteLLM's catalog into the user file's external section.
type UserFile ¶
Rate and catalog types.
func LoadUserFile ¶
LoadUserFile reads <userHome>/pricing.json; a missing file is not an error.