Actions16
- Content Actions
- Cached Content Actions
- Embedding Actions
- File Actions
- Model Actions
- Token Actions
Token → Count Tokens
AI-generatedSummary
Count tokens for a specified Gemini AI Studio model input to estimate token usage before processing.
Inputs
- Model (required) — Select the Gemini model to use for token counting; supports loading available models and arbitrary values.
- Input Mode (required) — Choose the input format to count tokens for: Simple Text, Contents JSON, Generate Content Request JSON, or Raw Request JSON.
- Text (required) — Enter simple text string to count tokens for when Input Mode is 'Simple Text'.
- Contents (JSON) (required) — Provide Gemini contents array JSON for token counting when Input Mode is 'Contents JSON'.
- Generate Content Request (JSON) (required) — Provide complete generateContentRequest JSON for counting tokens including system instructions or other config when Input Mode is 'Generate Content Request JSON'.
- Raw Request Body (JSON) (required) — Provide complete raw request JSON sent to the :countTokens endpoint when Input Mode is 'Raw Request JSON'.
Output shape
a single item with a JSON object containing the token count response from Gemini API
The output JSON matches the Gemini :countTokens API response and is paired with the input item. Errors provide messages when the request fails.