How to Count Gemini 3.6 Flash Tokens
Call models.countTokens with model gemini-3.6-flash and the same contents you plan to send. The method runs the model's tokenizer and returns the total number of input tokens without generating a response.
For a completed interaction, inspect its usage object. Google separates input, output, thought, cached, tool-use, and total tokens, so a preflight text count and the final interaction total answer different questions.
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const result = await client.models.countTokens({
model: "gemini-3.6-flash",
contents: "Count this Gemini 3.6 Flash prompt.",
});
console.log(result.totalTokens);What Gemini countTokens Can Measure
| Input type | Count before generation? | Important note |
|---|---|---|
| Text and chat history | Yes | Send the complete contents structure |
| Images and documents | Yes | Media follows Gemini-specific token accounting |
| Audio and video | Yes | Duration and media processing affect the total |
| System instructions and tools | Yes | Include the same configuration as the real request |
| Generated output and thinking | No | Read these from final interaction usage |
Gemini 3.6 Flash Context Planning
Google documents a 1,048,576-token input limit and a 65,536-token output limit for the current Flash generation. Do not fill the input allowance without considering files, system instructions, tool definitions, conversation state, and the output your workflow needs.
The Gemini 3.5 Flash page remains useful for applications pinned to that stable model. Use this Gemini 3.6 page only when the request model is gemini-3.6-flash, because model updates can change tokenization and usage behavior.
Tiktokenizer Reference Sources
Tokenizer behavior and model limits change. Verify production decisions with current provider documentation: