slimtoken.estimate_tokens
Estimate token usage in a request body using a bundled cl100k_base tokenizer. Get total and per-message breakdown, with support for model, tools, and format normalization.
Instructions
Count tokens in a request body using the real cl100k_base tokenizer (bundled, offline). Returns total + per-message breakdown. The model arg is accepted for forward-compat but the count is cl100k-approximate for non-cl100k models.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | No | model name (informational only) | |
| tools | No | ||
| format | No | request format of the body (normalized to canonical before counting) | anthropic |
| system | No | ||
| messages | Yes |