Skip to content

TokenTracker

reference
1 min readUpdated

Kind: Class

Source: atloria-monorepo/packages/doc-automation/src/v2/pipeline/token-tracker.ts

Methods

MethodSignatureReturns
recordUsage`recordUsage(usage: Omit<TokenUsage, 'timestamp''cost'>)`
calculateCost`calculateCost(inputTokens: number, outputTokens: number, model: 'claude''openai')`
hasCapacityhasCapacity(estimatedTokens: number)boolean
getRemainingBudgetgetRemainingBudget()number
getStageUsagegetStageUsage(stage: JobStage)StageTokenSummary
getSummarygetSummary()TokenSummary
getHistorygetHistory()TokenUsage[]
estimateCost`estimateCost(estimatedInputTokens: number, estimatedOutputTokens: number, model: 'claude''openai')`
estimatedCostUsd: number;
withinBudget: boolean;
budgetRemaining: number;

}| |reset|reset()|void` |

Where it refuses work

  • TokenTracker stops the work with TokenLimitError when summary.totalTokens > this.config.budget.maxTotal.

Was this page helpful?

Download as PDF