Count the exact tokens in a text
tokendiet_count_tokensUse when the user asks how many tokens a text, prompt, log, document or code paste is, whether it fits a context window (128K, 200K, 1M), or how big something is before they send it to an AI. Returns the exact o200k token count (GPT-4o family and later; Claude and Gemini usually within about 15%), plus words, characters and how much of each window it uses. Language models cannot count their own tokens, so call this instead of estimating. Example: {"text": ""}. Not for shortening text.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | The text to count (up to 200,000 characters). |