Count tokens for Anthropic/Claude models via API.
Messages to count tokens for
Model identifier (e.g., 'claude-sonnet-4')
Promise with token count result
Count tokens for Gemini models via API.
Text content to count tokens for
Model identifier (e.g., 'gemini-2.0-flash')
Promise with token count result
Count tokens for OpenAI models using local tiktoken.
Text to count tokens for
Optionalmodel: stringModel identifier (default: 'gpt-4o')
Token count result (synchronous, local)
Estimate tokens offline using character-based heuristic.
Text to estimate tokens for
Estimated token count
Clear the token count cache.
Get current cache statistics.
Interface for token counting operations.