Count tokens
count_tokensCount the tokens in a text (an estimate with OpenAI's cl100k tokenizer; other model families differ slightly).
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 text to count, such as a system prompt or a typical user message |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tokens | Yes | ||
| tokenizer | Yes | ||
| characters | Yes |