count_tokens
Estimate token count for any text or message list to decide whether to compress, prune, or skip content before sending to an API.
Instructions
Estimate token count for text or a message list before sending to an API. Use this to decide whether to compress, prune, or skip content.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Plain string OR list of {"role": "...", "content": "..."} dicts. | |
| model | No | Model name — used to pick the right tokenizer encoding. | gpt-4o |
| include_message_overhead | No | Add per-message role/separator overhead (4 tokens each). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||