usage

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package usage provides model price tables and cost estimation for worker token usage.

Index

Constants

View Source
const DefaultLocalPath = ".config/djinn/prices.yaml"

DefaultLocalPath is the documented path where a user can place an override prices.yaml file.

Variables

This section is empty.

Functions

func ProviderForModel added in v0.2.0

func ProviderForModel(model string) planv1.Provider

ProviderForModel returns the provider for a canonical model ID prefix.

Types

type ModelPrice

type ModelPrice struct {
	Label      string  `yaml:"label"`
	Input      float64 `yaml:"input"`
	Output     float64 `yaml:"output"`
	CacheRead  float64 `yaml:"cache_read"`
	CacheWrite float64 `yaml:"cache_write"`
	Thinking   float64 `yaml:"thinking"`
	Source     string  `yaml:"source"`
	Date       string  `yaml:"date"`
}

ModelPrice contains token pricing per million tokens in USD, its display label, and its public citation.

type PriceTable

type PriceTable struct {
	Date     string                `yaml:"date"`
	Currency string                `yaml:"currency"`
	Models   map[string]ModelPrice `yaml:"models"`
	Order    []string              `yaml:"-"`
}

PriceTable is the set of known model prices and labels at a given date.

func DefaultTable

func DefaultTable() (*PriceTable, error)

DefaultTable returns the embedded default price table.

func LoadTable

func LoadTable(overridePath ...string) (*PriceTable, error)

LoadTable loads the price table. If an override path is provided and non-empty, and the file exists, it is loaded; otherwise the embedded default table is returned. This provides a clear seam for future local overrides.

func (*PriceTable) Catalog added in v0.2.0

func (t *PriceTable) Catalog() []*planv1.CircleModel

Catalog returns all models in the price table in YAML declaration order with their canonical ID, label, and provider.

func (*PriceTable) Estimate

func (t *PriceTable) Estimate(u *planv1.Usage, model string, provider planv1.Provider) (cost float64, hasPrice bool, err error)

Estimate computes the estimated cost in USD for the given usage and model. Returns cost, whether a price exists for the model, and any error.

func (*PriceTable) ResolveModel

func (t *PriceTable) ResolveModel(model string, provider planv1.Provider) string

ResolveModel maps a requested or stream-reported model and provider to a canonical entry in the table.

Jump to

Keyboard shortcuts

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