count_gemini_tokens
Calculate token count for Gemini AI prompts to estimate costs and ensure they fit within model context limits.
Instructions
Count the number of tokens in a text string for the configured Gemini model.
Use this tool to:
Estimate prompt costs before making queries
Ensure prompts fit within model context limits
Optimize prompt length for efficiency
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_gemini_tokens"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | The text to count tokens for |