count_tokens
Count tokens for a text string or chat messages array for any supported AI model (GPT-4o, Claude, Gemini, Mistral, Llama).
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "count_tokens"
}
}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. |