Skip to main content

Token counter telemetry

Understand token-count precision in each result.

2 min readUpdated September 2026

Inspect the counter

token_counter_used reports the process-level active counter: tiktoken or heuristic.

tokens.pypython
from llmslim import compress
result = compress(long_text)
print(result.token_counter_used)

Questions

When is the heuristic used?

When the process cannot load the tiktoken encoder. LLMSlim emits one warning per process.