usage

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 18 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

Index

Constants

View Source
const PricesAsOf = "October 2026"

Variables

This section is empty.

Functions

func Cost

func Cost(model string, t Tokens, write1h int64, fast bool) (float64, bool)

func Local

func Local(model string) bool

func ReadCached

func ReadCached() ([]byte, time.Time, error)

func ReadTapped

func ReadTapped() ([]byte, time.Time, error)

func Tap

func Tap(r io.Reader) error

Types

type Day

type Day struct {
	Day string `json:"day"`
	Part
	Sessions int                `json:"sessions"`
	Models   map[string]float64 `json:"models,omitempty"`
	Hours    []float64          `json:"hours,omitempty"`
}

func MergeDays

func MergeDays(lists ...[]Day) []Day

type Limits

type Limits struct {
	Plan      string    `json:"plan,omitempty"`
	Windows   []Window  `json:"windows"`
	FetchedAt time.Time `json:"fetchedAt,omitzero"`
	Source    string    `json:"source,omitempty"`
	Error     string    `json:"error,omitempty"`
}

type LimitsClient

type LimitsClient struct {
	Cached func() ([]byte, time.Time, error)
	Tapped func() ([]byte, time.Time, error)
}

func (*LimitsClient) Get

func (c *LimitsClient) Get(_ context.Context) Limits

Get is the latest Claude Code itself reported: what it handed its status line, or the copy it keeps for /usage. atc never reads its sign-in or asks Anthropic on its own.

type ModelPart

type ModelPart struct {
	Model string `json:"model"`
	Part
}

type Part

type Part struct {
	Tokens
	Total    int64   `json:"total"`
	Cost     float64 `json:"cost"`
	Costs    Split   `json:"costs"`
	Messages int     `json:"messages"`
}

type Report

type Report struct {
	Days     []Day
	Sessions map[string]*SessionSpend
	Previous float64
	First    string
}

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

func (*Scanner) CostSince

func (s *Scanner) CostSince(from time.Time, transcripts ...string) float64

func (*Scanner) Report

func (s *Scanner) Report(root string, from time.Time, hourly bool) Report

Report adds up from until now per day (per hour if hourly) and each session per bucket and model. A zero from means everything on disk, starting at the first day with a message. Previous is the same length of time before from.

func (*Scanner) Session

func (s *Scanner) Session(transcripts ...string) Stats

func (*Scanner) Spend

func (s *Scanner) Spend(root string, from time.Time) Spend

type SessionSpend

type SessionSpend struct {
	Cost     float64                      `json:"cost"`
	Total    int64                        `json:"total"`
	Messages int                          `json:"messages"`
	Last     time.Time                    `json:"last"`
	Models   map[string]float64           `json:"models"`
	Slices   map[string]map[string]*Slice `json:"slices,omitempty"`
}

type Slice

type Slice [6]float64

Slice is one session's use of one model in one bucket, flat so a report of a thousand sessions stays small: dollars by token kind (input, output, cache read, cache write), then replies, then tokens.

type Spend

type Spend struct {
	Cost     float64                  `json:"cost"`
	Models   map[string]float64       `json:"models"`
	Sessions map[string]*SessionSpend `json:"sessions"`
}

type Split

type Split struct {
	Input      float64 `json:"input"`
	Output     float64 `json:"output"`
	CacheRead  float64 `json:"cacheRead"`
	CacheWrite float64 `json:"cacheWrite"`
}

func Costs

func Costs(model string, t Tokens, write1h int64, fast bool) (Split, bool)

func (Split) Sum

func (s Split) Sum() float64

type Stats

type Stats struct {
	Part
	Models    []ModelPart `json:"models"`
	Subagents struct {
		Part
		Count int `json:"count"`
	} `json:"subagents"`
	Turns     int       `json:"turns"`
	ToolCalls int       `json:"toolCalls"`
	Start     time.Time `json:"start,omitzero"`
	End       time.Time `json:"end,omitzero"`
	Wall      int64     `json:"wallSeconds"`
	Active    int64     `json:"activeSeconds"`
	Unpriced  []string  `json:"unpriced,omitempty"`
	Local     []string  `json:"local,omitempty"`
	PricesAt  string    `json:"pricesAsOf"`
}

type Tokens

type Tokens struct {
	Input      int64 `json:"input"`
	Output     int64 `json:"output"`
	CacheRead  int64 `json:"cacheRead"`
	CacheWrite int64 `json:"cacheWrite"`
}

func (Tokens) Total

func (t Tokens) Total() int64

type Window

type Window struct {
	Key      string    `json:"key"`
	Label    string    `json:"label"`
	Percent  float64   `json:"percent"`
	ResetsAt time.Time `json:"resetsAt,omitzero"`
	Severity string    `json:"severity,omitempty"`
	Scope    string    `json:"scope,omitempty"`
}

func ParseWindows

func ParseWindows(b []byte, now time.Time) []Window

func (Window) Counts

func (w Window) Counts(model string) bool

func (Window) From

func (w Window) From() time.Time

Jump to

Keyboard shortcuts

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