Skip to content

ccusage / data-loader / calculateContextTokens

Function: calculateContextTokens()

ts
function calculateContextTokens(transcriptPath): Promise<
  | null
  | {
  inputTokens: number;
  percentage: number;
  contextLimit: number;
}>;

Calculate context tokens from transcript file using improved JSONL parsing Based on the Python reference implementation for better accuracy

Parameters

ParameterTypeDescription
transcriptPathstringPath to the transcript JSONL file

Returns

Promise< | null | { inputTokens: number; percentage: number; contextLimit: number; }>

Object with context tokens info or null if unavailable

Released under the MIT License.