analyze

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const PricingCatalogVersion = "public-token-pricing-2026-03-20-google-audit"

Variables

View Source
var BuiltInAPIPricingSources = []string{
	"https://developers.openai.com/api/docs/pricing",
	"https://platform.claude.com/docs/en/about-claude/pricing",
	"https://ai.google.dev/gemini-api/docs/pricing?hl=en",
}

Functions

func APIPricingTemplate added in v0.1.7

func APIPricingTemplate() string

func NormalizeModelKey

func NormalizeModelKey(s string) string

Types

type APICostEstimate

type APICostEstimate struct {
	UncachedInputTokens    int64    `json:"uncachedInputTokens,omitempty" yaml:"uncachedInputTokens,omitempty"`
	InputUSDPerMTok        float64  `json:"inputUsdPerMToken" yaml:"inputUsdPerMToken"`
	CacheReadUSDPerMTok    *float64 `json:"cacheReadUsdPerMToken,omitempty" yaml:"cacheReadUsdPerMToken,omitempty"`
	CacheWriteUSDPerMTok   *float64 `json:"cacheWriteUsdPerMToken,omitempty" yaml:"cacheWriteUsdPerMToken,omitempty"`
	OutputUSDPerMTok       float64  `json:"outputUsdPerMToken" yaml:"outputUsdPerMToken"`
	InputUSD               float64  `json:"inputUsd" yaml:"inputUsd"`
	CacheReadUSD           float64  `json:"cacheReadUsd,omitempty" yaml:"cacheReadUsd,omitempty"`
	CacheWriteUSD          float64  `json:"cacheWriteUsd,omitempty" yaml:"cacheWriteUsd,omitempty"`
	OutputUSD              float64  `json:"outputUsd" yaml:"outputUsd"`
	TotalUSD               float64  `json:"totalUsd" yaml:"totalUsd"`
	IsComplete             bool     `json:"isComplete" yaml:"isComplete"`
	MissingPriceComponents []string `json:"missingPriceComponents,omitempty" yaml:"missingPriceComponents,omitempty"`
	PriceCatalogModel      string   `json:"priceCatalogModel" yaml:"priceCatalogModel"`
	Source                 string   `json:"source" yaml:"source"`
}

func EstimateAPICost

func EstimateAPICost(model string, stat *ModelStat) *APICostEstimate

func EstimateAPICostWithOverrides added in v0.1.7

func EstimateAPICostWithOverrides(model string, stat *ModelStat, overrides *APIPricingOverrides) *APICostEstimate

type APIPricingOverride added in v0.1.7

type APIPricingOverride struct {
	InputUSDPerMTok      *float64 `json:"inputUsdPerMToken,omitempty" yaml:"inputUsdPerMToken,omitempty"`
	CacheReadUSDPerMTok  *float64 `json:"cacheReadUsdPerMToken,omitempty" yaml:"cacheReadUsdPerMToken,omitempty"`
	CacheWriteUSDPerMTok *float64 `json:"cacheWriteUsdPerMToken,omitempty" yaml:"cacheWriteUsdPerMToken,omitempty"`
	OutputUSDPerMTok     *float64 `json:"outputUsdPerMToken,omitempty" yaml:"outputUsdPerMToken,omitempty"`
}

type APIPricingOverrides added in v0.1.7

type APIPricingOverrides struct {
	Path     string   `json:"path" yaml:"path"`
	ModelIDs []string `json:"modelIds" yaml:"modelIds"`
	// contains filtered or unexported fields
}

func LoadAPIPricingOverrides added in v0.1.7

func LoadAPIPricingOverrides(path string) (*APIPricingOverrides, error)

func (*APIPricingOverrides) CatalogVersion added in v0.1.7

func (o *APIPricingOverrides) CatalogVersion() string

func (*APIPricingOverrides) HasActiveModels added in v0.1.7

func (o *APIPricingOverrides) HasActiveModels() bool

func (*APIPricingOverrides) Sources added in v0.1.7

func (o *APIPricingOverrides) Sources() []string

type ModelStat

type ModelStat struct {
	Requests                int64            `json:"requests" yaml:"requests"`
	Cost                    float64          `json:"cost" yaml:"cost"`
	Input                   int64            `json:"inputTokens" yaml:"inputTokens"`
	CacheRead               int64            `json:"cacheReadTokens,omitempty" yaml:"cacheReadTokens,omitempty"`
	CacheWrite              int64            `json:"cacheWriteTokens,omitempty" yaml:"cacheWriteTokens,omitempty"`
	Output                  int64            `json:"outputTokens" yaml:"outputTokens"`
	ExtraUsageTokens        map[string]int64 `json:"extraUsageTokens,omitempty" yaml:"extraUsageTokens,omitempty"`
	EstimatedOverageCostUSD float64          `json:"estimatedOverageCostUsd,omitempty" yaml:"estimatedOverageCostUsd,omitempty"`
	EstimatedAPICost        *APICostEstimate `json:"estimatedApiCost,omitempty" yaml:"estimatedApiCost,omitempty"`
}

func (*ModelStat) AddExtraUsage added in v0.1.10

func (stat *ModelStat) AddExtraUsage(key string, tokens int64)

func (*ModelStat) HasTokenUsage added in v0.1.10

func (stat *ModelStat) HasTokenUsage() bool

func (*ModelStat) SortedExtraUsageKeys added in v0.1.10

func (stat *ModelStat) SortedExtraUsageKeys() []string

Jump to

Keyboard shortcuts

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