usage

package
v0.8.39 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package usage computes the USD cost of an LLM token breakdown from a model price table. It is deliberately small and self-contained: the daemon can't see an agent's LLM calls (they're opaque outbound traffic), so token counts arrive from the agent's own usage hook and cost is derived here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CostUSD

func CostUSD(model string, t Tokens) (cost float64, ok bool)

CostUSD returns the dollar cost of t under model's price table. ok is false when the model isn't priced (the caller should render cost as n/a, keeping the token counts visible).

Types

type Tokens

type Tokens struct {
	Input         int // fresh (uncached) input tokens
	CacheCreation int // tokens written to the prompt cache (billed > fresh input)
	CacheRead     int // tokens served from the prompt cache (billed << fresh input)
	Output        int // generated output tokens
}

Tokens is an Anthropic-shaped token breakdown for a session (cumulative). The fields mirror the `usage` block in a Claude Code transcript.

Jump to

Keyboard shortcuts

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