slimtoken.estimate_tokens
Estimate token usage in request bodies with a bundled, offline cl100k_base tokenizer. Receive total and per-message counts to optimize prompts before forwarding.
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.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"messages": "<messages>"
},
"name": "slimtoken.estimate_tokens"
}
}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 |