pricing

package
v3.1.0-dev.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

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):

  1. cfg.Model.Pricing[name] — operator override in .agents/config.json.
  2. .agents/pricing.json — project-local additions.
  3. ~/.core-agent/pricing.json — `manual` (/pricing set) and `external` (the daily LiteLLM refresh).
  4. builtin — core-models' compiled-in table.
  5. 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

View Source
const (
	SourceCfgOverride  = cm.SourceCfgOverride
	SourceProjectFile  = cm.SourceProjectFile
	SourceUserManual   = cm.SourceUserManual
	SourceUserExternal = cm.SourceUserExternal
	SourceBuiltin      = cm.SourceBuiltin
	SourceDeclared     = cm.SourceDeclared
)

Source names LookupWithSource reports.

View Source
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 Builtin

func Builtin() map[string]Rates

Builtin returns a copy of the compiled-in table, bare model ids only.

func BuiltinByBackend

func BuiltinByBackend() map[string]Rates

BuiltinByBackend returns a copy of the compiled-in (backend, model) table, keyed "<backend>/<model>".

func BuiltinContextWindow

func BuiltinContextWindow(modelID string) (int, bool)

BuiltinContextWindow returns the compiled-in max input window for a lowercase model id.

func BuiltinContextWindows

func BuiltinContextWindows() map[string]int

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

func SaveUserFile(userHome string, uf *UserFile) error

SaveUserFile writes <userHome>/pricing.json atomically.

Types

type Catalog

type Catalog = cm.Catalog

Rate and catalog types.

func NewCatalog

func NewCatalog(opts Options) (*Catalog, error)

NewCatalog reads every configured source and returns the merged catalog.

type CountByLayer

type CountByLayer = cm.CountByLayer

Rate and catalog types.

type ExternalSource

type ExternalSource = cm.ExternalSource

Rate and catalog types.

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 LongContext

type LongContext = cm.LongContext

Rate and catalog types.

type ManualSection

type ManualSection = cm.ManualSection

Rate and catalog types.

type ModelRates

type ModelRates = cm.ModelRates

Rate and catalog types.

type Options

type Options = cm.Options

Rate and catalog types.

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 Rates

type Rates = cm.Rates

Rate and catalog types.

type RefreshOptions

type RefreshOptions = cm.RefreshOptions

Rate and catalog types.

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

type UserFile = cm.UserFile

Rate and catalog types.

func LoadUserFile

func LoadUserFile(userHome string) (*UserFile, error)

LoadUserFile reads <userHome>/pricing.json; a missing file is not an error.

type Verdict

type Verdict = cm.Verdict

Rate and catalog types.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL