Skip to content

ccusage / calculate-cost / getTotalTokens

Function: getTotalTokens()

ts
function getTotalTokens(tokens): number;

Calculates the sum of all token types (input, output, cache creation, cache read)

Parameters

ParameterTypeDescription
tokensTokenDataToken data containing different token counts

Returns

number

Total number of tokens across all types

Released under the MIT License.