Skip to content

ccusage / calculate-cost / getTotalTokens

Function: getTotalTokens()

ts
function getTotalTokens(tokenCounts): number;

Calculates the total number of tokens across all token types Supports both raw usage data format and aggregated data format

Parameters

ParameterTypeDescription
tokenCountsAnyTokenCountsObject containing counts for each token type

Returns

number

Total number of tokens

Released under the MIT License.