Gemini-embedding-001: countTokens support, token correspondence and truncation behaviour

We need clarification for Gemini Developer API v1beta, model gemini-embedding-001.

Our embedding request uses:

POST /v1beta/models/gemini-embedding-001:embedContent

{“content”:{“role”:“user”,“parts”:[{“text”:T}]}}

It omits taskType, title, outputDimensionality and truncation options.

We are considering counting the identical text and Content first:

POST /v1beta/models/gemini-embedding-001:countTokens

{“contents”:[{“role”:“user”,“parts”:[{“text”:T}]}]}

Could the Google team clarify:

  1. Is countTokens supported for this exact model and request shape?

  2. Does totalTokens count the complete input without clipping, and equal or safely upper-bound the input-token measure used by embedContent? Does any role or request-framing overhead affect this relationship?

  3. If that count is at most 2,048, is the complete text processed without truncation when truncation options are omitted?

  4. What happens above the 2,048-token limit—rejection or truncation—and is any truncation explicitly reported in the response?

  5. What current pricing and quota rules apply to counting and direct gemini-embedding-001 embedding, including rejected requests? Does the billing FAQ’s statement that “GetTokens” is free and outside inference quota apply to this REST countTokens method?

Please provide an authoritative documentation reference or a model-specific clarification. We can supply synthetic examples; no customer data is needed.

Hello @Farouk_Matamir ,

  • Yes, you can use countTokens with gemini-embedding-001 and that request. It counts your whole text without cutting it off. Including "role": "user" adds 1 extra token to the count.
  • The model uses 8 of its 2,048 tokens for itself, even when you don’t set taskType. To make sure all your text is used, keep totalTokens at 2,041 or less when you include "role": "user" (2,040 or less without it).
  • If your text is longer, the request still succeeds, but the extra text is dropped without any warning in the response.
  • Counting tokens is free and doesn’t use your embedding quota (it’s the GetTokens call in the Billing FAQ). Requests that fail with a 400 or 500 error are not charged, but they still count toward your rate limits.
  • If you need to embed longer text, gemini-embedding-2 accepts up to 8,192 tokens and tells you how many tokens it used. Note that its embeddings don’t work with ones from gemini-embedding-001, so you would need to re-embed your existing data (see Embeddings).