Gemini 3.7 Flash rejects a valid request using an undocumented 32,768-token limit

gemini-3.7-flash returns 400 INVALID_ARGUMENT for a request that is far below its documented input limit. Using the reproduction script (below), countTokens reports 36,699 input tokens, but generateContent reports a different count of 32,825 and rejects it against an apparent 32,768-token limit.

The sample is a simplified, anonymized version of an actual input. It preserves the repeated records, shared identifiers, URLs, and similar text values while replacing all real data with generated values. The identical request succeeds with gemini-3.6-flash, which also reports promptTokenCount: 36699.

Model countTokens generateContent
gemini-3.6-flash 36,699 HTTP 200; promptTokenCount: 36699
gemini-3.7-flash 36,699 HTTP 400; reports 32,825 against a 32,768 limit

The Gemini 3.7 response is:

{
  "error": {
    "code": 400,
    "message": "Unable to submit request because the input token count is 32825 but model only supports up to 32768. Reduce the input token count and try again. You can also use the CountTokens API to calculate prompt token count and billable characters. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models",
    "status": "INVALID_ARGUMENT"
  }
}

Reproduction

This gist contains the generated plain-text prompt and a Bash script that submits it directly to the global Vertex AI API: https://gist.github.com/javan/7f0eafca9f00f7474312b8696c8ab3ce

export GOOGLE_CLOUD_PROJECT="your-project-id"

curl --fail --silent --show-error —location https://gist.githubusercontent.com/javan/7f0eafca9f00f7474312b8696c8ab3ce/raw/gemini-3.7-flash-repro.sh --output /tmp/gemini-3.7-flash-repro.sh

bash /tmp/gemini-3.7-flash-repro.sh

The script uses gcloud auth print-access-token by default. Set GOOGLE_ACCESS_TOKEN to override it.

The adjacent suffix boundary can be reproduced with:

SUFFIX_TOKENS=33 bash /tmp/gemini-3.7-flash-repro.sh # Gemini 3.7 returns 400
SUFFIX_TOKENS=34 bash /tmp/gemini-3.7-flash-repro.sh # Gemini 3.7 returns 200

The sample payload is a .txt file containing 2,221 newline-delimited lines. The Bash script submits it as one text part.

Boundary sensitivity

Small changes around the failing input produce a sharp transition:

Variant countTokens generateContent
98 records 36,443 HTTP 200
99 records 36,571 HTTP 400; reports 32,777
100 records 36,699 HTTP 400; reports 32,825
100 records plus 33 neutral tokens 36,734 HTTP 400; reports 32,770
100 records plus 34 neutral tokens 36,735 HTTP 200

Making the input longer does not have one consistent effect. Adding more similar records keeps the request failing through at least 153,699 public input tokens, while appending a small amount of unrelated neutral text makes it succeed.

This suggests that Gemini 3.7 may be deriving a second content-dependent representation whose token count can move in the opposite direction from the public input count, then enforcing an undocumented 32,768-token limit on that representation. That is only a hypothesis; the directly observed issue is that countTokens and generateContent disagree and a one-token change can cross a hidden boundary.