Count tokens
count_tokensCount tokens with the o200k or cl100k encoder and price the count against the published model table. Claude and Gemini rows are estimates, not those vendors' tokenizers.
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": {
"text": "<text>"
},
"name": "count_tokens"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | The prompt or document to count. | |
| encoding | No | o200k | |
| modelIds | No | Price rows to return. Unknown ids are rejected. | |
| cachedRatio | No | ||
| outputTokens | No | ||
| requestsPerDay | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chars | Yes | ||
| count | Yes | ||
| words | Yes | ||
| prices | Yes | ||
| encoding | Yes |