I would appreciate clarification on the following points for the direct Gemini Developer API REST endpoint v1beta/models/gemini-3.5-flash-lite:countTokens, using only generateContentRequest on a Free Tier project without billing.
Do the billing FAQ’s unbilled/inference-quota-exempt GetTokens statement and the Firebase count guide’s no-charge countTokens statement apply to this endpoint and request form?
Does the Firebase guide’s maximum 3000 RPM apply to this direct endpoint, and is it per project? What count-specific limits apply, and does this request affect model RPM, input TPM or RPD? What establishes current eligibility/capacity?
Does totalTokens include the complete system instruction, contents and generationConfig.responseJsonSchema plus every input framing token charged by the unchanged generateContent request? If anything is excluded, what exact official upper-bound relation applies to this model/request?
With the current omitted thinking settings, is maxOutputTokens:1024 a hard combined bound on thought and candidate output for this exact model/version?
Hello @Twin_Guide-SA, countTokens is free to use and does not consume your generation TPM/RPD quotas, though it remains governed by per-project RPM rate limits. It accounts for all input parts, system instructions, and structured schema tokens in the request, while maxOutputTokens serves as a combined upper bound covering both thinking and visible output tokens as detailed in our Tokens Documentation.
Thank you, Payal, for clarifying that countTokens includes structured-schema tokens for Gemini 3.5 Flash-Lite.
I have one follow-up question about using this API for production quota enforcement.
For gemini-3.5-flash-lite using Developer API v1beta, if I submit the same complete generateContentRequest to countTokens and generateContent, including systemInstruction, responseJsonSchema and thinkingLevel: MINIMAL:
Is countTokens.totalTokens guaranteed to be greater than or equal to usageMetadata.promptTokenCount returned by generateContent?
Is it also guaranteed to be an upper bound for the input-token quantity used to enforce the project’s TPM quota?
If not, is there a documented model-specific adjustment or upper-bound calculation?
I’m asking because the official token-counting documentation shows an example where the pre-generation count differs from the actual generation prompt-token usage.
I’m trying to establish a reliable input-token reservation without relying on arbitrary safety margins.
Hello @hotant, for details on how token counting works across input parts, schemas, and generation configurations, as well as how rate limits and token-per-minute (TPM) quotas are enforced, please refer to the official Understand and count tokens guide, the Tokens API Reference, and the Rate limits documentation.