Documentation
¶
Overview ¶
Package usage splits a project's token use the ways that show where it went (#417): input, cached input, output and reasoning, per model, per task and per attempt, with the retries apart. `orch report usage` and the dashboard's /api/usage read the same Build, so the two cannot disagree.
These are orch's own records of what each dispatch reported, in this project. They are not the provider's subscription quota (a ChatGPT or Claude plan's 5-hour window), which other projects and interactive use share; Quota carries that plan quota as claude and codex last reported it (#577). orch's budget guardrail is its own, per-project limit on these numbers unless a budget says `source: provider`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attempt ¶
Attempt is one attempt of a task. Attempt 0 holds rows written before orch recorded attempts.
type PlanQuota ¶ added in v0.31.0
type PlanQuota struct {
Backend string `json:"backend"`
Windows []state.QuotaWindow `json:"windows"`
SeenAt string `json:"seen_at"`
}
PlanQuota is one backend's subscription windows as its CLI last reported them (claude's rate_limit_event, codex's session rollout), as of SeenAt.
type QuotaReader ¶ added in v0.31.0
type QuotaReader interface {
LatestQuota(ctx context.Context, backend string) (state.ProviderQuota, bool, error)
}
QuotaReader is the slice of the state backend AddQuota reads.
type Task ¶
type Task struct {
TaskID string `json:"task_id"`
Attempts []Attempt `json:"attempts"`
// RetryTokens is what attempts after the first used.
RetryTokens int `json:"retry_tokens"`
Tokens
}
Task is one task's use, attempt by attempt.
type Tokens ¶
type Tokens struct {
Dispatches int `json:"dispatches"`
// Input is fresh input: what the dispatches sent that the prompt cache
// did not hold.
Input int `json:"input"`
// CachedInput is input read back from the prompt cache — context the
// agent re-read, cheaper per token but often most of them.
CachedInput int `json:"cached_input"`
CacheWrite int `json:"cache_write"`
// Output includes Reasoning.
Output int `json:"output"`
Reasoning int `json:"reasoning"`
CostUSD float64 `json:"cost_usd"`
// Estimated is true when some rows' counts were inferred because the CLI
// reported none.
Estimated bool `json:"estimated"`
}
Tokens is what a set of dispatches used.
type Usage ¶
type Usage struct {
Total Tokens `json:"total"`
RetryTokens int `json:"retry_tokens"`
ByModel []Model `json:"by_model"`
ByTask []Task `json:"by_task"`
// Quota is the plan quota each backend's CLI last reported, the whole
// account's, sorted by backend; filled by AddQuota, nil before.
Quota []PlanQuota `json:"quota,omitempty"`
}
Usage is the whole breakdown. ByModel and ByTask lead with the heaviest.