count_tokens
Count tokens for a text string or chat messages array for any supported AI model (GPT-4o, Claude, Gemini, Mistral, Llama).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | No | Plain text to count tokens for. | |
| model | No | Model ID, e.g. gpt-4o, claude-sonnet-4. Defaults to gpt-4o. | |
| messages | No | Chat messages array in OpenAI/Anthropic format. |